pushing error and audit log changes for portal
[portal.git] / ecomp-portal-BE-common / src / main / java / org / onap / portalapp / portal / controller / DashboardController.java
index 6137aec..6c359d0 100644 (file)
@@ -78,7 +78,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.web.bind.annotation.RequestBody;
 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.PostMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -132,7 +133,7 @@ public class DashboardController extends EPRestrictedBaseController {
         *            Request parameter.
         * @return Rest response wrapped around a CommonWidgetMeta object.
         */
-       @RequestMapping(value = "/widgetData", method = RequestMethod.GET, produces = "application/json")
+       @GetMapping(value = "/widgetData", produces = "application/json")
        public PortalRestResponse<CommonWidgetMeta> getWidgetData(HttpServletRequest request,
                        @RequestParam String resourceType) {
                if (!isValidResourceType(resourceType)) {
@@ -154,7 +155,7 @@ public class DashboardController extends EPRestrictedBaseController {
         *            read from POST body.
         * @return Rest response wrapped around a String; e.g., "success" or "ERROR"
         */
-       @RequestMapping(value = "/widgetDataBulk", method = RequestMethod.POST, produces = "application/json")
+       @PostMapping(value = "/widgetDataBulk", produces = "application/json")
        public PortalRestResponse<String> saveWidgetDataBulk(@RequestBody CommonWidgetMeta commonWidgetMeta) {
                logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetDataBulk: argument is {}", commonWidgetMeta);
                if (!DATA_VALIDATOR.isValid(commonWidgetMeta)){
@@ -183,7 +184,7 @@ public class DashboardController extends EPRestrictedBaseController {
         *            read from POST body
         * @return Rest response wrapped around a String; e.g., "success" or "ERROR"
         */
-       @RequestMapping(value = "/widgetData", method = RequestMethod.POST, produces = "application/json")
+       @PostMapping(value = "/widgetData", produces = "application/json")
        public PortalRestResponse<String> saveWidgetData(@RequestBody CommonWidget commonWidget, HttpServletRequest request, HttpServletResponse response) {
                logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetData: argument is {}", commonWidget);
                EPUser user = EPUserUtils.getUserSession(request);
@@ -249,7 +250,7 @@ public class DashboardController extends EPRestrictedBaseController {
         *            read from POST body
         * @return Rest response wrapped around a String; e.g., "success" or "ERROR"
         */
-       @RequestMapping(value = "/deleteData", method = RequestMethod.POST, produces = "application/json")
+       @PostMapping(value = "/deleteData", produces = "application/json")
        public PortalRestResponse<String> deleteWidgetData(@RequestBody CommonWidget commonWidget) {
                logger.debug(EELFLoggerDelegate.debugLogger, "deleteWidgetData: argument is {}", commonWidget);
                if (!DATA_VALIDATOR.isValid(commonWidget)){
@@ -269,7 +270,7 @@ public class DashboardController extends EPRestrictedBaseController {
         *         Result Item.
         */
        @EPAuditLog
-       @RequestMapping(value = "/search", method = RequestMethod.GET, produces = "application/json")
+       @GetMapping(value = "/search", produces = "application/json")
        public PortalRestResponse<Map<String, List<SearchResultItem>>> searchPortal(HttpServletRequest request,
                        @RequestParam String searchString) {
                if (!DATA_VALIDATOR.isValid(new SecureString(searchString))){
@@ -301,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);
                        }
@@ -330,7 +326,7 @@ public class DashboardController extends EPRestrictedBaseController {
         * @param request
         * @return Rest response wrapped around a list of String
         */
-       @RequestMapping(value = "/activeUsers", method = RequestMethod.GET, produces = "application/json")
+       @GetMapping(value = "/activeUsers", produces = "application/json")
        public List<String> getActiveUsers(HttpServletRequest request) {
                List<String> activeUsers;
                List<String> onlineUsers = new ArrayList<>();
@@ -358,7 +354,7 @@ public class DashboardController extends EPRestrictedBaseController {
         * @param request
         * @return Rest response wrapped around a number that is the number of milliseconds.
         */
-       @RequestMapping(value = "/onlineUserUpdateRate", method = RequestMethod.GET, produces = "application/json")
+       @GetMapping(value = "/onlineUserUpdateRate", produces = "application/json")
        public PortalRestResponse<Map<String, String>> getOnlineUserUpdateRate(HttpServletRequest request) {
                try {
                        String updateRate = SystemProperties.getProperty(EPCommonSystemProperties.ONLINE_USER_UPDATE_RATE);     
@@ -381,7 +377,7 @@ public class DashboardController extends EPRestrictedBaseController {
         * @param request
         * @return Rest response wrapped around a number that is the window width threshold to collapse right menu.
         */
-       @RequestMapping(value = "/windowWidthThresholdRightMenu", method = RequestMethod.GET, produces = "application/json")
+       @GetMapping(value = "/windowWidthThresholdRightMenu", produces = "application/json")
        public PortalRestResponse<Map<String, String>> getWindowWidthThresholdForRightMenu(HttpServletRequest request) {
                try {
                        String windowWidthString = SystemProperties.getProperty(EPCommonSystemProperties.WINDOW_WIDTH_THRESHOLD_RIGHT_MENU);    
@@ -402,7 +398,7 @@ public class DashboardController extends EPRestrictedBaseController {
         * @param request
         * @return Rest response wrapped around a number that is the window width threshold to collapse the left menu.
         */
-       @RequestMapping(value = "/windowWidthThresholdLeftMenu", method = RequestMethod.GET, produces = "application/json")
+       @GetMapping(value = "/windowWidthThresholdLeftMenu", produces = "application/json")
        public PortalRestResponse<Map<String, String>> getWindowWidthThresholdForLeftMenu(HttpServletRequest request) {
                try {
                        String windowWidthString = SystemProperties.getProperty(EPCommonSystemProperties.WINDOW_WIDTH_THRESHOLD_LEFT_MENU);     
@@ -422,7 +418,7 @@ public class DashboardController extends EPRestrictedBaseController {
         * @param request
         * @return Rest response wrapped around a List of String
         */
-       @RequestMapping(value = "/relatedUsers", method = RequestMethod.GET, produces = "application/json")
+       @GetMapping(value = "/relatedUsers", produces = "application/json")
        public PortalRestResponse<List<String>> activeUsers(HttpServletRequest request) {
                EPUser user = EPUserUtils.getUserSession(request);
                try {