aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/scheme
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-12 15:40:05 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-12 15:40:05 +0200
commit25d68c8900c2cc791f03ea3db173955ca237fd55 (patch)
treef4d28b97845d10a709590dce480195b322ba019b /src/main/java/at/gv/egiz/moazs/scheme
parent9dc0e72571a895e34a55c11d015c5d359b485aff (diff)
downloadmoa-zs-25d68c8900c2cc791f03ea3db173955ca237fd55.tar.gz
moa-zs-25d68c8900c2cc791f03ea3db173955ca237fd55.tar.bz2
moa-zs-25d68c8900c2cc791f03ea3db173955ca237fd55.zip
Allow App To Choose Between MsgResponse Sinks
- MZS Schema Change: Add "MsgResponseSinks" element to mzs:DeliveryRequest/Config that allows sender to configure how MsgResponses should be archived. - ConfigUtil: Interpret MsgResponseSink parameters from Spring Environment and merge with ConfigType. - MsgResponseBackend: Send responses to sinks according to MsgResponseSinks in Config - application.yaml: Add MsgResponseSinks parameter to configuration. - Uncouple Sink implementations from java.util.function.Function, because the sink interfaces are going to differ and there is no need to unite them under one interface. - Add and test LogResponseSink, which logs responses to it's logger. - MsgResponse: Add JAXB getter for response. Reason: Can be passed to marshaller.
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/scheme')
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java7
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java9
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java10
3 files changed, 26 insertions, 0 deletions
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 80e2059..5370448 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java
@@ -3,6 +3,12 @@ package at.gv.egiz.moazs.scheme;
import at.gv.egiz.moazs.MoaZSException;
import at.gv.zustellung.msg.xsd.DeliveryAnswerType;
+import javax.xml.bind.JAXBElement;
+
+/**
+ * Represents responses to DeliveryRequests that were received from the msg service.
+ * @param <T> The type of the response.
+ */
public abstract class MsgResponse <T> {
protected String id;
@@ -20,6 +26,7 @@ public abstract class MsgResponse <T> {
}
public abstract T getResponse();
+ public abstract JAXBElement<T> getResponseAsJAXBElement();
public abstract String getAppDeliveryID();
public abstract String getZSDeliveryID();
public abstract DeliveryAnswerType getAnswer();
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 de1fd38..784d000 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java
@@ -3,6 +3,9 @@ package at.gv.egiz.moazs.scheme;
import at.gv.egiz.moazs.MoaZSException;
import at.gv.zustellung.msg.xsd.DeliveryAnswerType;
import at.gv.zustellung.msg.xsd.DeliveryNotificationType;
+import at.gv.zustellung.msg.xsd.ObjectFactory;
+
+import javax.xml.bind.JAXBElement;
import static at.gv.zustellung.msg.xsd.DeliveryNotificationType.deliveryNotificationTypeBuilder;
@@ -10,6 +13,7 @@ public class NotificationResponse extends MsgResponse<DeliveryNotificationType>
private final DeliveryNotificationType notification;
private static final String ID_SUFFIX = ".NO";
+ private static final ObjectFactory factory = new ObjectFactory();
public NotificationResponse(DeliveryNotificationType notification) {
super.id = createResponseId(notification.getAppDeliveryID(), ID_SUFFIX);
@@ -26,6 +30,11 @@ public class NotificationResponse extends MsgResponse<DeliveryNotificationType>
}
@Override
+ public JAXBElement<DeliveryNotificationType> getResponseAsJAXBElement() {
+ return factory.createDeliveryNotification(notification);
+ }
+
+ @Override
public String getAppDeliveryID() {
return notification.getAppDeliveryID();
}
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 0705698..3b4710b 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java
@@ -4,6 +4,9 @@ import at.gv.egiz.moazs.MoaZSException;
import at.gv.zustellung.msg.xsd.DeliveryAnswerType;
import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType;
import at.gv.zustellung.msg.xsd.ErrorInfoType;
+import at.gv.zustellung.msg.xsd.ObjectFactory;
+
+import javax.xml.bind.JAXBElement;
import static at.gv.egiz.moazs.util.NullCoalesce.coalesce;
import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Error.errorBuilder;
@@ -15,6 +18,8 @@ public class RequestStatusResponse extends MsgResponse<DeliveryRequestStatusType
private final DeliveryRequestStatusType status;
private final DeliveryAnswerType answer;
private static final String ID_SUFFIX = ".RS";
+ private static final ObjectFactory factory = new ObjectFactory();
+
public RequestStatusResponse(DeliveryRequestStatusType status) {
this.status = status;
@@ -32,6 +37,11 @@ public class RequestStatusResponse extends MsgResponse<DeliveryRequestStatusType
}
@Override
+ public JAXBElement<DeliveryRequestStatusType> getResponseAsJAXBElement() {
+ return factory.createDeliveryRequestStatus(status);
+ }
+
+ @Override
public String getAppDeliveryID() {
return answer.getAppDeliveryID();
}