Fix sonar issues in MenuListController 74/78674/1
authorburdziak <olaf.burdziakowski@nokia.com>
Mon, 18 Feb 2019 14:47:25 +0000 (15:47 +0100)
committerburdziak <olaf.burdziakowski@nokia.com>
Mon, 18 Feb 2019 14:47:25 +0000 (15:47 +0100)
Change-Id: If380c7bfb51f837ae4b8416d49ae42746cb1d818
Issue-ID: PORTAL-523
Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/MenuListController.java

index 5ca764c..bedd9c4 100644 (file)
@@ -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);