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 extends MsgResponse { private final DeliveryNotificationType notification; private static final String ID_SUFFIX = ".NO"; public NotificationResponse(DeliveryNotificationType notification) { super.id = createResponseId(notification.getAppDeliveryID(), ID_SUFFIX); this.notification = notification; } public static String getResponseID(String appDeliveryID) { return createResponseId(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 notificationType = deliveryNotificationTypeBuilder() .withAppDeliveryID(exception.getAppDeliveryID()) .withDeliverySystem(exception.getDeliverySystem()) .withGZ(exception.getGz()) .withZSDeliveryID(exception.getZsDeliveryID()) .build(); return new NotificationResponse(notificationType); } }