aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/gv/egiz/moazs/App2MzsService.java12
-rw-r--r--src/main/java/at/gv/egiz/moazs/MoaZSException.java16
2 files changed, 23 insertions, 5 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/App2MzsService.java b/src/main/java/at/gv/egiz/moazs/App2MzsService.java
index 23cc0aa..09bcc63 100644
--- a/src/main/java/at/gv/egiz/moazs/App2MzsService.java
+++ b/src/main/java/at/gv/egiz/moazs/App2MzsService.java
@@ -15,6 +15,7 @@ import javax.jws.WebParam;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import static at.gv.egiz.moazs.MoaZSException.moaZSException;
import static at.gv.zustellung.msg.xsd.DeliveryAnswerType.deliveryAnswerTypeBuilder;
import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.deliveryRequestStatusTypeBuilder;
import static java.text.MessageFormat.format;
@@ -48,6 +49,8 @@ public class App2MzsService implements App2MzsPortType {
name = "DeliveryRequest")
DeliveryRequestType deliveryRequest) {
+ var appDeliveryID = deliveryRequest.getMetaData().getAppDeliveryID();
+
var future = supplyAsync(() -> augmenter.augment(deliveryRequest))
.thenApply(this::process);
@@ -56,14 +59,13 @@ public class App2MzsService implements App2MzsPortType {
} catch (TimeoutException e) {
future.thenAccept(appClient::sendNotification);
logger.info("Answer Timed Out", e);
-
- var appDeliveryID = deliveryRequest.getMetaData().getAppDeliveryID();
return generatePartialSuccessResponse(appDeliveryID);
} catch (Exception e ) {
logger.error("Could not deliver request.", e);
- var message = format("An error occurred while processing DeliveryRequest");
- throw new RuntimeException(message, e);
+ var message = format("An error occurred while processing DeliveryRequest with AppDeliveryID={0}. ", appDeliveryID);
+ throw new MoaZSException(message, e);
+
}
}
@@ -77,7 +79,7 @@ public class App2MzsService implements App2MzsPortType {
pipeline.processRequest(appDeliveryID);
return repository.getDeliveryRequestStatus(appDeliveryID)
- .orElseThrow(() -> new RuntimeException("Could not get a response for appDeliveryId = " + appDeliveryID));
+ .orElseThrow(() -> moaZSException("Could not get a response for AppDeliveryID={0}", appDeliveryID));
}
diff --git a/src/main/java/at/gv/egiz/moazs/MoaZSException.java b/src/main/java/at/gv/egiz/moazs/MoaZSException.java
new file mode 100644
index 0000000..ad211bd
--- /dev/null
+++ b/src/main/java/at/gv/egiz/moazs/MoaZSException.java
@@ -0,0 +1,16 @@
+package at.gv.egiz.moazs;
+
+public class MoaZSException extends RuntimeException {
+ public MoaZSException(String s, Throwable throwable) {
+ super(s, throwable);
+ }
+
+ public MoaZSException(String s) {
+ super(s);
+ }
+
+ public static MoaZSException moaZSException(String formatString, Object... objects) {
+ return new MoaZSException(String.format(formatString, objects));
+ }
+
+}