From c09e7acb84d7c9dfa5273f8118faa9e6ab352a06 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:56:34 +0200 Subject: [PATCH 1/8] remove spring-data-rest-hal-explorer --- wls-broadcast-service/pom.xml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/wls-broadcast-service/pom.xml b/wls-broadcast-service/pom.xml index 96d12e36..20938d9c 100644 --- a/wls-broadcast-service/pom.xml +++ b/wls-broadcast-service/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 de.muenchen.oss.wahllokalsystem @@ -197,10 +198,6 @@ - - org.springframework.data - spring-data-rest-hal-explorer - org.projectlombok lombok @@ -319,7 +316,7 @@ maven-surefire-plugin ${maven-surefire-plugin.version} - ${surefireArgLine} -Dfile.encoding=${project.build.sourceEncoding} + ${surefireArgLine} -Dfile.encoding=${project.build.sourceEncoding} @@ -339,10 +336,10 @@ prepare-agent - true - ${sonar.jacoco.reportPath} - - surefireArgLine + true + ${sonar.jacoco.reportPath} + + surefireArgLine @@ -376,8 +373,8 @@ itm-java-codeformat/java_codestyle_formatter.xml - - + + From 87086284cb3e487e5d334bf1fb228f4bd4a627fa Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:00:00 +0200 Subject: [PATCH 2/8] remove spring-data-rest config class and annotations --- .../SpringRestConfiguration.java | 51 ------------------- .../rest/TheEntityRepository.java | 15 +++--- 2 files changed, 6 insertions(+), 60 deletions(-) delete mode 100644 wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/configuration/SpringRestConfiguration.java diff --git a/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/configuration/SpringRestConfiguration.java b/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/configuration/SpringRestConfiguration.java deleted file mode 100644 index 1b0681ba..00000000 --- a/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/configuration/SpringRestConfiguration.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c): it@M - Dienstleister für Informations- und Telekommunikationstechnik - * der Landeshauptstadt München, 2024 - */ -package de.muenchen.oss.wahllokalsystem.configuration; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.rest.core.config.RepositoryRestConfiguration; -import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener; -import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies; -import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; -import org.springframework.validation.Validator; -import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; -import org.springframework.web.servlet.config.annotation.CorsRegistry; - -@Configuration -public class SpringRestConfiguration implements RepositoryRestConfigurer { - - /** - * The method returns a {@link Validator} to get correct validation error messages. - * - * @return A {@link LocalValidatorFactoryBean} to get correct validation error messages. - */ - @Bean - public Validator validator() { - return new LocalValidatorFactoryBean(); - } - - /** - * See {@link RepositoryRestConfigurer#configureRepositoryRestConfiguration} - */ - @Override - public void configureRepositoryRestConfiguration(final RepositoryRestConfiguration config, final CorsRegistry corsRegistry) { - config.setRepositoryDetectionStrategy(RepositoryDetectionStrategies.DEFAULT); - } - - /** - * See {@link RepositoryRestConfigurer#configureValidatingRepositoryEventListener} - */ - @Override - public void configureValidatingRepositoryEventListener(final ValidatingRepositoryEventListener validatingListener) { - validatingListener.addValidator("afterCreate", validator()); - validatingListener.addValidator("beforeCreate", validator()); - validatingListener.addValidator("afterSave", validator()); - validatingListener.addValidator("beforeSave", validator()); - validatingListener.addValidator("beforeLinkSave", validator()); - validatingListener.addValidator("afterLinkSave", validator()); - } - -} diff --git a/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/rest/TheEntityRepository.java b/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/rest/TheEntityRepository.java index 4ce3d0b9..c1a5c70f 100644 --- a/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/rest/TheEntityRepository.java +++ b/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/rest/TheEntityRepository.java @@ -11,19 +11,16 @@ import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.data.repository.CrudRepository; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.security.access.prepost.PreAuthorize; /** * Provides a Repository for {@link TheEntity}. This Repository is exported as a REST resource. *

- * The Repository handles CRUD Operations. Every Operation is secured and takes care of the tenancy. - * For specific Documentation on how the generated REST point behaves, please consider the Spring - * Data Rest Reference + * The Repository handles CRUD Operations. Every Operation is secured and takes care of the tenancy. For specific Documentation on how the generated REST point + * behaves, please consider the Spring Data Rest Reference * here. *

*/ -@RepositoryRestResource @PreAuthorize("hasAuthority(T(de.muenchen.oss.wahllokalsystem.security.AuthoritiesEnum).WLS_BROADCAST_SERVICE_READ_THEENTITY.name())") public interface TheEntityRepository extends CrudRepository { //NOSONAR @@ -45,8 +42,8 @@ public interface TheEntityRepository extends CrudRepository { / /** * Create or update a {@link TheEntity}. *

- * If the id already exists, the {@link TheEntity} will be overridden, hence update. - * If the id does not already exist, a new {@link TheEntity} will be created, hence create. + * If the id already exists, the {@link TheEntity} will be overridden, hence update. If the id does not already exist, a new {@link TheEntity} will be + * created, hence create. *

* * @param theEntity The {@link TheEntity} that will be saved. @@ -60,8 +57,8 @@ public interface TheEntityRepository extends CrudRepository { / /** * Create or update a collection of {@link TheEntity}. *

- * If the id already exists, the {@link TheEntity}s will be overridden, hence update. - * If the id does not already exist, the new {@link TheEntity}s will be created, hence create. + * If the id already exists, the {@link TheEntity}s will be overridden, hence update. If the id does not already exist, the new {@link TheEntity}s will be + * created, hence create. *

* * @param entities The {@link TheEntity} that will be saved. From f2d10d3c26b40a6381262fe5713cafc8c63cf1f2 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:04:23 +0200 Subject: [PATCH 3/8] remove yml configuration for spring data rest --- .../src/main/resources/application-dev.yml | 21 ++++++------------- .../src/main/resources/application-kon.yml | 9 -------- .../src/main/resources/application-local.yml | 9 -------- .../src/main/resources/application-prod.yml | 9 -------- .../src/main/resources/application-test.yml | 9 -------- 5 files changed, 6 insertions(+), 51 deletions(-) diff --git a/wls-broadcast-service/src/main/resources/application-dev.yml b/wls-broadcast-service/src/main/resources/application-dev.yml index e4930daa..c3f8f19e 100644 --- a/wls-broadcast-service/src/main/resources/application-dev.yml +++ b/wls-broadcast-service/src/main/resources/application-dev.yml @@ -1,25 +1,16 @@ spring: - # Spring data rest - data: - rest: - # Definition of page size for PagingAndSortingRepository - max-page-size: 0x7fffffff - default-page-size: 0x7fffffff - return-body-on-update: true - return-body-on-create: true - # Spring JPA h2.console.enabled: true jpa: database: H2 hibernate: - # always drop and create the db should be the best - # configuration for local (development) mode. this - # is also the default, that spring offers by convention. - # but here explicite: - ddl-auto: create-drop - naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + # always drop and create the db should be the best + # configuration for local (development) mode. this + # is also the default, that spring offers by convention. + # but here explicite: + ddl-auto: create-drop + naming.physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl # Logging for database operation show-sql: true properties: diff --git a/wls-broadcast-service/src/main/resources/application-kon.yml b/wls-broadcast-service/src/main/resources/application-kon.yml index 71edf659..d3432e6b 100644 --- a/wls-broadcast-service/src/main/resources/application-kon.yml +++ b/wls-broadcast-service/src/main/resources/application-kon.yml @@ -1,14 +1,5 @@ spring: - # Spring data rest - data: - rest: - # Definition of page size for PagingAndSortingRepository - max-page-size: 0x7fffffff - default-page-size: 0x7fffffff - return-body-on-update: true - return-body-on-create: true - # Spring JPA h2.console.enabled: true jpa: diff --git a/wls-broadcast-service/src/main/resources/application-local.yml b/wls-broadcast-service/src/main/resources/application-local.yml index 382e3a29..00195fe9 100644 --- a/wls-broadcast-service/src/main/resources/application-local.yml +++ b/wls-broadcast-service/src/main/resources/application-local.yml @@ -2,15 +2,6 @@ server: port: 39146 spring: - # Spring data rest - data: - rest: - # Definition of page size for PagingAndSortingRepository - max-page-size: 0x7fffffff - default-page-size: 0x7fffffff - return-body-on-update: true - return-body-on-create: true - # Spring JPA h2.console.enabled: true jpa: diff --git a/wls-broadcast-service/src/main/resources/application-prod.yml b/wls-broadcast-service/src/main/resources/application-prod.yml index 7307c276..a484ba0d 100644 --- a/wls-broadcast-service/src/main/resources/application-prod.yml +++ b/wls-broadcast-service/src/main/resources/application-prod.yml @@ -1,14 +1,5 @@ spring: - # Spring data rest - data: - rest: - # Definition of page size for PagingAndSortingRepository - max-page-size: 0x7fffffff - default-page-size: 0x7fffffff - return-body-on-update: true - return-body-on-create: true - # Spring JPA h2.console.enabled: true jpa: diff --git a/wls-broadcast-service/src/main/resources/application-test.yml b/wls-broadcast-service/src/main/resources/application-test.yml index 4ffc2806..562b25f4 100644 --- a/wls-broadcast-service/src/main/resources/application-test.yml +++ b/wls-broadcast-service/src/main/resources/application-test.yml @@ -1,14 +1,5 @@ spring: - # Spring data rest - data: - rest: - # Definition of page size for PagingAndSortingRepository - max-page-size: 0x7fffffff - default-page-size: 0x7fffffff - return-body-on-update: true - return-body-on-create: true - # Spring JPA h2.console.enabled: true jpa: From 90ec711b0e7402436717f533a1f789f798548d1a Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:08:17 +0200 Subject: [PATCH 4/8] remove yml configuration for spring data rest --- .../src/test/resources/application-test.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/wls-broadcast-service/src/test/resources/application-test.yml b/wls-broadcast-service/src/test/resources/application-test.yml index d3c91569..5dcd8fb7 100644 --- a/wls-broadcast-service/src/test/resources/application-test.yml +++ b/wls-broadcast-service/src/test/resources/application-test.yml @@ -1,14 +1,5 @@ spring: - # Spring data rest - data: - rest: - # Definition of page size for PagingAndSortingRepository - max-page-size: 0x7fffffff - default-page-size: 0x7fffffff - return-body-on-update: true - return-body-on-create: true - # Spring JPA h2.console.enabled: true jpa: From 568ce80dd6d9fc2142a25fd6a8f5564ae979ca4f Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:13:36 +0200 Subject: [PATCH 5/8] =?UTF-8?q?=E2=8F=AA=EF=B8=8F=20unintended=20format=20?= =?UTF-8?q?changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wls-broadcast-service/pom.xml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/wls-broadcast-service/pom.xml b/wls-broadcast-service/pom.xml index 20938d9c..23830478 100644 --- a/wls-broadcast-service/pom.xml +++ b/wls-broadcast-service/pom.xml @@ -1,6 +1,5 @@ - + 4.0.0 de.muenchen.oss.wahllokalsystem @@ -316,7 +315,7 @@ maven-surefire-plugin ${maven-surefire-plugin.version} - ${surefireArgLine} -Dfile.encoding=${project.build.sourceEncoding} + ${surefireArgLine} -Dfile.encoding=${project.build.sourceEncoding} @@ -336,10 +335,10 @@ prepare-agent - true - ${sonar.jacoco.reportPath} - - surefireArgLine + true + ${sonar.jacoco.reportPath} + + surefireArgLine
@@ -373,8 +372,8 @@ itm-java-codeformat/java_codestyle_formatter.xml - - + + From adb7a9b3640c8003d8f0131f270c46f0f17fac15 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Mon, 15 Apr 2024 18:22:16 +0200 Subject: [PATCH 6/8] remove caching test for spring data rest endpoints --- .../CacheControlConfigurationTest.java | 49 ------------------- 1 file changed, 49 deletions(-) delete mode 100644 wls-broadcast-service/src/test/java/de/muenchen/oss/wahllokalsystem/configuration/CacheControlConfigurationTest.java diff --git a/wls-broadcast-service/src/test/java/de/muenchen/oss/wahllokalsystem/configuration/CacheControlConfigurationTest.java b/wls-broadcast-service/src/test/java/de/muenchen/oss/wahllokalsystem/configuration/CacheControlConfigurationTest.java deleted file mode 100644 index 7fb4a66a..00000000 --- a/wls-broadcast-service/src/test/java/de/muenchen/oss/wahllokalsystem/configuration/CacheControlConfigurationTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c): it@M - Dienstleister für Informations- und Telekommunikationstechnik - * der Landeshauptstadt München, 2024 - */ -package de.muenchen.oss.wahllokalsystem.configuration; - -import de.muenchen.oss.wahllokalsystem.MicroServiceApplication; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.ActiveProfiles; - -import static de.muenchen.oss.wahllokalsystem.TestConstants.SPRING_TEST_PROFILE; -import static de.muenchen.oss.wahllokalsystem.TestConstants.SPRING_NO_SECURITY_PROFILE; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@SpringBootTest( - classes = { MicroServiceApplication.class }, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = { - "spring.datasource.url=jdbc:h2:mem:testexample;DB_CLOSE_ON_EXIT=FALSE", - "refarch.gracefulshutdown.pre-wait-seconds=0" - } -) -@ActiveProfiles(profiles = { SPRING_TEST_PROFILE, SPRING_NO_SECURITY_PROFILE }) -class CacheControlConfigurationTest { - - private static final String ENTITY_ENDPOINT_URL = "/theEntities"; - - private static final String EXPECTED_CACHE_CONTROL_HEADER_VALUES = "no-cache, no-store, must-revalidate"; - - @Autowired - private TestRestTemplate testRestTemplate; - - @Test - void testForCacheControlHeadersForEntityEndpoint() { - ResponseEntity response = testRestTemplate.exchange(ENTITY_ENDPOINT_URL, HttpMethod.GET, null, String.class); - assertEquals(HttpStatus.OK, response.getStatusCode()); - assertTrue(response.getHeaders().containsKey(HttpHeaders.CACHE_CONTROL)); - assertEquals(EXPECTED_CACHE_CONTROL_HEADER_VALUES, response.getHeaders().getCacheControl()); - } - -} From 616c5d2b41ab5667e0a3c2000b734417e0008584 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:44:44 +0200 Subject: [PATCH 7/8] disable old test that work with spring data rest --- .../wahllokalsystem/configuration/UnicodeConfigurationTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wls-broadcast-service/src/test/java/de/muenchen/oss/wahllokalsystem/configuration/UnicodeConfigurationTest.java b/wls-broadcast-service/src/test/java/de/muenchen/oss/wahllokalsystem/configuration/UnicodeConfigurationTest.java index e6f0c15d..8959a617 100644 --- a/wls-broadcast-service/src/test/java/de/muenchen/oss/wahllokalsystem/configuration/UnicodeConfigurationTest.java +++ b/wls-broadcast-service/src/test/java/de/muenchen/oss/wahllokalsystem/configuration/UnicodeConfigurationTest.java @@ -8,6 +8,7 @@ import de.muenchen.oss.wahllokalsystem.domain.TheEntity; import de.muenchen.oss.wahllokalsystem.rest.TheEntityRepository; import org.apache.commons.lang3.StringUtils; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -54,6 +55,7 @@ class UnicodeConfigurationTest { private TheEntityRepository theEntityRepository; @Test + @Disabled("rework with real controller") void testForNfcNormalization() { // Persist entity with decomposed string. final TheEntityDto theEntityDto = new TheEntityDto(); From f7babcd66ee42a0e55aea1afbb2d951db06c2196 Mon Sep 17 00:00:00 2001 From: MrSebastian <13592751+MrSebastian@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:57:08 +0200 Subject: [PATCH 8/8] spotless:apply --- .../oss/wahllokalsystem/rest/TheEntityRepository.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/rest/TheEntityRepository.java b/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/rest/TheEntityRepository.java index c1a5c70f..cab528f5 100644 --- a/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/rest/TheEntityRepository.java +++ b/wls-broadcast-service/src/main/java/de/muenchen/oss/wahllokalsystem/rest/TheEntityRepository.java @@ -16,7 +16,8 @@ /** * Provides a Repository for {@link TheEntity}. This Repository is exported as a REST resource. *

- * The Repository handles CRUD Operations. Every Operation is secured and takes care of the tenancy. For specific Documentation on how the generated REST point + * The Repository handles CRUD Operations. Every Operation is secured and takes care of the tenancy. + * For specific Documentation on how the generated REST point * behaves, please consider the Spring Data Rest Reference * here. *

@@ -42,7 +43,8 @@ public interface TheEntityRepository extends CrudRepository { / /** * Create or update a {@link TheEntity}. *

- * If the id already exists, the {@link TheEntity} will be overridden, hence update. If the id does not already exist, a new {@link TheEntity} will be + * If the id already exists, the {@link TheEntity} will be overridden, hence update. If the id does + * not already exist, a new {@link TheEntity} will be * created, hence create. *

* @@ -57,7 +59,8 @@ public interface TheEntityRepository extends CrudRepository { / /** * Create or update a collection of {@link TheEntity}. *

- * If the id already exists, the {@link TheEntity}s will be overridden, hence update. If the id does not already exist, the new {@link TheEntity}s will be + * If the id already exists, the {@link TheEntity}s will be overridden, hence update. If the id does + * not already exist, the new {@link TheEntity}s will be * created, hence create. *

*