Skip to content

Commit 96373eb

Browse files
authored
Merge pull request #552 from scireum/GA-12
GA 12.0.0
2 parents 25aca46 + 4ddf0a1 commit 96373eb

34 files changed

+938
-193
lines changed

.drone.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ clone:
1717

1818
steps:
1919
- name: compile
20-
image: scireum/sirius-build-jdk21
20+
image: scireum/sirius-build-jdk23
2121
commands:
2222
- mvn clean compile
2323
volumes: *scireum_volumes
@@ -28,7 +28,7 @@ steps:
2828
- push
2929

3030
- name: cron_unit_tests
31-
image: scireum/sirius-build-jdk21
31+
image: scireum/sirius-build-jdk23
3232
commands:
3333
- mvn clean test
3434
volumes: *scireum_volumes
@@ -48,7 +48,7 @@ steps:
4848
- cron
4949

5050
- name: test
51-
image: scireum/sirius-build-jdk21
51+
image: scireum/sirius-build-jdk23
5252
commands:
5353
- mvn clean test -Dtest.excluded.groups=nightly
5454
volumes: *scireum_volumes
@@ -57,7 +57,7 @@ steps:
5757
- pull_request
5858

5959
- name: deploy
60-
image: scireum/sirius-build-jdk21
60+
image: scireum/sirius-build-jdk23
6161
commands:
6262
- sed -i 's/DEVELOPMENT-SNAPSHOT/${DRONE_TAG}/g' pom.xml
6363
- mvn clean deploy -DskipTests
@@ -77,7 +77,7 @@ steps:
7777
- tag
7878

