aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-02 16:42:43 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-02 16:42:43 +0200
commit4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba (patch)
tree7708c40ffdc7e29aa784ee5d26308f18aa1f460b /src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java
parent030488bb7ff9572f35032d80d4101c06cfc98bf5 (diff)
downloadmoa-zs-4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba.tar.gz
moa-zs-4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba.tar.bz2
moa-zs-4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba.zip
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".
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java')
-rw-r--r--src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java35
1 files changed, 25 insertions, 10 deletions
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 aea01bb..37dbdc5 100644
--- a/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java
+++ b/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java
@@ -1,5 +1,6 @@
package at.gv.egiz.moazs.preprocess;
+import at.gv.egiz.moazs.mzs.MzsValidator;
import at.gv.zustellung.app2mzs.xsd.ConfigType;
import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,7 +16,10 @@ public class DeliveryRequestAugmenter {
private final ConfigUtil util;
private final Map<String, ConfigType> configs;
+ private final MzsValidator validator;
+ private static final String INCOMPLETE_TNVZ_ERROR_MESSAGE = "mzs:DeliveryRequest is incomplete because mandatory " +
+ "fields for sending a tnvz:QueryPersonRequest are missing.";
private static final String INCOMPLETE_CONFIG_ERROR_MESSAGE = "Could not find a profile for " +
"the delivery request configuration, and the configuration attached to mzs:DeliveryRequest is incomplete.";
private static final String INCOMPLETE_MERGED_CONFIG_ERROR_MESSAGE = "I merged parameters from " +
@@ -23,9 +27,10 @@ public class DeliveryRequestAugmenter {
"configuration is incomplete.";
@Autowired
- public DeliveryRequestAugmenter(Map<String, ConfigType> deliveryRequestConfigs, ConfigUtil util) {
+ public DeliveryRequestAugmenter(Map<String, ConfigType> deliveryRequestConfigs, ConfigUtil util, MzsValidator validator) {
this.configs = deliveryRequestConfigs;
this.util = util;
+ this.validator = validator;
}
/**
@@ -33,7 +38,7 @@ public class DeliveryRequestAugmenter {
*
* @param request
* @throws at.gv.egiz.moazs.MoaZSException
- * @return augmented request
+ * @return augmented request and validated
*/
public DeliveryRequestType augment(DeliveryRequestType request) {
@@ -43,10 +48,13 @@ public class DeliveryRequestAugmenter {
if (fallbackConfig == null) {
- if (util.isComplete(requestConfig))
- return request;
- else
+ if (!validator.isConfigProfileComplete(request.getConfig())) {
throw moaZSException(INCOMPLETE_CONFIG_ERROR_MESSAGE);
+ } else if (!validator.isTnvzComplete(request)) {
+ throw moaZSException(INCOMPLETE_TNVZ_ERROR_MESSAGE);
+ } else {
+ return request;
+ }
} else {
@@ -54,13 +62,20 @@ public class DeliveryRequestAugmenter {
? fallbackConfig
: util.merge(requestConfig, fallbackConfig);
- if (util.isComplete(mergedConfig)) {
- return deliveryRequestTypeBuilder(request)
- .withConfig(mergedConfig)
- .build();
- } else {
+ if (!validator.isConfigProfileComplete(mergedConfig)) {
throw moaZSException(INCOMPLETE_MERGED_CONFIG_ERROR_MESSAGE, fallbackProfileId);
}
+
+ var mergedRequest = deliveryRequestTypeBuilder(request)
+ .withConfig(mergedConfig)
+ .build();
+
+ if (!validator.isTnvzComplete(mergedRequest)) {
+ throw moaZSException(INCOMPLETE_TNVZ_ERROR_MESSAGE);
+ }
+
+ return mergedRequest;
+
}
}