From 78aa4b019f64b6ba94df59e21efd4f9261bb070e Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Fri, 23 Aug 2019 14:13:27 +0200 Subject: Add Trace Logs to DeliveryRequestBackend --- .../egiz/moazs/backend/DeliveryRequestBackend.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/main/java/at/gv/egiz/moazs') diff --git a/src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java b/src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java index 46b0c2c..178e26c 100644 --- a/src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java +++ b/src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java @@ -5,6 +5,7 @@ import at.gv.egiz.moazs.MoaZSException; import at.gv.egiz.moazs.client.ClientFactory; import at.gv.egiz.moazs.client.TnvzHelper; import at.gv.egiz.moazs.repository.DeliveryRepository; +import at.gv.egiz.moazs.scheme.Marshaller; import at.gv.egiz.moazs.scheme.Mzs2MsgConverter; import at.gv.egiz.moazs.scheme.RequestStatusResponse; import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType; @@ -37,12 +38,22 @@ public class DeliveryRequestBackend implements Consumer { private static final String BINARY_RESPONSE_MISSING_ERROR_MSG = "Binary DeliveryRequestStatus for AppDeliveryID=%s is not in repository. " ; + private static final at.gv.zustellung.app2mzs.xsd.ObjectFactory mzsOF = new at.gv.zustellung.app2mzs.xsd.ObjectFactory(); + private static final at.gv.zustellung.msg.xsd.ObjectFactory msgOF = new at.gv.zustellung.msg.xsd.ObjectFactory(); + + @Autowired(required = false) + private Marshaller mzsMarshaller; + + @Autowired(required = false) + private Marshaller msgMarshaller; + private final DeliveryRepository repository; private final TnvzHelper tnvzHelper; private final Mzs2MsgConverter converter; private final ClientFactory clientFactory; private final Consumer signatureVerifier; + @Autowired public DeliveryRequestBackend(DeliveryRepository repository, TnvzHelper tnvzHelper, @@ -72,14 +83,19 @@ public class DeliveryRequestBackend implements Consumer { var fallbackAnswerBuilder = errorBuilder().withAppDeliveryID(appDeliveryID); try { + + log.trace("Fetch mzs:DeliveryRequest wiht AppDeliveryID={} from repository.", appDeliveryID); var mzsRequest = repository.retrieveDeliveryRequest(appDeliveryID).orElseThrow( () -> moaZSException(format(DELIVERY_REQUEST_MISSING_ERROR_MSG, appDeliveryID))); + traceMzsRequest(mzsRequest); fallbackAnswerBuilder.withDeliverySystem(mzsRequest.getConfig().getMSGClient().getURL()); var msgRequest = buildMsgRequest(mzsRequest); + traceMsgRequest(msgRequest); var msgClientParams = mzsRequest.getConfig().getMSGClient(); App2ZusePort client = clientFactory.create(msgClientParams, App2ZusePort.class); status = client.delivery(msgRequest); + traceMsgResponse(status); var response = new RequestStatusResponse(status); @@ -113,6 +129,7 @@ public class DeliveryRequestBackend implements Consumer { private at.gv.zustellung.msg.xsd.DeliveryRequestType buildMsgRequest(DeliveryRequestType mzsRequest) throws MoaZSException { if (mzsRequest.getConfig().isPerformQueryPersonRequest()) { + log.trace("Perform QueryPersonRequest. "); var tnvzClientParams = mzsRequest.getConfig().getTNVZClient(); TNVZServicePort tvnzPort = clientFactory.create(tnvzClientParams, TNVZServicePort.class); var identification = tnvzHelper.performQueryPersonRequest(mzsRequest, tvnzPort); @@ -122,4 +139,23 @@ public class DeliveryRequestBackend implements Consumer { } } + private void traceMzsRequest(DeliveryRequestType mzsRequest) { + if (log.isTraceEnabled() && mzsMarshaller != null) { + log.trace("mzs:DeliveryRequest: {}", mzsMarshaller.marshallXml(mzsOF.createDeliveryRequest(mzsRequest))); + } + } + + private void traceMsgRequest(at.gv.zustellung.msg.xsd.DeliveryRequestType msgRequest) { + if (log.isTraceEnabled() && msgMarshaller != null) { + log.trace("msg:DeliveryRequest: {}", msgMarshaller.marshallXml(msgOF.createDeliveryRequest(msgRequest))); + } + } + + private void traceMsgResponse(DeliveryRequestStatusType status) { + if (log.isTraceEnabled() && msgMarshaller != null) { + log.trace("msg:DeliveryResponse: {}", msgMarshaller.marshallXml(msgOF.createDeliveryResponse(status))); + } + } + + } -- cgit v1.2.3