diff options
author | Christopher Lott (cl778h) <clott@research.att.com> | 2017-09-07 08:52:41 -0400 |
---|---|---|
committer | Christopher Lott (cl778h) <clott@research.att.com> | 2017-09-07 08:54:52 -0400 |
commit | 8cd208ebaa33627daf05d8ffff7b28e53a7067d0 (patch) | |
tree | 0b07ec3c6305c46f34eae69d8fb6fa824aaae256 /ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller | |
parent | b52d4cebc430a083ec1e6881c4f01dfe709ac726 (diff) |
Adjust code for Sonar issues
Made non-functional updates to address static code analysis issues.
Update license header with simple double-quote characters.
Issue: PORTAL-72, PORTAL-90
Change-Id: Ic2c330daea07d721f0e6b350ebf03da97073f7ce
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller')
4 files changed, 79 insertions, 69 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/FusionBaseController.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/FusionBaseController.java index 48c145b3..980feaec 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/FusionBaseController.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/FusionBaseController.java @@ -6,7 +6,7 @@ * =================================================================== * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the “License”); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -19,7 +19,7 @@ * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -63,77 +63,70 @@ import org.springframework.web.bind.annotation.ModelAttribute; import com.fasterxml.jackson.databind.ObjectMapper; @Controller -public abstract class FusionBaseController implements SecurityInterface{ - +public abstract class FusionBaseController implements SecurityInterface { + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FusionBaseController.class); - - @Override - public boolean isAccessible() { - return true; - } - - public boolean isRESTfulCall(){ - return true; - } + @Autowired private FnMenuService fnMenuService; - + @Autowired - private MenuBuilder menuBuilder; - + private MenuBuilder menuBuilder; + @Autowired - private DataAccessService dataAccessService; - + private DataAccessService dataAccessService; + @Autowired - AppService appService; - + private AppService appService; + @SuppressWarnings({ "unchecked", "rawtypes" }) @ModelAttribute("menu") public Map<String, Object> getMenu(HttpServletRequest request) { HttpSession session = null; - Map<String, Object> model = new HashMap<String, Object>(); + Map<String, Object> model = new HashMap<>(); try { - try { - String appName = appService.getDefaultAppName(); - if (appName==null || appName=="") { - appName = SystemProperties.SDK_NAME; - } - logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, appName); - } catch (Exception e) { - } - + String appName = appService.getDefaultAppName(); + if (appName == null || appName == "") + appName = SystemProperties.SDK_NAME; + logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, appName); + session = request.getSession(); User user = UserUtils.getUserSession(request); - if(session!=null && user!=null){ - Set<MenuData> menuResult = (Set<MenuData>) session.getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); - if(menuResult==null){ - Set appMenu = getMenuBuilder().getMenu(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_SET_NAME),dataAccessService); - session.setAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME), MenuBuilder.filterMenu(appMenu, request)); - menuResult = (Set<MenuData>) session.getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); + if (session != null && user != null) { + Set<MenuData> menuResult = (Set<MenuData>) session + .getAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); + if (menuResult == null) { + Set appMenu = getMenuBuilder().getMenu( + SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_SET_NAME), + dataAccessService); + session.setAttribute(SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME), + MenuBuilder.filterMenu(appMenu, request)); + menuResult = (Set<MenuData>) session.getAttribute( + SystemProperties.getProperty(SystemProperties.APPLICATION_MENU_ATTRIBUTE_NAME)); } - model = setMenu(menuResult); + model = setMenu(menuResult); } } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage()); + logger.error(EELFLoggerDelegate.errorLogger, "getMenu failed", e); } return model; } - - public Map<String, Object> setMenu(Set<MenuData> menuResult) throws Exception{ + + public Map<String, Object> setMenu(Set<MenuData> menuResult) throws Exception { ObjectMapper mapper = new ObjectMapper(); - List<List<MenuData>> childItemList = new ArrayList<List<MenuData>>();; - List<MenuData> parentList = new ArrayList<MenuData>();; - Map<String, Object> model = new HashMap<String, Object>(); - try{ - fnMenuService.setMenuDataStructure(childItemList, parentList, menuResult); - }catch(Exception e){ - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage()); - } + List<List<MenuData>> childItemList = new ArrayList<>(); + List<MenuData> parentList = new ArrayList<>(); + try { + fnMenuService.setMenuDataStructure(childItemList, parentList, menuResult); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "setMenu failed", e); + } + Map<String, Object> model = new HashMap<>(); model.put("childItemList", mapper.writeValueAsString(childItemList)); model.put("parentList", mapper.writeValueAsString(parentList)); return model; } - + public MenuBuilder getMenuBuilder() { return menuBuilder; } @@ -149,5 +142,14 @@ public abstract class FusionBaseController implements SecurityInterface{ public void setDataAccessService(DataAccessService dataAccessService) { this.dataAccessService = dataAccessService; } - + + @Override + public boolean isAccessible() { + return true; + } + + public boolean isRESTfulCall() { + return true; + } + } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/RestrictedBaseController.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/RestrictedBaseController.java index 1659dc32..5fdac61b 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/RestrictedBaseController.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/RestrictedBaseController.java @@ -6,7 +6,7 @@ * =================================================================== * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the “License”); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -19,7 +19,7 @@ * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -37,32 +37,35 @@ */ package org.onap.portalsdk.core.controller; -public class RestrictedBaseController extends FusionBaseController{ - +public class RestrictedBaseController extends FusionBaseController { + protected String viewName; private String exceptionView; + @Override public boolean isAccessible() { return false; } + @Override - public boolean isRESTfulCall(){ + public boolean isRESTfulCall() { return false; } + protected String getViewName() { return viewName; } + protected void setViewName(String viewName) { this.viewName = viewName; } public String getExceptionView() { - return (exceptionView == null) ? "runtime_error_handler" : exceptionView; + return (exceptionView == null) ? "runtime_error_handler" : exceptionView; } public void setExceptionView(String exceptionView) { this.exceptionView = exceptionView; } - } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/RestrictedRESTfulBaseController.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/RestrictedRESTfulBaseController.java index 1dfffaa0..5a33c752 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/RestrictedRESTfulBaseController.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/RestrictedRESTfulBaseController.java @@ -6,7 +6,7 @@ * =================================================================== * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the “License”); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -19,7 +19,7 @@ * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -37,32 +37,35 @@ */ package org.onap.portalsdk.core.controller; -public class RestrictedRESTfulBaseController extends FusionBaseController{ - +public class RestrictedRESTfulBaseController extends FusionBaseController { + protected String viewName; private String exceptionView; + @Override public boolean isAccessible() { return false; } + @Override - public boolean isRESTfulCall(){ + public boolean isRESTfulCall() { return true; } + protected String getViewName() { return viewName; } + protected void setViewName(String viewName) { this.viewName = viewName; } public String getExceptionView() { - return (exceptionView == null) ? "runtime_error_handler" : exceptionView; + return (exceptionView == null) ? "runtime_error_handler" : exceptionView; } public void setExceptionView(String exceptionView) { this.exceptionView = exceptionView; } - } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/UnRestrictedBaseController.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/UnRestrictedBaseController.java index 81f0c54d..b78f7bfb 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/UnRestrictedBaseController.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/controller/UnRestrictedBaseController.java @@ -6,7 +6,7 @@ * =================================================================== * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the “License”); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -19,7 +19,7 @@ * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -37,17 +37,19 @@ */ package org.onap.portalsdk.core.controller; -public class UnRestrictedBaseController extends FusionBaseController{ +public class UnRestrictedBaseController extends FusionBaseController { protected String viewName; - + @Override public boolean isAccessible() { return true; } + @Override - public boolean isRESTfulCall(){ + public boolean isRESTfulCall() { return false; } + protected String getViewName() { return viewName; } |