X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fcontroller%2FAuditLogController.java;h=512fbea1bdd9bca2487152a15997e3a0db61a9f8;hb=a04d98b55a44d67918ff79bc550e760fd9e1e278;hp=cff8245a33ceffb631aa2c5bc482268b97108034;hpb=7971d223f73c936027011a0241a0c73cc68fe8b0;p=portal.git 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 cff8245a..512fbea1 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 @@ -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);