diff --git a/Jenkinsfile b/Jenkinsfile index 88e9db21d229a1e15b4c4364e390c58f84ce7edc..c1d239ddccf9b09bd4db657d93eeb6e4b23819fb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,7 +29,7 @@ pipeline { def interfaceVersion = getPomVersion('pluto-interface/pom.xml') def mailVersion = getPomVersion('mail-service/pom.xml') - if(env.BRANCH_NAME == 'release'){ + if(env.BRANCH_NAME == 'release' || env.BRANCH_NAME == 'release-hf-1.16'){ if ( !(rootVersion ==~ RELEASE_REGEX) || !(serverVersion ==~ RELEASE_REGEX) || !(interfaceVersion ==~ RELEASE_REGEX) || !(mailVersion ==~ RELEASE_REGEX)) { error("Keine Release Version für Branch ${env.BRANCH_NAME}.") } @@ -80,6 +80,7 @@ pipeline { anyOf { branch 'master' branch 'release' + branch 'release-hf-1.16' } } steps { @@ -250,7 +251,7 @@ pipeline { Void deployHelmChart(String helmChartVersion) { withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]){ - if (env.BRANCH_NAME == 'release') { + if (env.BRANCH_NAME == 'release' || env.BRANCH_NAME == 'release-hf-1.16') { result = sh script: '''curl -u $USERNAME:$PASSWORD https://nexus.ozg-sh.de/service/rest/v1/components?repository=ozg-base-apps -F file=@pluto-'''+helmChartVersion+'''.tgz''', returnStdout: true } else { @@ -269,7 +270,7 @@ String generateHelmChartVersion() { if (env.BRANCH_NAME == 'master') { chartVersion += "-${env.GIT_COMMIT.take(7)}" } - else if (env.BRANCH_NAME != 'release') { + else if (env.BRANCH_NAME != 'release' && env.BRANCH_NAME != 'release-hf-1.16') { chartVersion += "-${env.BRANCH_NAME}" } @@ -388,4 +389,4 @@ String getElementAccessToken() { withCredentials([string(credentialsId: 'element-login-json', variable: 'LOGIN_JSON')]) { return readJSON ( text: sh (script: '''curl -XPOST -d \"$LOGIN_JSON\" https://matrix.ozg-sh.de/_matrix/client/v3/login''', returnStdout: true)).access_token } -} \ No newline at end of file +} diff --git a/bescheid-manager/src/main/java/de/ozgcloud/bescheid/BescheidService.java b/bescheid-manager/src/main/java/de/ozgcloud/bescheid/BescheidService.java index 613a0fb9d0ee0c78b61a82b27b46d027046c46f5..9b12c1628de7aebdff17cf1caa81b005657a6bf6 100644 --- a/bescheid-manager/src/main/java/de/ozgcloud/bescheid/BescheidService.java +++ b/bescheid-manager/src/main/java/de/ozgcloud/bescheid/BescheidService.java @@ -2,6 +2,8 @@ package de.ozgcloud.bescheid; import java.util.Objects; +import jakarta.annotation.PostConstruct; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -20,6 +22,15 @@ class BescheidService { @Autowired(required = false) private BescheidRemoteService remoteService; + @PostConstruct + void logStatus() { + if (Objects.isNull(ERROR_MESSAGE_NO_SERVICE)) { + LOG.info("No BescheidRemoteService configured - Bescheid creation is not possible."); + } else { + LOG.info("Bescheid-Manager is configured."); + } + } + public Bescheid createBescheid(BescheidRequest request) { checkRemoteService(); diff --git a/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsBescheidRemoteService.java b/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsBescheidRemoteService.java index f23cac9489d4c17821a943889bbe6f2b24a76760..3cb8cb1f077118777ca6ece8429b1a7b23818462 100644 --- a/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsBescheidRemoteService.java +++ b/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsBescheidRemoteService.java @@ -6,8 +6,11 @@ import java.util.Collection; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.http.HttpStatusCode; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; +import org.springframework.web.reactive.function.BodyExtractors; +import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; import com.fasterxml.jackson.core.JsonProcessingException; @@ -15,6 +18,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import de.itvsh.kop.common.binaryfile.FileDataDeserializer; +import de.itvsh.kop.common.errorhandling.TechnicalException; import de.ozgcloud.bescheid.Bescheid; import de.ozgcloud.bescheid.BescheidRemoteService; import de.ozgcloud.bescheid.BescheidRequest; @@ -28,6 +32,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.SneakyThrows; import lombok.extern.log4j.Log4j2; +import reactor.core.publisher.Mono; @Log4j2 @Service @@ -45,14 +50,20 @@ class SmartDocumentsBescheidRemoteService implements BescheidRemoteService { @Override public Bescheid create(BescheidRequest request, Vorgang vorgang) { return smartDocumentsWebClient.post().accept(MediaType.APPLICATION_JSON) - .contentType(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON_UTF8) .bodyValue(createRequest(request, vorgang)) .retrieve() + .onStatus(HttpStatusCode::is4xxClientError, this::handleClientError) .bodyToMono(SmartDocumentsResponse.class) .map(response -> buildBescheid(request, response)) .block(); } + Mono<? extends Throwable> handleClientError(ClientResponse response) { + return response.body(BodyExtractors.toMono(String.class)) + .map(content -> new TechnicalException("Client-Error: " + content)); + } + Bescheid buildBescheid(BescheidRequest request, SmartDocumentsResponse smartDocumentsResponse) { var smartDocumentsFile = getSmartDocumentsFile(smartDocumentsResponse); diff --git a/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsConfiguration.java b/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsConfiguration.java index 17eff2b9a9d0f65e92d8cf5db9b2446394bb7497..579a53d016fe65a7a0c9110173ead505b2793476 100644 --- a/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsConfiguration.java +++ b/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsConfiguration.java @@ -1,21 +1,53 @@ package de.ozgcloud.bescheid.smartdocuments; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.web.reactive.function.client.ExchangeFilterFunctions; import org.springframework.web.reactive.function.client.WebClient; +import reactor.netty.http.client.HttpClient; +import reactor.netty.transport.ProxyProvider; + @Configuration +@ConditionalOnProperty("ozgcloud.bescheid.smart-documents.url") class SmartDocumentsConfiguration { + @Autowired + private SmartDocumentsProperties properties; + @Bean("smartDocuments") - @ConditionalOnProperty("ozgcloud.bescheid.smart-documents.url") - WebClient smartDocumentsWebClient(SmartDocumentsProperties properties) { + WebClient smartDocumentsWebClient() { + ReactorClientHttpConnector connector = new ReactorClientHttpConnector(buildHttpClient()); + return WebClient.builder() .baseUrl(properties.getUrl()) .filter(ExchangeFilterFunctions.basicAuthentication(properties.getBasicAuth().getUsername(), properties.getBasicAuth().getPassword())) + .clientConnector(connector) .build(); } + private HttpClient buildHttpClient() { + if (properties.getProxy() != null) { + return createProxyHttpClient(); + } else { + return createNoProxyHttpClient(); + } + } + + private HttpClient createNoProxyHttpClient() { + return HttpClient.create(); + } + + private HttpClient createProxyHttpClient() { + return HttpClient.create() + .proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP) + .host(properties.getProxy().getHost()) + .port(properties.getProxy().getPort()) + .username(properties.getProxy().getUsername()) + .password(username -> properties.getProxy().getPassword())); + } + } diff --git a/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsProperties.java b/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsProperties.java index 191593e4d7e91ea6d308528fa819e2a5372ed4c6..c45e9383c581e237dbf565d6daab0a5b9c217dc7 100644 --- a/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsProperties.java +++ b/bescheid-manager/src/main/java/de/ozgcloud/bescheid/smartdocuments/SmartDocumentsProperties.java @@ -1,13 +1,14 @@ package de.ozgcloud.bescheid.smartdocuments; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; + import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; import org.springframework.validation.annotation.Validated; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; @@ -43,6 +44,11 @@ public class SmartDocumentsProperties { @NotBlank private String template; + /** + * Proxy Configuration if required. + */ + private ProxyConfiguration proxy; + @Getter @Setter static class UsernamePassword { @@ -57,4 +63,26 @@ public class SmartDocumentsProperties { @NotBlank private String password; } + + @Getter + @Setter + static class ProxyConfiguration { + /** + * Host Address of the proxy server with protocol + */ + @NotBlank + private String host; + /** + * Port Number of the proxy server + */ + private int port = 8080; + /** + * Username for Authentication for the proxy server + */ + private String username; + /** + * Username for Authentication for the proxy server + */ + private String password; + } } diff --git a/bescheid-manager/src/test/java/de/ozgcloud/bescheid/vorgang/VorgangTestFactory.java b/bescheid-manager/src/test/java/de/ozgcloud/bescheid/vorgang/VorgangTestFactory.java index 8f02dff6e4cea452e8e159e68d43b9bc93378d1f..d6c02552c3b866edb6e8de5d2c20439d09815d01 100644 --- a/bescheid-manager/src/test/java/de/ozgcloud/bescheid/vorgang/VorgangTestFactory.java +++ b/bescheid-manager/src/test/java/de/ozgcloud/bescheid/vorgang/VorgangTestFactory.java @@ -14,9 +14,9 @@ public class VorgangTestFactory { return Vorgang.builder() .id(ID) .serviceKonto(ServiceKontoTestFactory.create()) - .vorgangName("Antrag auf ein Halteverbot") + .vorgangName("KFAS_LIVE_KI_10_Haltverbot_befristet") .vorgangNummer("ABC-123-XY") - .aktenzeichen("DE-HV-003"); + .aktenzeichen("DE-HÖÄ-003"); } } diff --git a/pluto-server/pom.xml b/pluto-server/pom.xml index eb9a9a4b504e2d33943d07d51a87b5d347d6b6c1..4fcc8c071567181188b252d643509ff406a36b03 100644 --- a/pluto-server/pom.xml +++ b/pluto-server/pom.xml @@ -58,6 +58,7 @@ <zip.version>2.11.1</zip.version> <jsoup.version>1.15.3</jsoup.version> <mongock.version>5.3.4</mongock.version> + <testcontainer.version>1.17.3</testcontainer.version> <maven-deploy-plugin.version>3.0.0</maven-deploy-plugin.version> <find-and-replace-maven-plugin.version>1.1.0</find-and-replace-maven-plugin.version> @@ -341,12 +342,19 @@ <configuration> <mainClass>de.itvsh.ozg.pluto.PlutoServerApplication</mainClass> <image> + <!-- cann be removed when common-lib > 2.3.2--> + <builder>paketobuildpacks/builder-jammy-base</builder> + <env> + <BPE_DELIM_JAVA_TOOL_OPTIONS xml:space="preserve"> </BPE_DELIM_JAVA_TOOL_OPTIONS> + <BPE_APPEND_JAVA_TOOL_OPTIONS>-Dfile.encoding=UTF-8</BPE_APPEND_JAVA_TOOL_OPTIONS> + </env> <builder>paketobuildpacks/builder-jammy-base</builder> </image> <profiles> <profile>local</profile> <profile>a12proc</profile> </profiles> + </image> </configuration> </plugin> diff --git a/pluto-server/src/main/resources/application-local.yml b/pluto-server/src/main/resources/application-local.yml index 160885256028aabe8eead9b8c8e13548226828b2..a1c5c99179a6712b7ff195fa29c4790a22930237 100644 --- a/pluto-server/src/main/resources/application-local.yml +++ b/pluto-server/src/main/resources/application-local.yml @@ -69,6 +69,11 @@ ozgcloud: password: MGM templateGroup: Kiel template: Halteverbot +# proxy: +# host: http://localhost +# port: 8080 +# username: theo +# password: geheim user: cleanup: cron: 0 */5 * * * * diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/PlutoServerApplicationTests.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/PlutoServerApplicationTest.java similarity index 100% rename from pluto-server/src/test/java/de/itvsh/ozg/pluto/PlutoServerApplicationTests.java rename to pluto-server/src/test/java/de/itvsh/ozg/pluto/PlutoServerApplicationTest.java