aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/MoaZSException.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/MoaZSException.java')
-rw-r--r--src/main/java/at/gv/egiz/moazs/MoaZSException.java158
1 files changed, 21 insertions, 137 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/MoaZSException.java b/src/main/java/at/gv/egiz/moazs/MoaZSException.java
index dbb2894..499dc14 100644
--- a/src/main/java/at/gv/egiz/moazs/MoaZSException.java
+++ b/src/main/java/at/gv/egiz/moazs/MoaZSException.java
@@ -1,167 +1,51 @@
package at.gv.egiz.moazs;
-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;
public class MoaZSException extends RuntimeException {
public static final String ERROR_MZS_MIMETYPE_MISSMATCH = "8001";
public static final String ERROR_MZS_NO_TNVZ_PERSON_QUERY_RESULTS = "8002";
+ public static final String ERROR_MZS_BINARY_RESPONSE_MISSING = "8003";
+ public static final String ERROR_MZS_RESPONSE_MISSING = "8004";
public static final String ERROR_MOASP_SIGNATURE_INVALID = "7001";
- @Nullable
- private final String errorCode;
- @Nullable
- private final PreAdviceNoteSentType preAdviceNoteSent;
- @Nullable
- private final String deliverySystem;
- @Nullable
- private final String gz;
- @Nullable
- private final String zsDeliveryID;
- @Nullable
- private final String appDeliveryID;
+ @Nullable private final String code;
+ @Nullable private final PreAdviceNoteSentType preAdviceNoteSent;
- private MoaZSException(Builder builder) {
- super(builder.message, builder.cause);
- this.errorCode = builder.errorCode;
- this.preAdviceNoteSent = builder.preAdviceNoteSent;
- this.deliverySystem = builder.deliverySystem;
- this.gz = builder.gz;
- this.zsDeliveryID = builder.zsDeliveryID;
- this.appDeliveryID = builder.appDeliveryID;
+ private MoaZSException(String message, Throwable cause, @Nullable String code, @Nullable PreAdviceNoteSentType preAdviceNoteSent) {
+ super(message, cause);
+ this.code = code;
+ this.preAdviceNoteSent = preAdviceNoteSent;
}
- public static MoaZSException moaZSException(String message, Throwable cause) {
- return moaZSExceptionBuilder(message).withCause(cause).build();
- }
-
- public static MoaZSException moaZSException(String formatString, Object... objects) {
- return moaZSExceptionBuilder(formatString, objects).build();
- }
-
- public static MoaZSException moaZSException(String message) {
- return moaZSExceptionBuilder(message).build();
- }
-
- public static Builder moaZSExceptionBuilder(String formatString, Object... objects) {
- return new Builder().withMessage(String.format(formatString, objects));
+ @Nullable public String getCode() {
+ return code;
}
- public static Builder moaZSExceptionBuilder(String message) {
- return new Builder().withMessage(message);
- }
-
- public static Builder moaZSExceptionBuilder() {
- return new Builder();
- }
-
- @Nullable
- public String getErrorCode() {
- return errorCode;
- }
-
- @Nullable
- public PreAdviceNoteSentType getPreAdviceNoteSent() {
+ @Nullable public PreAdviceNoteSentType getPreAdviceNoteSent() {
return preAdviceNoteSent;
}
- @Nullable
- public String getDeliverySystem() {
- return deliverySystem;
+ public static MoaZSException moaZSException(String message, Throwable cause) {
+ return new MoaZSException(message, cause, null, null);
}
- @Nullable
- public String getGz() {
- return gz;
+ public static MoaZSException moaZSException(String message) {
+ return new MoaZSException(message, null, null, null);
}
- @Nullable
- public String getZsDeliveryID() {
- return zsDeliveryID;
+ public static MoaZSException moaZSException(String message, String code) {
+ return new MoaZSException(message, null, code, null);
}
- @Nullable
- public String getAppDeliveryID() {
- return appDeliveryID;
+ public static MoaZSException moaZSException(String message, String code, Throwable cause) {
+ return new MoaZSException(message, cause, code, null);
}
- public static class Builder {
-
- private String message;
- private Throwable cause;
- private String errorCode;
- 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;
- }
-
- public Builder withMessage(String formatString, Object... objects ) {
- this.message = String.format(formatString, objects);
- return this;
- }
-
- public Builder withCause(Throwable cause) {
- this.cause = cause;
- return this;
- }
-
- public Builder withErrorCode(String errorCode) {
- this.errorCode = errorCode;
- return this;
- }
-
- public Builder withPreAdviceNoteSent(PersonResultType personResult) {
- if (personResult.getError() != null) {
- this.preAdviceNoteSent = personResult.getError().getPreAdviceNoteSent();
- }
- return this;
- }
-
- public Builder withDeliverySystem(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest) {
- this.deliverySystem = mzsRequest.getConfig().getMSGClient().getURL();
- return this;
- }
-
-
- 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 withAppDeliveryID(String appDeliveryID) {
- this.appDeliveryID = appDeliveryID;
- return this;
- }
-
- public MoaZSException build() {
- return new MoaZSException(this);
- }
+ public static MoaZSException moaZSException(String message, String code, PreAdviceNoteSentType preAdviceNoteSent) {
+ return new MoaZSException(message, null, code, preAdviceNoteSent);
}
}