From 28a62e49e8d1940dc5474e9d71b5ed1e0c521d5d Mon Sep 17 00:00:00 2001 From: Rupinder Date: Tue, 21 Apr 2020 16:26:00 +0530 Subject: [PATCH 1/1] added proper annotation Issue-ID: PORTAL-865 Change-Id: Ic4bcd3f18c5f56a4846a203860231aafed2af060 Signed-off-by: Rupinder --- .../controller/BasicAuthAccountController.java | 12 +++++++---- .../portal/controller/CommonWidgetController.java | 3 ++- .../portal/controller/DashboardController.java | 24 +++++++++++++--------- .../DashboardSearchResultController.java | 18 +++++++++------- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java index f655d352..ab040bb0 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java @@ -60,6 +60,10 @@ 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; @@ -96,7 +100,7 @@ public class BasicAuthAccountController extends EPRestrictedBaseController { * @throws Exception * on failure */ - @RequestMapping(value = { "/portalApi/basicAuthAccount" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/basicAuthAccount" }) public PortalRestResponse createBasicAuthAccount(HttpServletRequest request, HttpServletResponse response, @RequestBody BasicAuthCredentials newBasicAuthAccount) throws Exception { @@ -153,7 +157,7 @@ public class BasicAuthAccountController extends EPRestrictedBaseController { * on failure */ - @RequestMapping(value = { "/portalApi/basicAuthAccount" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/basicAuthAccount" }) public PortalRestResponse> getBasicAuthAccount(HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -182,7 +186,7 @@ public class BasicAuthAccountController extends EPRestrictedBaseController { * @throws Exception * on failure */ - @RequestMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }, method = RequestMethod.PUT) + @PutMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }) public PortalRestResponse updateAccount(HttpServletRequest request, HttpServletResponse response, @PathVariable("accountId") long accountId, @RequestBody BasicAuthCredentials newBasicAuthAccount) throws Exception { @@ -219,7 +223,7 @@ public class BasicAuthAccountController extends EPRestrictedBaseController { * @throws Exception * on failure */ - @RequestMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/basicAuthAccount/{accountId}" }) public PortalRestResponse deleteAccount(HttpServletRequest request, HttpServletResponse response, @PathVariable("accountId") long accountId) throws Exception { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/CommonWidgetController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/CommonWidgetController.java index ee17ac0a..417a2940 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/CommonWidgetController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/CommonWidgetController.java @@ -48,6 +48,7 @@ import org.onap.portalapp.portal.transport.CommonWidgetMeta; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -83,7 +84,7 @@ public class CommonWidgetController extends EPRestrictedBaseController implement * Request parameter. * @return Rest response wrapped around a CommonWidgetMeta object. */ - @RequestMapping(value = "/commonWidgets", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/commonWidgets", produces = "application/json") public PortalRestResponse getWidgetData(HttpServletRequest request, @RequestParam String resourceType) { if (!isValidResourceType(resourceType)){ diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java index 6137aec9..17a28476 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardController.java @@ -78,6 +78,10 @@ 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.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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -132,7 +136,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 getWidgetData(HttpServletRequest request, @RequestParam String resourceType) { if (!isValidResourceType(resourceType)) { @@ -154,7 +158,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 saveWidgetDataBulk(@RequestBody CommonWidgetMeta commonWidgetMeta) { logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetDataBulk: argument is {}", commonWidgetMeta); if (!DATA_VALIDATOR.isValid(commonWidgetMeta)){ @@ -183,7 +187,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 saveWidgetData(@RequestBody CommonWidget commonWidget, HttpServletRequest request, HttpServletResponse response) { logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetData: argument is {}", commonWidget); EPUser user = EPUserUtils.getUserSession(request); @@ -249,7 +253,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 deleteWidgetData(@RequestBody CommonWidget commonWidget) { logger.debug(EELFLoggerDelegate.debugLogger, "deleteWidgetData: argument is {}", commonWidget); if (!DATA_VALIDATOR.isValid(commonWidget)){ @@ -269,7 +273,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>> searchPortal(HttpServletRequest request, @RequestParam String searchString) { if (!DATA_VALIDATOR.isValid(new SecureString(searchString))){ @@ -330,7 +334,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 getActiveUsers(HttpServletRequest request) { List activeUsers; List onlineUsers = new ArrayList<>(); @@ -358,7 +362,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> getOnlineUserUpdateRate(HttpServletRequest request) { try { String updateRate = SystemProperties.getProperty(EPCommonSystemProperties.ONLINE_USER_UPDATE_RATE); @@ -381,7 +385,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> getWindowWidthThresholdForRightMenu(HttpServletRequest request) { try { String windowWidthString = SystemProperties.getProperty(EPCommonSystemProperties.WINDOW_WIDTH_THRESHOLD_RIGHT_MENU); @@ -402,7 +406,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> getWindowWidthThresholdForLeftMenu(HttpServletRequest request) { try { String windowWidthString = SystemProperties.getProperty(EPCommonSystemProperties.WINDOW_WIDTH_THRESHOLD_LEFT_MENU); @@ -422,7 +426,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> activeUsers(HttpServletRequest request) { EPUser user = EPUserUtils.getUserSession(request); try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardSearchResultController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardSearchResultController.java index 04ee5e0b..2a1b9e80 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardSearchResultController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/DashboardSearchResultController.java @@ -68,6 +68,10 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -90,7 +94,7 @@ public class DashboardSearchResultController 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 getWidgetData(HttpServletRequest request, @RequestParam String resourceType) { if (stringIsNotSafeHtml(resourceType)) { @@ -107,7 +111,7 @@ public class DashboardSearchResultController 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 saveWidgetDataBulk(@Valid @RequestBody CommonWidgetMeta commonWidgetMeta) { logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetDataBulk: argument is {}", commonWidgetMeta); if (commonWidgetMeta.getCategory() == null || commonWidgetMeta.getCategory().trim().equals("")){ @@ -137,7 +141,7 @@ public class DashboardSearchResultController 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 saveWidgetData(@Valid @RequestBody CommonWidget commonWidget) { logger.debug(EELFLoggerDelegate.debugLogger, "saveWidgetData: argument is {}", commonWidget); if (commonWidget.getCategory() == null || commonWidget.getCategory().trim().equals("")){ @@ -186,7 +190,7 @@ public class DashboardSearchResultController 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 deleteWidgetData(@Valid @RequestBody CommonWidget commonWidget) { if (commonWidget!=null){ Validator validator = VALIDATOR_FACTORY.getValidator(); @@ -208,7 +212,7 @@ public class DashboardSearchResultController extends EPRestrictedBaseController * @return Rest response wrapped around a Map of String to List of Search * Result Item. */ - @RequestMapping(value = "/allPortal", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/allPortal", produces = "application/json") public PortalRestResponse>> searchPortal(HttpServletRequest request, @RequestParam String searchString) { @@ -246,7 +250,7 @@ public class DashboardSearchResultController 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 getActiveUsers(HttpServletRequest request) { List activeUsers = null; List onlineUsers = new ArrayList<>(); @@ -274,7 +278,7 @@ public class DashboardSearchResultController 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> activeUsers(HttpServletRequest request) { EPUser user = EPUserUtils.getUserSession(request); try { -- 2.16.6