*
* ============LICENSE_END============================================
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
*/
package org.onap.portalapp.portal.logging.aop;
import java.net.InetAddress;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
private EELFLoggerDelegate adviceLogger = EELFLoggerDelegate.getLogger(EPEELFLoggerAdvice.class);
/**
- * DateTime Format according to the ECOMP Application Logging Guidelines.
+ * DateTime Format according to the ONAP Application Logging Guidelines.
*/
/**
- * @return Current date and time in the format specified by the ECOMP
+ * @return Current date and time in the format specified by the ONAP
* Application Logging Guidelines.
*/
public static String getCurrentDateTimeUTC() {
String className = "";
if (passOnArgs.length > 0 && passOnArgs[0] != null)
className = passOnArgs[0].toString();
- String methodName = "";
+ String methodName = EPCommonSystemProperties.ECOMP_PORTAL_BE;
if (passOnArgs.length > 1 && passOnArgs[1] != null)
methodName = passOnArgs[1].toString();
MDC.put(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP, getCurrentDateTimeUTC());
MDC.put(EPCommonSystemProperties.TARGET_ENTITY, EPCommonSystemProperties.ECOMP_PORTAL_BE);
MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, methodName);
- if (MDC.get(Configuration.MDC_KEY_REQUEST_ID) == null || MDC.get(Configuration.MDC_KEY_REQUEST_ID).isEmpty()){
+ if (MDC.get(Configuration.MDC_KEY_REQUEST_ID) == null||MDC.get(Configuration.MDC_KEY_REQUEST_ID).isEmpty()){
String requestId = UUID.randomUUID().toString();
MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId);
}
if (passOnArgs.length > 0 && passOnArgs[0] != null)
className = passOnArgs[0].toString();
// Method Name
- String methodName = "";
+ String methodName = EPCommonSystemProperties.ECOMP_PORTAL_BE;
if (passOnArgs.length > 1 && passOnArgs[1] != null)
methodName = passOnArgs[1].toString();
if (MDC.get(EPCommonSystemProperties.TARGET_ENTITY) == null
|| MDC.get(EPCommonSystemProperties.TARGET_ENTITY) == "")
MDC.put(EPCommonSystemProperties.TARGET_ENTITY, EPCommonSystemProperties.ECOMP_PORTAL_BE);
+
+ if (MDC.get(Configuration.MDC_KEY_REQUEST_ID) == null||MDC.get(Configuration.MDC_KEY_REQUEST_ID).isEmpty()){
+ String requestId = UUID.randomUUID().toString();
+ MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId);
+ }
+ MDC.put(EPCommonSystemProperties.PARTNER_NAME, "Unknown");
+ MDC.put(Configuration.MDC_SERVICE_NAME, EPCommonSystemProperties.ECOMP_PORTAL_BE);
+
MDC.put(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP,
MDC.get(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP));
if (securityEventType != null && args.length > 0 && args[0] != null && args[0] instanceof HttpServletRequest
&& securityEventType == SecurityEventTypeEnum.INCOMING_REST_MESSAGE
&& (MDC.get(EPCommonSystemProperties.FULL_URL) == null
- || MDC.get(EPCommonSystemProperties.FULL_URL).isEmpty())) {
+ || MDC.get(EPCommonSystemProperties.FULL_URL).isEmpty())) {
HttpServletRequest req = (HttpServletRequest) args[0];
this.setHttpRequestBasedDefaultsIntoGlobalLoggingContext(req, securityEventType, methodName);
}
MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId);
// Load user agent into MDC context, if available.
- String accessingClient = "Unknown";
- accessingClient = req.getHeader(SystemProperties.USERAGENT_NAME);
+ String accessingClient = req.getHeader(SystemProperties.USERAGENT_NAME);
+ accessingClient = (accessingClient == null || accessingClient.trim().length()==0)?"Unknown":accessingClient;
if (accessingClient != null && accessingClient.trim().length()==0 && (accessingClient.contains("Mozilla")
|| accessingClient.contains("Chrome") || accessingClient.contains("Safari"))) {
accessingClient = EPCommonSystemProperties.ECOMP_PORTAL_FE;
- }else if(accessingClient==null || accessingClient.isEmpty())
- accessingClient = "Unknown";
+ }
MDC.put(EPCommonSystemProperties.PARTNER_NAME, accessingClient);
// Load loginId into MDC context.
MDC.put(EPCommonSystemProperties.FULL_URL, EPCommonSystemProperties.UNKNOWN);
MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTP);
restURL = UserUtils.getFullURL(req);
- if (restURL != null && restURL != "") {
+ //if (restURL != null && restURL != "") {
+ if (restURL != null && restURL.trim().length()>0) {
MDC.put(EPCommonSystemProperties.FULL_URL, restURL);
if (restURL.toLowerCase().contains("https")) {
MDC.put(EPCommonSystemProperties.PROTOCOL, EPCommonSystemProperties.HTTPS);
}
// Rest Path
- MDC.put(Configuration.MDC_SERVICE_NAME, (restMethod==null || restMethod.isEmpty()) ? "Unknown" : restMethod);
+ MDC.put(Configuration.MDC_SERVICE_NAME, restMethod);
String restPath = req.getServletPath();
- if (restPath != null && !restPath.isEmpty()) {
+ //if (restPath != null && restPath != "") {
+ if (restPath != null && restPath.trim().length()>0) {
+
MDC.put(Configuration.MDC_SERVICE_NAME, restPath);
}
MDC.put(EPCommonSystemProperties.TARGET_SERVICE_NAME, "search");
}
} else {
- MDC.put(Configuration.MDC_SERVICE_NAME, (restMethod==null || restMethod.isEmpty()) ? "Unknown" : restMethod);
+ MDC.put(Configuration.MDC_SERVICE_NAME, restMethod);
MDC.put(EPCommonSystemProperties.PARTNER_NAME, EPCommonSystemProperties.ECOMP_PORTAL_FE);
}
public String getInternalResponseCode() {
return MDC.get(EPCommonSystemProperties.RESPONSE_CODE);
}
+
}