diff options
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/MoaZSException.java')
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/MoaZSException.java | 99 |
1 files changed, 65 insertions, 34 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/MoaZSException.java b/src/main/java/at/gv/egiz/moazs/MoaZSException.java index 322f06b..1e86c22 100644 --- a/src/main/java/at/gv/egiz/moazs/MoaZSException.java +++ b/src/main/java/at/gv/egiz/moazs/MoaZSException.java @@ -1,10 +1,13 @@ package at.gv.egiz.moazs; -import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType; -import at.gv.zustellung.msg.xsd.DeliveryRequestType; +import at.gv.zustellung.msg.xsd.DeliveryAnswerType; +import at.gv.zustellung.msg.xsd.PreAdviceNoteSentType; import at.gv.zustellung.tnvz.xsd.PersonResultType; import org.springframework.lang.Nullable; +import java.util.concurrent.ExecutorService; + + public class MoaZSException extends RuntimeException { public static final String ERROR_MZS_MIMETYPE_MISSMATCH = "8001"; @@ -14,25 +17,29 @@ public class MoaZSException extends RuntimeException { @Nullable private final String errorCode; @Nullable - private final PersonResultType tnvzResult; + private final PreAdviceNoteSentType preAdviceNoteSent; + @Nullable + private final String deliverySystem; @Nullable - private final DeliveryRequestStatusType msgResult; + private final String gz; @Nullable - private final DeliveryRequestType msgRequest; + private final String zsDeliveryID; @Nullable - private final at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest; + private final String appDeliveryID; - private MoaZSException(String message, Throwable cause, String errorCode, PersonResultType tnvzResult, - DeliveryRequestStatusType msgResult, DeliveryRequestType msgRequest, - at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest) { + private MoaZSException(String message, @Nullable Throwable cause, @Nullable String errorCode, @Nullable PreAdviceNoteSentType preAdviceNoteSent, + @Nullable String deliverySystem, @Nullable String gz, @Nullable String zsDeliveryID, + @Nullable String appDeliveryID) { super(message, cause); this.errorCode = errorCode; - this.tnvzResult = tnvzResult; - this.msgResult = msgResult; - this.msgRequest = msgRequest; - this.mzsRequest = mzsRequest; + this.preAdviceNoteSent = preAdviceNoteSent; + this.deliverySystem = deliverySystem; + this.gz = gz; + this.zsDeliveryID = zsDeliveryID; + this.appDeliveryID = appDeliveryID; } + public static MoaZSException moaZSException(String message, Throwable cause) { return moaZSExceptionBuilder(message).withCause(cause).build(); } @@ -63,23 +70,28 @@ public class MoaZSException extends RuntimeException { } @Nullable - public PersonResultType getTnvzResult() { - return tnvzResult; + public PreAdviceNoteSentType getPreAdviceNoteSent() { + return preAdviceNoteSent; + } + + @Nullable + public String getDeliverySystem() { + return deliverySystem; } @Nullable - public DeliveryRequestStatusType getMsgResult() { - return msgResult; + public String getGz() { + return gz; } @Nullable - public at.gv.zustellung.app2mzs.xsd.DeliveryRequestType getMzsRequest() { - return mzsRequest; + public String getZsDeliveryID() { + return zsDeliveryID; } @Nullable - public DeliveryRequestType getMsgRequest() { - return msgRequest; + public String getAppDeliveryID() { + return appDeliveryID; } public static class Builder { @@ -87,14 +99,26 @@ public class MoaZSException extends RuntimeException { private String message; private Throwable cause; private String errorCode; - private PersonResultType tnvzResult; - private DeliveryRequestStatusType msgResult; - private DeliveryRequestType msgRequest; - private at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest; + private PreAdviceNoteSentType preAdviceNoteSent; + private String deliverySystem; + private String gz; + private String zsDeliveryID; + private String appDeliveryID; private Builder() { } + public Builder(MoaZSException exception){ + this.message = exception.getMessage(); + this.cause = exception.getCause(); + this.errorCode = exception.getErrorCode(); + this.preAdviceNoteSent = exception.getPreAdviceNoteSent(); + this.deliverySystem = exception.getDeliverySystem(); + this.gz = exception.getGz(); + this.zsDeliveryID = exception.getZsDeliveryID(); + this.appDeliveryID = exception.getAppDeliveryID(); + } + public Builder withMessage(String message) { this.message = message; return this; @@ -115,28 +139,35 @@ public class MoaZSException extends RuntimeException { return this; } - public Builder withTnvzResult(PersonResultType tnvzResult) { - this.tnvzResult = tnvzResult; + public Builder withPreAdviceNoteSent(PersonResultType personResult) { + if (personResult.getError() != null) { + this.preAdviceNoteSent = personResult.getError().getPreAdviceNoteSent(); + } return this; } - public Builder withMsgResult(DeliveryRequestStatusType msgResult) { - this.msgResult = msgResult; + public Builder withDeliverySystem(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest) { + this.deliverySystem = mzsRequest.getConfig().getMSGClient().getURL(); return this; } - public Builder withMsgRequest(DeliveryRequestType msgRequest) { - this.msgRequest = msgRequest; + + public Builder withAllParametersInAnswer(DeliveryAnswerType answer) { + this.deliverySystem = answer.getDeliverySystem(); + this.gz = answer.getGZ(); + this.zsDeliveryID = answer.getZSDeliveryID(); + this.appDeliveryID = answer.getAppDeliveryID(); return this; } - public Builder withMzsRequest(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest) { - this.mzsRequest = mzsRequest; + public Builder withAppDeliveryID(String appDeliveryID) { + this.appDeliveryID = appDeliveryID; return this; } public MoaZSException build() { - return new MoaZSException(message, cause, errorCode, tnvzResult, msgResult, msgRequest, mzsRequest); + return new MoaZSException(message, cause, errorCode, preAdviceNoteSent, deliverySystem, gz, + zsDeliveryID, appDeliveryID); } } |