aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/mzs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/mzs')
-rw-r--r--src/main/java/at/gv/egiz/moazs/mzs/MzsClient.java13
-rw-r--r--src/main/java/at/gv/egiz/moazs/mzs/MzsService.java105
-rw-r--r--src/main/java/at/gv/egiz/moazs/mzs/MzsValidator.java74
3 files changed, 0 insertions, 192 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/mzs/MzsClient.java b/src/main/java/at/gv/egiz/moazs/mzs/MzsClient.java
deleted file mode 100644
index 980dce1..0000000
--- a/src/main/java/at/gv/egiz/moazs/mzs/MzsClient.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package at.gv.egiz.moazs.mzs;
-
-import at.gv.zustellung.app2mzs.xsd.DeliveryResponseType;
-import org.springframework.stereotype.Component;
-
-@Component
-public class MzsClient {
-
- public void sendNotification(DeliveryResponseType responseType) {
- throw new UnsupportedOperationException("Not implemented.");
- }
-
-}
diff --git a/src/main/java/at/gv/egiz/moazs/mzs/MzsService.java b/src/main/java/at/gv/egiz/moazs/mzs/MzsService.java
deleted file mode 100644
index f4ecfdb..0000000
--- a/src/main/java/at/gv/egiz/moazs/mzs/MzsService.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package at.gv.egiz.moazs.mzs;
-
-import at.gv.egiz.moazs.pipeline.DeliveryPipeline;
-import at.gv.egiz.moazs.preprocess.DeliveryRequestAugmenter;
-import at.gv.egiz.moazs.repository.DeliveryRepository;
-import at.gv.egiz.moazs.scheme.Msg2MzsConverter;
-import at.gv.zustellung.app2mzs.xsd.App2MzsPortType;
-import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType;
-import at.gv.zustellung.app2mzs.xsd.DeliveryResponseType;
-import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType;
-import org.apache.cxf.annotations.SchemaValidation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import javax.jws.WebParam;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import static at.gv.egiz.moazs.MoaZSException.moaZSException;
-import static at.gv.egiz.moazs.MoaZSException.moaZSExceptionBuilder;
-import static at.gv.zustellung.app2mzs.xsd.PartialSuccessType.partialSuccessTypeBuilder;
-import static java.util.concurrent.CompletableFuture.supplyAsync;
-
-//todo : validate Schema in both directions.
-@Service
-@SchemaValidation(type = SchemaValidation.SchemaValidationType.IN)
-public class MzsService implements App2MzsPortType {
-
- private static final Logger logger = LoggerFactory.getLogger(MzsService.class);
-
- //TODO move timeout and namespaces to config
- private static final int TIMEOUT_FOR_ANWSER = 10;
-
- private final DeliveryRepository repository;
- private final DeliveryPipeline pipeline;
- private final MzsClient appClient;
- private final DeliveryRequestAugmenter augmenter;
- private final Msg2MzsConverter converter;
-
- @Autowired
- public MzsService(DeliveryRepository repository, DeliveryPipeline pipeline, MzsClient appClient,
- DeliveryRequestAugmenter augmenter, Msg2MzsConverter converter) {
- this.repository = repository;
- this.pipeline = pipeline;
- this.appClient = appClient;
- this.augmenter = augmenter;
- this.converter = converter;
- }
-
- @Override
- public DeliveryResponseType app2Mzs(
- @WebParam(partName = "DeliveryRequest",
- name = "DeliveryRequest")
- DeliveryRequestType deliveryRequest) {
-
- var appDeliveryID = deliveryRequest.getMetaData().getAppDeliveryID();
-
- var future = supplyAsync(() -> augmenter.augment(deliveryRequest))
- .thenApply(this::process)
- .thenApply(status -> converter.convert(status, repository.getSignedDeliveryRequestStatus(appDeliveryID)));
-
- try {
- return future.get(TIMEOUT_FOR_ANWSER, TimeUnit.SECONDS);
- } catch (TimeoutException e) {
- logger.info("Answer Timed Out", e);
-
- future.thenAccept(appClient::sendNotification);
- return generatePartialSuccessResponse(appDeliveryID);
-
- } catch (Exception e) {
- throw moaZSExceptionBuilder("An error occurred while processing DeliveryRequest " +
- "with AppDeliveryID=%s.", appDeliveryID)
- .withCause(e)
- .build();
- }
-
- }
-
- private DeliveryRequestStatusType process(DeliveryRequestType deliveryRequest) {
-
- var appDeliveryID = deliveryRequest.getMetaData().getAppDeliveryID();
- logger.info("Receive request with appDeliveryID = {}.", appDeliveryID);
-
- repository.add(deliveryRequest);
- pipeline.processRequest(appDeliveryID);
-
- return repository.getDeliveryRequestStatus(appDeliveryID)
- .orElseThrow(() -> moaZSException("Could not get a response for AppDeliveryID=%s.", appDeliveryID));
-
- }
-
- private DeliveryResponseType generatePartialSuccessResponse(String appDeliveryId) {
-
- var partial = partialSuccessTypeBuilder()
- .withAppDeliveryID(appDeliveryId)
- .build();
-
- return DeliveryResponseType.deliveryResponseTypeBuilder()
- .withPartialSuccess(partial)
- .build();
- }
-
-}
diff --git a/src/main/java/at/gv/egiz/moazs/mzs/MzsValidator.java b/src/main/java/at/gv/egiz/moazs/mzs/MzsValidator.java
deleted file mode 100644
index 26ea7dc..0000000
--- a/src/main/java/at/gv/egiz/moazs/mzs/MzsValidator.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package at.gv.egiz.moazs.mzs;
-
-import at.gv.zustellung.app2mzs.xsd.ClientType;
-import at.gv.zustellung.app2mzs.xsd.ConfigType;
-import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType;
-import at.gv.zustellung.app2mzs.xsd.KeyStoreType;
-import org.springframework.lang.Nullable;
-import org.springframework.stereotype.Component;
-
-@Component
-public class MzsValidator {
-
- /**
- * Checks if the mandatory fields that are needed to send a tnvz:QueryPersonRequest are present.
- * @param request
- * @return true if mandatory fields are present.
- */
- public boolean isTnvzComplete(DeliveryRequestType request) {
- return !request.getConfig().isPerformQueryPersonRequest() ||
- (request.getTnvzMetaData() != null
- && request.getSender().getCorporateBody() != null);
-
-
- }
-
- /**
- * Check if all mandatory fields of configuration are present.
- *
- * @param profile
- * @return true if all mandatory fields are present.
- */
- public boolean isConfigProfileComplete(@Nullable ConfigType profile) {
- return profile != null
- && profile.isPerformQueryPersonRequest() != null
- && isTVNZClientConfigured(profile.getTNVZClient(), profile.isPerformQueryPersonRequest())
- && isMSGClientConfigured(profile.getMSGClient());
- }
-
- private boolean isTVNZClientConfigured(ClientType tnvzClient, Boolean isPerformQueryPersonRequest) {
- return !isPerformQueryPersonRequest || (tnvzClient != null
- && tnvzClient.getURL() != null
- && tnvzClient.getReceiveTimeout() != null
- && tnvzClient.getConnectionTimeout() != null
- && isSSLConfigured(tnvzClient));
- }
-
- private boolean isMSGClientConfigured(ClientType msgClientParams) {
- return msgClientParams != null
- && msgClientParams.getURL() != null
- && isSSLConfigured(msgClientParams)
- && msgClientParams.getReceiveTimeout() != null
- && msgClientParams.getConnectionTimeout() != null;
- }
-
- private boolean isSSLConfigured(ClientType clientParams) {
- return !clientParams.getURL().startsWith("https") || (clientParams.getSSL() != null
- && clientParams.getSSL().isTrustAll() != null
- && clientParams.getSSL().isLaxHostNameVerification() != null
- && isKeyStoreConfigured(clientParams.getSSL().getKeyStore())
- && isTrustStoreConfigured(clientParams.getSSL().getTrustStore()));
- }
-
- private boolean isKeyStoreConfigured(KeyStoreType keyStore) {
- return keyStore == null || (keyStore.getPassword() != null
- && keyStore.getFileType() != null
- && keyStore.getFileName() != null);
- }
-
- private boolean isTrustStoreConfigured(KeyStoreType trustStore) {
- return trustStore == null || (trustStore.getPassword() != null
- && "JKS".equals(trustStore.getFileType())
- && trustStore.getFileName() != null);
- }
-}