From 8f3b805a558c4ed454db2b691032cea800d7b6dd Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Tue, 16 Jul 2019 14:33:26 +0200 Subject: Implement ForwardResponseToService Sink And All Its Implications MZS Schema Change: - Add configuration for ForwardResponseToServiceSink (add parameters in mzs:DeliveryRequest/Config) - Add sink configuration in application.yaml, convert from Spring Environment to ConfigType, and merge ConfigTypes. - Validate sink configuration completeness. Contract added: - Add contract mzs2app.wsdl: This contract specifies how mzs:DeliveryRequestStatus' and mzs:DeliveryNotifications are forwarded to the sender application. - Implement "ForwardResponseToService" Sink. - Add and implement MsgResponse.sendToMzsClient() : This is a somewhat unfortunate solution because, intuitively, sending should be done by it's caller, the "ForwardResponseToService"-sink. However, this solution prevents differences between msg:DeliveryRequestStatus and msg:DeliveryNotification (and code that needs to handle differences, i.e. sending) from sprawling outside of the respective MsgResponse derivatives. We move the entire "send" process into MsgResponse to prevent a hard-to-maintain "if type == notification then do x else to y" construct in ForwardResponseToServiceSink. Otherwise, introducing the MsgResponse wrapper was pointless. --- .../gv/egiz/moazs/scheme/NotificationResponse.java | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java') 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 784d000..21e00a1 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java @@ -1,12 +1,16 @@ package at.gv.egiz.moazs.scheme; import at.gv.egiz.moazs.MoaZSException; +import at.gv.zustellung.app2mzs.xsd.Mzs2AppPortType; 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 java.util.Optional; +import java.util.concurrent.CompletableFuture; + import static at.gv.zustellung.msg.xsd.DeliveryNotificationType.deliveryNotificationTypeBuilder; public class NotificationResponse extends MsgResponse { @@ -50,17 +54,23 @@ public class NotificationResponse extends MsgResponse } @Override - public MsgResponse generateError(MoaZSException exception) { + public NotificationResponse generateError(MoaZSException exception) { - //TODO: test this! + //TODO: use copy constructor? var notificationType = deliveryNotificationTypeBuilder() - .withAppDeliveryID(exception.getAppDeliveryID()) - .withDeliverySystem(exception.getDeliverySystem()) - .withGZ(exception.getGz()) - .withZSDeliveryID(exception.getZsDeliveryID()) - .build(); + .withAppDeliveryID(exception.getAppDeliveryID()) + .withDeliverySystem(exception.getDeliverySystem()) + .withGZ(exception.getGz()) + .withZSDeliveryID(exception.getZsDeliveryID()) + .build(); return new NotificationResponse(notificationType); + } + @Override + public CompletableFuture sendToMzsClient(Msg2MzsConverter converter, Optional signedNotification, Mzs2AppPortType client) { + var mzsNotification = converter.convert(notification, signedNotification); + client.forwardNotification(mzsNotification); + return CompletableFuture.completedFuture(null); } } -- cgit v1.2.3