aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/service')
-rw-r--r--src/main/java/at/gv/egiz/moazs/service/MzsService.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/service/MzsService.java b/src/main/java/at/gv/egiz/moazs/service/MzsService.java
index a0e6248..fc1f804 100644
--- a/src/main/java/at/gv/egiz/moazs/service/MzsService.java
+++ b/src/main/java/at/gv/egiz/moazs/service/MzsService.java
@@ -2,6 +2,7 @@ package at.gv.egiz.moazs.service;
import at.gv.egiz.moazs.backend.MsgResponseSinkHub;
import at.gv.egiz.moazs.preprocess.DeliveryRequestAugmenter;
+import at.gv.egiz.moazs.preprocess.MzsDeliveryRequestValidator;
import at.gv.egiz.moazs.repository.DeliveryRepository;
import at.gv.egiz.moazs.scheme.Msg2MzsConverter;
import at.gv.egiz.moazs.scheme.RequestStatusResponse;
@@ -43,16 +44,18 @@ public class MzsService implements App2MzsPortType {
private final DeliveryRequestAugmenter augmenter;
private final Msg2MzsConverter converter;
private final MsgResponseSinkHub hub;
+ private final MzsDeliveryRequestValidator validator;
@Autowired
public MzsService(DeliveryRepository repository, Consumer<String> deliveryRequestBackend,
DeliveryRequestAugmenter augmenter, Msg2MzsConverter converter,
- MsgResponseSinkHub hub) {
+ MsgResponseSinkHub hub, MzsDeliveryRequestValidator validator) {
this.repository = repository;
this.backend = deliveryRequestBackend;
this.augmenter = augmenter;
this.converter = converter;
this.hub = hub;
+ this.validator = validator;
}
@Override
@@ -63,6 +66,8 @@ public class MzsService implements App2MzsPortType {
var completeRequest = augmenter.augment(deliveryRequest);
+ validator.isRequestValid(completeRequest);
+
var requestProcessed = supplyAsync(() -> process(completeRequest));
try {
@@ -80,7 +85,7 @@ public class MzsService implements App2MzsPortType {
return converter.convert(status, binaryStatus);
} catch (TimeoutException e) {
- return handleAssyncStatus(appDeliveryID, completeRequest, requestProcessed);
+ return applySinkHubToAsyncResponse(appDeliveryID, completeRequest, requestProcessed);
} catch (Exception e) {
var message = format(MZS_SERVICE_ERROR_MSG, appDeliveryID);
@@ -89,16 +94,6 @@ public class MzsService implements App2MzsPortType {
}
- private DeliveryResponseType handleAssyncStatus(String appDeliveryID, DeliveryRequestType request,
- CompletableFuture<RequestStatusResponse> requestProcessed) {
-
- log.info(format(SERVICE_TIME_OUT_REACHED_MSG, appDeliveryID));
- var sinkParams = request.getConfig().getMsgResponseSinks();
- requestProcessed.thenAcceptAsync(response -> hub.applySinks(response, sinkParams));
-
- return generatePartialSuccessResponse(appDeliveryID);
- }
-
private RequestStatusResponse process(DeliveryRequestType deliveryRequest) {
var appDeliveryID = deliveryRequest.getMetaData().getAppDeliveryID();
@@ -113,6 +108,16 @@ public class MzsService implements App2MzsPortType {
}
+ private DeliveryResponseType applySinkHubToAsyncResponse(String appDeliveryID, DeliveryRequestType request,
+ CompletableFuture<RequestStatusResponse> requestProcessed) {
+
+ log.info(format(SERVICE_TIME_OUT_REACHED_MSG, appDeliveryID));
+ var sinkParams = request.getConfig().getMsgResponseSinks();
+ requestProcessed.thenAcceptAsync(response -> hub.applySinks(response, sinkParams));
+
+ return generatePartialSuccessResponse(appDeliveryID);
+ }
+
private DeliveryResponseType generatePartialSuccessResponse(String appDeliveryId) {
var partial = partialSuccessTypeBuilder()