diff --git a/.github/workflows/admin-api-documentation.yml b/.github/workflows/admin-api-documentation.yml
index bb109a4d..62943348 100644
--- a/.github/workflows/admin-api-documentation.yml
+++ b/.github/workflows/admin-api-documentation.yml
@@ -19,7 +19,7 @@ jobs:
- name: Setup JVM
uses: actions/setup-java@v1
with:
- java-version: 11.0.10
+ java-version: 17
java-package: jdk
architecture: x64
diff --git a/pom.xml b/pom.xml
index 0b11b68f..5b2409d1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.0.6
+ 3.3.6
@@ -89,17 +89,14 @@
org.springframework.security
spring-security-web
- ${spring-security.version}
org.springframework.security
spring-security-config
- ${spring-security.version}
org.springframework.security
spring-security-core
- ${spring-security.version}
@@ -124,17 +121,6 @@
plexus-utils
3.3.0
-
-
- io.swagger.core.v3
- swagger-annotations
- 2.2.15
-
-
- io.springfox
- springfox-boot-starter
- ${springfox.boot.starter.version}
-
io.swagger.parser.v3
swagger-parser
@@ -171,9 +157,8 @@
${keycloak.version}
- javax.ws.rs
- javax.ws.rs-api
- ${javax.ws.rs-api.version}
+ jakarta.ws.rs
+ jakarta.ws.rs-api
@@ -183,11 +168,11 @@
true
+
org.apache.commons
commons-lang3
- ${commons-lang3.version}
@@ -212,7 +197,6 @@
org.liquibase
liquibase-core
- ${liquibase-core.version}
@@ -242,17 +226,14 @@
org.apache.logging.log4j
log4j-core
- ${log4j.version}
org.apache.logging.log4j
log4j-api
- ${log4j.version}
org.apache.logging.log4j
log4j-to-slf4j
- ${log4j.version}
@@ -266,12 +247,6 @@
org.yaml
snakeyaml
- 2.0
-
-
- io.swagger.core.v3
- swagger-annotations
- 2.2.15
@@ -282,7 +257,6 @@
com.h2database
h2
test
- ${h2.version}
org.springframework.boot
@@ -294,12 +268,6 @@
spring-security-test
test
-
- junit
- junit
- 4.12
- test
-
com.c4-soft.springaddons
@@ -318,6 +286,7 @@
+
org.springframework.boot
spring-boot-maven-plugin
@@ -554,7 +523,6 @@
org.liquibase
liquibase-maven-plugin
- ${liquibase-maven-plugin.version}
src/main/resources/liquibase.properties
@@ -563,7 +531,7 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- 3.3.0
+ 3.6.0
validate
@@ -587,9 +555,8 @@
org.apache.maven.plugins
maven-compiler-plugin
-
- 17
--enable-preview
+ ${java.version}
@@ -629,6 +596,24 @@
+
+ org.openrewrite.maven
+ rewrite-maven-plugin
+ 5.46.1
+
+ true
+
+ org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3
+
+
+
+
+ org.openrewrite.recipe
+ rewrite-spring
+ 5.24.1
+
+
+
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/admin/controller/AgencyAdminController.java b/src/main/java/de/caritas/cob/agencyservice/api/admin/controller/AgencyAdminController.java
index db71124b..70e27627 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/admin/controller/AgencyAdminController.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/admin/controller/AgencyAdminController.java
@@ -16,7 +16,7 @@
import de.caritas.cob.agencyservice.api.model.Sort;
import de.caritas.cob.agencyservice.api.model.UpdateAgencyDTO;
import de.caritas.cob.agencyservice.generated.api.admin.controller.AgencyadminApi;
-import io.swagger.annotations.Api;
+import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
@@ -33,7 +33,7 @@
* Controller to handle all agency admin requests.
*/
@RestController
-@Api(tags = "admin-agency-controller")
+@Tag(name = "admin-agency-controller")
@RequiredArgsConstructor
public class AgencyAdminController implements AgencyadminApi {
@@ -92,8 +92,6 @@ public ResponseEntity searchAgencies(
@Override
@PreAuthorize("hasAuthority('AUTHORIZATION_AGENCY_ADMIN')")
public ResponseEntity createAgency(@Valid AgencyDTO agencyDTO) {
-
-
agencyValidator.validate(agencyDTO);
var agencyAdminFullResponseDTO = agencyAdminService
.createAgency(agencyDTO);
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/controller/AgencyController.java b/src/main/java/de/caritas/cob/agencyservice/api/controller/AgencyController.java
index bb50d200..fc77df5c 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/controller/AgencyController.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/controller/AgencyController.java
@@ -6,7 +6,7 @@
import de.caritas.cob.agencyservice.api.model.FullAgencyResponseDTO;
import de.caritas.cob.agencyservice.api.service.AgencyService;
import de.caritas.cob.agencyservice.generated.api.controller.AgenciesApi;
-import io.swagger.annotations.Api;
+import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import java.util.Optional;
import lombok.NonNull;
@@ -22,7 +22,7 @@
* Controller for agency API requests
*/
@RestController
-@Api(tags = "agency-controller")
+@Tag(name = "agency-controller")
@RequiredArgsConstructor
public class AgencyController implements AgenciesApi {
@@ -40,10 +40,10 @@ public class AgencyController implements AgenciesApi {
@Override
public ResponseEntity> getAgencies(
@RequestParam Integer consultingType, @RequestParam(required = false) String postcode,
- @RequestParam(value = "topicId", required = false) Integer topicId,
- @RequestParam(value = "age", required = false) Integer age,
- @RequestParam(value = "gender", required = false) String gender,
- @RequestParam(value = "counsellingRelation", required = false) String counsellingRelation
+ @RequestParam(required = false) Integer topicId,
+ @RequestParam(required = false) Integer age,
+ @RequestParam(required = false) String gender,
+ @RequestParam(required = false) String counsellingRelation
) {
var agencies = agencyService.getAgencies(Optional.ofNullable(postcode), consultingType,
@@ -62,7 +62,7 @@ public ResponseEntity> getAgencies(
*/
@Override
public ResponseEntity> getAgenciesByIds(
- @PathVariable("agencyIds") List agencyIds) {
+ @PathVariable List agencyIds) {
var agencies = agencyService.getAgencies(agencyIds);
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIController.java b/src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIController.java
deleted file mode 100644
index e89a9613..00000000
--- a/src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIController.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package de.caritas.cob.agencyservice.api.controller;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import springfox.documentation.annotations.ApiIgnore;
-
-@Controller
-@ApiIgnore
-public class CustomSwaggerUIController {
- @Value("${springfox.docuPath}")
- private String docuPath;
-
- @RequestMapping(value = "${springfox.docuPath}")
- public String index() {
- return "redirect:" + docuPath + "/swagger-ui.html";
- }
-}
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/exception/KeycloakException.java b/src/main/java/de/caritas/cob/agencyservice/api/exception/KeycloakException.java
index da6b3358..20c2d37d 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/exception/KeycloakException.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/exception/KeycloakException.java
@@ -1,7 +1,10 @@
package de.caritas.cob.agencyservice.api.exception;
+import java.io.Serial;
+
public class KeycloakException extends RuntimeException {
+ @Serial
private static final long serialVersionUID = -5083156826149548581L;
/**
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/exception/MissingConsultingTypeException.java b/src/main/java/de/caritas/cob/agencyservice/api/exception/MissingConsultingTypeException.java
index dc289c17..9576d6cc 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/exception/MissingConsultingTypeException.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/exception/MissingConsultingTypeException.java
@@ -1,7 +1,10 @@
package de.caritas.cob.agencyservice.api.exception;
+import java.io.Serial;
+
public class MissingConsultingTypeException extends Exception {
+ @Serial
private static final long serialVersionUID = -6127271234647444277L;
/**
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/BadRequestException.java b/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/BadRequestException.java
index 66d2ca47..627d5807 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/BadRequestException.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/BadRequestException.java
@@ -1,9 +1,11 @@
package de.caritas.cob.agencyservice.api.exception.httpresponses;
import de.caritas.cob.agencyservice.api.service.LogService;
+import java.io.Serial;
public class BadRequestException extends CustomHttpStatusException {
+ @Serial
private static final long serialVersionUID = -8047408802295905803L;
/**
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/CustomHttpStatusException.java b/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/CustomHttpStatusException.java
index 3dee1c53..aaea3229 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/CustomHttpStatusException.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/CustomHttpStatusException.java
@@ -2,6 +2,7 @@
import static java.util.Objects.nonNull;
+import java.io.Serial;
import java.util.function.Consumer;
/**
@@ -9,6 +10,7 @@
*/
public abstract class CustomHttpStatusException extends RuntimeException {
+ @Serial
private static final long serialVersionUID = -3545035432045919306L;
private final Consumer loggingMethod;
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/InternalServerErrorException.java b/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/InternalServerErrorException.java
index c431dcd7..31f82bc6 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/InternalServerErrorException.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/exception/httpresponses/InternalServerErrorException.java
@@ -1,6 +1,7 @@
package de.caritas.cob.agencyservice.api.exception.httpresponses;
import de.caritas.cob.agencyservice.api.service.LogService;
+import java.io.Serial;
import java.util.function.Consumer;
/**
@@ -8,6 +9,7 @@
*/
public class InternalServerErrorException extends CustomHttpStatusException {
+ @Serial
private static final long serialVersionUID = 6051508644381775936L;
/**
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/manager/consultingtype/ConsultingTypeManager.java b/src/main/java/de/caritas/cob/agencyservice/api/manager/consultingtype/ConsultingTypeManager.java
index 8ba60546..fdf4def9 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/manager/consultingtype/ConsultingTypeManager.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/manager/consultingtype/ConsultingTypeManager.java
@@ -28,7 +28,7 @@ public ExtendedConsultingTypeResponseDTO getConsultingTypeSettings(int consultin
return consultingTypeService.getExtendedConsultingTypeResponseDTO(consultingTypeId);
} catch (RestClientException ex) {
throw new MissingConsultingTypeException(
- String.format("No settings for consulting type %s found.", consultingTypeId));
+ "No settings for consulting type %s found.".formatted(consultingTypeId));
}
}
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/repository/agency/Agency.java b/src/main/java/de/caritas/cob/agencyservice/api/repository/agency/Agency.java
index 5de6e9e5..ce19bece 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/repository/agency/Agency.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/repository/agency/Agency.java
@@ -43,9 +43,6 @@
@Getter
@Setter
@Builder
-@FilterDef(
- name = "tenantFilter",
- parameters = {@ParamDef(name = "tenantId", type = Long.class)})
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
public class Agency implements TenantAware {
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/repository/agencypostcoderange/AgencyPostcodeRange.java b/src/main/java/de/caritas/cob/agencyservice/api/repository/agencypostcoderange/AgencyPostcodeRange.java
index 42d0a13d..9efb3092 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/repository/agencypostcoderange/AgencyPostcodeRange.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/repository/agencypostcoderange/AgencyPostcodeRange.java
@@ -38,7 +38,6 @@
@Getter
@Setter
@Builder
-@FilterDef(name = "tenantFilter", parameters = {@ParamDef(name = "tenantId", type = Long.class)})
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
public class AgencyPostcodeRange implements TenantAware {
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/repository/package-info.java b/src/main/java/de/caritas/cob/agencyservice/api/repository/package-info.java
new file mode 100644
index 00000000..5e8caf01
--- /dev/null
+++ b/src/main/java/de/caritas/cob/agencyservice/api/repository/package-info.java
@@ -0,0 +1,11 @@
+@FilterDefs({
+ @FilterDef(
+ name = "tenantFilter",
+ parameters = {@ParamDef(name = "tenantId", type = Long.class)}
+ )
+})
+package de.caritas.cob.agencyservice.api.repository;
+
+import org.hibernate.annotations.FilterDef;
+import org.hibernate.annotations.FilterDefs;
+import org.hibernate.annotations.ParamDef;
\ No newline at end of file
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/service/AgencyService.java b/src/main/java/de/caritas/cob/agencyservice/api/service/AgencyService.java
index 1d453a67..ca9a1455 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/service/AgencyService.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/service/AgencyService.java
@@ -34,6 +34,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
/**
* Service for agencies.
@@ -75,6 +76,7 @@ public class AgencyService {
* @param agencyIds the ids of requested agencies
* @return a list containing regarding agencies
*/
+ @Transactional
public List getAgencies(List agencyIds) {
return getAgencyRepositoryForSearch().findByIdIn(agencyIds).stream()
.map(this::convertToAgencyResponseDTO)
@@ -98,7 +100,7 @@ public List getAgencies(int consultingTypeId) {
} catch (MissingConsultingTypeException ex) {
throw new BadRequestException(
- String.format("Consulting type with id %s does not exist", consultingTypeId));
+ "Consulting type with id %s does not exist".formatted(consultingTypeId));
}
}
@@ -190,7 +192,7 @@ private List findAgencies(AgencySearch agencySearch) {
}
private void assertTopicIdIsProvided(Optional topicId) {
- if (!topicId.isPresent()) {
+ if (topicId.isEmpty()) {
throw new BadRequestException("Topic id not provided in the search");
}
}
@@ -261,10 +263,10 @@ private AgencyRepository getAgencyRepositoryForSearch() {
}
private void assertAgeAndGenderAreProvided(Optional age, Optional gender) {
- if (!age.isPresent()) {
+ if (age.isEmpty()) {
throw new BadRequestException("Age not provided in the search");
}
- if (!gender.isPresent()) {
+ if (gender.isEmpty()) {
throw new BadRequestException("Age not provided in the search");
}
}
@@ -311,10 +313,14 @@ private AgencyResponseDTO convertToAgencyResponseDTO(Agency agency) {
.tenantId(agency.getTenantId())
.consultingType(agency.getConsultingTypeId())
.agencySpecificPrivacy(renderedAgencySpecificPrivacy)
- .topicIds(agency.getAgencyTopics().stream().map(AgencyTopic::getTopicId).toList())
+ .topicIds(getAgencyTopics(agency).stream().map(AgencyTopic::getTopicId).toList())
.agencyLogo(agency.getAgencyLogo());
}
+ private static List getAgencyTopics(Agency agency) {
+ return agency.getAgencyTopics() == null ? Lists.newArrayList() : agency.getAgencyTopics();
+ }
+
protected String getRenderedAgencySpecificPrivacy(Agency agency) {
RestrictedTenantDTO tenantDataHoldingFeatureToggles = getTenantDataRelevantForFeatureToggles(
agency);
@@ -342,7 +348,7 @@ private FullAgencyResponseDTO convertToFullAgencyResponseDTO(Agency agency) {
.external(agency.isExternal())
.demographics(getDemographics(agency))
.tenantId(agency.getTenantId())
- .topicIds(agency.getAgencyTopics().stream().map(AgencyTopic::getTopicId).toList())
+ .topicIds(getAgencyTopics(agency).stream().map(AgencyTopic::getTopicId).toList())
.agencyLogo(agency.getAgencyLogo());
}
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/service/CentralDataProtectionTemplateService.java b/src/main/java/de/caritas/cob/agencyservice/api/service/CentralDataProtectionTemplateService.java
index f685b7ee..b5dc7095 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/service/CentralDataProtectionTemplateService.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/service/CentralDataProtectionTemplateService.java
@@ -10,7 +10,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
-import javax.annotation.Nullable;
+import jakarta.annotation.Nullable;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/service/LogService.java b/src/main/java/de/caritas/cob/agencyservice/api/service/LogService.java
index 4c0fa323..2c5dcf4e 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/service/LogService.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/service/LogService.java
@@ -2,7 +2,7 @@
import static org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace;
-import javax.ws.rs.BadRequestException;
+import jakarta.ws.rs.BadRequestException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
diff --git a/src/main/java/de/caritas/cob/agencyservice/api/service/TenantHibernateInterceptor.java b/src/main/java/de/caritas/cob/agencyservice/api/service/TenantHibernateInterceptor.java
index 9e1bce47..9835be1f 100644
--- a/src/main/java/de/caritas/cob/agencyservice/api/service/TenantHibernateInterceptor.java
+++ b/src/main/java/de/caritas/cob/agencyservice/api/service/TenantHibernateInterceptor.java
@@ -8,17 +8,18 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.EmptyInterceptor;
+import org.hibernate.Interceptor;
@RequiredArgsConstructor
@Slf4j
-public class TenantHibernateInterceptor extends EmptyInterceptor {
+public class TenantHibernateInterceptor implements Interceptor {
private final Long TECHNICAL_TENANT_ID = 0L;
private static Boolean multiTenancyEnabled;
@Override
- public void preFlush(Iterator entities) {
+ public void preFlush(Iterator