Skip to content

Commit e4bfc8b

Browse files
committed
java 24/ newer spring
1 parent 34fc3df commit e4bfc8b

5 files changed

Lines changed: 82 additions & 74 deletions

File tree

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM maven:3-eclipse-temurin-21 as builder
1+
FROM maven:3-eclipse-temurin-24 as builder
22
LABEL maintainer="contact@bittich.be"
33

44
WORKDIR /app
@@ -11,7 +11,7 @@ COPY ./src ./src
1111

1212
RUN mvn package -DskipTests
1313

14-
FROM ibm-semeru-runtimes:open-21-jre
14+
FROM ibm-semeru-runtimes:open-24-jre
1515

1616
WORKDIR /app
1717

pom.xml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.springframework.boot</groupId>
66
<artifactId>spring-boot-starter-parent</artifactId>
7-
<version>3.2.6</version>
7+
<version>3.5.6</version>
88
<relativePath /> <!-- lookup parent from repository -->
99
</parent>
1010
<groupId>tech.artcoded</groupId>
@@ -13,16 +13,16 @@
1313
<name>triplestore</name>
1414
<description>Triplestore based on tdb</description>
1515
<properties>
16-
<java.version>21</java.version>
17-
<artemis-jms-server.version>2.31.2</artemis-jms-server.version>
18-
<ehcache.version>3.10.8</ehcache.version>
19-
<jena.version>4.10.0</jena.version>
20-
<camel.version>4.5.0</camel.version>
21-
<commons-io.version>2.16.1</commons-io.version>
22-
<commons-lang3.version>3.14.0</commons-lang3.version>
23-
<guava.version>32.1.3-jre</guava.version>
24-
<micrometer-registry-prometheus.version>1.12.0</micrometer-registry-prometheus.version>
25-
<bucket4j.version>0.10.3</bucket4j.version>
16+
<java.version>24</java.version>
17+
<artemis-jms-server.version>2.42.0</artemis-jms-server.version>
18+
<ehcache.version>3.11.1</ehcache.version>
19+
<jena.version>5.5.0</jena.version>
20+
<camel.version>4.14.0</camel.version>
21+
<commons-io.version>2.20.0</commons-io.version>
22+
<commons-lang3.version>3.19.0</commons-lang3.version>
23+
<guava.version>33.5.0-jre</guava.version>
24+
<micrometer-registry-prometheus.version>1.15.4</micrometer-registry-prometheus.version>
25+
<bucket4j.version>0.13.0</bucket4j.version>
2626
</properties>
2727
<scm>
2828
<connection>
@@ -31,11 +31,11 @@
3131
<tag>2024.0.6</tag>
3232
</scm>
3333
<dependencies>
34-
<dependency>
35-
<groupId>com.giffing.bucket4j.spring.boot.starter</groupId>
36-
<artifactId>bucket4j-spring-boot-starter</artifactId>
34+
<dependency>
35+
<groupId>com.giffing.bucket4j.spring.boot.starter</groupId>
36+
<artifactId>bucket4j-spring-boot-starter</artifactId>
3737
<version>${bucket4j.version}</version>
38-
</dependency>
38+
</dependency>
3939

4040
<dependency>
4141
<groupId>org.springframework.boot</groupId>
@@ -170,6 +170,21 @@
170170

171171
<build>
172172
<plugins>
173+
<plugin>
174+
<groupId>org.apache.maven.plugins</groupId>
175+
<artifactId>maven-compiler-plugin</artifactId>
176+
<configuration>
177+
<source>${java.version}</source>
178+
<target>${java.version}</target>
179+
<annotationProcessorPaths>
180+
<path>
181+
<groupId>org.projectlombok</groupId>
182+
<artifactId>lombok</artifactId>
183+
<version>${lombok.version}</version>
184+
</path>
185+
</annotationProcessorPaths>
186+
</configuration>
187+
</plugin>
173188
<plugin>
174189
<groupId>org.springframework.boot</groupId>
175190
<artifactId>spring-boot-maven-plugin</artifactId>

src/main/java/tech/artcoded/triplestore/security/ResourceServerConfig.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,30 @@
1010
import org.springframework.security.oauth2.jwt.Jwt;
1111
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
1212
import org.springframework.security.web.SecurityFilterChain;
13-
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
14-
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
13+
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
1514

