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 { 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 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; } }