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=e89f9921dfb029139eb0af248cc97d7c38db27a9;hb=54c5ed82662ef681375675e58abc8058e3203466;hp=cff8245a33ceffb631aa2c5bc482268b97108034;hpb=9dfdfbac35f9355c562ca567243526a864fdbb9d;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..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 @@ -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; @@ -91,7 +92,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 +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);