From 34a47ef924cb0b58f3a9b88a0a73936fad89f7d8 Mon Sep 17 00:00:00 2001 From: burdziak Date: Thu, 22 Mar 2018 10:17:40 +0100 Subject: Fixes in EchoService Change-Id: I0e1a0798f7f7eb89edaf4731c7e5a02bf362e4b2 Issue-ID: AAI-918 Signed-off-by: burdziak --- .../org/onap/aai/datarouter/service/EchoService.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/onap/aai/datarouter/service/EchoService.java b/src/main/java/org/onap/aai/datarouter/service/EchoService.java index 4ff658b..8192935 100644 --- a/src/main/java/org/onap/aai/datarouter/service/EchoService.java +++ b/src/main/java/org/onap/aai/datarouter/service/EchoService.java @@ -44,6 +44,8 @@ public class EchoService { private static Logger logger = LoggerFactory.getInstance().getLogger(EchoService.class.getName()); private static Logger auditLogger = LoggerFactory.getInstance().getAuditLogger(EchoService.class.getName()); + private static final String XFROMAPPID = "X-FromAppId"; + private static final String XTRANSACTIONID = "X-TransactionId"; @GET @Path("echo/{input}") @@ -55,15 +57,15 @@ public class EchoService { String fromAppId = ""; String transId; - if (headers.getRequestHeaders().getFirst("X-FromAppId") != null) { - fromAppId = headers.getRequestHeaders().getFirst("X-FromAppId"); + if (headers.getRequestHeaders().getFirst(XFROMAPPID) != null) { + fromAppId = headers.getRequestHeaders().getFirst(XFROMAPPID); } - if ((headers.getRequestHeaders().getFirst("X-TransactionId") == null) - || headers.getRequestHeaders().getFirst("X-TransactionId").isEmpty()) { + if ((headers.getRequestHeaders().getFirst(XTRANSACTIONID) == null) + || headers.getRequestHeaders().getFirst(XTRANSACTIONID).isEmpty()) { transId = java.util.UUID.randomUUID().toString(); } else { - transId = headers.getRequestHeaders().getFirst("X-TransactionId"); + transId = headers.getRequestHeaders().getFirst(XTRANSACTIONID); } MdcContext.initialize(transId, DataRouterConstants.DATA_ROUTER_SERVICE_NAME, "", fromAppId, @@ -83,9 +85,7 @@ public class EchoService { auditLogger.info(DataRouterMsgs.PROCESS_REST_REQUEST, new LogFields().setField(LogLine.DefinedFields.RESPONSE_CODE, status) .setField(LogLine.DefinedFields.RESPONSE_DESCRIPTION, respStatusString), - (req != null) ? req.getMethod() : "Unknown", - (req != null) ? req.getRequestURL().toString() : "Unknown", - (req != null) ? req.getRemoteHost() : "Unknown", Integer.toString(status)); + req.getMethod(), req.getRequestURL().toString(), req.getRemoteHost(), Integer.toString(status)); MDC.clear(); return "Hello, " + input + "."; -- cgit 1.2.3-korg