From d8c668bbca31a835c387a3d52293c9938c424f58 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Tue, 9 Jul 2019 10:32:54 +0200 Subject: 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. --- .../util/StoreSOAPBodyBinaryInRepositoryInterceptor.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/main/java/at/gv/egiz/moazs/util') 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 d70c8bd..39566fe 100644 --- a/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java +++ b/src/main/java/at/gv/egiz/moazs/util/StoreSOAPBodyBinaryInRepositoryInterceptor.java @@ -16,6 +16,7 @@ import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Map; +import java.util.function.Function; import static at.gv.egiz.moazs.MoaZSException.moaZSException; @@ -26,16 +27,17 @@ public class StoreSOAPBodyBinaryInRepositoryInterceptor extends AbstractPhaseInt private final CXFMessageUtils messageUtils; private final SOAPUtils soapUtils; - private final Map idSuffixes; + private final Map> idGenerators; private final BinaryRepository repository; @Autowired public StoreSOAPBodyBinaryInRepositoryInterceptor(CXFMessageUtils extractor, SOAPUtils soapUtils, - Map idSuffixes, BinaryRepository repository) { + Map> idGenerators, + BinaryRepository repository) { super(Phase.RECEIVE); this.messageUtils = extractor; this.soapUtils = soapUtils; - this.idSuffixes = idSuffixes; + this.idGenerators = idGenerators; this.repository = repository; } @@ -57,12 +59,12 @@ public class StoreSOAPBodyBinaryInRepositoryInterceptor extends AbstractPhaseInt String appDeliveryID = soapUtils.getAppDeliveryIDFrom(document); String rootTag = document.getTagName(); - if (!idSuffixes.containsKey(rootTag)) { + if (!idGenerators.containsKey(rootTag)) { log.trace("Will not add message of type {}. ", rootTag); return; } - var id = appDeliveryID + idSuffixes.get(rootTag); + var id = idGenerators.get(rootTag).apply(appDeliveryID); repository.add(id, response); if(log.isTraceEnabled()) { -- cgit v1.2.3