/**
* ============LICENSE_START=======================================================
- * Gizmo
+ * org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property.
- * Copyright © 2017 Amdocs
- * All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.crud.logging;
*/
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;
}
/**