diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-09 10:32:54 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-07-09 10:32:54 +0200 |
commit | d8c668bbca31a835c387a3d52293c9938c424f58 (patch) | |
tree | 819c44930a05071e8f8645a1427f9485a79da664 /src/main/java/at/gv/egiz/moazs/scheme | |
parent | c1a1a5130a4ecf755da72941ad3525beb919447f (diff) | |
download | moa-zs-d8c668bbca31a835c387a3d52293c9938c424f58.tar.gz moa-zs-d8c668bbca31a835c387a3d52293c9938c424f58.tar.bz2 moa-zs-d8c668bbca31a835c387a3d52293c9938c424f58.zip |
Refactor MsgResponse and its IDs
StoreSOAPBodyBinaryInRepositoryInterceptor:
- Replace "generate body's id via concatenation" with "give the right
generator function the app delivery id and let the generator
function do the work". Reason: Prevent the logistics of deriving IDs
to spill into unrelated components.
MsgResponse refactor:
- Make MsgResponse an abstract class.
- Derive ResponseID's ONLY in MsgResponse::createResponseID.
Others:
- Ensure that all invocations to DeliveryRepository.getResponse and
BinaryRepository.get use "responseID" instead of ambiguous "id" or
incorrect "appDeliveryID".
- Move SingleThreadedDeliveryPipeline into process package.
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/scheme')
3 files changed, 28 insertions, 34 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java index fe46451..699819f 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/MsgResponse.java @@ -3,13 +3,26 @@ package at.gv.egiz.moazs.scheme; import at.gv.egiz.moazs.MoaZSException; import at.gv.zustellung.msg.xsd.DeliveryAnswerType; -public interface MsgResponse <T> { - - String getResponseID(); - T getResponse(); - String getAppDeliveryID(); - String getZSDeliveryID(); - DeliveryAnswerType getAnswer(); - MsgResponse<T> generateError(MoaZSException exception); +public abstract class MsgResponse <T> { + + protected String id; + + protected MsgResponse(){ + this.id = ""; + } + + public static String createResponseId(String appDeliveryID, String idSuffix) { + return appDeliveryID + idSuffix; + } + + public String getResponseID() { + return id; + } + + abstract public T getResponse(); + abstract public String getAppDeliveryID(); + abstract public String getZSDeliveryID(); + abstract public DeliveryAnswerType getAnswer(); + abstract public MsgResponse<T> generateError(MoaZSException exception); } diff --git a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java index f465a28..7670ab7 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/NotificationResponse.java @@ -6,24 +6,18 @@ import at.gv.zustellung.msg.xsd.DeliveryNotificationType; import static at.gv.zustellung.msg.xsd.DeliveryNotificationType.deliveryNotificationTypeBuilder; -public class NotificationResponse implements MsgResponse<DeliveryNotificationType> { +public class NotificationResponse extends MsgResponse<DeliveryNotificationType> { private final DeliveryNotificationType notification; - private final String id; - private static final String ID_SUFFIX = ".NO"; + private final static String ID_SUFFIX = ".NO"; public NotificationResponse(DeliveryNotificationType notification) { + super.id = createResponseId(notification.getAppDeliveryID(), ID_SUFFIX); this.notification = notification; - this.id = getId(notification.getAppDeliveryID()); } - @Override - public String getResponseID() { - return this.id; - } - - public static String getId(String appDeliveryID) { - return appDeliveryID + ID_SUFFIX; + public static String getResponseID(String appDeliveryID) { + return createResponseId(appDeliveryID, ID_SUFFIX); } @Override @@ -60,8 +54,4 @@ public class NotificationResponse implements MsgResponse<DeliveryNotificationTyp return new NotificationResponse(notification); } - - public static String getIdSuffix() { - return ID_SUFFIX; - } } diff --git a/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java b/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java index 89c8be3..0705698 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/RequestStatusResponse.java @@ -10,17 +10,16 @@ import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Error.errorBuil import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.deliveryRequestStatusTypeBuilder; import static at.gv.zustellung.msg.xsd.ErrorInfoType.errorInfoTypeBuilder; -public class RequestStatusResponse implements MsgResponse<DeliveryRequestStatusType> { +public class RequestStatusResponse extends MsgResponse<DeliveryRequestStatusType> { private final DeliveryRequestStatusType status; private final DeliveryAnswerType answer; - private final String responseID; private static final String ID_SUFFIX = ".RS"; public RequestStatusResponse(DeliveryRequestStatusType status) { this.status = status; this.answer = coalesce(status.getSuccess(), status.getPartialSuccess(), status.getError()).get(); - this.responseID = getResponseID(answer.getAppDeliveryID()); + super.id = createResponseId(answer.getAppDeliveryID(), ID_SUFFIX); } public static String getResponseID(String appDeliveryID) { @@ -28,11 +27,6 @@ public class RequestStatusResponse implements MsgResponse<DeliveryRequestStatusT } @Override - public String getResponseID() { - return this.responseID; - } - - @Override public DeliveryRequestStatusType getResponse() { return status; } @@ -81,7 +75,4 @@ public class RequestStatusResponse implements MsgResponse<DeliveryRequestStatusT } - public static String getIdSuffix() { - return ID_SUFFIX; - } } |