aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorSotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>2018-06-06 15:37:35 +0100
committerSotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>2018-06-06 15:37:35 +0100
commit36a7dbfd2672ee6629c4b375df2d6982d942fa43 (patch)
tree8924257b3b13c36531eb32df14605d70a3137444 /src/main/java
parentc57a430c6dbd6951091978404a164000024fce20 (diff)
Add tests for X-FromMsId
Add tests for X-FromMsId header parameter changes Issue-ID: AAI-1198 Change-Id: I6342cf95e5c635b500245bfa90040376ffa1b992 Signed-off-by: Sotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/crud/logging/LoggingUtil.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/main/java/org/onap/crud/logging/LoggingUtil.java b/src/main/java/org/onap/crud/logging/LoggingUtil.java
index f9cb905..31c0c1f 100644
--- a/src/main/java/org/onap/crud/logging/LoggingUtil.java
+++ b/src/main/java/org/onap/crud/logging/LoggingUtil.java
@@ -37,21 +37,29 @@ public class LoggingUtil {
*/
public static void initMdcContext(HttpServletRequest httpReq, HttpHeaders headers) {
String fromIp = httpReq.getRemoteAddr();
- String fromAppId = "";
- String transId = null;
- if (headers.getRequestHeaders().getFirst("X-FromAppId") != null) {
+ MdcContext.initialize(getTransactionId(headers), CrudServiceConstants.CRD_SERVICE_NAME, "", getAppId(headers), fromIp);
+ }
+
+ public static String getAppId(HttpHeaders headers) {
+ String fromAppId = "";
+ if (headers.getRequestHeaders().getFirst("X-FromMsId") != null) {
+ fromAppId = headers.getRequestHeaders().getFirst("X-FromMsId");
+ } else if (headers.getRequestHeaders().getFirst("X-FromAppId") != null) {
fromAppId = headers.getRequestHeaders().getFirst("X-FromAppId");
}
-
+ return fromAppId;
+ }
+
+ public static String getTransactionId(HttpHeaders headers) {
+ String transId = null;
if ((headers.getRequestHeaders().getFirst("X-TransactionId") == null)
- || headers.getRequestHeaders().getFirst("X-TransactionId").isEmpty()) {
+ || headers.getRequestHeaders().getFirst("X-TransactionId").isEmpty()) {
transId = java.util.UUID.randomUUID().toString();
} else {
transId = headers.getRequestHeaders().getFirst("X-TransactionId");
}
-
- MdcContext.initialize(transId, CrudServiceConstants.CRD_SERVICE_NAME, "", fromAppId, fromIp);
+ return transId;
}
/**