Skip to content

Commit

Permalink
[UP] ⬆️ Upgrade to spring boot 3
Browse files Browse the repository at this point in the history
Signed-off-by: Cécile Chemin <[email protected]>
  • Loading branch information
CChemin committed Jan 30, 2024
1 parent 5f84667 commit 7108bec
Show file tree
Hide file tree
Showing 44 changed files with 193 additions and 281 deletions.
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Sugoi-api implements spring actuator documentation available here : [link](https
| management.info.defaults.enabled | | | |
| management.endpoint.metrics.enabled | | | |
| management.endpoint.prometheus.enabled | | | |
| management.metrics.export.prometheus.enabled | | | |
| management.prometheus.metrics.export.enabled | | | |

A metrics event module is provided to add metrics when events occured. This is disabled by default and could be enable with :

Expand Down
102 changes: 28 additions & 74 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
<jacoco.unit-tests.limit.class-complexity>20</jacoco.unit-tests.limit.class-complexity>
<jacoco.unit-tests.limit.method-complexity>5</jacoco.unit-tests.limit.method-complexity>
<java.version>17</java.version>
<spring-boot.version>2.7.18</spring-boot.version>
<spring-boot.version>3.1.4</spring-boot.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<tomcat.version>9.0.78</tomcat.version>
<tomcat.version>10.1.18</tomcat.version>
<commons-io.version>2.11.0</commons-io.version>
<com.unboundid.version>6.0.8</com.unboundid.version>
<org.xmlunit.version>2.9.1</org.xmlunit.version>
<commons-lang.version>2.6</commons-lang.version>
<org.springdoc.version>1.7.0</org.springdoc.version>
<org.springdoc.version>2.3.0</org.springdoc.version>
<cucumber.version>7.5.0</cucumber.version>
<cucumber-reporting-plugin.version>7.3.0</cucumber-reporting-plugin.version>
<httpclient.version>4.5.14</httpclient.version>
Expand All @@ -42,8 +42,10 @@
<freemarker.version>2.3.32</freemarker.version>
<git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version>
<commons-io.version>2.11.0</commons-io.version>
<net.sf.ehcache.version>2.10.9.2</net.sf.ehcache.version>
<org.ehcache.version>3.10.8</org.ehcache.version>
<maven.jar.plugin.version>3.3.0</maven.jar.plugin.version>
<javax.jms-api.version>2.0.1</javax.jms-api.version>
<org.activemq.version>6.0.1</org.activemq.version>
</properties>

<dependencies></dependencies>
Expand All @@ -57,66 +59,6 @@
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>5.8.8</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>5.8.8</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
<version>5.8.8</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.8.8</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>5.8.8</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
<version>5.8.8</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<version>5.8.8</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-resource-server</artifactId>
<version>5.8.8</version>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-core</artifactId>
<version>5.8.8</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -301,13 +243,7 @@

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${org.springdoc.version}</version>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-security</artifactId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${org.springdoc.version}</version>
</dependency>

Expand Down Expand Up @@ -358,14 +294,32 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>{commons-io.version}</version>
<version>${commons-io.version}</version>
</dependency>

<dependency>
<groupId>net.sf.ehcache</groupId>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>${net.sf.ehcache.version}</version>
<version>${org.ehcache.version}</version>
</dependency>

<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>${javax.jms-api.version}</version>
</dependency>

<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>${org.activemq.version}</version>
</dependency>

<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-kahadb-store</artifactId>
<version>${org.activemq.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
14 changes: 14 additions & 0 deletions sugoi-api-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>

<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import fr.insee.sugoi.converter.utils.MapFromAttribute;
import jakarta.xml.bind.annotation.XmlAttribute;
import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;
import javax.xml.bind.annotation.XmlAttribute;

@JacksonXmlRootElement(localName = "application", namespace = Namespace.ANNUAIRE)
@JsonPropertyOrder({"name", "role"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import fr.insee.sugoi.model.Habilitation;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

/**
* Java class for HabilitationsType complex type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import jakarta.xml.bind.DatatypeConverter;
import java.io.IOException;
import javax.xml.bind.DatatypeConverter;

public class CertificateSerializer extends StdSerializer<byte[]> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import fr.insee.sugoi.converter.ouganext.OrganisationOuganext;
import fr.insee.sugoi.converter.utils.CustomObjectMapper;
import fr.insee.sugoi.model.*;
import jakarta.xml.bind.JAXBException;
import java.security.cert.CertificateException;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.junit.jupiter.api.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationModule;

public class CustomObjectMapper {

Expand All @@ -32,7 +32,7 @@ public static ObjectMapper JsonObjectMapper() {

public static XmlMapper XMLObjectMapper() {
XmlMapper xmlMapper = new XmlMapper();
JaxbAnnotationModule module = new JaxbAnnotationModule();
JakartaXmlBindAnnotationModule module = new JakartaXmlBindAnnotationModule();
xmlMapper.registerModule(module);
xmlMapper.enable(SerializationFeature.INDENT_OUTPUT);
xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
Expand Down
2 changes: 1 addition & 1 deletion sugoi-api-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</dependency>

<dependency>
<groupId>net.sf.ehcache</groupId>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,40 @@
*/
package fr.insee.sugoi.core.configuration;

import net.sf.ehcache.config.CacheConfiguration;
import org.springframework.cache.CacheManager;
import org.ehcache.config.builders.CacheConfigurationBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;
import org.ehcache.config.units.EntryUnit;
import org.ehcache.jsr107.Eh107Configuration;
import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
import org.springframework.cache.annotation.CachingConfigurer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.cache.interceptor.SimpleCacheErrorHandler;
import org.springframework.cache.interceptor.SimpleCacheResolver;
import org.springframework.cache.interceptor.SimpleKeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableCaching
public class EhCacheConfig implements CachingConfigurer {

@Bean(destroyMethod = "shutdown")
public net.sf.ehcache.CacheManager ehCacheManager() {

CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setName("Realms");
cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
cacheConfiguration.setMaxEntriesLocalHeap(1000);

CacheConfiguration cacheConfiguration1 = new CacheConfiguration();
cacheConfiguration1.setName("Realm");
cacheConfiguration1.setMemoryStoreEvictionPolicy("LRU");
cacheConfiguration1.setMaxEntriesLocalHeap(1000);

net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();

config.addCache(cacheConfiguration);
config.addCache(cacheConfiguration1);

return net.sf.ehcache.CacheManager.newInstance(config);
}

@Bean
@Override
public CacheManager cacheManager() {
return new EhCacheCacheManager(ehCacheManager());
}

@Bean
@Override
public KeyGenerator keyGenerator() {
return new SimpleKeyGenerator();
}

@Bean
@Override
public CacheResolver cacheResolver() {
return new SimpleCacheResolver(cacheManager());
}

@Bean
@Override
public CacheErrorHandler errorHandler() {
return new SimpleCacheErrorHandler();
public JCacheManagerCustomizer cacheManagerCustomizer() {
javax.cache.configuration.Configuration<String, Object> realmsConfiguration =
Eh107Configuration.fromEhcacheCacheConfiguration(
CacheConfigurationBuilder.newCacheConfigurationBuilder(
String.class,
Object.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(1000, EntryUnit.ENTRIES))
.build());
javax.cache.configuration.Configuration<String, Object> realmConfiguration =
Eh107Configuration.fromEhcacheCacheConfiguration(
CacheConfigurationBuilder.newCacheConfigurationBuilder(
String.class,
Object.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(1000, EntryUnit.ENTRIES))
.build());

return cm -> {
cm.createCache("Realms", realmsConfiguration);
cm.createCache("Realm", realmConfiguration);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public interface RealmProvider {
*
* @return List<Realm>, the realm list
*/
@Cacheable("Realms")
@Cacheable(value = "Realms", key = "#root.methodName")
public List<Realm> findAll();

@CacheEvict(
Expand Down
1 change: 0 additions & 1 deletion sugoi-api-core/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
spring.main.allow-bean-definition-overriding=true
logging.level.org.springframework.cache=TRACE

fr.insee.sugoi.store.defaultReader=
fr.insee.sugoi.store.defaultWriter=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
<artifactId>activemq-kahadb-store</artifactId>
</dependency>

<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
</dependency>

<dependency>
<groupId>com.unboundid</groupId>
<artifactId>unboundid-ldapsdk</artifactId>
Expand Down Expand Up @@ -83,6 +88,10 @@
<artifactId>wiremock-standalone</artifactId>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>

</dependencies>

Expand Down
Loading

0 comments on commit 7108bec

Please sign in to comment.