7979
- name: sonar
80-
image: scireum/sirius-build-jdk21
80+
image: scireum/sirius-build-jdk23
8181
commands:
8282
- sed -i 's/DEVELOPMENT-SNAPSHOT/${DRONE_TAG}/g' pom.xml
8383
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent test org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dsonar.projectKey=${DRONE_REPO_NAME}

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### Description
2+
3+
<!-- Describe your changes in detail. Also mention how to handle breaking changes if there are any -->
4+
5+
### Additional Notes
6+
7+
- This PR fixes or works on following ticket(s): [SIRI-](https://scireum.myjetbrains.com/youtrack/issue/SIRI-)
8+
- This PR is related to PR: <!-- URL of PR if applicable, remove otherwise -->
9+
10+
### Checklist
11+
12+
- [ ] Code change has been tested and works locally
13+
- [ ] Code was formatted via IntelliJ and follows SonarLint & [best practices](https://scireum.myjetbrains.com/youtrack/articles/MISC-A-16/CodeStyle-JavaDoc)
14+
- [ ] Patch Tasks: Is local execution of Patch Tasks necessary? If so, please also mark the PR with the tag.

build.gradle.kts

Lines changed: 0 additions & 26 deletions
This file was deleted.

pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.scireum</groupId>
88
<artifactId>sirius-parent</artifactId>
9-
<version>11.5.1</version>
9+
<version>13.1.0</version>
1010
</parent>
1111
<artifactId>sirius-kernel</artifactId>
1212
<name>SIRIUS kernel</name>
@@ -32,28 +32,28 @@
3232
<dependency>
3333
<groupId>com.google.guava</groupId>
3434
<artifactId>guava</artifactId>
35-
<version>32.1.3-jre</version>
35+
<version>33.3.1-jre</version>
3636
</dependency>
3737

3838
<!-- JSR305 annotations like @Nonnull etc. -->
3939
<dependency>
40-
<groupId>com.google.code.findbugs</groupId>
41-
<artifactId>jsr305</artifactId>
42-
<version>3.0.2</version>
40+
<groupId>com.github.spotbugs</groupId>
41+
<artifactId>spotbugs-annotations</artifactId>
42+
<version>4.8.6</version>
4343
</dependency>
4444

4545
<!-- Required logging bridge to make slf4j log to our logging system -->
4646
<dependency>
4747
<groupId>org.slf4j</groupId>
4848
<artifactId>slf4j-jdk14</artifactId>
49-
<version>2.0.9</version>
49+
<version>2.0.16</version>
5050
</dependency>
5151

5252
<!-- Used to auto-start Docker environments. Excluding dependencies not required for docker-compose. -->
5353
<dependency>
5454
<groupId>com.palantir.docker.compose</groupId>
5555
<artifactId>docker-compose-rule-core</artifactId>
56-
<version>2.0.0</version>
56+
<version>2.3.0</version>
5757
<exclusions>
5858
<exclusion>
5959
<groupId>com.palantir.conjure.java.runtime</groupId>
@@ -69,7 +69,7 @@
6969
<dependency>
7070
<groupId>commons-io</groupId>
7171
<artifactId>commons-io</artifactId>
72-
<version>2.15.1</version>
72+
<version>2.18.0</version>
7373
</dependency>
7474
<!-- Required, as the version provided by docker-compose-rule-core has security issues -->
7575
<dependency>

src/main/java/sirius/kernel/commons/Dates.java

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
package sirius.kernel.commons;
1010

11+
import javax.annotation.Nonnull;
1112
import java.time.LocalDate;
1213
import java.time.LocalDateTime;
1314
import java.util.Arrays;
@@ -42,10 +43,7 @@ public static LocalDateTime computeLatestDateTime(LocalDateTime... dateTimes) {
4243
* @return the latest date-time object or <tt>null</tt> if no date is given
4344
*/
4445
public static LocalDateTime computeLatestDateTime(List<LocalDateTime> dateTimes) {
45-
return dateTimes.stream()
46-
.filter(Objects::nonNull)
47-
.max(LocalDateTime::compareTo)
48-
.orElse(null);
46+
return dateTimes.stream().filter(Objects::nonNull).max(LocalDateTime::compareTo).orElse(null);
4947
}
5048

5149
/**
@@ -60,14 +58,12 @@ public static LocalDate computeLatestDate(LocalDate... dates) {
6058

6159
/**
6260
* Computes the latest date of the given date objects.
61+
*
6362
* @param dates a list of date objects to compare
6463
* @return the latest date object or <tt>null</tt> if no date is given
6564
*/
6665
public static LocalDate computeLatestDate(List<LocalDate> dates) {
67-
return dates.stream()
68-
.filter(Objects::nonNull)
69-
.max(LocalDate::compareTo)
70-
.orElse(null);
66+
return dates.stream().filter(Objects::nonNull).max(LocalDate::compareTo).orElse(null);
7167
}
7268

7369
/**
@@ -87,10 +83,7 @@ public static LocalDateTime computeEarliestDateTime(LocalDateTime... dateTimes)
8783
* @return the earliest date-time object or <tt>null</tt> if no date is given
8884
*/
8985
public static LocalDateTime computeEarliestDateTime(List<LocalDateTime> dateTimes) {
90-
return dateTimes.stream()
91-
.filter(Objects::nonNull)
92-
.min(LocalDateTime::compareTo)
93-
.orElse(null);
86+
return dateTimes.stream().filter(Objects::nonNull).min(LocalDateTime::compareTo).orElse(null);
9487
}
9588

9689
/**
@@ -110,9 +103,42 @@ public static LocalDate computeEarliestDate(LocalDate... dates) {
110103
* @return the earliest date object or <tt>null</tt> if no date is given
111104
*/
112105
public static LocalDate computeEarliestDate(List<LocalDate> dates) {
113-
return dates.stream()
114-
.filter(Objects::nonNull)
115-
.min(LocalDate::compareTo)
116-
.orElse(null);
106+
return dates.stream().filter(Objects::nonNull).min(LocalDate::compareTo).orElse(null);
107+
}
108+
109+
/**
110+
* Determines if the given date is before or after the given reference date.
111+
*
112+
* @param dateToCheck the date to check
113+
* @param referenceDate the reference date
114+
* @return <tt>true</tt> if the date is before or after the reference date, <tt>false</tt> otherwise
115+
*/
116+
public static boolean isBeforeOrEqual(@Nonnull LocalDate dateToCheck, @Nonnull LocalDate referenceDate) {
117+
return dateToCheck.isBefore(referenceDate) || dateToCheck.equals(referenceDate);
118+
}
119+
120+
/**
121+
* Determines if the given date is after or equal to the given reference date.
122+
*
123+
* @param dateToCheck the date to check
124+
* @param referenceDate the reference date
125+
* @return <tt>true</tt> if the date is after or equal to the reference date, <tt>false</tt> otherwise
126+
*/
127+
public static boolean isAfterOrEqual(@Nonnull LocalDate dateToCheck, @Nonnull LocalDate referenceDate) {
128+
return dateToCheck.isAfter(referenceDate) || dateToCheck.equals(referenceDate);
129+
}
130+
131+
/**
132+
* Determines if the given date is within the given range, inclusive the range dates.
133+
*
134+
* @param startDate the range's start date
135+
* @param endDate the range's end date
136+
* @param dateToCheck the date to check
137+
* @return <tt>true</tt> if the date is within the range, <tt>false</tt> otherwise
138+
*/
139+
public static boolean isWithinRange(@Nonnull LocalDate startDate,
140+
@Nonnull LocalDate endDate,
141+
@Nonnull LocalDate dateToCheck) {
142+
return isAfterOrEqual(dateToCheck, startDate) && isBeforeOrEqual(dateToCheck, endDate);
117143
}
118144
}

src/main/java/sirius/kernel/commons/Files.java

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import java.nio.file.Path;
1919
import java.nio.file.SimpleFileVisitor;
2020
import java.nio.file.attribute.BasicFileAttributes;
21+
import java.util.List;
2122
import java.util.Optional;
2223
import java.util.regex.Pattern;
24+
import java.util.stream.Stream;
2325

2426
/**
2527
* Helperclass for handling files in Java 8.
@@ -28,6 +30,11 @@ public class Files {
2830

2931
private static final Pattern NON_PATH_CHARACTERS = Pattern.compile("[^a-zA-Z0-9\\-.]");
3032

33+
/**
34+
* Contains a list of file names and endings which are considered to be metadata.
35+
*/
36+
private static final List<String> METADATA_FILES = List.of("__MACOSX", ".DS_Store", "Thumbs.db");
37+
3138
private Files() {
3239
}
3340

@@ -147,8 +154,39 @@ public static String getFilenameWithoutExtension(@Nullable String path) {
147154
}
148155

149156
/**
150-
* If the given file is not null and exists, tries to delete that file and logs when a file cannot be deleted. T
151-
* his is useful for error reporting and to diagnose why a file cannot be deleted.
157+
* Determines if the given path is hidden.
158+
* <p>
159+
* A path is considered hidden if it starts with a dot.
160+
*
161+
* @param fileOrDirectoryName the path to check
162+
* @return <tt>true</tt> if the path is hidden, <tt>false</tt> otherwise
163+
*/
164+
public static boolean isConsideredHidden(@Nullable String fileOrDirectoryName) {
165+
if (Strings.isEmpty(fileOrDirectoryName)) {
166+
return false;
167+
}
168+
return fileOrDirectoryName.startsWith(".");
169+
}
170+
171+
/**
172+
* Determines if the given path is a metadata file.
173+
* <p>
174+
* A metadata file is a file which is not part of the actual content but rather contains metadata or is used by
175+
* the operating system or other tools.
176+
*
177+
* @param fileOrDirectoryName the path to check
178+
* @return <tt>true</tt> if the path is a metadata file that is listed in the METADATA_FILES list, <tt>false</tt> otherwise
179+
*/
180+
public static boolean isConsideredMetadata(@Nullable String fileOrDirectoryName) {
181+
if (Strings.isEmpty(fileOrDirectoryName)) {
182+
return false;
183+
}
184+
return METADATA_FILES.stream().anyMatch(fileOrDirectoryName::startsWith);
185+
}
186+
187+
/**
188+
* If the given file is not null and exists, tries to delete that file and logs when a file cannot be deleted.
189+
* This is useful for error reporting and to diagnose why a file cannot be deleted.
152190
*
153191
* @param file the file to delete
154192
*/
@@ -213,4 +251,27 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx
213251
}
214252
});
215253
}
254+
255+
/**
256+
* Returns a stream of all parts of the given path.
257+
* <p>
258+
* The stream will contain the filename, the parent directory, the parent of the parent and so on.
259+
*
260+
* @param path the path to split
261+
* @return a stream of all parts of the given path
262+
*/
263+
public static Stream<String> streamPath(String path) {
264+
if (Strings.isEmpty(path)) {
265+
return Stream.empty();
266+
}
267+
268+
Stream.Builder<String> builder = Stream.builder();
269+
builder.add(Files.getFilenameAndExtension(path));
270+
String parent = Files.getBasepath(path);
271+
while (Strings.isFilled(parent)) {
272+
builder.add(Files.getFilenameAndExtension(parent));
273+
parent = Files.getBasepath(parent);
274+
}
275+
return builder.build();
276+
}
216277
}

src/main/java/sirius/kernel/commons/StringCleanup.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,20 @@ public static String uppercase(@Nonnull String input) {
462462
return input.toUpperCase();
463463
}
464464

465+
/**
466+
* Capitalizes the first character of the given string.
467+
*
468+
* @param input the input to process
469+
* @return the resulting string
470+
*/
471+
public static String capitalize(@Nonnull String input) {
472+
char titleCasedChar = Character.toTitleCase(input.charAt(0));
473+
if (titleCasedChar == input.charAt(0)) {
474+
return input;
475+
}
476+
return titleCasedChar + input.substring(1);
477+
}
478+
465479
/**
466480
* Removes all {@linkplain #PATTERN_STRIP_XML XML tags} from the given string.
467481
*

0 commit comments

Comments
 (0)