From f1dd7327d1ef59213016a9077c7d6881649373d8 Mon Sep 17 00:00:00 2001 From: burdziak Date: Mon, 18 Feb 2019 15:47:25 +0100 Subject: Fix sonar issues in MenuListController Change-Id: If380c7bfb51f837ae4b8416d49ae42746cb1d818 Issue-ID: PORTAL-523 Signed-off-by: burdziak --- .../onap/portalapp/controller/core/MenuListController.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java index 5ca764c1..bedd9c41 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java @@ -74,6 +74,8 @@ public class MenuListController extends RestrictedBaseController { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MenuListController.class); + private static final String APPLICATION_JSON = "application/json"; + @Autowired private FnMenuService fnMenuService; @Autowired @@ -110,7 +112,7 @@ public class MenuListController extends RestrictedBaseController { JsonMessage msg = new JsonMessage(mapper.writeValueAsString(parentList), mapper.writeValueAsString(childItemList), userName); JSONObject j = new JSONObject(msg); - response.setContentType("application/json"); + response.setContentType(APPLICATION_JSON); response.getWriter().write(j.toString()); logger.debug(EELFLoggerDelegate.debugLogger, "getMenu ends"); } catch (Exception e) { @@ -132,12 +134,12 @@ public class MenuListController extends RestrictedBaseController { try { String appName = (String) session .getAttribute(SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)); - if (appName != null && appName.equals("app_display_name")) { + if (appName != null && "app_display_name".equals(appName)) { appName = ""; } JsonMessage msg = new JsonMessage(appName); JSONObject j = new JSONObject(msg); - response.setContentType("application/json"); + response.setContentType(APPLICATION_JSON); response.getWriter().write(j.toString()); logger.debug(EELFLoggerDelegate.debugLogger, "getAppName ends"); } catch (Exception e) { @@ -194,7 +196,7 @@ public class MenuListController extends RestrictedBaseController { String contextId = null; if (request.getCookies() != null) { for (Cookie ck : request.getCookies()) { - if (ck.getName().equalsIgnoreCase("EPService")) + if ("EPService".equalsIgnoreCase(ck.getName())) contextId = ck.getValue(); } } @@ -207,7 +209,7 @@ public class MenuListController extends RestrictedBaseController { model.put(sharedContext.getCkey(), sharedContext.getCvalue()); } JSONObject j = new JSONObject(model); - response.setContentType("application/json"); + response.setContentType(APPLICATION_JSON); response.getWriter().write(j.toString()); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "getUserInfo failed", e); @@ -248,7 +250,7 @@ public class MenuListController extends RestrictedBaseController { isAppCentralized = true; map.put("isAppCentralized", Boolean.toString(isAppCentralized)); JSONObject j = new JSONObject(map); - response.setContentType("application/json"); + response.setContentType(APPLICATION_JSON); response.getWriter().write(j.toString()); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "Failed to serialize JSON", e); -- cgit 1.2.3-korg