From b8ed1af9e5880f30951f02512dfe658b0b8b1dd1 Mon Sep 17 00:00:00 2001 From: Rupinder Date: Thu, 4 Jun 2020 11:27:54 +0530 Subject: [PATCH] fixed some sonar code smells Issue-ID: PORTAL-865 Change-Id: Ic7cbaa4fadb34147184d2ba599a22ebe4d7ac9ac Signed-off-by: Rupinder --- .../portal/controller/TicketEventController.java | 3 +- .../portal/controller/UserController.java | 8 ++-- .../controller/UserNotificationController.java | 2 - .../portal/controller/UserRolesController.java | 44 ++++++++-------------- .../controller/WebAnalyticsExtAppController.java | 1 - 5 files changed, 23 insertions(+), 35 deletions(-) diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java index 56a4df3d..26559ae9 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java @@ -67,6 +67,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -105,7 +106,7 @@ public class TicketEventController implements BasicAuthenticationController { @ApiOperation( value = "Accepts messages from external ticketing systems and creates notifications for Portal users.", response = PortalRestResponse.class) - @RequestMapping(value = { "/ticketevent" }, method = RequestMethod.POST) + @PostMapping(value = { "/ticketevent" }) public PortalRestResponse handleRequest(HttpServletRequest request, HttpServletResponse response, @RequestBody String ticketEventJson) throws Exception { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserController.java index fc76a0e6..eec14f71 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserController.java @@ -55,6 +55,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; 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.PutMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -79,7 +81,7 @@ public class UserController extends EPRestrictedBaseController { * * @return PortalRestResponse of EPUser */ - @RequestMapping(value = { "/portalApi/loggedinUser" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/loggedinUser" }, produces = "application/json") public PortalRestResponse getLoggedinUser(HttpServletRequest request) { PortalRestResponse portalRestResponse = null; try { @@ -106,8 +108,8 @@ public class UserController extends EPRestrictedBaseController { * Body with user information * @return PortalRestResponse of String */ - @RequestMapping(value = { - "/portalApi/modifyLoggedinUser" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { + "/portalApi/modifyLoggedinUser" }, produces = "application/json") public PortalRestResponse modifyLoggedinUser(HttpServletRequest request, @RequestBody ProfileDetail profileDetail) { PortalRestResponse portalRestResponse = null; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserNotificationController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserNotificationController.java index cec01bad..8b874621 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserNotificationController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserNotificationController.java @@ -51,10 +51,8 @@ import org.springframework.beans.factory.annotation.Autowired; 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.PostMapping; 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; import org.onap.portalapp.controller.EPRestrictedBaseController; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java index b3d64dbc..906563cf 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/UserRolesController.java @@ -82,8 +82,8 @@ import org.springframework.beans.factory.annotation.Autowired; 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.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -117,7 +117,7 @@ public class UserRolesController extends EPRestrictedBaseController { * @param response HttpServletResponse * @return array of found users as json */ - @RequestMapping(value = { "/portalApi/queryUsers" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/queryUsers" }, produces = "application/json") public String getPhoneBookSearchResult(HttpServletRequest request, @RequestParam("search") String searchString, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -147,8 +147,7 @@ public class UserRolesController extends EPRestrictedBaseController { * @param response HttpServletResponse * @return for GET: array of all applications with boolean isAdmin=true/false for each application */ - @RequestMapping(value = { "/portalApi/adminAppsRoles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/adminAppsRoles" }, produces = "application/json") public AppsListWithAdminRole getAppsWithAdminRoleStateForUser(HttpServletRequest request, @RequestParam("user") String orgUserId, HttpServletResponse response) { @@ -198,8 +197,7 @@ public class UserRolesController extends EPRestrictedBaseController { * @param response HttpServletResponse * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/adminAppsRoles" }, method = { - RequestMethod.PUT }, produces = "application/json") + @PutMapping(value = { "/portalApi/adminAppsRoles" }, produces = "application/json") public FieldsValidator putAppsWithAdminRoleStateForUser(HttpServletRequest request, @RequestBody AppsListWithAdminRole newAppsListWithAdminRoles, HttpServletResponse response) { @@ -275,8 +273,7 @@ public class UserRolesController extends EPRestrictedBaseController { * @param extRequestValue set to false if request is from users page otherwise true * @return List */ - @RequestMapping(value = { "/portalApi/userAppRoles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/userAppRoles" }, produces = "application/json") public List getAppRolesForUser(HttpServletRequest request, @RequestParam("user") String orgUserId, @RequestParam("app") Long appid, @RequestParam("externalRequest") Boolean extRequestValue, @RequestParam("isSystemUser") Boolean isSystemUser, @@ -354,8 +351,7 @@ public class UserRolesController extends EPRestrictedBaseController { return result; } - @RequestMapping(value = { "/portalApi/userAppRoles" }, method = { - RequestMethod.PUT }, produces = "application/json") + @PutMapping(value = { "/portalApi/userAppRoles" }, produces = "application/json") public PortalRestResponse putAppWithUserRoleStateForUser(HttpServletRequest request, @RequestBody AppWithRolesForUser newAppRolesForUser, HttpServletResponse response) { // FieldsValidator fieldsValidator = new FieldsValidator(); @@ -435,8 +431,7 @@ public class UserRolesController extends EPRestrictedBaseController { return portalResponse; } - @RequestMapping(value = { "/portalApi/updateRemoteUserProfile" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/updateRemoteUserProfile" }, produces = "application/json") public PortalRestResponse updateRemoteUserProfile(HttpServletRequest request, HttpServletResponse response) { @@ -455,8 +450,7 @@ public class UserRolesController extends EPRestrictedBaseController { } - @RequestMapping(value = { "/portalApi/app/{appId}/users" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/app/{appId}/users" }, produces = "application/json") public List getUsersFromAppEndpoint(HttpServletRequest request, @PathVariable("appId") Long appId) throws HTTPException { try { @@ -468,8 +462,7 @@ public class UserRolesController extends EPRestrictedBaseController { } } - @RequestMapping(value = { "/portalApi/app/{appId}/roles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/app/{appId}/roles" }, produces = "application/json") public List testGetRoles(HttpServletRequest request, @PathVariable("appId") Long appId) throws HTTPException { EcompRole[] appRoles = applicationsRestClientService.get(EcompRole[].class, appId, "/roles"); @@ -480,8 +473,7 @@ public class UserRolesController extends EPRestrictedBaseController { return rolesList; } - @RequestMapping(value = { "/portalApi/admin/import/app/{appId}/roles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/admin/import/app/{appId}/roles" }, produces = "application/json") public List importRolesFromRemoteApplication(HttpServletRequest request, @PathVariable("appId") Long appId) throws HTTPException { List rolesList = userRolesService.importRolesFromRemoteApplication(appId); @@ -491,8 +483,7 @@ public class UserRolesController extends EPRestrictedBaseController { return rolesList; } - @RequestMapping(value = { "/portalApi/app/{appId}/user/{orgUserId}/roles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/app/{appId}/user/{orgUserId}/roles" }, produces = "application/json") public EcompRole testGetRoles(HttpServletRequest request, @PathVariable("appId") Long appId, @PathVariable("orgUserId") String orgUserId) throws Exception { if (!EcompPortalUtils.legitimateUserId(orgUserId)) { @@ -513,8 +504,7 @@ public class UserRolesController extends EPRestrictedBaseController { return roles[0]; } - @RequestMapping(value = { "/portalApi/saveUserAppRoles" }, method = { - RequestMethod.PUT }, produces = "application/json") + @PutMapping(value = { "/portalApi/saveUserAppRoles" }, produces = "application/json") public FieldsValidator putAppWithUserRoleRequest(HttpServletRequest request, @RequestBody AppWithRolesForUser newAppRolesForUser, HttpServletResponse response) { FieldsValidator fieldsValidator = null; @@ -534,8 +524,7 @@ public class UserRolesController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { "/portalApi/appCatalogRoles" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/appCatalogRoles" }, produces = "application/json") public List getUserAppCatalogRoles(HttpServletRequest request, @RequestParam("appName") String appName) { EPUser user = EPUserUtils.getUserSession(request); @@ -560,7 +549,7 @@ public class UserRolesController extends EPRestrictedBaseController { } }; - @RequestMapping(value = "/portalApi/externalRequestAccessSystem", method = RequestMethod.GET, + @GetMapping(value = "/portalApi/externalRequestAccessSystem", produces = "application/json") public ExternalSystemAccess readExternalRequestAccess(HttpServletRequest request) { ExternalSystemAccess result = null; @@ -574,8 +563,7 @@ public class UserRolesController extends EPRestrictedBaseController { return result; } - @RequestMapping(value = { "/portalApi/checkIfUserIsSuperAdmin" }, method = RequestMethod.GET, - produces = "application/json") + @GetMapping(value = { "/portalApi/checkIfUserIsSuperAdmin" }, produces = "application/json") public boolean checkIfUserIsSuperAdmin(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java index a8eb1d63..929ac474 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java @@ -81,7 +81,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.AsyncRestTemplate; -- 2.16.6