diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-08-23 14:13:27 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-08-23 15:17:14 +0200 |
commit | 78aa4b019f64b6ba94df59e21efd4f9261bb070e (patch) | |
tree | 6b9e1739bdf56d36a3c2692820730ea81df182d7 /src/main/java/at | |
parent | e6e0950a506d814415d8036e68e54d2034b6d3e7 (diff) | |
download | moa-zs-78aa4b019f64b6ba94df59e21efd4f9261bb070e.tar.gz moa-zs-78aa4b019f64b6ba94df59e21efd4f9261bb070e.tar.bz2 moa-zs-78aa4b019f64b6ba94df59e21efd4f9261bb070e.zip |
Add Trace Logs to DeliveryRequestBackend
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java | 36 |
1 files changed, 36 insertions, 0 deletions
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<String> { 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<byte[]> signatureVerifier; + @Autowired public DeliveryRequestBackend(DeliveryRepository repository, TnvzHelper tnvzHelper, @@ -72,14 +83,19 @@ public class DeliveryRequestBackend implements Consumer<String> { 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<String> { 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<String> { } } + 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))); + } + } + + } |