aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv')
-rw-r--r--src/main/java/at/gv/egiz/moazs/config/RepositoryConfig.java8
-rw-r--r--src/main/java/at/gv/egiz/moazs/process/SingleNodeResponseHandler.java4
-rw-r--r--src/main/java/at/gv/egiz/moazs/process/SingleThreadedDeliveryPipeline.java (renamed from src/main/java/at/gv/egiz/moazs/pipeline/SingleThreadedDeliveryPipeline.java)0
-rw-r--r--src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java2
-rw-r--r--src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java5
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java29
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java20
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java13
-rw-r--r--src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java12
-rw-r--r--src/main/java/at/gv/egiz/moazs/verify/MsgResponseVerifier.java6
10 files changed, 48 insertions, 51 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/config/RepositoryConfig.java b/src/main/java/at/gv/egiz/moazs/config/RepositoryConfig.java
index ee73b9e..01a4cc3 100644
--- a/src/main/java/at/gv/egiz/moazs/config/RepositoryConfig.java
+++ b/src/main/java/at/gv/egiz/moazs/config/RepositoryConfig.java
@@ -11,6 +11,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import java.util.Map;
+import java.util.function.Function;
@Configuration
@Profile("!cluster")
@@ -25,8 +26,9 @@ public class RepositoryConfig {
}
@Bean
- public Map<String, String> idSuffixes() {
- return Map.of(NameSpace.MSG_DELIVERY_REQUEST_STATUS, RequestStatusResponse.getIdSuffix(),
- NameSpace.MSG_DELIVERY_NOTIFICATION, NotificationResponse.getIdSuffix());
+ public Map<String, Function<String, String>> idGenerators() {
+
+ return Map.of(NameSpace.MSG_DELIVERY_REQUEST_STATUS, RequestStatusResponse::getResponseID,
+ NameSpace.MSG_DELIVERY_NOTIFICATION, NotificationResponse::getResponseID);
}
}
diff --git a/src/main/java/at/gv/egiz/moazs/process/SingleNodeResponseHandler.java b/src/main/java/at/gv/egiz/moazs/process/SingleNodeResponseHandler.java
index ec609cb..b115e27 100644
--- a/src/main/java/at/gv/egiz/moazs/process/SingleNodeResponseHandler.java
+++ b/src/main/java/at/gv/egiz/moazs/process/SingleNodeResponseHandler.java
@@ -19,8 +19,8 @@ public class SingleNodeResponseHandler implements MsgResponseHandler {
}
@Override
- public void handle(String id) {
- supplyAsync(() -> verifier.verify(id))
+ public void handle(String responseID) {
+ supplyAsync(() -> verifier.verify(responseID))
.thenAcceptAsync((response) -> sink.handle(response));
}
}
diff --git a/src/main/java/at/gv/egiz/moazs/pipeline/SingleThreadedDeliveryPipeline.java b/src/main/java/at/gv/egiz/moazs/process/SingleThreadedDeliveryPipeline.java
index 69065d7..69065d7 100644
--- a/src/main/java/at/gv/egiz/moazs/pipeline/SingleThreadedDeliveryPipeline.java
+++ b/src/main/java/at/gv/egiz/moazs/process/SingleThreadedDeliveryPipeline.java
diff --git a/src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java b/src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java
index d0a8148..57d2d07 100644
--- a/src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java
+++ b/src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java
@@ -17,7 +17,7 @@ public interface DeliveryRepository {
void add(MsgResponse response);
- Optional<MsgResponse> getResponse(String id);
+ Optional<MsgResponse> getResponse(String responseID);
}
diff --git a/src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java b/src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java
index d9abb7b..3b5a020 100644
--- a/src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java
+++ b/src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java
@@ -39,12 +39,11 @@ public class InMemoryDeliveryRepository implements DeliveryRepository {
@Override
public void add(MsgResponse response) {
String key = response.getResponseID();
- System.out.println("storing with response id " + key);
responseRepository.put(key, response);
}
@Override
- public Optional<MsgResponse> getResponse(String id) {
- return ofNullable(responseRepository.getIfPresent(id));
+ public Optional<MsgResponse> getResponse(String responseID) {
+ return ofNullable(responseRepository.getIfPresent(responseID));
}
}
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java
index fe46451..699819f 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java
@@ -3,13 +3,26 @@ package at.gv.egiz.moazs.scheme;
import at.gv.egiz.moazs.MoaZSException;
import at.gv.zustellung.msg.xsd.DeliveryAnswerType;
-public interface MsgResponse <T> {
-
- String getResponseID();
- T getResponse();
- String getAppDeliveryID();
- String getZSDeliveryID();
- DeliveryAnswerType getAnswer();
- MsgResponse<T> generateError(MoaZSException exception);
+public abstract class MsgResponse <T> {
+
+ protected String id;
+
+ protected MsgResponse(){
+ this.id = "";
+ }
+
+ public static String createResponseId(String appDeliveryID, String idSuffix) {
+ return appDeliveryID + idSuffix;
+ }
+
+ public String getResponseID() {
+ return id;
+ }
+
+ abstract public T getResponse();
+ abstract public String getAppDeliveryID();
+ abstract public String getZSDeliveryID();
+ abstract public DeliveryAnswerType getAnswer();
+ abstract public MsgResponse<T> generateError(MoaZSException exception);
}
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java
index f465a28..7670ab7 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java
@@ -6,24 +6,18 @@ import at.gv.zustellung.msg.xsd.DeliveryNotificationType;
import static at.gv.zustellung.msg.xsd.DeliveryNotificationType.deliveryNotificationTypeBuilder;
-public class NotificationResponse implements MsgResponse<DeliveryNotificationType> {
+public class NotificationResponse extends MsgResponse<DeliveryNotificationType> {
private final DeliveryNotificationType notification;
- private final String id;
- private static final String ID_SUFFIX = ".NO";
+ private final static String ID_SUFFIX = ".NO";
public NotificationResponse(DeliveryNotificationType notification) {
+ super.id = createResponseId(notification.getAppDeliveryID(), ID_SUFFIX);
this.notification = notification;
- this.id = getId(notification.getAppDeliveryID());
}
- @Override
- public String getResponseID() {
- return this.id;
- }
-
- public static String getId(String appDeliveryID) {
- return appDeliveryID + ID_SUFFIX;
+ public static String getResponseID(String appDeliveryID) {
+ return createResponseId(appDeliveryID, ID_SUFFIX);
}
@Override
@@ -60,8 +54,4 @@ public class NotificationResponse implements MsgResponse<DeliveryNotificationTyp
return new NotificationResponse(notification);
}
-
- public static String getIdSuffix() {
- return ID_SUFFIX;
- }
}
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java
index 89c8be3..0705698 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java
@@ -10,17 +10,16 @@ import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Error.errorBuil
import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.deliveryRequestStatusTypeBuilder;
import static at.gv.zustellung.msg.xsd.ErrorInfoType.errorInfoTypeBuilder;
-public class RequestStatusResponse implements MsgResponse<DeliveryRequestStatusType> {
+public class RequestStatusResponse extends MsgResponse<DeliveryRequestStatusType> {
private final DeliveryRequestStatusType status;
private final DeliveryAnswerType answer;
- private final String responseID;
private static final String ID_SUFFIX = ".RS";
public RequestStatusResponse(DeliveryRequestStatusType status) {
this.status = status;
this.answer = coalesce(status.getSuccess(), status.getPartialSuccess(), status.getError()).get();
- this.responseID = getResponseID(answer.getAppDeliveryID());
+ super.id = createResponseId(answer.getAppDeliveryID(), ID_SUFFIX);
}
public static String getResponseID(String appDeliveryID) {
@@ -28,11 +27,6 @@ public class RequestStatusResponse implements MsgResponse<DeliveryRequestStatusT
}
@Override
- public String getResponseID() {
- return this.responseID;
- }
-
- @Override
public DeliveryRequestStatusType getResponse() {
return status;
}
@@ -81,7 +75,4 @@ public class RequestStatusResponse implements MsgResponse<DeliveryRequestStatusT
}
- public static String getIdSuffix() {
- return ID_SUFFIX;
- }
}
diff --git a/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java b/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
index d70c8bd..39566fe 100644
--- a/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
+++ b/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
@@ -16,6 +16,7 @@ import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Map;
+import java.util.function.Function;
import static at.gv.egiz.moazs.MoaZSException.moaZSException;
@@ -26,16 +27,17 @@ public class StoreSOAPBodyBinaryInRepositoryInterceptor extends AbstractPhaseInt
private final CXFMessageUtils messageUtils;
private final SOAPUtils soapUtils;
- private final Map<String, String> idSuffixes;
+ private final Map<String, Function<String, String>> idGenerators;
private final BinaryRepository repository;
@Autowired
public StoreSOAPBodyBinaryInRepositoryInterceptor(CXFMessageUtils extractor, SOAPUtils soapUtils,
- Map<String, String> idSuffixes, BinaryRepository repository) {
+ Map<String, Function<String, String>> idGenerators,
+ BinaryRepository repository) {
super(Phase.RECEIVE);
this.messageUtils = extractor;
this.soapUtils = soapUtils;
- this.idSuffixes = idSuffixes;
+ this.idGenerators = idGenerators;
this.repository = repository;
}
@@ -57,12 +59,12 @@ public class StoreSOAPBodyBinaryInRepositoryInterceptor extends AbstractPhaseInt
String appDeliveryID = soapUtils.getAppDeliveryIDFrom(document);
String rootTag = document.getTagName();
- if (!idSuffixes.containsKey(rootTag)) {
+ if (!idGenerators.containsKey(rootTag)) {
log.trace("Will not add message of type {}. ", rootTag);
return;
}
- var id = appDeliveryID + idSuffixes.get(rootTag);
+ var id = idGenerators.get(rootTag).apply(appDeliveryID);
repository.add(id, response);
if(log.isTraceEnabled()) {
diff --git a/src/main/java/at/gv/egiz/moazs/verify/MsgResponseVerifier.java b/src/main/java/at/gv/egiz/moazs/verify/MsgResponseVerifier.java
index c5e04d9..6b4ef7a 100644
--- a/src/main/java/at/gv/egiz/moazs/verify/MsgResponseVerifier.java
+++ b/src/main/java/at/gv/egiz/moazs/verify/MsgResponseVerifier.java
@@ -33,12 +33,12 @@ public class MsgResponseVerifier {
this.verifier = verifier;
}
- public MsgResponse verify(String id) {
+ public MsgResponse verify(String responseID) {
- var response = repo.getResponse(id).get();
+ var response = repo.getResponse(responseID).get();
var builder = moaZSExceptionBuilder().withAllParametersInAnswer(response.getAnswer());
- var binaryResponse = binaryRepo.get(id).get();
+ var binaryResponse = binaryRepo.get(responseID).get();
try {
verifier.verify(binaryResponse);