summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common/src/main/java/org/onap
diff options
context:
space:
mode:
authorMuni Mohan Kunchi <munmohan@att.com>2020-09-17 18:37:26 -0400
committerMuni Mohan Kunchi <munmohan@att.com>2020-09-22 13:55:37 -0400
commit54c5ed82662ef681375675e58abc8058e3203466 (patch)
tree729dfbcf0da5cf277ed780a4eea021dee2bbd83d /ecomp-portal-BE-common/src/main/java/org/onap
parentce34d843f7e16ecddc839ee9976b4652bfdde571 (diff)
pushing error and audit log changes for portal
Issue-ID: PORTAL-1011 Signed-off-by: Muni Mohan Kunchi <munmohan@att.com> Change-Id: I3f3b32b2d418330604db05c2bf16193e03f07f66
Diffstat (limited to 'ecomp-portal-BE-common/src/main/java/org/onap')
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuditLogController.java21
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java11
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java64
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java36
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java75
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java39
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java52
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/ApplicationCodes.properties2
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPAppMessagesEnum.java107
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPErrorCodesEnum.java1
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/logic/EPLogUtil.java111
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java4
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java8
13 files changed, 246 insertions, 285 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuditLogController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuditLogController.java
index dc5127c6..e89f9921 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuditLogController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AuditLogController.java
@@ -56,6 +56,7 @@ import com.att.eelf.configuration.Configuration;
import org.onap.portalapp.controller.EPRestrictedBaseController;
import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.domain.EcompAuditLog;
import org.onap.portalapp.portal.logging.aop.EPEELFLoggerAdvice;
import org.onap.portalapp.portal.logging.logic.EPLogUtil;
import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
@@ -150,21 +151,11 @@ public class AuditLogController extends EPRestrictedBaseController {
String requestId = UUID.randomUUID().toString();
MDC.put(Configuration.MDC_KEY_REQUEST_ID, requestId);
}
- // Log file
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- SimpleDateFormat ecompLogDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
- String beginDateTime = MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- Date beginDate = ecompLogDateFormat.parse(beginDateTime);
- auditService.logActivity(auditLog, null);
- String endDateTime = MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- Date endDate = ecompLogDateFormat.parse(endDateTime);
- String timeDifference = String.format("%d", endDate.getTime() - beginDate.getTime());
- MDC.put(SystemProperties.MDC_TIMER, timeDifference);
- MDC.put(EPCommonSystemProperties.STATUS_CODE, "COMPLETE");
- logger.info(EELFLoggerDelegate.auditLogger, EPLogUtil.formatAuditLogMessage(
- "AuditLogController.auditLog", cdType, user.getOrgUserId(), affectedAppId, comment));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage(
+ "AuditLogController.auditLog", cdType, user.getOrgUserId(), affectedAppId, comment);
+
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
}
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "auditLog failed", e);
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java
index ff89bb88..6c359d02 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java
@@ -302,15 +302,10 @@ public class DashboardController extends EPRestrictedBaseController {
MDC.put(EPCommonSystemProperties.PARTNER_NAME, EPCommonSystemProperties.ECOMP_PORTAL_FE);
MDC.put(com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME, EPCommonSystemProperties.ECOMP_PORTAL_BE);
auditService.logActivity(auditLog, null);
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,EPEELFLoggerAdvice.getCurrentDateTimeUTC());
-
MDC.put(EPCommonSystemProperties.STATUS_CODE, "COMPLETE");
- EcompPortalUtils.calculateDateTimeDifferenceForLog(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger, EPLogUtil.formatAuditLogMessage("DashboardController.PortalRestResponse",
- EcompAuditLog.CD_ACTIVITY_SEARCH, user.getOrgUserId(), null, searchString));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("DashboardController.PortalRestResponse",
+ EcompAuditLog.CD_ACTIVITY_SEARCH, user.getOrgUserId(), null, searchString);
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
MDC.remove(EPCommonSystemProperties.STATUS_CODE);
return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", results);
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java
index 67e71c50..f9c36af1 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java
@@ -412,17 +412,10 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl
PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditLog.setAffectedRecordId(user.getOrgUserId());
auditService.logActivity(auditLog, null);
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("ExternalAccessRolesController.saveRoleFunction", activityCode,
- String.valueOf(user.getId()), user.getOrgUserId(), availableRoleFunction.getCode()));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("ExternalAccessRolesController.saveRoleFunction", activityCode,
+ String.valueOf(user.getId()), user.getOrgUserId(), availableRoleFunction.getCode());
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
} else {
logger.error(EELFLoggerDelegate.errorLogger, "saveRoleFunction failed");
return new PortalRestResponse<>(PortalRestStatusEnum.ERROR,
@@ -465,18 +458,11 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl
PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditLog.setAffectedRecordId(user.getOrgUserId());
auditService.logActivity(auditLog, null);
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("ExternalAccessRolesController.deleteRoleFunction",
- EcompAuditLog.CD_ACTIVITY_EXTERNAL_AUTH_DELETE_FUNCTION, String.valueOf(user.getId()),
- user.getOrgUserId(), code));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("ExternalAccessRolesController.deleteRoleFunction",
+ EcompAuditLog.CD_ACTIVITY_EXTERNAL_AUTH_DELETE_FUNCTION, String.valueOf(user.getId()),
+ user.getOrgUserId(), code);
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
} else {
logger.error(EELFLoggerDelegate.errorLogger, "deleteRoleFunction failed");
return new PortalRestResponse<>(PortalRestStatusEnum.ERROR,
@@ -521,17 +507,10 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl
PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditLog.setAffectedRecordId(user.getOrgUserId());
auditService.logActivity(auditLog, null);
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("ExternalAccessRolesController.saveRole", activityCode,
- String.valueOf(user.getId()), user.getOrgUserId(), role.getName()));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("ExternalAccessRolesController.saveRole", activityCode,
+ String.valueOf(user.getId()), user.getOrgUserId(), role.getName());
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
} else {
if(saveRoleResult.getDetailMessage().contains("406")){
response.setStatus(HttpServletResponse.SC_NOT_ACCEPTABLE);
@@ -582,18 +561,11 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl
PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditLog.setAffectedRecordId(user.getOrgUserId());
auditService.logActivity(auditLog, null);
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("ExternalAccessRolesController.deleteRole",
- EcompAuditLog.CD_ACTIVITY_EXTERNAL_AUTH_DELETE_ROLE, String.valueOf(user.getId()),
- user.getOrgUserId(), code));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("ExternalAccessRolesController.deleteRole",
+ EcompAuditLog.CD_ACTIVITY_EXTERNAL_AUTH_DELETE_ROLE, String.valueOf(user.getId()),
+ user.getOrgUserId(), code);
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
} else {
logger.error(EELFLoggerDelegate.errorLogger, "deleteRole failed");
return new PortalRestResponse<>(PortalRestStatusEnum.ERROR,
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java
index 0cc3e3fa..4d687e4e 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java
@@ -151,18 +151,11 @@ public class PortalAdminController extends EPRestrictedBaseController {
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "createPortalAdmin: failed for save audit log", e);
}
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("PortalAdminController.createPortalAdmin",
- EcompAuditLog.CD_ACTIVITY_ADD_PORTAL_ADMIN, user.getOrgUserId(), userId,
- "A new Portal Admin has been added"));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("PortalAdminController.createPortalAdmin",
+ EcompAuditLog.CD_ACTIVITY_ADD_PORTAL_ADMIN, user.getOrgUserId(), userId,
+ "A new Portal Admin has been added");
+
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
}
}
EcompPortalUtils.logAndSerializeObject(logger, "/portalAdmin", "POST result =", response.getStatus());
@@ -208,19 +201,12 @@ public class PortalAdminController extends EPRestrictedBaseController {
auditLog.setActivityCode(EcompAuditLog.CD_ACTIVITY_DELETE_PORTAL_ADMIN);
auditLog.setAffectedRecordId(sbcid);
auditService.logActivity(auditLog, null);
-
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("PortalAdminController.deletePortalAdmin",
- EcompAuditLog.CD_ACTIVITY_DELETE_PORTAL_ADMIN, user.getOrgUserId(), sbcid,
- "A Portal Admin has been deleted"));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("PortalAdminController.deletePortalAdmin",
+ EcompAuditLog.CD_ACTIVITY_DELETE_PORTAL_ADMIN, user.getOrgUserId(), sbcid,
+ "A Portal Admin has been deleted");
+
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
}
}
EcompPortalUtils.logAndSerializeObject(logger, "/portalAdmin", "DELETE result =", response.getStatus());
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java
index 4b983d8d..70cca1f3 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java
@@ -258,21 +258,13 @@ public class RoleManageController extends EPRestrictedBaseController {
"Deleted role for app:" + app.getId() + " and role:'" + roleId + "'",
PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditService.logActivity(auditLog, null);
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,
- EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,
- EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("RoleManageController.removeRole",
- EcompAuditLog.CD_ACTIVITY_EXTERNAL_AUTH_DELETE_ROLE,
- String.valueOf(requestedUser.getId()), requestedUser.getOrgUserId(),
- roleId.toString()));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("RoleManageController.removeRole",
+ EcompAuditLog.CD_ACTIVITY_EXTERNAL_AUTH_DELETE_ROLE,
+ String.valueOf(requestedUser.getId()), requestedUser.getOrgUserId(),
+ roleId.toString());
+
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
} else {
restCallStatus = "Remove Role failed";
responseMap.put("error", externalRequestFieldsValidator.getDetailMessage());
@@ -379,19 +371,11 @@ public class RoleManageController extends EPRestrictedBaseController {
PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditLog.setAffectedRecordId(user.getOrgUserId());
auditService.logActivity(auditLog, null);
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,
- EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,
- EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("RoleManageController.saveRole", activityCode,
- String.valueOf(user.getId()), user.getOrgUserId(), role.getName()));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("RoleManageController.saveRole", activityCode,
+ String.valueOf(user.getId()), user.getOrgUserId(), role.getName());
+
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
responseMap.put("status", "Success");
responseMap.put("role", domainRole);
} else {
@@ -573,16 +557,10 @@ public class RoleManageController extends EPRestrictedBaseController {
"saveRoleFunction role for app:" + app.getId() + " and function:'" + code + "'",
PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditService.logActivity(auditLog, null);
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("RoleManageController.saveRoleFunction", activityCode,
- String.valueOf(requestedUser.getId()), requestedUser.getOrgUserId(), code));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("RoleManageController.saveRoleFunction", activityCode,
+ String.valueOf(requestedUser.getId()), requestedUser.getOrgUserId(), code);
+
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
}
private void addIfTypeActionDoesNotExits(CentralV2RoleFunction domainRoleFunction) {
@@ -645,21 +623,12 @@ public class RoleManageController extends EPRestrictedBaseController {
+ domainRoleFunction.getCode() + "'",
PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditService.logActivity(auditLog, null);
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,
- EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,
- EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("RoleManageController.removeRoleFunction",
- EcompAuditLog.CD_ACTIVITY_EXTERNAL_AUTH_DELETE_FUNCTION,
- String.valueOf(user.getId()), user.getOrgUserId(),
- domainRoleFunction.getCode()));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("RoleManageController.removeRoleFunction",
+ EcompAuditLog.CD_ACTIVITY_EXTERNAL_AUTH_DELETE_FUNCTION,
+ String.valueOf(user.getId()), user.getOrgUserId(),
+ domainRoleFunction.getCode());
+
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
logger.info(EELFLoggerDelegate.auditLogger,
"Remove role function " + domainRoleFunction.getName());
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java
index 906563cf..9f89051d 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java
@@ -55,6 +55,7 @@ import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
import org.onap.portalapp.portal.logging.aop.EPAuditLog;
import org.onap.portalapp.portal.logging.aop.EPEELFLoggerAdvice;
+import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum;
import org.onap.portalapp.portal.logging.logic.EPLogUtil;
import org.onap.portalapp.portal.service.AdminRolesService;
import org.onap.portalapp.portal.service.ApplicationsRestClientService;
@@ -242,21 +243,12 @@ public class UserRolesController extends EPRestrictedBaseController {
auditLog.setComments(
EcompPortalUtils.truncateString(newAppRoles.toString(), PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditService.logActivity(auditLog, null);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("UserRolesController.putAppsWithAdminRoleStateForUser",
+ EcompAuditLog.CD_ACTIVITY_UPDATE_ACCOUNT_ADMIN, user.getOrgUserId(),
+ newAppsListWithAdminRoles.orgUserId, newAppRoles.toString());
- MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- if (newAppsListWithAdminRoles != null) {
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("UserRolesController.putAppsWithAdminRoleStateForUser",
- EcompAuditLog.CD_ACTIVITY_UPDATE_ACCOUNT_ADMIN, user.getOrgUserId(),
- newAppsListWithAdminRoles.orgUserId, newAppRoles.toString()));
- }
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
}
EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/adminAppsRoles", "put result =", changesApplied);
@@ -400,20 +392,13 @@ public class UserRolesController extends EPRestrictedBaseController {
auditLog.setComments(EcompPortalUtils.truncateString(sbUserApps.toString(),
PortalConstants.AUDIT_LOG_COMMENT_SIZE));
auditService.logActivity(auditLog, null);
+ String auditMessageInfo = EPLogUtil.formatAuditLogMessage("UserRolesController.putAppWithUserRoleStateForUser",
+ EcompAuditLog.CD_ACTIVITY_UPDATE_USER, user.getOrgUserId(),
+ newAppRolesForUser.getOrgUserId(), sbUserApps.toString());
- MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP,
- EPEELFLoggerAdvice.getCurrentDateTimeUTC());
- EcompPortalUtils.calculateDateTimeDifferenceForLog(
- MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
- MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
- logger.info(EELFLoggerDelegate.auditLogger,
- EPLogUtil.formatAuditLogMessage("UserRolesController.putAppWithUserRoleStateForUser",
- EcompAuditLog.CD_ACTIVITY_UPDATE_USER, user.getOrgUserId(),
- newAppRolesForUser.getOrgUserId(), sbUserApps.toString()));
- MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
- MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
- MDC.remove(SystemProperties.MDC_TIMER);
- portalResponse = new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", null);
+ EPLogUtil.logAuditMessage(logger, auditMessageInfo);
+
+ portalResponse = new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", null);
}
if (!changesApplied.isResult())
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
index 71338a84..4c67429b 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/aop/EPEELFLoggerAdvice.java
@@ -137,6 +137,45 @@ public class EPEELFLoggerAdvice {
}
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(className);
+ logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#after: finished {}", methodName);
+ // add the metrics log
+ logger.info(EELFLoggerDelegate.metricsLogger, methodName + " operation is completed.");
+
+ // Log security message, if necessary
+ if (securityEventType != null) {
+ MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP,getCurrentDateTimeUTC());
+ MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, getCurrentDateTimeUTC());
+ this.calculateDateTimeDifference(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
+ MDC.put(EPCommonSystemProperties.STATUS_CODE, "INPROGRESS");
+ MDC.put("CustomField1", "ENTRY");
+ MDC.put("CustomField2", "InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
+ try {
+ MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName());
+ } catch (Exception e) {
+ adviceLogger.error(EELFLoggerDelegate.errorLogger,
+ " while setting the IP address ", e);
+ }
+ this.logSecurityMessage(logger, securityEventType, methodName);
+
+ // Outgoing & LDAP messages are part of Incoming requests so,
+ // keep "RequestId", "PartnerName", "ServiceName", "LoginId" &
+ // "ResponseCode" etc. in memory and remove it only when
+ // finished processing the parent incoming message.
+ if (securityEventType != SecurityEventTypeEnum.OUTGOING_REST_MESSAGE
+ && securityEventType != SecurityEventTypeEnum.LDAP_PHONEBOOK_USER_SEARCH) {
+ MDC.remove(Configuration.MDC_KEY_REQUEST_ID);
+ MDC.remove(EPCommonSystemProperties.PARTNER_NAME);
+ MDC.remove(Configuration.MDC_SERVICE_NAME);
+ MDC.remove(EPCommonSystemProperties.MDC_LOGIN_ID);
+ MDC.remove(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE);
+ }else{
+ MDC.remove(Configuration.MDC_KEY_REQUEST_ID);
+ MDC.remove(EPCommonSystemProperties.PARTNER_NAME);
+ MDC.remove(Configuration.MDC_SERVICE_NAME);
+ }
+
+ MDC.remove(Configuration.MDC_SERVER_FQDN);
+ }
logger.debug(EELFLoggerDelegate.debugLogger, "EPEELFLoggerAdvice#before: entering {}", methodName);
return new Object[] { "" };
}
@@ -220,7 +259,14 @@ public class EPEELFLoggerAdvice {
MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, getCurrentDateTimeUTC());
this.calculateDateTimeDifference(MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
-
+ MDC.put("CustomField1", "EXIT");
+ MDC.put("CustomField2", "InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
+ try {
+ MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName());
+ } catch (Exception e) {
+ adviceLogger.error(EELFLoggerDelegate.errorLogger,
+ " while setting the IP address ", e);
+ }
this.logSecurityMessage(logger, securityEventType, methodName);
// Outgoing & LDAP messages are part of Incoming requests so,
@@ -241,6 +287,7 @@ public class EPEELFLoggerAdvice {
}
// clear when finishes audit logging
+ MDC.remove(Configuration.MDC_SERVER_FQDN);
MDC.remove(EPCommonSystemProperties.FULL_URL);
MDC.remove(EPCommonSystemProperties.PROTOCOL);
MDC.remove(EPCommonSystemProperties.STATUS_CODE);
@@ -248,7 +295,10 @@ public class EPEELFLoggerAdvice {
MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
MDC.remove(EPCommonSystemProperties.RESPONSE_CODE);
+
}
+ MDC.remove("CustomField1");
+ MDC.remove("CustomField2");
MDC.remove(className + methodName + EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP);
MDC.remove(EPCommonSystemProperties.METRICSLOG_BEGIN_TIMESTAMP);
MDC.remove(EPCommonSystemProperties.METRICSLOG_END_TIMESTAMP);
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/ApplicationCodes.properties b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/ApplicationCodes.properties
index cd686ce2..cd09f2de 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/ApplicationCodes.properties
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/ApplicationCodes.properties
@@ -139,3 +139,5 @@ INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT= |||Description: {0}.
INTERNALUNEXPECTEDERROR_ONE_ARGUMENT= |||Description: {0}.
INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT= |||Description: {0}.
+
+PORTAL_COMMON_ERROR= |||Description: {0}.
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPAppMessagesEnum.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPAppMessagesEnum.java
index 8062926f..222ec0f2 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPAppMessagesEnum.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPAppMessagesEnum.java
@@ -77,159 +77,162 @@ public enum EPAppMessagesEnum {
900-999 Unknown Errors
- Unexpected exception
*/
-
+
+ PortalCommonError(EPErrorCodesEnum.PORTAL_COMMON_ERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.ERROR,
+ "900", "exception", "Details: {0}.", "Please check the logs for more information."),
+
BeUebAuthenticationError(EPErrorCodesEnum.BEUEBAUTHENTICATIONERROR_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR100E", "An Authentication failure occurred during access to UEB server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."),
+ "100", "An Authentication failure occurred during access to UEB server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."),
BeRestApiAuthenticationError(EPErrorCodesEnum.BERESTAPIAUTHENTICATIONERROR, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR101E", "Rejected an incoming REST API request due to invalid credentials", "", "Please check application credentials defined in Database or properties files."),
+ "101", "Rejected an incoming REST API request due to invalid credentials", "", "Please check application credentials defined in Database or properties files."),
InternalAuthenticationInfo(EPErrorCodesEnum.INTERNALAUTHENTICATIONINFO_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO,
- "ERR199I", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."),
+ "199", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."),
InternalAuthenticationWarning(EPErrorCodesEnum.INTERNALAUTHENTICATIONWARNING_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN,
- "ERR199W", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."),
+ "199", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."),
InternalAuthenticationError(EPErrorCodesEnum.INTERNALAUTHENTICATIONERROR_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR199E", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."),
+ "199", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."),
InternalAuthenticationFatal(EPErrorCodesEnum.INTERNALAUTHENTICATIONFATAL_ONE_ARGUMENT, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL,
- "ERR199F", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."),
+ "199", "Internal authentication problem", "Details: {0}.", "Please check the logs for more information."),
BeHealthCheckError(EPErrorCodesEnum.BeHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR,
- "ERR200E", "ECOMP-PORTAL Back-end probably lost connectivity to either one of the following components: MySQL DB, UEB Cluster", "", "Please check the logs for more information."),
+ "200", "ECOMP-PORTAL Back-end probably lost connectivity to either one of the following components: MySQL DB, UEB Cluster", "", "Please check the logs for more information."),
BeHealthCheckMySqlError(EPErrorCodesEnum.BEHEALTHCHECKMYSQLERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR,
- "ERR201E", "ECOMP-PORTAL Back-end probably lost connectivity to MySQL DB", "", "Check connectivity to MYSQL is configured correctly under system.properties file."),
+ "201", "ECOMP-PORTAL Back-end probably lost connectivity to MySQL DB", "", "Check connectivity to MYSQL is configured correctly under system.properties file."),
BeHealthCheckUebClusterError(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR,
- "ERR203E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "", "Check connectivity to UEB cluster which is configured under portal.properties file."),
+ "203", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "", "Check connectivity to UEB cluster which is configured under portal.properties file."),
FeHealthCheckError(EPErrorCodesEnum.FEHEALTHCHECKERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR,
- "ERR204E", "Unable to connect to a valid ECOMP-PORTAL Back-end Server.", "", "Please check connectivity from this FE instance towards BE or BE Load Balancer."),
+ "204", "Unable to connect to a valid ECOMP-PORTAL Back-end Server.", "", "Please check connectivity from this FE instance towards BE or BE Load Balancer."),
BeHealthCheckRecovery(EPErrorCodesEnum.BEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO,
- "ERR205I", "ECOMP-PORTAL Back-end Recovery to either one of the following components: MySQL DB, UEB Cluster", "", "Please check logs for more specific information about the problem."),
+ "205", "ECOMP-PORTAL Back-end Recovery to either one of the following components: MySQL DB, UEB Cluster", "", "Please check logs for more specific information about the problem."),
BeHealthCheckMySqlRecovery(EPErrorCodesEnum.BEHEALTHCHECKMYSQLRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO,
- "ERR206I", "ECOMP-PORTAL Back-end connection recovery to MySQL DB", "", "Please check logs for more specific information about the problem."),
+ "206", "ECOMP-PORTAL Back-end connection recovery to MySQL DB", "", "Please check logs for more specific information about the problem."),
BeHealthCheckUebClusterRecovery(EPErrorCodesEnum.BEHEALTHCHECKUEBCLUSTERRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO,
- "ERR208I", "ECOMP-PORTAL Back-end connection recovery to UEB Cluster", "", "Please check logs for more specific information about the problem."),
+ "208", "ECOMP-PORTAL Back-end connection recovery to UEB Cluster", "", "Please check logs for more specific information about the problem."),
FeHealthCheckRecovery(EPErrorCodesEnum.FEHEALTHCHECKRECOVERY, ErrorTypeEnum.RECOVERY, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO,
- "ERR209I", "Connectivity to ECOMP-PORTAL Front-end Server is recovered", "", "Please check logs for more specific information about the problem."),
+ "209", "Connectivity to ECOMP-PORTAL Front-end Server is recovered", "", "Please check logs for more specific information about the problem."),
BeUebConnectionError(EPErrorCodesEnum.BEUEBCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR210E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."),
+ "210", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."),
BeUebUnkownHostError(EPErrorCodesEnum.BEUEBUNKOWNHOSTERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR211E", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Cannot reach host: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."),
+ "211", "ECOMP-PORTAL Back-end probably lost connectivity to UEB Cluster", "Cannot reach host: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."),
BeUebRegisterOnboardingAppError(EPErrorCodesEnum.BEUEBREGISTERONBOARDINGAPPERROR, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR212E", "Failed to register the On-boarding application with UEB Communication server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."),
+ "212", "Failed to register the On-boarding application with UEB Communication server", "Details: {0}.", "Please check UEB server list and keys configured under Portal.Properties file."),
BeHttpConnectionError(EPErrorCodesEnum.BEHTTPCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR213E", "It could be that communication to an external application might resulted an exception or failed to reach the external application",
+ "213", "It could be that communication to an external application might resulted an exception or failed to reach the external application",
"Details: {0}.", "Please check logs for more information."),
MusicHealthCheckZookeeperError(EPErrorCodesEnum.MUSICHEALTHCHECKZOOKEEPERERROR_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR214E", "Connectivity to Music Cluster -zookeeper server", "Details: {0}.", "Please check zookeeper server list and check the logs for more information"),
+ "214", "Connectivity to Music Cluster -zookeeper server", "Details: {0}.", "Please check zookeeper server list and check the logs for more information"),
MusicHealthCheckCassandraError(EPErrorCodesEnum.MUSICHEALTHCHECKCASSANDRAERROR_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR215E", "Connectivity to Music Cluster -Cassandra server", "Details: {0}.", "Please check Cassandra server list and check the logs for more information"),
+ "215", "Connectivity to Music Cluster -Cassandra server", "Details: {0}.", "Please check Cassandra server list and check the logs for more information"),
InternalConnectionInfo(EPErrorCodesEnum.INTERNALCONNECTIONINFO_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO,
- "ERR299I", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."),
+ "299", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."),
InternalConnectionWarning(EPErrorCodesEnum.INTERNALCONNECTIONWARNING_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN,
- "ERR299W", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."),
+ "299", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."),
InternalConnectionError(EPErrorCodesEnum.INTERNALCONNECTIONERROR_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR299E", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."),
+ "299", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."),
InternalConnectionFatal(EPErrorCodesEnum.INTERNALCONNECTIONFATAL_ONE_ARGUMENT, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL,
- "ERR299F", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."),
+ "299", "Internal Connection problem", "Details: {0}.", "Please check logs for more information."),
BeUebObjectNotFoundError(EPErrorCodesEnum.BEUEBOBJECTNOTFOUNDERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR303E", "Error occurred during access to U-EB Server.", "Data not found: {0}.", "An error occurred during access to UEB Server, {1} failed to either register or unregister to/from UEB topic."),
+ "303", "Error occurred during access to U-EB Server.", "Data not found: {0}.", "An error occurred during access to UEB Server, {1} failed to either register or unregister to/from UEB topic."),
BeUserMissingError(EPErrorCodesEnum.BEUSERMISSINGERROR_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR310E", "User is not found", "", "User {0} must be added to the corresponding application with proper user roles."),
+ "310", "User is not found", "", "User {0} must be added to the corresponding application with proper user roles."),
BeUserInactiveWarning(EPErrorCodesEnum.BEUSERINACTIVEWARNING_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN,
- "ERR313W", "User is found but in-active", "", "User {0} must be added to the corresponding application with proper user roles."),
+ "313", "User is found but in-active", "", "User {0} must be added to the corresponding application with proper user roles."),
BeUserAdminPrivilegesInfo(EPErrorCodesEnum.BEUSERADMINPRIVILEGESINFO_ONE_ARGUMENT, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN,
- "ERR314W", "User is found but don't have administrative privileges", "", "User {0} should be given administrator role for the corresponding application to perform the necessary actions."),
+ "314", "User is found but don't have administrative privileges", "", "User {0} should be given administrator role for the corresponding application to perform the necessary actions."),
BeInvalidJsonInput(EPErrorCodesEnum.BEINVALIDJSONINPUT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR405E", "Failed to convert JSON input to object", "", "Please check logs for more information."),
+ "405", "Failed to convert JSON input to object", "", "Please check logs for more information."),
BeIncorrectHttpStatusError(EPErrorCodesEnum.BEINCORRECTHTTPSTATUSERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR407E", "Communication to an external application is resulted in with Incorrect Http response code", "", "Please check logs for more information."),
+ "407", "Communication to an external application is resulted in with Incorrect Http response code", "", "Please check logs for more information."),
BeInitializationError(EPErrorCodesEnum.BEINITIALIZATIONERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR,
- "ERR500E", "ECOMP-PORTAL Back-end was not initialized properly", "", "Please check logs for more information."),
+ "500", "ECOMP-PORTAL Back-end was not initialized properly", "", "Please check logs for more information."),
BeUebSystemError(EPErrorCodesEnum.BEUEBSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR502E", "Error occurred during access to U-EB Server", "Details: {0}.", "An error occurred in {1} distribution mechanism. Please check the logs for more information."),
+ "502", "Error occurred during access to U-EB Server", "Details: {0}.", "An error occurred in {1} distribution mechanism. Please check the logs for more information."),
BeDaoSystemError(EPErrorCodesEnum.BEDAOSYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR,
- "ERR505E", "Performing DDL or DML operations on database might have failed", "", "Please check MySQL DB health or look at the logs for more details."),
+ "505", "Performing DDL or DML operations on database might have failed", "", "Please check MySQL DB health or look at the logs for more details."),
BeSystemError(EPErrorCodesEnum.BESYSTEMERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR,
- "ERR506E", "Unexpected error during operation", "", "Please check logs for more information."),
+ "506", "Unexpected error during operation", "", "Please check logs for more information."),
BeExecuteRollbackError(EPErrorCodesEnum.BEEXECUTEROLLBACKERROR, ErrorTypeEnum.DATA_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR507E", "Roll-back operation towards database has failed", "", "Please check MYSQL DB health or look at the logs for more details."),
+ "507", "Roll-back operation towards database has failed", "", "Please check MYSQL DB health or look at the logs for more details."),
FeHttpLoggingError(EPErrorCodesEnum.FEHTTPLOGGINGERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.ERROR,
- "ERR517E", "Error when logging FE HTTP request/response", "", "Please check MYSQL DB health or look at the logs for more details."),
+ "517", "Error when logging FE HTTP request/response", "", "Please check MYSQL DB health or look at the logs for more details."),
FePortalServletError(EPErrorCodesEnum.FEPORTALSERVLETERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR518E", "Error when trying to access FE Portal page.", "", "Please check logs for more information."),
+ "518", "Error when trying to access FE Portal page.", "", "Please check logs for more information."),
BeDaoCloseSessionError(EPErrorCodesEnum.BEDAOCLOSESESSIONERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR519E", "Close local session operation with database failed", "", "Please check MYSQL DB health or look at the logs form more details."),
+ "519", "Close local session operation with database failed", "", "Please check MYSQL DB health or look at the logs form more details."),
BeRestApiGeneralError(EPErrorCodesEnum.BERESTAPIGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR,
- "ERR900E", "Unexpected error during ECOMP-PORTAL Back-end REST API execution", "", "Please check error log for more information."),
+ "900", "Unexpected error during ECOMP-PORTAL Back-end REST API execution", "", "Please check error log for more information."),
FeHealthCheckGeneralError(EPErrorCodesEnum.FEHEALTHCHECKGENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.ERROR,
- "ERR901E", "General error during FE Health Check", "", "Please check error log for more information."),
+ "901", "General error during FE Health Check", "", "Please check error log for more information."),
InternalUnexpectedInfo(EPErrorCodesEnum.INTERNALUNEXPECTEDINFO_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.INFORMATIONAL, ErrorSeverityEnum.INFO,
- "ERR999I", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
+ "999", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
InternalUnexpectedWarning(EPErrorCodesEnum.INTERNALUNEXPECTEDWARNING_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MINOR, ErrorSeverityEnum.WARN,
- "ERR999W", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
+ "999", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
InternalUnexpectedError(EPErrorCodesEnum.INTERNALUNEXPECTEDERROR_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR999E", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
+ "999", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
InternalUnexpectedFatal(EPErrorCodesEnum.INTERNALUNEXPECTEDFATAL_ONE_ARGUMENT, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.CRITICAL, ErrorSeverityEnum.FATAL,
- "ERR999F", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
+ "999", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
ExternalAuthAccessConnectionError(EPErrorCodesEnum.EXTERNALAUTHACCESS_CONNECTIONERROR, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR220E", "AAF Connection problem", "Details: {0}.", "Please check logs for more information."),
+ "220", "AAF Connection problem", "Details: {0}.", "Please check logs for more information."),
ExternalAuthAccessAuthenticationError(EPErrorCodesEnum.EXTERNALAUTHACCESS_AUTHENTICATIONERROR, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR120E", "AAF authentication problem", "Details: {0}.", "Please check logs for more information."),
+ "120", "AAF authentication problem", "Details: {0}.", "Please check logs for more information."),
ExternalAuthAccessGeneralError(EPErrorCodesEnum.EXTERNALAUTHACCESS_GENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR520E", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
+ "520", "Unexpected error", "Details: {0}.", "Please check logs for more information."),
SchedulerAccessConnectionError(EPErrorCodesEnum.SCHEDULER_ACCESS_CONNECTIONERROR, ErrorTypeEnum.CONNECTION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR240E", "Scheduler Connection problem", "Details: {0}.", "Please check logs for more information."),
+ "240", "Scheduler Connection problem", "Details: {0}.", "Please check logs for more information."),
SchedulerAuxAccessAuthenticationError(EPErrorCodesEnum.SCHEDULERAUX_ACCESS_AUTHENTICATIONERROR, ErrorTypeEnum.AUTHENTICATION_PROBLEM, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR140E", "SchedulerAux authentication problem", "Details: {0}.", "Please check logs for more information."),
+ "140", "SchedulerAux authentication problem", "Details: {0}.", "Please check logs for more information."),
SchedulerAccessGeneralError(EPErrorCodesEnum.SCHEDULER_ACCESS_GENERALERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR540E", "Unexpected Scheduler error", "Details: {0}.", "Please check logs for more information."),
+ "540", "Unexpected Scheduler error", "Details: {0}.", "Please check logs for more information."),
SchedulerInvalidAttributeError(EPErrorCodesEnum.SCHEDULER_INVALID_ATTRIBUTEERROR, ErrorTypeEnum.SYSTEM_ERROR, AlarmSeverityEnum.MAJOR, ErrorSeverityEnum.ERROR,
- "ERR515E", "Unable to create Scheduler", "Details: {0}.", "Please check logs for more information."),
+ "515", "Unable to create Scheduler", "Details: {0}.", "Please check logs for more information."),
;
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPErrorCodesEnum.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPErrorCodesEnum.java
index a93f7722..c24a7980 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPErrorCodesEnum.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/format/EPErrorCodesEnum.java
@@ -111,6 +111,7 @@ public enum EPErrorCodesEnum implements EELFResolvableErrorEnum {
SCHEDULER_INVALID_ATTRIBUTEERROR,
MUSICHEALTHCHECKZOOKEEPERERROR_ONE_ARGUMENT,
MUSICHEALTHCHECKCASSANDRAERROR_ONE_ARGUMENT,
+ PORTAL_COMMON_ERROR,
;
/**
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/logic/EPLogUtil.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/logic/EPLogUtil.java
index 364f2959..57b93a20 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/logic/EPLogUtil.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/logging/logic/EPLogUtil.java
@@ -38,18 +38,28 @@
package org.onap.portalapp.portal.logging.logic;
import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY;
+import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
+import java.net.InetAddress;
import java.text.MessageFormat;
+import org.onap.portalapp.portal.domain.EcompAuditLog;
+import org.onap.portalapp.portal.logging.aop.EPEELFLoggerAdvice;
import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum;
+import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
+import org.onap.portalapp.portal.utils.EcompPortalUtils;
import org.onap.portalsdk.core.logging.format.AlarmSeverityEnum;
import org.onap.portalsdk.core.logging.format.ErrorSeverityEnum;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
import org.slf4j.MDC;
import org.springframework.http.HttpStatus;
+import com.att.eelf.configuration.Configuration;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.configuration.EELFLogger.Level;
+
public class EPLogUtil {
@@ -73,44 +83,7 @@ public class EPLogUtil {
logEcompError(classLogger, epMessageEnum, null, param);
}
- /**
- * Formats and writes a message to the error log with the class name and the
- * specified parameters, using log level info, warn or error appropriate for
- * the specified severity
- *
- * @param epMessageEnum
- * Enum carrying alarm and error severity
- * @param param
- * Values used to build the message.
- */
- public static void logEcompError(EPAppMessagesEnum epMessageEnum, String... param) {
- try {
- AlarmSeverityEnum alarmSeverityEnum = epMessageEnum.getAlarmSeverity();
- ErrorSeverityEnum errorSeverityEnum = epMessageEnum.getErrorSeverity();
-
- MDC.put(MDC_ALERT_SEVERITY, alarmSeverityEnum.severity());
- MDC.put("ErrorCode", epMessageEnum.getErrorCode());
- MDC.put("ErrorDescription", epMessageEnum.getErrorDescription());
- MDC.put("ClassName", EPLogUtil.class.getName());
- String resolution = EPLogUtil
- .formatMessage(epMessageEnum.getDetails() + " " + epMessageEnum.getResolution(), (Object[]) param);
- if (errorSeverityEnum == ErrorSeverityEnum.WARN) {
- errorLogger.warn(resolution);
- } else if (errorSeverityEnum == ErrorSeverityEnum.INFO) {
- errorLogger.info(resolution);
- } else {
- errorLogger.error(resolution);
- }
- } catch (Exception e) {
- errorLogger.error("logEcompError failed", e);
- } finally {
- MDC.remove("ErrorCode");
- MDC.remove("ErrorDescription");
- MDC.remove("ClassName");
- MDC.remove(MDC_ALERT_SEVERITY);
- }
- }
/**
* Formats and writes a message to the error log with the class name,
@@ -130,35 +103,43 @@ public class EPLogUtil {
@SuppressWarnings("static-access")
public static void logEcompError(EELFLoggerDelegate classLogger, EPAppMessagesEnum epMessageEnum, Throwable th,
String... param) {
-
+ //INFO, WARN, ERROR, FATAL
AlarmSeverityEnum alarmSeverityEnum = epMessageEnum.getAlarmSeverity();
ErrorSeverityEnum errorSeverityEnum = epMessageEnum.getErrorSeverity();
- MDC.put(MDC_ALERT_SEVERITY, alarmSeverityEnum.severity());
+ MDC.put("ErrorCategory", errorSeverityEnum.name());
MDC.put("ErrorCode", epMessageEnum.getErrorCode());
MDC.put("ErrorDescription", epMessageEnum.getErrorDescription());
+ MDC.put(MDC_SERVICE_NAME, EPCommonSystemProperties.ECOMP_PORTAL_BE);
final String message = EPLogUtil.formatMessage(epMessageEnum.getDetails() + " " + epMessageEnum.getResolution(),
(Object[]) param);
if (errorSeverityEnum == ErrorSeverityEnum.INFO) {
- if (th == null)
- classLogger.info(classLogger.errorLogger, message);
- else
- classLogger.info(classLogger.errorLogger, message, th);
+ if (th == null) {
+ classLogger.logWrite(classLogger.errorLogger, Level.INFO, message, null, null);
+ }
+ else {
+ classLogger.logWrite(classLogger.errorLogger, Level.INFO, message, null, th.getMessage());
+ }
} else if (errorSeverityEnum == ErrorSeverityEnum.WARN) {
- if (th == null)
- classLogger.warn(classLogger.errorLogger, message);
- else
- classLogger.warn(classLogger.errorLogger, message, th);
+ if (th == null) {
+ classLogger.logWrite(classLogger.errorLogger, Level.WARN, message, null, null);
+ }
+ else {
+ classLogger.logWrite(classLogger.errorLogger, Level.WARN, message, null, th.getMessage());
+ }
} else {
- if (th == null)
- classLogger.error(classLogger.errorLogger, message);
- else
- classLogger.error(classLogger.errorLogger, message, th);
+ if (th == null) {
+ classLogger.logWrite(classLogger.errorLogger, Level.ERROR, message, null, null);
+ }
+ else {
+ classLogger.logWrite(classLogger.errorLogger, Level.ERROR, message, null, th.getMessage());
+ }
}
// Clean up
- MDC.remove(MDC_ALERT_SEVERITY);
+ MDC.remove(MDC_SERVICE_NAME);
+ MDC.remove("ErrorCategory");
MDC.remove("ErrorCode");
MDC.remove("ErrorDescription");
}
@@ -181,6 +162,32 @@ public class EPLogUtil {
return sbFormattedMessage.toString();
}
+ public static void logAuditMessage(EELFLoggerDelegate classLogger, String message) {
+ MDC.put(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
+ MDC.put(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP, EPEELFLoggerAdvice.getCurrentDateTimeUTC());
+ EcompPortalUtils.calculateDateTimeDifferenceForLog(
+ MDC.get(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP),
+ MDC.get(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP));
+ MDC.put("CustomField1", "EXIT");
+ MDC.put("CustomField2", "InvocationID="+MDC.get(Configuration.MDC_KEY_REQUEST_ID));
+ try {
+ MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getCanonicalHostName());
+ } catch (Exception e) {
+ classLogger.logWrite(classLogger.errorLogger, Level.WARN, message, null, " exception while setting IP adress.");
+ }
+ MDC.put(EPCommonSystemProperties.STATUS_CODE, "COMPLETE");
+
+ classLogger.logWrite(classLogger.auditLogger, Level.INFO, message, null, null);
+ MDC.remove(Configuration.MDC_SERVER_FQDN);
+ MDC.remove(EPCommonSystemProperties.AUDITLOG_BEGIN_TIMESTAMP);
+ MDC.remove(EPCommonSystemProperties.AUDITLOG_END_TIMESTAMP);
+ MDC.remove(EPCommonSystemProperties.STATUS_CODE);
+ MDC.remove(SystemProperties.MDC_TIMER);
+ MDC.remove("CustomField1");
+ MDC.remove("CustomField2");
+ }
+
+
/**
* Builds a comma-separated string of values to document a user action.
*
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java
index 969ccc5f..6df7944a 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AdminRolesServiceImpl.java
@@ -149,7 +149,7 @@ public class AdminRolesServiceImpl implements AdminRolesService {
" where userId = " + user.getId() + " and role.id = " + ACCOUNT_ADMIN_ROLE_ID, null, null);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getAppsWithAdminRoleStateForUser 1 failed", e);
- EPLogUtil.logEcompError(EPAppMessagesEnum.BeDaoSystemError);
+ EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError);
}
for (EPUserApp userApp : userAppList) {
appsUserAdmin.put(userApp.getAppId(), userApp.getUserId());
@@ -166,7 +166,7 @@ public class AdminRolesServiceImpl implements AdminRolesService {
appsList = dataAccessService.getList(EPApp.class, null);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "getAppsWithAdminRoleStateForUser 2 failed", e);
- EPLogUtil.logEcompError(EPAppMessagesEnum.BeDaoSystemError);
+ EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError);
}
for (EPApp app : appsList) {
AppNameIdIsAdmin appNameIdIsAdmin = new AppNameIdIsAdmin();
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
index ab504fba..73003659 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java
@@ -198,7 +198,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
decreptedAppPwd = CipherUtil.decryptPKC(encriptedPwd,
KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY));
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, "createClientFor failed to decrypt", e);
+ logger.error(EELFLoggerDelegate.errorLogger, "createClientFor failed to decrypt", e.getMessage());
}
}
WebClient client = createClientForPath(appBaseUri, restPath);
@@ -339,7 +339,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE,
Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiGeneralError, e);
- logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the GET REST API call", e);
+ logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the GET REST API call", e.getMessage());
}
return response;
}
@@ -366,7 +366,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE,
Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiGeneralError, e);
- logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the POST REST API call", e);
+ logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the POST REST API call", e.getMessage());
}
if (response != null) {
@@ -419,7 +419,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient
MDC.put(EPCommonSystemProperties.EXTERNAL_API_RESPONSE_CODE,
Integer.toString(HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeRestApiGeneralError, e);
- logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the PUT REST API call", e);
+ logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while making the PUT REST API call", e.getMessage());
}
if (response != null) {