Pushing fix for tracking app and tab click activities.
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / controller / AuditLogController.java
index cff8245..512fbea 100644 (file)
@@ -48,7 +48,7 @@ import org.onap.portalapp.validation.SecureString;
 import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -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;
@@ -70,8 +71,9 @@ import org.onap.portalsdk.core.util.SystemProperties;
 @RestController
 @RequestMapping("/portalApi/auditLog")
 public class AuditLogController extends EPRestrictedBaseController {
-       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DashboardController.class);
+       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AuditLogController.class);
        private static final DataValidator dataValidator = new DataValidator();
+       
 
        private AuditService auditService;
        @Autowired
@@ -91,7 +93,7 @@ public class AuditLogController extends EPRestrictedBaseController {
         * @param comment
         *            Comment
         */
-       @RequestMapping(value = "/store", method = RequestMethod.GET, produces = "application/json")
+       @GetMapping(value = "/store", produces = "application/json")
        public void auditLog(HttpServletRequest request, @RequestParam String affectedAppId, @RequestParam String type,
                        @RequestParam String comment) {
                logger.debug(EELFLoggerDelegate.debugLogger, "auditLog: appId {}, type {}, comment {}", affectedAppId, type,
@@ -150,21 +152,12 @@ 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);