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. --- .../preprocess/MzsDeliveryRequestValidator.java | 42 +++++++++++++++------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java') diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java b/src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java index 8f9cd27..2c2fc36 100644 --- a/src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java +++ b/src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java @@ -1,9 +1,6 @@ package at.gv.egiz.moazs.preprocess; -import at.gv.zustellung.app2mzs.xsd.ClientType; -import at.gv.zustellung.app2mzs.xsd.ConfigType; -import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType; -import at.gv.zustellung.app2mzs.xsd.KeyStoreType; +import at.gv.zustellung.app2mzs.xsd.*; import org.springframework.lang.Nullable; import org.springframework.stereotype.Component; @@ -19,8 +16,6 @@ public class MzsDeliveryRequestValidator { return !request.getConfig().isPerformQueryPersonRequest() || (request.getTnvzMetaData() != null && request.getSender().getCorporateBody() != null); - - } /** @@ -33,7 +28,8 @@ public class MzsDeliveryRequestValidator { return profile != null && profile.isPerformQueryPersonRequest() != null && isTVNZClientConfigured(profile.getTNVZClient(), profile.isPerformQueryPersonRequest()) - && isMSGClientConfigured(profile.getMSGClient()); + && isClientConfigured(profile.getMSGClient()) + && areSinksConfigured(profile.getMsgResponseSinks()); } private boolean isTVNZClientConfigured(ClientType tnvzClient, Boolean isPerformQueryPersonRequest) { @@ -44,12 +40,12 @@ public class MzsDeliveryRequestValidator { && isSSLConfigured(tnvzClient)); } - private boolean isMSGClientConfigured(ClientType msgClientParams) { - return msgClientParams != null - && msgClientParams.getURL() != null - && isSSLConfigured(msgClientParams) - && msgClientParams.getReceiveTimeout() != null - && msgClientParams.getConnectionTimeout() != null; + private boolean isClientConfigured(ClientType clientParams) { + return clientParams != null + && clientParams.getURL() != null + && isSSLConfigured(clientParams) + && clientParams.getReceiveTimeout() != null + && clientParams.getConnectionTimeout() != null; } private boolean isSSLConfigured(ClientType clientParams) { @@ -71,4 +67,24 @@ public class MzsDeliveryRequestValidator { && "JKS".equals(trustStore.getFileType()) && trustStore.getFileName() != null); } + + private boolean areSinksConfigured(MsgResponseSinksType sinks) { + return sinks != null + && sinks.isLogResponse() != null + && isSaveResponseToFileConfigured(sinks.getSaveResponseToFile()) + && isForwardResponseToServiceConfigured(sinks.getForwardResponseToService()); + } + + private boolean isSaveResponseToFileConfigured(SaveResponseToFileType fileSink) { + return fileSink != null + && (!fileSink.isActive() || fileSink.getPath() != null); + } + + private boolean isForwardResponseToServiceConfigured(ForwardResponseToServiceType forwardSink) { + return forwardSink != null + && (!forwardSink.isActive() || isClientConfigured(forwardSink.getMzsClient())); + } + + + } -- cgit v1.2.3