From 11084b1ee5fe03ac32a10831626790340b2de26f Mon Sep 17 00:00:00 2001 From: Arindam Mondal Date: Fri, 13 Mar 2020 11:30:25 +0900 Subject: [PATCH] Sonar code Smell Issue-ID: USECASEUI-407 Spring framework 4.3 introduced variants of the @RequestMapping annotation to better represent the semantics of the annotated methods. The use of @GetMapping, @PostMapping, @PutMapping, @PatchMapping and @DeleteMapping should be preferred to the use of the raw @RequestMapping(method = RequestMethod.XYZ). Change-Id: Ic86eaf183919976d60bd0e581be2c8b13da20baf Signed-off-by: Arindam Mondal --- .../server/controller/csmf/SlicingController.java | 9 ++++---- .../controller/lcm/ServiceTemplateController.java | 24 +++++++++++----------- .../service/customer/CcvpnCustomerService.java | 4 ---- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/csmf/SlicingController.java b/server/src/main/java/org/onap/usecaseui/server/controller/csmf/SlicingController.java index 89ee912d..97226bae 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/csmf/SlicingController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/csmf/SlicingController.java @@ -22,10 +22,11 @@ import org.onap.usecaseui.server.service.csmf.SlicingService; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; 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.ResponseBody; @Controller @@ -43,18 +44,16 @@ public class SlicingController { } @ResponseBody - @RequestMapping( + @PostMapping( value = {"/5gSlicing"}, - method = RequestMethod.POST, produces = "application/json") public ServiceResult createSlicingService(@RequestBody SlicingOrder slicingOrder) { return slicingService.createSlicingService(slicingOrder); } @ResponseBody - @RequestMapping( + @GetMapping( value = {"/5gSlicing/orders/status/{status}/pageNo/{pageNo}/pageSize/{pageSize}"}, - method = RequestMethod.GET, produces = "application/json") public ServiceResult querySlicingServiceOrder( @PathVariable(value="status") String status, diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java index 7591c396..3a874123 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java @@ -15,10 +15,11 @@ */ package org.onap.usecaseui.server.controller.lcm; +import java.util.List; +import javax.annotation.Resource; import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput; -import org.onap.usecaseui.server.bean.lcm.TemplateInput; -import org.onap.usecaseui.server.service.lcm.ServiceTemplateService; import org.onap.usecaseui.server.service.lcm.CustomerService; +import org.onap.usecaseui.server.service.lcm.ServiceTemplateService; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCController; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate; @@ -26,11 +27,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.List; -import java.util.ArrayList; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; @Controller @org.springframework.context.annotation.Configuration @@ -50,26 +50,26 @@ public class ServiceTemplateController { } @ResponseBody - @RequestMapping(value = {"/uui-lcm/service-templates"}, method = RequestMethod.GET , produces = "application/json") + @GetMapping(value = {"/uui-lcm/service-templates"} , produces = "application/json") public List getServiceTemplates(){ return serviceTemplateService.listDistributedServiceTemplate(); } @ResponseBody - @RequestMapping(value = {"/uui-lcm/service-templates/{uuid}"}, method = RequestMethod.GET , produces = "application/json") + @GetMapping(value = {"/uui-lcm/service-templates/{uuid}"}, produces = "application/json") public ServiceTemplateInput getServiceTemplateInput(@PathVariable("uuid") String uuid, @RequestParam("toscaModelPath") String toscaModelPath){ ServiceTemplateInput serviceTemplateInput = serviceTemplateService.fetchServiceTemplateInput(uuid, "/api"+toscaModelPath); return serviceTemplateInput; } @ResponseBody - @RequestMapping(value = {"/uui-lcm/locations/"}, method = RequestMethod.GET , produces = "application/json") + @GetMapping(value = {"/uui-lcm/locations/"}, produces = "application/json") public List getLocations(){ return serviceTemplateService.listVim(); } @ResponseBody - @RequestMapping(value = {"/uui-lcm/getAllNI/{networkId}"}, method = RequestMethod.GET , produces = "application/json") + @GetMapping(value = {"/uui-lcm/getAllNI/{networkId}"}, produces = "application/json") public List getAllNetworkInterface(@PathVariable("networkId") String networkId){ List nIList = customerService.fetchNIList(networkId); @@ -77,7 +77,7 @@ public class ServiceTemplateController { } @ResponseBody - @RequestMapping(value = {"/uui-lcm/sdnc-controllers/"}, method = RequestMethod.GET , produces = "application/json") + @GetMapping(value = {"/uui-lcm/sdnc-controllers/"}, produces = "application/json") public List getSDNCControllers(){ return serviceTemplateService.listSDNCControllers(); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/customer/CcvpnCustomerService.java b/server/src/main/java/org/onap/usecaseui/server/service/customer/CcvpnCustomerService.java index ca1e9f7c..02e85823 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/customer/CcvpnCustomerService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/customer/CcvpnCustomerService.java @@ -15,15 +15,11 @@ */ package org.onap.usecaseui.server.service.customer; -import org.onap.usecaseui.server.bean.customer.ServiceInstance; import org.onap.usecaseui.server.bean.customer.ServiceInstances; -import java.util.List; - public interface CcvpnCustomerService { public ServiceInstances getServiceInstances(String customerId, String serviceType); - //public String getServiceInformation(String serviceInstanceId) throws Exception; public String querySubscriptionType(String customerId); } -- 2.16.6