1615
@Configuration
1716
@EnableWebSecurity
1817
@ConditionalOnProperty(prefix = "application.security", name = "enabled", havingValue = "true")
1918
public class ResourceServerConfig {
2019

21-
private final HandlerMappingIntrospector introspector;
22-
23-
public ResourceServerConfig(HandlerMappingIntrospector introspector) {
24-
this.introspector = introspector;
20+
public ResourceServerConfig() {
2521
}
2622

2723
@Bean
2824
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
29-
var prometheusMatcher = new MvcRequestMatcher(introspector, "/api/actuator/prometheus/**");
30-
var publicMatcher = new MvcRequestMatcher(introspector, "/public/**");
31-
http
32-
.csrf().disable()
33-
.authorizeHttpRequests()
34-
.requestMatchers(publicMatcher).permitAll()
35-
.requestMatchers(prometheusMatcher)
36-
.hasAnyRole("PROMETHEUS")
37-
.anyRequest().authenticated()
38-
.and()
39-
.oauth2ResourceServer()
40-
.jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverter()));
25+
26+
var mvc = PathPatternRequestMatcher.withDefaults();
27+
http.csrf(c -> c.disable())
28+
.authorizeHttpRequests(a -> a.requestMatchers(mvc.matcher("/public/**")).permitAll()
29+
.requestMatchers(mvc.matcher("/api/actuator/prometheus/**"))
30+
.hasAnyRole("PROMETHEUS")
31+
.anyRequest().authenticated())
32+
33+
.httpBasic(auth -> auth.realmName("ArtcodedTriplestore"))
34+
.oauth2ResourceServer(a -> a.jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverter())));
4135
return http.build();
36+
4237
}
4338

