package at.gv.egiz.moazs; import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType; import at.gv.zustellung.msg.xsd.DeliveryRequestType; 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_MOASP_SIGNATURE_INVALID = "7001"; @Nullable private final String errorCode; @Nullable private final PersonResultType tnvzResult; @Nullable private final DeliveryRequestStatusType msgResult; @Nullable private final DeliveryRequestType msgRequest; @Nullable private final at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest; private MoaZSException(String message, Throwable cause, String errorCode, PersonResultType tnvzResult, DeliveryRequestStatusType msgResult, DeliveryRequestType msgRequest, at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest) { super(message, cause); this.errorCode = errorCode; this.tnvzResult = tnvzResult; this.msgResult = msgResult; this.msgRequest = msgRequest; this.mzsRequest = mzsRequest; } 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)); } public static Builder moaZSExceptionBuilder(String message) { return new Builder().withMessage(message); } @Nullable public String getErrorCode() { return errorCode; } @Nullable public PersonResultType getTnvzResult() { return tnvzResult; } @Nullable public DeliveryRequestStatusType getMsgResult() { return msgResult; } @Nullable public at.gv.zustellung.app2mzs.xsd.DeliveryRequestType getMzsRequest() { return mzsRequest; } @Nullable public DeliveryRequestType getMsgRequest() { return msgRequest; } public static class Builder { 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 Builder() { } public Builder withMessage(String message) { this.message = message; return this; } public Builder withCause(Throwable cause) { this.cause = cause; return this; } public Builder withErrorCode(String errorCode) { this.errorCode = errorCode; return this; } public Builder withTnvzResult(PersonResultType tnvzResult) { this.tnvzResult = tnvzResult; return this; } public Builder withMsgResult(DeliveryRequestStatusType msgResult) { this.msgResult = msgResult; return this; } public Builder withMsgRequest(DeliveryRequestType msgRequest) { this.msgRequest = msgRequest; return this; } public Builder withMzsRequest(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType mzsRequest) { this.mzsRequest = mzsRequest; return this; } public MoaZSException build() { return new MoaZSException(message, cause, errorCode, tnvzResult, msgResult, msgRequest, mzsRequest); } } }