aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-04-30 11:00:46 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-04-30 11:00:46 +0200
commit296d842878e530ee819fa2f58012665b76e2e670 (patch)
tree45e0078c39b5cdf4f3e8e412f4813e3bca8bd2d6 /src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java
parent9a038cf18d6ebd4c68218c20ebc174b779afa7fa (diff)
downloadmoa-zs-296d842878e530ee819fa2f58012665b76e2e670.tar.gz
moa-zs-296d842878e530ee819fa2f58012665b76e2e670.tar.bz2
moa-zs-296d842878e530ee819fa2f58012665b76e2e670.zip
Add Optional mzs:DeliveryRequest/Config & Validate / Augment It
Add Optional "Config" to MZS Schema: - Add mzs:DeliveryRequest/Config Element with a "PerformQueryPersonRequest" node - The config element contains parameters that are interpreted by moa-zs and not forwarded to the ZD - The boolean PerformQueryPersonRequest tells moa-zs if moa-zs should perform a QueryPersonRequest towards the TNVZ. - If config is missing, moa-zs augments the delivery request with parameters from the app's configuartion or the default configuartion Other Changes: - Validate and augment incoming requests with the DeliveryPreprocessor. - Add stub for TlnvzClient. - Remove some leftover ObjectFactory imports (because of the builder they are not needed anymore) Fixes - Fixed incorrect API usage of Messageformat.format: format string needs an index. pom.xml - Add Hamcrest Dependency (for writing more expressive tests) - Add copy constructor to JAXB Builder Testing - Test validation of incoming request - Refactor testcases to improve readability
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java')
-rw-r--r--src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java b/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java
index 20252ff..5a8e377 100644
--- a/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java
+++ b/src/main/java/at/gv/egiz/moazs/pipeline/SameThreadDeliveryPipeline.java
@@ -2,37 +2,39 @@ package at.gv.egiz.moazs.pipeline;
import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType;
+import at.gv.egiz.moazs.TnvzClient;
import at.gv.egiz.moazs.repository.DeliveryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
-import java.util.Optional;
-
-import static java.text.MessageFormat.format;
-
@Component
@Profile("!cluster")
public class SameThreadDeliveryPipeline implements DeliveryPipeline {
private final DeliveryRepository repository;
+ private final TnvzClient tnvzClient;
- public SameThreadDeliveryPipeline(@Autowired DeliveryRepository repository) {
+ public SameThreadDeliveryPipeline(@Autowired DeliveryRepository repository, TnvzClient tnvzClient) {
this.repository = repository;
+ this.tnvzClient = tnvzClient;
}
@Override
public void processRequest(String appDeliveryId) {
- Optional<DeliveryRequestType> request = repository.getDeliveryRequest(appDeliveryId);
- if (request.isEmpty()) {
- throw new RuntimeException(format(
- "Request with appDeliveryId = {} does not exist.", appDeliveryId));
- }
-
- //do business logic
+ var request = repository.getDeliveryRequest(appDeliveryId).orElseThrow();
+ checkAddressability(request);
//store response to repository
}
+ private void checkAddressability(DeliveryRequestType request) {
+ if (request.getConfig().isPerformQueryPersonRequest()) {
+ if (!tnvzClient.isAddressable(request.getReceiver())) {
+ throw new RuntimeException("Receiver is not addressable.");
+ }
+ }
+ }
+
}