summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common/src
diff options
context:
space:
mode:
authorburdziak <olaf.burdziakowski@nokia.com>2019-03-19 10:53:47 +0100
committerburdziak <olaf.burdziakowski@nokia.com>2019-03-19 10:53:47 +0100
commit9baa053329dcb227c32f74a446d59c067e5ac821 (patch)
treec69cafa35ae5453566129818a299dbf085c52314 /ecomp-sdk/epsdk-app-common/src
parent1ded3bb69c5e91cd879d83e13d2b3295710cdb4f (diff)
Fix sonar issues in BroadcastListController
Change-Id: If213a08c9cdc6d35e510e1abf70ac08186e06d6a Issue-ID: PORTAL-523 Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
Diffstat (limited to 'ecomp-sdk/epsdk-app-common/src')
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastListController.java25
1 files changed, 14 insertions, 11 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastListController.java
index 8b740d0b..c9c666fb 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastListController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastListController.java
@@ -37,6 +37,7 @@
*/
package org.onap.portalapp.controller.sample;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
@@ -65,6 +66,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class BroadcastListController extends RestrictedBaseController {
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(BroadcastListController.class);
+ private static final String UTF8 = "UTF-8";
+
@Autowired
private BroadcastService broadcastService;
@@ -78,7 +81,7 @@ public class BroadcastListController extends RestrictedBaseController {
@RequestMapping(value = { "/get_broadcast_list" }, method = RequestMethod.GET)
public void getBroadcast(HttpServletRequest request, HttpServletResponse response) {
- Map<String, Object> model = new HashMap<String, Object>();
+ Map<String, Object> model = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
try {
model.put("model", broadcastService.getBcModel(request));
@@ -94,7 +97,7 @@ public class BroadcastListController extends RestrictedBaseController {
}
@RequestMapping(value = { "/broadcast_list/remove" }, method = RequestMethod.POST)
- public ModelAndView remove(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ModelAndView remove(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
@@ -106,9 +109,9 @@ public class BroadcastListController extends RestrictedBaseController {
broadcastService.removeBroadcastMessage(broadcastMessage);
- response.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
String responseString = mapper.writeValueAsString(broadcastMessage);
@@ -118,8 +121,8 @@ public class BroadcastListController extends RestrictedBaseController {
return null;
} catch (Exception e) {
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
out.write("An error occurred while removing the BroadcastMessage in the remove ()");
logger.error(EELFLoggerDelegate.errorLogger, "remove() failed", e);
@@ -129,7 +132,7 @@ public class BroadcastListController extends RestrictedBaseController {
}
@RequestMapping(value = { "/broadcast_list/toggleActive" }, method = RequestMethod.POST)
- public ModelAndView toggleActive(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ModelAndView toggleActive(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
@@ -141,9 +144,9 @@ public class BroadcastListController extends RestrictedBaseController {
broadcastService.saveBroadcastMessage(broadcastMessage);
- response.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
String responseString = mapper.writeValueAsString(broadcastMessage);
@@ -153,8 +156,8 @@ public class BroadcastListController extends RestrictedBaseController {
return null;
} catch (Exception e) {
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
out.write("An error occurred while saving the BroadcastMessage in the toggleActive () ");
logger.error(EELFLoggerDelegate.errorLogger, "toggleActive() failed", e);