4439
private Converter<Jwt, ? extends AbstractAuthenticationToken> jwtAuthenticationConverter() {

src/main/java/tech/artcoded/triplestore/sparql/route/MigrationRouteBuilder.java

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.apache.camel.ExchangePattern;
88
import org.apache.camel.Header;
99
import org.apache.camel.builder.RouteBuilder;
10-
import org.apache.commons.compress.utils.FileNameUtils;
10+
import org.apache.commons.io.FilenameUtils;
1111
import org.apache.commons.io.IOUtils;
1212
import org.apache.jena.rdf.model.ModelFactory;
1313
import org.apache.jena.riot.Lang;
@@ -23,7 +23,6 @@
2323
import java.util.UUID;
2424

2525
import static java.util.Optional.ofNullable;
26-
import static org.apache.commons.compress.utils.FileNameUtils.getBaseName;
2726
import static tech.artcoded.triplestore.sparql.route.Constants.*;
2827

2928
@Component
@@ -34,9 +33,9 @@ public class MigrationRouteBuilder extends RouteBuilder {
3433
private String defaultGraph;
3534

3635
private static final Cache<String, String> GRAPH_CACHE = Caffeine.newBuilder()
37-
.expireAfterAccess(Duration.ofMinutes(5))
38-
.maximumSize(1000)
39-
.build();
36+
.expireAfterAccess(Duration.ofMinutes(5))
37+
.maximumSize(1000)
38+
.build();
4039

4140
public MigrationRouteBuilder(TDBService tdbService) {
4241
this.tdbService = tdbService;
@@ -45,50 +44,49 @@ public MigrationRouteBuilder(TDBService tdbService) {
4544
record Migration(String uuid, long count) {
4645
}
4746

48-
4947
@Override
5048
public void configure() throws Exception {
5149
onException(Exception.class)
52-
.handled(true)
53-
.log("Exception occurred due: ${exception.message}")
54-
;
50+
.handled(true)
51+
.log("Exception occurred due: ${exception.message}");
5552

5653
from("file:{{triplestore.migration.dir}}?sortBy=file:name;file:modified")
57-
.routeId("MigrationRoute::Entrypoint")
58-
.log("receiving file '${headers.%s}', will execute migration to the triplestore".formatted(Exchange.FILE_NAME))
59-
.convertBodyTo(byte[].class)
60-
.choice()
61-
.when(header(Exchange.FILE_NAME).endsWith("graph"))
62-
.bean(() -> this, "addGraphToCache")
63-
.otherwise()
64-
.setProperty(HEADER_TITLE, simple("'${headers.%s}', has been executed to the triplestore".formatted(Exchange.FILE_NAME)))
65-
.setProperty(HEADER_TYPE, constant(SYNC_FILE_TRIPLESTORE))
66-
.to(ExchangePattern.InOnly, "direct:perform-migration")
67-
.endChoice();
54+
.routeId("MigrationRoute::Entrypoint")
55+
.log("receiving file '${headers.%s}', will execute migration to the triplestore".formatted(Exchange.FILE_NAME))
56+
.convertBodyTo(byte[].class)
57+
.choice()
58+
.when(header(Exchange.FILE_NAME).endsWith("graph"))
59+
.bean(() -> this, "addGraphToCache")
60+
.otherwise()
61+
.setProperty(HEADER_TITLE,
62+
simple("'${headers.%s}', has been executed to the triplestore".formatted(Exchange.FILE_NAME)))
63+
.setProperty(HEADER_TYPE, constant(SYNC_FILE_TRIPLESTORE))
64+
.to(ExchangePattern.InOnly, "direct:perform-migration")
65+
.endChoice();
6866

6967
from("direct:perform-migration")
70-
.routeId("MigrationRoute::PerformMigrationInternal")
71-
.bean(() -> this, "performMigration")
72-
.choice()
73-
.when(simple("${body.count} > 0"))
74-
.transform(simple("${body.uuid}"))
75-
.setHeader(CORRELATION_ID, body())
76-
.setHeader(HEADER_TITLE, exchangeProperty(HEADER_TITLE))
77-
.setHeader(HEADER_TYPE, exchangeProperty(HEADER_TYPE))
78-
.to(ExchangePattern.InOnly, NOTIFICATION_ENDPOINT)
79-
.otherwise()
80-
.log("No triples changed")
81-
.endChoice();
68+
.routeId("MigrationRoute::PerformMigrationInternal")
69+
.bean(() -> this, "performMigration")
70+
.choice()
71+
.when(simple("${body.count} > 0"))
72+
.transform(simple("${body.uuid}"))
73+
.setHeader(CORRELATION_ID, body())
74+
.setHeader(HEADER_TITLE, exchangeProperty(HEADER_TITLE))
75+
.setHeader(HEADER_TYPE, exchangeProperty(HEADER_TYPE))
76+
.to(ExchangePattern.InOnly, NOTIFICATION_ENDPOINT)
77+
.otherwise()
78+
.log("No triples changed")
79+
.endChoice();
8280
}
8381

8482
void addGraphToCache(@Body byte[] file,
85-
@Header(Exchange.FILE_NAME) String fileName) {
86-
GRAPH_CACHE.put(getBaseName(fileName), IOUtils.toString(file, StandardCharsets.UTF_8.name()));
83+
@Header(Exchange.FILE_NAME) String fileName) {
84+
GRAPH_CACHE.put(FilenameUtils.getBaseName(fileName), IOUtils.toString(file, StandardCharsets.UTF_8.name()));
8785
}
8886

8987
Migration performMigration(@Body byte[] file,
90-
@Header(Exchange.FILE_NAME) String fileName) {
91-
String extension = FileNameUtils.getExtension(fileName);
88+
@Header(Exchange.FILE_NAME) String fileName) {
89+
String extension = FilenameUtils.getExtension(fileName);
9290

9391
if ("sparql".equalsIgnoreCase(extension)) {
9492
var summary = tdbService.executeUpdateQuery(IOUtils.toString(file, StandardCharsets.UTF_8.name()));
@@ -97,11 +95,11 @@ Migration performMigration(@Body byte[] file,
9795
Lang lang = RDFLanguages.filenameToLang(fileName);
9896
var model = ModelFactory.createDefaultModel();
9997
RDFDataMgr.read(model, new ByteArrayInputStream(file), lang);
100-
String graph = ofNullable(GRAPH_CACHE.getIfPresent(getBaseName(fileName))).orElseGet(() -> defaultGraph);
98+
String graph = ofNullable(GRAPH_CACHE.getIfPresent(FilenameUtils.getBaseName(fileName)))
99+
.orElseGet(() -> defaultGraph);
101100
var summary = tdbService.batchLoadData(graph, model);
102101
return new Migration(UUID.randomUUID().toString(), summary);
103102
}
104103

105-
106104
}
107105
}

src/main/java/tech/artcoded/triplestore/sparql/route/UpdateRouteBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void configure() throws Exception {
4646
simple("Update query has been executed to the triplestore"))
4747
.setProperty(HEADER_TYPE, constant(UPDATE_QUERY_TRIPLESTORE))
4848
.transform()
49-
.body(o -> UUID.randomUUID().toString())
49+
.body(_ -> UUID.randomUUID().toString())
5050
.setHeader(CORRELATION_ID, body())
5151
.setHeader(HEADER_TITLE, exchangeProperty(HEADER_TITLE))
5252
.setHeader(HEADER_TYPE, exchangeProperty(HEADER_TYPE))

0 commit comments

Comments
 (0)