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. --- .../backend/ForwardResponseToServiceSink.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java (limited to 'src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java') diff --git a/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java b/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java new file mode 100644 index 0000000..4b3c085 --- /dev/null +++ b/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java @@ -0,0 +1,33 @@ +package at.gv.egiz.moazs.backend; + +import at.gv.egiz.moazs.client.ClientFactory; +import at.gv.egiz.moazs.repository.DeliveryRepository; +import at.gv.egiz.moazs.scheme.Msg2MzsConverter; +import at.gv.egiz.moazs.scheme.MsgResponse; +import at.gv.zustellung.app2mzs.xsd.ClientType; +import at.gv.zustellung.app2mzs.xsd.Mzs2AppPortType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.concurrent.CompletableFuture; + +@Component +public class ForwardResponseToServiceSink { + + private final ClientFactory factory; + private final DeliveryRepository repository; + private final Msg2MzsConverter converter; + + @Autowired + public ForwardResponseToServiceSink(ClientFactory factory, DeliveryRepository repository, Msg2MzsConverter converter) { + this.factory = factory; + this.repository = repository; + this.converter = converter; + } + + public CompletableFuture send(MsgResponse msgResponse, ClientType params) { + var binaryResponse = repository.retrieveBinaryResponse(msgResponse.getResponseID()); + Mzs2AppPortType client = factory.create(params, Mzs2AppPortType.class); + return msgResponse.sendToMzsClient(converter, binaryResponse, client); + } +} -- cgit v1.2.3