From 70e8a1b80fea9d61c46dbd55aa1b461a8bb3a0f7 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Wed, 28 Aug 2019 13:34:41 +0200 Subject: 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 --- .../at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java | 8 +------- .../gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/main/java/at/gv/egiz/moazs/preprocess') diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java b/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java index 4796844..7dc0f25 100644 --- a/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java +++ b/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java @@ -24,17 +24,15 @@ public class DeliveryRequestAugmenter { private final ConfigUtil util; private final Map configs; - private final MzsDeliveryRequestValidator validator; private final Marshaller mzsMarshaller; private static final String CONFIG_MISSING_ERROR_MSG = "Delivery request configuration is missing."; @Autowired public DeliveryRequestAugmenter(Map deliveryRequestConfigs, ConfigUtil util, - MzsDeliveryRequestValidator validator, Marshaller mzsMarshaller) { + Marshaller mzsMarshaller) { this.configs = deliveryRequestConfigs; this.util = util; - this.validator = validator; this.mzsMarshaller = mzsMarshaller; } @@ -61,14 +59,10 @@ public class DeliveryRequestAugmenter { trace("Augmented config", augmentedConfig); - validator.isConfigProfileComplete(augmentedConfig); - var augmentedRequest = deliveryRequestTypeBuilder(request) .withConfig(augmentedConfig) .build(); - validator.isTnvzComplete(augmentedRequest); - return augmentedRequest; } 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 67086a2..b0568d7 100644 --- a/src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java +++ b/src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java @@ -12,6 +12,17 @@ import static java.lang.String.format; @Component public class MzsDeliveryRequestValidator { + + /** + * Checks if request is valid and can be processed. + * @param request + * @throws MoaZSException if the request is invalid. + */ + public void isRequestValid(DeliveryRequestType request) { + isTnvzComplete(request); + isConfigProfileComplete(request.getConfig()); + } + /** * Checks if the mandatory fields that are needed to send a tnvz:QueryPersonRequest are present. * @param request -- cgit v1.2.3