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-07-08 18:02:37 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-08 18:02:37 +0200
commitc1a1a5130a4ecf755da72941ad3525beb919447f (patch)
treeecaca5da80571e10f25186402ee73d8e062d4544 /src/main/java/at/gv/egiz/moazs/MoaZSException.java
parent78f0715d86a055aed11138df5f66b0794e72326a (diff)
downloadmoa-zs-c1a1a5130a4ecf755da72941ad3525beb919447f.tar.gz
moa-zs-c1a1a5130a4ecf755da72941ad3525beb919447f.tar.bz2
moa-zs-c1a1a5130a4ecf755da72941ad3525beb919447f.zip
Implement Zuse2App Services
- Add zuse2app.wsdl contract. - Add MsgResponse as an type-agnostic view for DeliveryRequestStatus and DeliveryNotification messages. Reason: Both DeliveryNotification and DeliveryRequestStatus messages have similar fields and need to be treated similarly (e.g.: receive from msg service, store to repository, verify signature, store to file...). In order to prevent duplicated code, the wrapper interface provides a type-agnostic view onto these messages for depending components to operate on. - Add MsgResponseHandler interface; decides how to process MsgResponse. Also implement this handler with a multi-threaded single-node implementation. - Add MsgResponseSink interface; decides how to archive MsgResponse. - Implement and test SafeResponseToFileSink. Change Identifier for MsgResponses: - Before, DeliveryRequestStatus and DeliveryNotifications had their own repositories. Now, both types are stored in the same repository (the MsgResponse repository) to streamline the handling of MsgResponses. We need to change the identification of MsgReponses, otherwise the identifiers (AppDeliveryID) clash. - MsgResponses are not identified by: <AppDeliveryId>+<typeSpecificSuffix> - Rewrite StoreSOAPInterceptor to accommodate fact that, both DeliveryRequestStatus and DeliveryNotification messages have different IDs upon storage / retrieval. Restructure packages and components as follows: - client: All components that are involved when consuming a web service. - process: "fabric" of MoaZS; contains business logic that orchestrates back-end tasks of MoaZS's operational services, e.g.: by processing a delivery request. - service: Implementation of MoaZS's front-end services. Refactoring: - MoaZSException: Remove unused fields. Before: Store mzsrequest, tnvzresult, msgrequest and msgresult as members. Now: Only keep the fields that are needed later, e.g for generating a msg:DeliveryRequestStatus element. Add copy constructor to Builder. - Put storage of byte[] into a dedicated "BinaryRepository". Reason: This was useful in a former design. Now it's not really needed anymore. - Put "create Endpoint" code into EndpointFactory. Reason: Eliminate duplicated code when configuring a service. Testing: - Activate Stacktraces in surefire.
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/MoaZSException.java')
-rw-r--r--src/main/java/at/gv/egiz/moazs/MoaZSException.java99
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);
}
}