From 4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Tue, 2 Jul 2019 16:42:43 +0200 Subject: Handle tnvz Query Edge Cases by Improving Validation TnvzHelper Fixes - Handle additional edge cases. - Mzs:Schema Change: Eliminate PreAdviceNote redundancy by removing it from mzs:DeliveryRequest/TnvzMetaData; PreadviceNote is already in the Receiver element. Update TnvzHelper accordingly. - Implement and integrate tnvz completeness check into DeliveryRequestAugmenter to ensure that, after augmentation, tnvz can be performed. Refactor mzs:DeliveryRequest Validation: - Before: Validating, merging and generatig ConfigType in ConfigUtil. - Change: Need to add validation of DeliveryRequest (Reason: For performing Tnvz Requests, the DeliveryRequest needs to be in a consistent state). - Problem: DeliveryRequest validation does not fit into ConfigUtil. - Solution: Put validation of DeliveryRequest and Config into new Component "MzsValidation". --- .../egiz/moazs/preprocess/ConfigProfileGenerator.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java') diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java index fa1ccd6..c2f2415 100644 --- a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java +++ b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java @@ -1,6 +1,7 @@ package at.gv.egiz.moazs.preprocess; import at.gv.egiz.moazs.MoaZSException; +import at.gv.egiz.moazs.mzs.MzsValidator; import at.gv.egiz.moazs.util.StringUtils; import at.gv.zustellung.app2mzs.xsd.ConfigType; import org.slf4j.Logger; @@ -29,6 +30,7 @@ public class ConfigProfileGenerator { private final SpringPropertiesFacade properties; private final ConfigUtil util; + private final MzsValidator validator; private final boolean verifyCompletenessOfDefaultConfiguration; private final String profilePrefix; private final String defaultConfigKey; @@ -40,11 +42,12 @@ public class ConfigProfileGenerator { private ConfigProfileGenerator( SpringPropertiesFacade properties, ConfigUtil util, - boolean verifyCompletenessOfDefaultConfiguration, + MzsValidator validator, boolean verifyCompletenessOfDefaultConfiguration, String profilePrefix, String defaultConfigKey) { this.util = util; this.properties = properties; + this.validator = validator; this.verifyCompletenessOfDefaultConfiguration = verifyCompletenessOfDefaultConfiguration; this.profilePrefix = profilePrefix; this.defaultConfigKey = defaultConfigKey; @@ -68,7 +71,7 @@ public class ConfigProfileGenerator { var defaultProfile = profiles.get(defaultConfigKey); - if (!util.isComplete(defaultProfile)) { + if (!validator.isConfigProfileComplete(defaultProfile)) { if (verifyCompletenessOfDefaultConfiguration) throw MoaZSException.moaZSException(PROFILE_NOT_COMPLETE_ERROR_MESSAGE); else { @@ -110,6 +113,7 @@ public class ConfigProfileGenerator { public static class ConfigProfileGeneratorBuilder { private SpringPropertiesFacade properties; private ConfigUtil util; + private MzsValidator validator; private boolean verify = true; private String profilePrefix = "delivery-request-configuration-profiles"; private String defaultConfigKey = "default"; @@ -124,6 +128,11 @@ public class ConfigProfileGenerator { return this; } + public ConfigProfileGeneratorBuilder withValidator(MzsValidator validator) { + this.validator = validator; + return this; + } + public ConfigProfileGeneratorBuilder withVerifyCompletenessOfDefaultConfiguration( boolean verify) { this.verify = verify; @@ -141,10 +150,10 @@ public class ConfigProfileGenerator { } public ConfigProfileGenerator build() { - if (properties == null || util == null || profilePrefix == null || defaultConfigKey == null) + if (properties == null || util == null || profilePrefix == null || defaultConfigKey == null || validator == null) throw new IllegalArgumentException("Cannot build ConfigProfileGenerator: " + "One or more arguments are null."); - return new ConfigProfileGenerator(properties, util, verify, profilePrefix, defaultConfigKey); + return new ConfigProfileGenerator(properties, util, validator, verify, profilePrefix, defaultConfigKey); } } } -- cgit v1.2.3