diff options
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/scheme')
4 files changed, 37 insertions, 11 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java b/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java index 67f3d13..271cf67 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java @@ -1,9 +1,6 @@ package at.gv.egiz.moazs.scheme; -import at.gv.zustellung.app2mzs.xsd.DeliveryResponseType; -import at.gv.zustellung.app2mzs.xsd.ErrorType; -import at.gv.zustellung.app2mzs.xsd.PartialSuccessType; -import at.gv.zustellung.app2mzs.xsd.SuccessType; +import at.gv.zustellung.app2mzs.xsd.*; import at.gv.zustellung.msg.xsd.DeliveryAnswerType; import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType; import org.springframework.stereotype.Component; @@ -34,6 +31,12 @@ public class Msg2MzsConverter { return responseBuilder.build(); } + public DeliveryNotificationType convert(at.gv.zustellung.msg.xsd.DeliveryNotificationType notificatione, Optional<byte[]> signedStatus) { + //TODO + return null; + } + + private SuccessType convert(DeliveryRequestStatusType.Success success, Optional<byte[]> signedStatus) { return successTypeBuilder() .withAppDeliveryID(success.getAppDeliveryID()) diff --git a/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java index 5370448..8bd88d9 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java @@ -1,9 +1,12 @@ package at.gv.egiz.moazs.scheme; import at.gv.egiz.moazs.MoaZSException; +import at.gv.zustellung.app2mzs.xsd.Mzs2AppPortType; import at.gv.zustellung.msg.xsd.DeliveryAnswerType; import javax.xml.bind.JAXBElement; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; /** * Represents responses to DeliveryRequests that were received from the msg service. @@ -31,5 +34,6 @@ public abstract class MsgResponse <T> { public abstract String getZSDeliveryID(); public abstract DeliveryAnswerType getAnswer(); public abstract MsgResponse<T> generateError(MoaZSException exception); + public abstract CompletableFuture<Void> sendToMzsClient(Msg2MzsConverter converter, Optional<byte[]> signedStatus, Mzs2AppPortType client); } diff --git a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java index 784d000..21e00a1 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java @@ -1,12 +1,16 @@ package at.gv.egiz.moazs.scheme; import at.gv.egiz.moazs.MoaZSException; +import at.gv.zustellung.app2mzs.xsd.Mzs2AppPortType; import at.gv.zustellung.msg.xsd.DeliveryAnswerType; import at.gv.zustellung.msg.xsd.DeliveryNotificationType; import at.gv.zustellung.msg.xsd.ObjectFactory; import javax.xml.bind.JAXBElement; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + import static at.gv.zustellung.msg.xsd.DeliveryNotificationType.deliveryNotificationTypeBuilder; public class NotificationResponse extends MsgResponse<DeliveryNotificationType> { @@ -50,17 +54,23 @@ public class NotificationResponse extends MsgResponse<DeliveryNotificationType> } @Override - public MsgResponse<DeliveryNotificationType> generateError(MoaZSException exception) { + public NotificationResponse generateError(MoaZSException exception) { - //TODO: test this! + //TODO: use copy constructor? var notificationType = deliveryNotificationTypeBuilder() - .withAppDeliveryID(exception.getAppDeliveryID()) - .withDeliverySystem(exception.getDeliverySystem()) - .withGZ(exception.getGz()) - .withZSDeliveryID(exception.getZsDeliveryID()) - .build(); + .withAppDeliveryID(exception.getAppDeliveryID()) + .withDeliverySystem(exception.getDeliverySystem()) + .withGZ(exception.getGz()) + .withZSDeliveryID(exception.getZsDeliveryID()) + .build(); return new NotificationResponse(notificationType); + } + @Override + public CompletableFuture<Void> sendToMzsClient(Msg2MzsConverter converter, Optional<byte[]> signedNotification, Mzs2AppPortType client) { + var mzsNotification = converter.convert(notification, signedNotification); + client.forwardNotification(mzsNotification); + return CompletableFuture.completedFuture(null); } } diff --git a/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java index 3b4710b..14e22ad 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java @@ -1,12 +1,15 @@ package at.gv.egiz.moazs.scheme; import at.gv.egiz.moazs.MoaZSException; +import at.gv.zustellung.app2mzs.xsd.Mzs2AppPortType; import at.gv.zustellung.msg.xsd.DeliveryAnswerType; import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType; import at.gv.zustellung.msg.xsd.ErrorInfoType; import at.gv.zustellung.msg.xsd.ObjectFactory; import javax.xml.bind.JAXBElement; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; import static at.gv.egiz.moazs.util.NullCoalesce.coalesce; import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Error.errorBuilder; @@ -82,7 +85,13 @@ public class RequestStatusResponse extends MsgResponse<DeliveryRequestStatusType .build(); return new RequestStatusResponse(status); + } + @Override + public CompletableFuture<Void> sendToMzsClient(Msg2MzsConverter converter, Optional<byte[]> signedStatus, Mzs2AppPortType client) { + var msgStatus = converter.convert(status, signedStatus); + client.forwardStatus(msgStatus); + return CompletableFuture.completedFuture(null); } } |