pushing error and audit log changes for portal
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / controller / PortalAdminController.java
index 563a387..4d687e4 100644 (file)
@@ -70,12 +70,9 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
@@ -154,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());
@@ -211,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());