aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/MoaZSException.java
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-28 10:48:20 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-28 10:48:20 +0200
commite1f365955aa22cdf8e44429af2b744388ce0c05b (patch)
tree71fec813cce57d4a74650dec259685052c405190 /src/main/java/at/gv/egiz/moazs/MoaZSException.java
parent695ab1f836160d40c4352a2c3127f4f687912817 (diff)
downloadmoa-zs-e1f365955aa22cdf8e44429af2b744388ce0c05b.tar.gz
moa-zs-e1f365955aa22cdf8e44429af2b744388ce0c05b.tar.bz2
moa-zs-e1f365955aa22cdf8e44429af2b744388ce0c05b.zip
Integrate Sign.Verification and Improve Error Handling of Pipeline
- Ensure proper communication of errors between pipeline and mzs service by converting MoaZSExceptions into DeliveryRequestStatus messages. - Revise MoaZSException: Add optional fields; those fields are a) helpful to construct meaningful error messages and b) optional because, depending on where an exception appears, either existent or non-existent and thus optional. Add inner-class Builder. - Integrate Signature Verification into pipeline and add Stub for SignatureVerification. - Move TNVZResponse's Mimetype check into dedicated class (Reason: separate abstration layers). - Update api changes in testcases.
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/MoaZSException.java')
-rw-r--r--src/main/java/at/gv/egiz/moazs/MoaZSException.java123
1 files changed, 116 insertions, 7 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/MoaZSException.java b/src/main/java/at/gv/egiz/moazs/MoaZSException.java
index 11d9b4e..db04241 100644
--- a/src/main/java/at/gv/egiz/moazs/MoaZSException.java
+++ b/src/main/java/at/gv/egiz/moazs/MoaZSException.java
@@ -1,20 +1,129 @@
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 MoaZSException(String s, Throwable throwable) {
- super(s, throwable);
- }
- public MoaZSException(String s) {
- super(s);
+ 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 formatString, Object... objects) {
- return new MoaZSException(String.format(formatString, objects));
+ return moaZSExceptionBuilder(formatString, objects).build();
}
public static MoaZSException moaZSException(String message) {
- return new MoaZSException(String.format(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 extends Throwable {
+
+ 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);
+ }
}
}