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49:03 +0200
Subject: [PATCH 07/11] improve code: use replace variable
---
.../basisdatenservice/configuration/ClientConfiguration.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/ClientConfiguration.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/ClientConfiguration.java
index e6cc9c434..6cb9b0548 100644
--- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/ClientConfiguration.java
+++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/ClientConfiguration.java
@@ -29,11 +29,10 @@ public RestTemplate restTemplate(final WlsResponseErrorHandler wlsResponseErrorH
return execution.execute(request, body);
}
- if (!(authentication.getCredentials() instanceof AbstractOAuth2Token)) {
+ if (!(authentication.getCredentials() instanceof AbstractOAuth2Token token)) {
return execution.execute(request, body);
}
- val token = (AbstractOAuth2Token) authentication.getCredentials();
request.getHeaders().setBearerAuth(token.getTokenValue());
return execution.execute(request, body);
});
From 51e8aef63b2652036e4110a42520d9f481e4c887 Mon Sep 17 00:00:00 2001
From: MrSebastian <13592751+MrSebastian@users.noreply.github.com>
Date: Mon, 1 Jul 2024 12:21:24 +0200
Subject: [PATCH 08/11] change client and model package
---
docs/src/guides/how-to-create-client-from-open-api-json.md | 4 ++--
wls-basisdaten-service/pom.xml | 4 ++--
.../configuration/BasePathConfiguration.java | 2 +-
.../wahllokalsystem/basisdatenservice/rest/DemoClient.java | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/docs/src/guides/how-to-create-client-from-open-api-json.md b/docs/src/guides/how-to-create-client-from-open-api-json.md
index c931efb71..e9ccb177d 100644
--- a/docs/src/guides/how-to-create-client-from-open-api-json.md
+++ b/docs/src/guides/how-to-create-client-from-open-api-json.md
@@ -49,9 +49,9 @@ Für jeden zu erzeugenden Client mus ein `execution`-Element definiert werden.
- de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.eai.api
+ ${groupId}.basisdatenservice.eai.aou.client
- de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.eai.model
+ ${groupId}.basisdatenservice.eai.aou.model
false
diff --git a/wls-basisdaten-service/pom.xml b/wls-basisdaten-service/pom.xml
index 7cb0910dd..c679cb63a 100644
--- a/wls-basisdaten-service/pom.xml
+++ b/wls-basisdaten-service/pom.xml
@@ -353,8 +353,8 @@
java
resttemplate
- de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.eai.api
- de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.eai.model
+ ${groupId}.basisdatenservice.eai.aou.client
+ ${groupId}.basisdatenservice.eai.aou.model
false
false
diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/BasePathConfiguration.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/BasePathConfiguration.java
index a833679d6..b158469b9 100644
--- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/BasePathConfiguration.java
+++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/BasePathConfiguration.java
@@ -1,6 +1,6 @@
package de.muenchen.oss.wahllokalsystem.basisdatenservice.configuration;
-import de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.eai.ApiClient;
+import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.ApiClient;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/DemoClient.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/DemoClient.java
index da508a950..2a10352b4 100644
--- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/DemoClient.java
+++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/DemoClient.java
@@ -1,6 +1,6 @@
package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest;
-import de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.eai.api.WahlvorschlagControllerApi;
+import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.client.WahlvorschlagControllerApi;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.springframework.stereotype.Component;
From f7ccbbb5e64ef469db9d91e4e9792d206a8f1b60 Mon Sep 17 00:00:00 2001
From: MrSebastian <13592751+MrSebastian@users.noreply.github.com>
Date: Mon, 1 Jul 2024 12:24:17 +0200
Subject: [PATCH 09/11] wrap rest template code in configuration class
---
...how-to-create-client-from-open-api-json.md | 45 ++++++++++---------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/docs/src/guides/how-to-create-client-from-open-api-json.md b/docs/src/guides/how-to-create-client-from-open-api-json.md
index e9ccb177d..17ccf9fc2 100644
--- a/docs/src/guides/how-to-create-client-from-open-api-json.md
+++ b/docs/src/guides/how-to-create-client-from-open-api-json.md
@@ -118,29 +118,34 @@ Damit der generierte Client verwendet werden kann, muss dem Spring-Context noch
```java
-@Bean
-public RestTemplate restTemplate(final WlsResponseErrorHandler wlsResponseErrorHandler) {
- val restTemplate = new RestTemplate();
-
- /* definieren des Errorhandlers für Antworten vom externen Service */
- restTemplate.setErrorHandler(wlsResponseErrorHandler);
- /* Ergänzen eines Interceptors um den Bearer-Token an den nächsten Service weiter zu geben */
- restTemplate.getInterceptors().add((request, body, execution) -> {
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
- if (authentication == null) {
- return execution.execute(request, body);
- }
-
- if (!(authentication.getCredentials() instanceof AbstractOAuth2Token)) {
+@Configuration
+public class ClientConfiguration {
+
+ @Bean
+ public RestTemplate restTemplate(final WlsResponseErrorHandler wlsResponseErrorHandler) {
+ val restTemplate = new RestTemplate();
+
+ /* definieren des Errorhandlers für Antworten vom externen Service */
+ restTemplate.setErrorHandler(wlsResponseErrorHandler);
+ /* Ergänzen eines Interceptors um den Bearer-Token an den nächsten Service weiter zu geben */
+ restTemplate.getInterceptors().add((request, body, execution) -> {
+ Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ if (authentication == null) {
+ return execution.execute(request, body);
+ }
+
+ if (!(authentication.getCredentials() instanceof AbstractOAuth2Token)) {
+ return execution.execute(request, body);
+ }
+
+ val token = (AbstractOAuth2Token) authentication.getCredentials();
+ request.getHeaders().setBearerAuth(token.getTokenValue());
return execution.execute(request, body);
- }
+ });
- val token = (AbstractOAuth2Token) authentication.getCredentials();
- request.getHeaders().setBearerAuth(token.getTokenValue());
- return execution.execute(request, body);
- });
+ return restTemplate;
+ }
- return restTemplate;
}
```
From 6c9f541e92acc987931eb7adcc61877e4b18767d Mon Sep 17 00:00:00 2001
From: MrSebastian <13592751+MrSebastian@users.noreply.github.com>
Date: Mon, 1 Jul 2024 12:24:50 +0200
Subject: [PATCH 10/11] wrap wslResponseErrorHandler code in configuration
class
---
.../how-to-create-client-from-open-api-json.md | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/docs/src/guides/how-to-create-client-from-open-api-json.md b/docs/src/guides/how-to-create-client-from-open-api-json.md
index 17ccf9fc2..67a245b46 100644
--- a/docs/src/guides/how-to-create-client-from-open-api-json.md
+++ b/docs/src/guides/how-to-create-client-from-open-api-json.md
@@ -153,10 +153,16 @@ Wie zu erkennen ist, wird für das RestTemplate ein ErrorHandler benötigt, wobe
aus `wls-common:exception` verwenden. Eine entsprechende Bean muss ebenfalls noch dem Spring-Context hinzugefügt werden:
```java
+@Configuration
+public class ClientConfiguration {
+
+ //other configurations like the restTemplate bean factory method
-@Bean
-public WlsResponseErrorHandler wlsResponseErrorHandler(final ObjectMapper objectMapper) {
- return new WlsResponseErrorHandler(objectMapper);
+ @Bean
+ public WlsResponseErrorHandler wlsResponseErrorHandler(final ObjectMapper objectMapper) {
+ return new WlsResponseErrorHandler(objectMapper);
+ }
+
}
```
From 0fb04b642cee5a2b9467b67ed0fddb74d25f59b4 Mon Sep 17 00:00:00 2001
From: MrSebastian <13592751+MrSebastian@users.noreply.github.com>
Date: Mon, 1 Jul 2024 12:26:28 +0200
Subject: [PATCH 11/11] add hint that error will occur
---
wls-basisdaten-service/src/test/resources/demo.http | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wls-basisdaten-service/src/test/resources/demo.http b/wls-basisdaten-service/src/test/resources/demo.http
index 0c014406f..ebca281b3 100644
--- a/wls-basisdaten-service/src/test/resources/demo.http
+++ b/wls-basisdaten-service/src/test/resources/demo.http
@@ -17,6 +17,6 @@ username = wls_all
GET http://kubernetes.docker.internal:8100/auth/realms/wls_realm/protocol/openid-connect/userinfo
Authorization: {{ token_type }} {{ auth_token }}
-### Demo für client zu EAI
+### Demo für client zu EAI - will result in 500 als long as eai is not implemented (not implemented yet)
GET http://localhost:39151/demo
Authorization: {{ token_type }} {{ auth_token }}
\ No newline at end of file