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.java14
1 files changed, 8 insertions, 6 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 cbc56e4..8f0ef86 100644
--- a/src/main/java/at/gv/egiz/moazs/service/MzsService.java
+++ b/src/main/java/at/gv/egiz/moazs/service/MzsService.java
@@ -20,8 +20,8 @@ import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import static at.gv.egiz.moazs.MoaZSException.moaZSException;
-import static at.gv.egiz.moazs.MoaZSException.moaZSExceptionBuilder;
import static at.gv.zustellung.app2mzs.xsd.PartialSuccessType.partialSuccessTypeBuilder;
+import static java.lang.String.format;
import static java.util.concurrent.CompletableFuture.supplyAsync;
//todo : validate Schema in both directions.
@@ -33,6 +33,9 @@ public class MzsService implements App2MzsPortType {
//TODO move timeout and namespaces to config
private static final int TIMEOUT_FOR_ANWSER = 10;
+ private static final String MZS_SERVICE_ERROR_MSG = "An error occurred while processing DeliveryRequest " +
+ "with AppDeliveryID=%s.";
+ private static final String RESPONSE_MISSING_ERROR_MSG = "Could not get a response for AppDeliveryID=%s.";
private final DeliveryRepository repository;
private final Consumer<String> backend;
@@ -71,10 +74,8 @@ public class MzsService implements App2MzsPortType {
return generatePartialSuccessResponse(appDeliveryID);
} catch (Exception e) {
- throw moaZSExceptionBuilder("An error occurred while processing DeliveryRequest " +
- "with AppDeliveryID=%s.", appDeliveryID)
- .withCause(e)
- .build();
+ var message = format(MZS_SERVICE_ERROR_MSG, appDeliveryID);
+ throw moaZSException(message, e);
}
}
@@ -82,6 +83,7 @@ public class MzsService implements App2MzsPortType {
private DeliveryRequestStatusType process(DeliveryRequestType deliveryRequest) {
var appDeliveryID = deliveryRequest.getMetaData().getAppDeliveryID();
+ //TODO: fix too.
logger.info("Receive request with appDeliveryID = {}.", appDeliveryID);
repository.store(deliveryRequest);
@@ -89,7 +91,7 @@ public class MzsService implements App2MzsPortType {
var statusId = RequestStatusResponse.getResponseID(appDeliveryID);
var response = repository.retrieveResponse(statusId)
- .orElseThrow(() -> moaZSException("Could not get a response for AppDeliveryID=%s.", appDeliveryID));
+ .orElseThrow(() -> moaZSException(format(RESPONSE_MISSING_ERROR_MSG, appDeliveryID)));
return (DeliveryRequestStatusType) response.getResponse();
}