From 6959228c5c557df0204a2902807b35d90063b600 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Wed, 15 May 2019 14:55:09 +0200 Subject: Handle Config Related Edge Cases in Augmenter & ProfileGenerator ConfigProfileGenerator: - Cancel startup if default Config profile is incomplete. - Add property flag 'verify-completeness-of-default-delivery-request-configuration', which allows admin to disable completeness check. In that case, just log a warning if the default profile is incomplete. Augmenter: - Ensure that after merging the config is complete (or throw an exception otherwise). - Refactor: Move ConfigProfileValidator from ConfigProfileGenerator to dedicated "ConfigProfileValidator" class; Reason: Augmenter needs to check completness of at-runtime-compiled configuration. - Refactor: Rewrote code for better readability. Others - NPE Fix in ConfigProfileMerger: If FallbackConfigProfile/Server is empty, use PrimaryProfile/Server. --- .../egiz/moazs/config/DeliveryRequestAugmenterConfig.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/gv/egiz/moazs/config') diff --git a/src/main/java/at/gv/egiz/moazs/config/DeliveryRequestAugmenterConfig.java b/src/main/java/at/gv/egiz/moazs/config/DeliveryRequestAugmenterConfig.java index d5b52c5..01d13f5 100644 --- a/src/main/java/at/gv/egiz/moazs/config/DeliveryRequestAugmenterConfig.java +++ b/src/main/java/at/gv/egiz/moazs/config/DeliveryRequestAugmenterConfig.java @@ -1,10 +1,14 @@ package at.gv.egiz.moazs.config; import at.gv.egiz.moazs.preprocess.ConfigProfileGenerator; +import at.gv.egiz.moazs.preprocess.ConfigProfileMerger; +import at.gv.egiz.moazs.preprocess.ConfigProfileValidator; import at.gv.zustellung.app2mzs.xsd.ConfigType; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.ConfigurableEnvironment; import java.util.Map; @@ -13,8 +17,17 @@ public class DeliveryRequestAugmenterConfig { @Bean @Autowired - Map deliveryRequestConfigs(ConfigProfileGenerator generator) { + public Map deliveryRequestConfigs(ConfigProfileGenerator generator) { return generator.generate(); } + @Value("${verify-completeness-of-default-delivery-request-configuration:true}") + private boolean verifyCompletenessOfDefaultConfiguration; + + @Bean + @Autowired + public ConfigProfileGenerator configProfileGenerator(ConfigurableEnvironment env, ConfigProfileMerger merger, ConfigProfileValidator validator) { + return new ConfigProfileGenerator(env, merger, verifyCompletenessOfDefaultConfiguration, validator); + } + } -- cgit v1.2.3