aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-04-29 14:28:48 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-04-29 14:37:08 +0200
commit9a038cf18d6ebd4c68218c20ebc174b779afa7fa (patch)
tree74a5ca5a464112de3c03bec79fbfce2a606556d8 /src/main/java/at/gv/egiz
parentdf2cf5c818067110dc1dfe8506f146f64ae26fe5 (diff)
downloadmoa-zs-9a038cf18d6ebd4c68218c20ebc174b779afa7fa.tar.gz
moa-zs-9a038cf18d6ebd4c68218c20ebc174b779afa7fa.tar.bz2
moa-zs-9a038cf18d6ebd4c68218c20ebc174b779afa7fa.zip
Make JAXB Objects Immutable and Add Builder Utility
- Use Immutable-XJC from https://github.com/sabomichal/immutable-xjc - Update existing JAXB-object manipulations to use the Builder - Remove jaxbMarshallerTest (as it relies on mutable JAXB interfaces) Reason for making JAXB objects immutable: I put JAXB objects in the repository. Depending on the configuration, the repository can be a simple hashmap; in that case I might end up sharing JAXB objects between threads. Immutable shared object should make life a little simpler.
Diffstat (limited to 'src/main/java/at/gv/egiz')
-rw-r--r--src/main/java/at/gv/egiz/moazs/App2MzsService.java43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/App2MzsService.java b/src/main/java/at/gv/egiz/moazs/App2MzsService.java
index 8626c24..66ab795 100644
--- a/src/main/java/at/gv/egiz/moazs/App2MzsService.java
+++ b/src/main/java/at/gv/egiz/moazs/App2MzsService.java
@@ -1,9 +1,16 @@
package at.gv.egiz.moazs;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryAnswerType;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryAnswerType.DeliveryAnswerTypeBuilder;
import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType.DeliveryRequestStatusTypeBuilder;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType.Error.ErrorBuilder;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ErrorInfoType;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ErrorInfoType.ErrorInfoTypeBuilder;
import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ObjectFactory;
import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs.App2MzsPortType;
import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType;
+import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType.DeliveryRequestTypeBuilder;
import at.gv.egiz.moazs.pipeline.DeliveryPipeline;
import at.gv.egiz.moazs.repository.DeliveryRepository;
import org.slf4j.Logger;
@@ -66,32 +73,30 @@ public class App2MzsService implements App2MzsPortType {
private DeliveryRequestStatusType generatePartialSuccessResponse(String appDeliveryId, String message) {
- var partialSuccess = objectFactory.createDeliveryAnswerType();
- partialSuccess.setAppDeliveryID(appDeliveryId);
+ var answer = new DeliveryAnswerTypeBuilder()
+ .withAppDeliveryID(appDeliveryId)
+ .build();
- var response = objectFactory.createDeliveryRequestStatusType();
- response.setPartialSuccess(partialSuccess);
-
- response.setSignature(null);
-
- return response;
+ return new DeliveryRequestStatusTypeBuilder()
+ .withPartialSuccess(answer)
+ .build();
}
private DeliveryRequestStatusType generateErrorResponse(String appDeliveryId, String message) {
- var error = objectFactory.createDeliveryRequestStatusTypeError();
- error.setAppDeliveryID(appDeliveryId);
-
- var info = objectFactory.createErrorInfoType();
- info.setCode("500");
- info.setText(message);
- error.setErrorInfo(info);
+ var info = new ErrorInfoTypeBuilder()
+ .withCode("500")
+ .withText(message)
+ .build();
- var response = objectFactory.createDeliveryRequestStatusType();
- response.setError(error);
- response.setSignature(null);
+ var error = new ErrorBuilder()
+ .withAppDeliveryID(appDeliveryId)
+ .withErrorInfo(info)
+ .build();
- return response;
+ return new DeliveryRequestStatusTypeBuilder()
+ .withError(error)
+ .build();
}
private DeliveryRequestStatusType process(DeliveryRequestType deliveryRequest) throws RuntimeException {