aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java')
-rw-r--r--src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java b/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
index 2db81ab..d70c8bd 100644
--- a/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
+++ b/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java
@@ -1,6 +1,6 @@
package at.gv.egiz.moazs.util;
-import at.gv.egiz.moazs.repository.DeliveryRepository;
+import at.gv.egiz.moazs.repository.BinaryRepository;
import at.gv.egiz.moazs.scheme.SOAPUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
@@ -15,6 +15,7 @@ import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.util.Map;
import static at.gv.egiz.moazs.MoaZSException.moaZSException;
@@ -25,14 +26,16 @@ public class StoreSOAPBodyBinaryInRepositoryInterceptor extends AbstractPhaseInt
private final CXFMessageUtils messageUtils;
private final SOAPUtils soapUtils;
- private final DeliveryRepository repository;
+ private final Map<String, String> idSuffixes;
+ private final BinaryRepository repository;
@Autowired
public StoreSOAPBodyBinaryInRepositoryInterceptor(CXFMessageUtils extractor, SOAPUtils soapUtils,
- DeliveryRepository repository) {
+ Map<String, String> idSuffixes, BinaryRepository repository) {
super(Phase.RECEIVE);
this.messageUtils = extractor;
this.soapUtils = soapUtils;
+ this.idSuffixes = idSuffixes;
this.repository = repository;
}
@@ -45,17 +48,28 @@ public class StoreSOAPBodyBinaryInRepositoryInterceptor extends AbstractPhaseInt
log.trace("Interceptor received this SOAP message: {}. ", new String(content, StandardCharsets.UTF_8));
}
- if(content.length > 0) {
- Element document = soapUtils.toDOM(content);
- byte[] status = soapUtils.unwrapSoapEnvelope(document);
- String appDeliveryID = soapUtils.getAppDeliveryIDFrom(document);
- repository.addSignedDeliveryRequestStatus(status, appDeliveryID);
+ if (content.length <= 0) {
+ return;
+ }
+
+ Element document = soapUtils.toDOM(content);
+ byte[] response = soapUtils.unwrapSoapEnvelope(document);
+ String appDeliveryID = soapUtils.getAppDeliveryIDFrom(document);
+ String rootTag = document.getTagName();
- if(log.isTraceEnabled()) {
- log.trace("DeliveryRequestStatus with AppDeliveryID={} unwrapped and stored: {}. ",
- appDeliveryID, new String(status, StandardCharsets.UTF_8));
- }
+ if (!idSuffixes.containsKey(rootTag)) {
+ log.trace("Will not add message of type {}. ", rootTag);
+ return;
}
+
+ var id = appDeliveryID + idSuffixes.get(rootTag);
+ repository.add(id, response);
+
+ if(log.isTraceEnabled()) {
+ log.trace("Msg Response with AppDeliveryID={} unwrapped and stored: {}. ",
+ appDeliveryID, new String(response, StandardCharsets.UTF_8));
+ }
+
} catch (ParserConfigurationException | SAXException | IOException | NullPointerException e) {
throw moaZSException("Could not extract signed data from message.", e);
}