From 2e921528557a23b96fb6b52b2b53a28048a826fd Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 3 May 2019 20:54:32 +0200 Subject: update abstract protocols/RequestImpl.java to inject an external generated transactionId --- .../impl/idp/controller/protocols/RequestImpl.java | 31 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java index 5667fad7..f037f4ab 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java @@ -35,13 +35,13 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import javax.naming.ConfigurationException; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.lang.NonNull; +import org.springframework.lang.Nullable; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.data.EAAFConstants; @@ -96,14 +96,37 @@ public abstract class RequestImpl implements IRequest, Serializable{ private final Map genericDataStorage = new HashMap(); + /** + * Initialize this pendingRequest object + * + * @param req {@link HttpServletRequest} + * @param authConfig {@link IConfiguration} + * @throws EAAFException + * + */ + public final void initialize(HttpServletRequest req, IConfiguration authConfig) throws EAAFException { + initialize(req, authConfig, null); + + } /** - * @throws ConfigurationException + * Initialize this pendingRequest object + * + * @param req {@link HttpServletRequest} + * @param authConfig {@link IConfiguration} + * @param transactionId transactionId that should be used in this pendingRequest for logging. If 'null' a new one will be generated + * + * @throws EAAFException * */ - public final void initialize(HttpServletRequest req, IConfiguration authConfig) throws EAAFException { + public final void initialize(@NonNull HttpServletRequest req, @NonNull IConfiguration authConfig, @Nullable String transactionId) throws EAAFException { + //use external transactionId or create new one if empty or null + if (StringUtils.isNotEmpty(transactionId)) + uniqueTransactionIdentifer = transactionId; + else + uniqueTransactionIdentifer = Random.nextLongRandom(); + //set unique transaction identifier for logging - uniqueTransactionIdentifer = Random.nextLongRandom(); TransactionIDUtils.setTransactionId(uniqueTransactionIdentifer); //initialize session object -- cgit v1.2.3