From 858fda6824501c6d40a7fc5a130d2c04510c5231 Mon Sep 17 00:00:00 2001 From: Rupinder Date: Thu, 4 Jun 2020 11:04:48 +0530 Subject: [PATCH] fixed some issues from sonar Issue-ID: PORTAL-865 Change-Id: I310d08614f54b931a21585e702b1e58b50e1fcf6 Signed-off-by: Rupinder --- .../portalapp/portal/controller/RoleManageController.java | 8 +++----- .../portal/controller/RolesApprovalSystemController.java | 10 ++++++---- .../portal/controller/SchedulerAuxController.java | 3 ++- .../portalapp/portal/controller/SchedulerController.java | 10 ++++++---- .../portal/controller/SharedContextRestController.java | 14 ++++++++------ 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java index e308182c..ead2ee9b 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java @@ -7,10 +7,10 @@ * Modifications Copyright (c) 2019 Samsung * =================================================================== * Modifications Copyright (c) 2020 IBM - * =================================================================== - * + * =================================================================== + * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -97,10 +97,8 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.http.ResponseEntity; 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.RestController; import org.springframework.web.servlet.ModelAndView; import com.fasterxml.jackson.databind.DeserializationFeature; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RolesApprovalSystemController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RolesApprovalSystemController.java index 487cc4d5..5b953b6e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RolesApprovalSystemController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RolesApprovalSystemController.java @@ -56,7 +56,9 @@ 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.RequestMethod; +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.RestController; import io.swagger.annotations.ApiOperation; @@ -81,7 +83,7 @@ public class RolesApprovalSystemController implements BasicAuthenticationControl * @return PortalRestResponse with appropriate status value and message */ @ApiOperation(value = "Creates an application user with the specified roles.", response = PortalRestResponse.class) - @RequestMapping(value = { "/userProfile" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/userProfile" }, produces = "application/json") public PortalRestResponse postUserProfile(HttpServletRequest request, @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) { ExternalRequestFieldsValidator reqResult = null; @@ -129,7 +131,7 @@ public class RolesApprovalSystemController implements BasicAuthenticationControl * @return PortalRestResponse with appropriate status value and message */ @ApiOperation(value = "Updates an application user to have only the specified roles.", response = PortalRestResponse.class) - @RequestMapping(value = { "/userProfile" }, method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = { "/userProfile" }, produces = "application/json") public PortalRestResponse putUserProfile(HttpServletRequest request, @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) { ExternalRequestFieldsValidator reqResult = null; @@ -176,7 +178,7 @@ public class RolesApprovalSystemController implements BasicAuthenticationControl * @return PortalRestResponse with appropriate status value and message */ @ApiOperation(value = "Processes a request to delete one or more application roles for one specified user who has roles.", response = PortalRestResponse.class) - @RequestMapping(value = { "/userProfile" }, method = RequestMethod.DELETE, produces = "application/json") + @DeleteMapping(value = { "/userProfile" }, produces = "application/json") public PortalRestResponse deleteUserProfile(HttpServletRequest request, @RequestBody ExternalSystemUser extSysUser, HttpServletResponse response) { ExternalRequestFieldsValidator reqResult = null; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java index 85c48b7b..20fddf91 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerAuxController.java @@ -58,6 +58,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; 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.RestController; @@ -75,7 +76,7 @@ public class SchedulerAuxController extends EPRestrictedBaseController { /** The logger. */ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerAuxController.class); - @RequestMapping(value = "/get_policy", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/get_policy", produces = "application/json") public ResponseEntity getPolicyInfo(HttpServletRequest request) throws Exception { try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java index 69f25683..53275763 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java @@ -77,6 +77,8 @@ import org.springframework.http.ResponseEntity; 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.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -102,7 +104,7 @@ public class SchedulerController extends EPRestrictedBaseController { this.adminRolesService = adminRolesService; } - @RequestMapping(value = "/get_time_slots/{scheduler_request}", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/get_time_slots/{scheduler_request}", produces = "application/json") public ResponseEntity getTimeSlots(HttpServletRequest request, @PathVariable("scheduler_request") String schedulerRequest) throws Exception { if (checkIfUserISValidToMakeSchedule(request)) { @@ -169,7 +171,7 @@ public class SchedulerController extends EPRestrictedBaseController { } @SuppressWarnings("unchecked") - @RequestMapping(value = "/post_create_new_vnf_change", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/post_create_new_vnf_change", produces = "application/json") public ResponseEntity postCreateNewVNFChange(HttpServletRequest request, @RequestBody JSONObject schedulerRequest) throws Exception { if (checkIfUserISValidToMakeSchedule(request)) { @@ -249,7 +251,7 @@ public class SchedulerController extends EPRestrictedBaseController { } } - @RequestMapping(value = "/submit_vnf_change_timeslots", method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/submit_vnf_change_timeslots", produces = "application/json") public ResponseEntity postSubmitVnfChangeTimeslots(HttpServletRequest request, @RequestBody JSONObject schedulerRequest) throws Exception { if (checkIfUserISValidToMakeSchedule(request)) { @@ -335,7 +337,7 @@ public class SchedulerController extends EPRestrictedBaseController { * @return Rest response wrapped around a String; e.g., "success" or "ERROR" * @throws Exception */ - @RequestMapping(value = "/get_scheduler_constant", method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/get_scheduler_constant", produces = "application/json") public PortalRestResponse> getSchedulerConstant(HttpServletRequest request, HttpServletResponse response) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "get scheduler constant"); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SharedContextRestController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SharedContextRestController.java index 9e3428e6..232b691f 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SharedContextRestController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SharedContextRestController.java @@ -63,6 +63,8 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ExceptionHandler; 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.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -114,7 +116,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Gets a value for the specified context and key.", response = SharedContext.class) - @RequestMapping(value = { "/get" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/get" }, produces = "application/json") public String getContext(HttpServletRequest request, @RequestParam String context_id, @RequestParam String ckey) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "getContext for ID " + context_id + ", key " + ckey); @@ -151,7 +153,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Gets user information for the specified context.", response = SharedContext.class, responseContainer = "List") - @RequestMapping(value = { "/get_user" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/get_user" }, produces = "application/json") public String getUserContext(HttpServletRequest request, @RequestParam String context_id) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "getUserContext for ID " + context_id); @@ -197,7 +199,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Tests for presence of the specified key in the specified context.", response = SharedContextJsonResponse.class) - @RequestMapping(value = { "/check" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/check" }, produces = "application/json") public String checkContext(HttpServletRequest request, @RequestParam String context_id, @RequestParam String ckey) throws Exception { @@ -236,7 +238,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Removes the specified key in the specified context.", response = SharedContextJsonResponse.class) - @RequestMapping(value = { "/remove" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/remove" }, produces = "application/json") public String removeContext(HttpServletRequest request, @RequestParam String context_id, @RequestParam String ckey) throws Exception { @@ -275,7 +277,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Clears all key-value pairs in the specified context.", response = SharedContextJsonResponse.class) - @RequestMapping(value = { "/clear" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/clear" }, produces = "application/json") public String clearContext(HttpServletRequest request, @RequestParam String context_id) throws Exception { logger.debug(EELFLoggerDelegate.debugLogger, "clearContext for " + context_id); @@ -311,7 +313,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll * on bad arguments */ @ApiOperation(value = "Sets a context value for the specified context and key. Creates the context if no context with the specified ID-key pair exists, overwrites the value if it exists already.", response = SharedContextJsonResponse.class) - @RequestMapping(value = { "/set" }, method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = { "/set" }, produces = "application/json") public String setContext(HttpServletRequest request, @RequestBody String userJson) throws Exception { if (userJson !=null){ SecureString secureUserJson = new SecureString(userJson); -- 2.16.6