diff options
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java')
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java new file mode 100644 index 0000000..f465a28 --- /dev/null +++ b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java @@ -0,0 +1,67 @@ +package at.gv.egiz.moazs.scheme; + +import at.gv.egiz.moazs.MoaZSException; +import at.gv.zustellung.msg.xsd.DeliveryAnswerType; +import at.gv.zustellung.msg.xsd.DeliveryNotificationType; + +import static at.gv.zustellung.msg.xsd.DeliveryNotificationType.deliveryNotificationTypeBuilder; + +public class NotificationResponse implements MsgResponse<DeliveryNotificationType> { + + private final DeliveryNotificationType notification; + private final String id; + private static final String ID_SUFFIX = ".NO"; + + public NotificationResponse(DeliveryNotificationType notification) { + this.notification = notification; + this.id = getId(notification.getAppDeliveryID()); + } + + @Override + public String getResponseID() { + return this.id; + } + + public static String getId(String appDeliveryID) { + return appDeliveryID + ID_SUFFIX; + } + + @Override + public DeliveryNotificationType getResponse() { + return notification; + } + + @Override + public String getAppDeliveryID() { + return notification.getAppDeliveryID(); + } + + @Override + public String getZSDeliveryID() { + return notification.getZSDeliveryID(); + } + + @Override + public DeliveryAnswerType getAnswer() { + return notification; + } + + @Override + public MsgResponse<DeliveryNotificationType> generateError(MoaZSException exception) { + + //TODO: test this! + var notification = deliveryNotificationTypeBuilder() + .withAppDeliveryID(exception.getAppDeliveryID()) + .withDeliverySystem(exception.getDeliverySystem()) + .withGZ(exception.getGz()) + .withZSDeliveryID(exception.getZsDeliveryID()) + .build(); + + return new NotificationResponse(notification); + + } + + public static String getIdSuffix() { + return ID_SUFFIX; + } +} |