From: Rupinder Date: Tue, 21 Apr 2020 13:28:55 +0000 (+0530) Subject: lowered code smells X-Git-Tag: 3.4.0~73^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=portal.git;a=commitdiff_plain;h=ad4dc7cf7d0411a08733bfef27a6954a098f7052 lowered code smells Issue-ID: PORTAL-865 Change-Id: Id64f7eee433892b7fa241ea26424efff742f7229 Signed-off-by: Rupinder --- diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java index ca66809f..d78d6146 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/HealthCheckController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -46,6 +48,7 @@ import javax.servlet.http.HttpServletResponse; import org.slf4j.MDC; import org.springframework.context.annotation.EnableAspectJAutoProxy; 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; import org.onap.music.main.MusicUtil; @@ -118,7 +121,7 @@ public class HealthCheckController extends EPUnRestrictedBaseController { private final String statusDown = "DOWN"; private final String statusOk = "OK"; - @RequestMapping(value = { "/portalApi/healthCheck" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/healthCheck" }, produces = "application/json") public HealthStatus healthCheck(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(500, ""); @@ -229,8 +232,8 @@ public class HealthCheckController extends EPUnRestrictedBaseController { return healthStatus; } - @RequestMapping(value = { - "/portalApi/healthCheckSuspend" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/healthCheckSuspend" }, produces = "application/json") public HealthStatus healthCheckSuspend(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(500, "Suspended for manual failover mechanism"); @@ -243,8 +246,8 @@ public class HealthCheckController extends EPUnRestrictedBaseController { return healthStatus; } - @RequestMapping(value = { - "/portalApi/healthCheckResume" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/healthCheckResume" }, produces = "application/json") public HealthStatus healthCheckResume(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(500, "Resumed from manual failover mechanism"); @@ -255,7 +258,7 @@ public class HealthCheckController extends EPUnRestrictedBaseController { return healthStatus; } - @RequestMapping(value = { "/portalApi/ping" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/ping" }, produces = "application/json") public HealthStatus ping(HttpServletRequest request, HttpServletResponse response) { HealthStatus healthStatus = new HealthStatus(200, "OK"); EcompPortalUtils.logAndSerializeObject(logger, "/portalApi/ping", "GET result =", response.getStatus()); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java index 508b1be2..d371dd5c 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/LanguageController.java @@ -1,6 +1,8 @@ /** * Copyright (C) 2019 CMCC, Inc. and others. All rights reserved. * + * Modification Copyright © 2020 IBM. + * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -22,6 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired; 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; import com.alibaba.fastjson.JSONObject; @@ -33,19 +37,19 @@ public class LanguageController { @Autowired private LanguageService languageService; - @RequestMapping(value = "/language",method = RequestMethod.GET, produces = "application/json;charset=UTF-8") + @GetMapping(value = "/language", produces = "application/json;charset=UTF-8") public JSONObject getLanguageList() { return languageService.getLanguages(); } - @RequestMapping(value = "/languageSetting/user/{loginId}",method = RequestMethod.POST) + @PostMapping(value = "/languageSetting/user/{loginId}") public void setUpUserLanguage(@RequestBody JSONObject jsonLanguageId, @PathVariable("loginId") String loginId) throws Exception { Integer languageId = jsonLanguageId.getInteger("languageId"); languageService.setUpUserLanguage(languageId,loginId); } - @RequestMapping(value = "/languageSetting/user/{loginId}",method = RequestMethod.GET) + @GetMapping(value = "/languageSetting/user/{loginId}") public JSONObject getUserLanguage(HttpServletRequest request, HttpServletResponse response, @PathVariable("loginId") String loginId) { return languageService.getUserLanguage(loginId); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java index 2e1a2b46..b7d3cc78 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -69,6 +71,10 @@ 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.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; @@ -90,7 +96,7 @@ public class MicroserviceController extends EPRestrictedBaseController { @Autowired private MicroserviceService microserviceService; - @RequestMapping(value = { "/portalApi/microservices" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/microservices" }) public PortalRestResponse createMicroservice(HttpServletRequest request, HttpServletResponse response, @Valid @RequestBody MicroserviceData newServiceData) throws Exception { if (newServiceData == null) { @@ -113,13 +119,13 @@ public class MicroserviceController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "SUCCESS", ""); } - @RequestMapping(value = { "/portalApi/microservices" }, method = RequestMethod.GET) + @GetMapping(value = { "/portalApi/microservices" }) public List getMicroservice(HttpServletRequest request, HttpServletResponse response) throws Exception { return microserviceService.getMicroserviceData(); } - @RequestMapping(value = { "/portalApi/microservices/{serviceId}" }, method = RequestMethod.PUT) + @PutMapping(value = { "/portalApi/microservices/{serviceId}" }) public PortalRestResponse updateMicroservice(HttpServletRequest request, HttpServletResponse response, @PathVariable("serviceId") long serviceId, @Valid @RequestBody MicroserviceData newServiceData) { @@ -140,7 +146,7 @@ public class MicroserviceController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.OK, "SUCCESS", ""); } - @RequestMapping(value = { "/portalApi/microservices/{serviceId}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/microservices/{serviceId}" }) public PortalRestResponse deleteMicroservice(HttpServletRequest request, HttpServletResponse response, @PathVariable("serviceId") long serviceId) { try { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceProxyController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceProxyController.java index fed3b98e..134d99ef 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceProxyController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceProxyController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -52,6 +54,7 @@ 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.RequestMapping; +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.client.HttpClientErrorException; @@ -69,8 +72,7 @@ public class MicroserviceProxyController extends EPUnRestrictedBaseController { @Autowired private MicroserviceProxyService microserviceProxyService; - @RequestMapping(value = { "/portalApi/microservice/proxy/{serviceId}" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/microservice/proxy/{serviceId}" }, produces = "application/json") public String getMicroserviceProxy(HttpServletRequest request, HttpServletResponse response, @PathVariable("serviceId") long serviceId) throws Exception { EPUser user = EPUserUtils.getUserSession(request); @@ -83,8 +85,7 @@ public class MicroserviceProxyController extends EPUnRestrictedBaseController { return isValidJSON(answer) ? answer : "{\"error\":\"" + answer.replace(System.getProperty("line.separator"), "") + "\"}"; } - @RequestMapping(value = { "/portalApi/microservice/proxy/parameter/{widgetId}" }, method = { - RequestMethod.GET }, produces = "application/json") + @GetMapping(value = { "/portalApi/microservice/proxy/parameter/{widgetId}" }, produces = "application/json") public String getMicroserviceProxyByWidgetId(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId) throws Exception { EPUser user = EPUserUtils.getUserSession(request); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java index 32b28c7d..563a387a 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/PortalAdminController.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== * * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); @@ -69,6 +71,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; @@ -92,7 +98,7 @@ public class PortalAdminController extends EPRestrictedBaseController { this.auditService = auditService; } - @RequestMapping(value = { "/portalApi/portalAdmins" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { "/portalApi/portalAdmins" }, produces = "application/json") public List getPortalAdmins(HttpServletRequest request, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); List portalAdmins = null; @@ -120,7 +126,7 @@ public class PortalAdminController extends EPRestrictedBaseController { * @param response * @return FieldsValidator */ - @RequestMapping(value = { "/portalApi/portalAdmin" }, method = RequestMethod.POST) + @PostMapping(value = { "/portalApi/portalAdmin" }) public FieldsValidator createPortalAdmin(HttpServletRequest request, @RequestBody String userId, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request); @@ -167,7 +173,7 @@ public class PortalAdminController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { "/portalApi/portalAdmin/{userInfo}" }, method = RequestMethod.DELETE) + @DeleteMapping(value = { "/portalApi/portalAdmin/{userInfo}" }) public FieldsValidator deletePortalAdmin(HttpServletRequest request, @PathVariable("userInfo") String userInfo, HttpServletResponse response) { @@ -225,8 +231,8 @@ public class PortalAdminController extends EPRestrictedBaseController { return fieldsValidator; } - @RequestMapping(value = { - "/portalApi/adminAppsRoles/{appId}" }, method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = { + "/portalApi/adminAppsRoles/{appId}" }, produces = "application/json") public List getRolesByApp(HttpServletRequest request, @PathVariable("appId") Long appId, HttpServletResponse response) { EPUser user = EPUserUtils.getUserSession(request);