aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/repository
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-04-18 11:05:31 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-04-18 14:48:17 +0200
commitaed1250912476f47fd772b0cedd20c850cdcff6e (patch)
treee7fe6aed56b12e53a9b2a7eef62d339e7d23b8b2 /src/main/java/at/gv/egiz/moazs/repository
parent4215362c64064947cea880d55c4aae7894304783 (diff)
downloadmoa-zs-aed1250912476f47fd772b0cedd20c850cdcff6e.tar.gz
moa-zs-aed1250912476f47fd772b0cedd20c850cdcff6e.tar.bz2
moa-zs-aed1250912476f47fd772b0cedd20c850cdcff6e.zip
Change App2mzs Interface and Init Delivery Pipeline
- Change app2mzs interface: output message from app2mzs:DeliveryRequest was app2mzs:DeliveryResponse, now its msg:DeliveryRequestStatus. Reason: ZD returns msg:DeliveryRequestStatus which is signed. Moazs does not convert msg:DeliveryRequestStatus into app2mzs:DeliveryResponse because the conversion woudl break the signature. - App2MzsService: Make beans final and inject them with constructor; Refactor DeliveryRequestHandler into App2MZSService. - DeliveryPipeline: Add Interface and a "SameThreadImplementation" that executes the pipeline in the same threat and can be used in single mode. - DeliveryRepository: Augment interface for storing and retrieving request status objects; Add in-memory-implementation for status objects. - Utils: Add helper function for coalescing multiple values
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/repository')
-rw-r--r--src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java6
-rw-r--r--src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java34
-rw-r--r--src/main/java/at/gv/egiz/moazs/repository/RedisDeliveryRepository.java10
3 files changed, 41 insertions, 9 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java b/src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java
index d5766b6..f736160 100644
--- a/src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java
+++ b/src/main/java/at/gv/egiz/moazs/repository/DeliveryRepository.java
@@ -1,5 +1,6 @@
package at.gv.egiz.moazs.repository;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType;
import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType;
import org.springframework.stereotype.Repository;
@@ -12,4 +13,9 @@ public interface DeliveryRepository {
Optional<DeliveryRequestType> getDeliveryRequest(String appDeliveryID);
+ void add(DeliveryRequestStatusType status);
+
+ Optional<DeliveryRequestStatusType> getDeliveryRequestStatus(String appDeliveryID);
+
+
}
diff --git a/src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java b/src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java
index e5486d7..5712c2d 100644
--- a/src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java
+++ b/src/main/java/at/gv/egiz/moazs/repository/InMemoryDeliveryRepository.java
@@ -1,5 +1,6 @@
package at.gv.egiz.moazs.repository;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType;
import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
@@ -11,30 +12,45 @@ import org.springframework.stereotype.Repository;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
+import static at.gv.egiz.moazs.util.NullCoalesce.coalesce;
+import static java.util.Optional.ofNullable;
+
@Repository
@Profile("!cluster")
public class InMemoryDeliveryRepository implements DeliveryRepository {
private static final Logger logger = LoggerFactory.getLogger(InMemoryDeliveryRepository.class);
- private static final Cache<String, DeliveryRequestType> rep = CacheBuilder.newBuilder()
+ private static final Cache<String, DeliveryRequestType> requestRepository = CacheBuilder.newBuilder()
.expireAfterWrite(30, TimeUnit.MINUTES)
.build();
- public InMemoryDeliveryRepository() {
- logger.info("InMemoryDeliveryRepository()");
- }
+ private static final Cache<String, DeliveryRequestStatusType> statusRepository = CacheBuilder.newBuilder()
+ .expireAfterWrite(30, TimeUnit.MINUTES)
+ .build();
@Override
public void add(DeliveryRequestType request) {
- String key = request.getMetaData().getAppDeliveryID();
- logger.info("Save DeliveryRequest with AppDeliveryId = {} to Cache.", key);
- rep.put(key, request);
+ var key = request.getMetaData().getAppDeliveryID();
+ requestRepository.put(key, request);
}
@Override
public Optional<DeliveryRequestType> getDeliveryRequest(String appDeliveryID) {
- DeliveryRequestType deliveryRequestType = rep.getIfPresent(appDeliveryID);
- return Optional.ofNullable(deliveryRequestType);
+ var deliveryRequestType = requestRepository.getIfPresent(appDeliveryID);
+ return ofNullable(deliveryRequestType);
+ }
+
+ @Override
+ public void add(DeliveryRequestStatusType status) {
+ var key = coalesce(status.getSuccess(), status.getPartialSuccess(), status.getError())
+ .get().getAppDeliveryID();
+ statusRepository.put(key, status);
+ }
+
+ @Override
+ public Optional<DeliveryRequestStatusType> getDeliveryRequestStatus(String appDeliveryID) {
+ var deliveryRequestType = statusRepository.getIfPresent(appDeliveryID);
+ return ofNullable(deliveryRequestType);
}
}
diff --git a/src/main/java/at/gv/egiz/moazs/repository/RedisDeliveryRepository.java b/src/main/java/at/gv/egiz/moazs/repository/RedisDeliveryRepository.java
index 4f39f31..cd02dac 100644
--- a/src/main/java/at/gv/egiz/moazs/repository/RedisDeliveryRepository.java
+++ b/src/main/java/at/gv/egiz/moazs/repository/RedisDeliveryRepository.java
@@ -1,5 +1,6 @@
package at.gv.egiz.moazs.repository;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType;
import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType;
import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.ObjectFactory;
import at.gv.egiz.moazs.Marshaller;
@@ -59,4 +60,13 @@ public class RedisDeliveryRepository implements DeliveryRepository {
return Optional.of(request.getValue());
}
+ @Override
+ public void add(DeliveryRequestStatusType status) {
+ throw new RuntimeException("Not Implemented Yet");
+ }
+
+ @Override
+ public Optional<DeliveryRequestStatusType> getDeliveryRequestStatus(String appDeliveryID) {
+ throw new RuntimeException("Not Implemented Yet");
+ }
}