diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-08-28 13:34:41 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-08-28 13:36:35 +0200 |
commit | 70e8a1b80fea9d61c46dbd55aa1b461a8bb3a0f7 (patch) | |
tree | d653c457ebf7331d7aa07b9c6f1ea122312480e3 /src/main/java/at/gv/egiz/moazs/service | |
parent | ff0a32339c4e8dbc81be89a38990f3963c285121 (diff) | |
download | moa-zs-70e8a1b80fea9d61c46dbd55aa1b461a8bb3a0f7.tar.gz moa-zs-70e8a1b80fea9d61c46dbd55aa1b461a8bb3a0f7.tar.bz2 moa-zs-70e8a1b80fea9d61c46dbd55aa1b461a8bb3a0f7.zip |
Fixes and Refactoring
- JAXB Hack: Handle InterruptionException properly (as in [1], "Dont
swallow Interrupts")
- Mzs2MsgConverter: Rename convert(Person) to
convertReceiverPerson(Person) to emphasize that this method can only
be used to convert Receiver Persons (Reminder: Receiver Persons are
PhysicalPersons / CorporateBodies. SenderPersons can also be
Authorities)
- Mzs2MsgConverter: Remove assertion because not needed anymore.
- Refactor: Move mzs:DeliveryRequest validation out ouf augmenter and
into service.
- Refactor: Create a single entry point for validating a
mzs:DeliveryRequest.
- Remove unused imports.
- Fix log messages.
[1] https://www.ibm.com/developerworks/java/library/j-jtp05236/index.html?ca=drs-#2.1
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/service')
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/service/MzsService.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/service/MzsService.java b/src/main/java/at/gv/egiz/moazs/service/MzsService.java index a0e6248..fc1f804 100644 --- a/src/main/java/at/gv/egiz/moazs/service/MzsService.java +++ b/src/main/java/at/gv/egiz/moazs/service/MzsService.java @@ -2,6 +2,7 @@ package at.gv.egiz.moazs.service; import at.gv.egiz.moazs.backend.MsgResponseSinkHub; import at.gv.egiz.moazs.preprocess.DeliveryRequestAugmenter; +import at.gv.egiz.moazs.preprocess.MzsDeliveryRequestValidator; import at.gv.egiz.moazs.repository.DeliveryRepository; import at.gv.egiz.moazs.scheme.Msg2MzsConverter; import at.gv.egiz.moazs.scheme.RequestStatusResponse; @@ -43,16 +44,18 @@ public class MzsService implements App2MzsPortType { private final DeliveryRequestAugmenter augmenter; private final Msg2MzsConverter converter; private final MsgResponseSinkHub hub; + private final MzsDeliveryRequestValidator validator; @Autowired public MzsService(DeliveryRepository repository, Consumer<String> deliveryRequestBackend, DeliveryRequestAugmenter augmenter, Msg2MzsConverter converter, - MsgResponseSinkHub hub) { + MsgResponseSinkHub hub, MzsDeliveryRequestValidator validator) { this.repository = repository; this.backend = deliveryRequestBackend; this.augmenter = augmenter; this.converter = converter; this.hub = hub; + this.validator = validator; } @Override @@ -63,6 +66,8 @@ public class MzsService implements App2MzsPortType { var completeRequest = augmenter.augment(deliveryRequest); + validator.isRequestValid(completeRequest); + var requestProcessed = supplyAsync(() -> process(completeRequest)); try { @@ -80,7 +85,7 @@ public class MzsService implements App2MzsPortType { return converter.convert(status, binaryStatus); } catch (TimeoutException e) { - return handleAssyncStatus(appDeliveryID, completeRequest, requestProcessed); + return applySinkHubToAsyncResponse(appDeliveryID, completeRequest, requestProcessed); } catch (Exception e) { var message = format(MZS_SERVICE_ERROR_MSG, appDeliveryID); @@ -89,16 +94,6 @@ public class MzsService implements App2MzsPortType { } - private DeliveryResponseType handleAssyncStatus(String appDeliveryID, DeliveryRequestType request, - CompletableFuture<RequestStatusResponse> requestProcessed) { - - log.info(format(SERVICE_TIME_OUT_REACHED_MSG, appDeliveryID)); - var sinkParams = request.getConfig().getMsgResponseSinks(); - requestProcessed.thenAcceptAsync(response -> hub.applySinks(response, sinkParams)); - - return generatePartialSuccessResponse(appDeliveryID); - } - private RequestStatusResponse process(DeliveryRequestType deliveryRequest) { var appDeliveryID = deliveryRequest.getMetaData().getAppDeliveryID(); @@ -113,6 +108,16 @@ public class MzsService implements App2MzsPortType { } + private DeliveryResponseType applySinkHubToAsyncResponse(String appDeliveryID, DeliveryRequestType request, + CompletableFuture<RequestStatusResponse> requestProcessed) { + + log.info(format(SERVICE_TIME_OUT_REACHED_MSG, appDeliveryID)); + var sinkParams = request.getConfig().getMsgResponseSinks(); + requestProcessed.thenAcceptAsync(response -> hub.applySinks(response, sinkParams)); + + return generatePartialSuccessResponse(appDeliveryID); + } + private DeliveryResponseType generatePartialSuccessResponse(String appDeliveryId) { var partial = partialSuccessTypeBuilder() |