From: Sunder Tattavarada Date: Tue, 27 Mar 2018 12:47:26 +0000 (+0000) Subject: Merge "Sonar Issues for ExternalAppConfig.java" X-Git-Tag: v2.2.0~27 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=229ae9fdd468bec4da29218688c090873cfab907;hp=-c;p=portal.git Merge "Sonar Issues for ExternalAppConfig.java" --- 229ae9fdd468bec4da29218688c090873cfab907 diff --combined ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java index c059a01c,0bdcaebd..c3fdf0a9 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java @@@ -61,7 -61,6 +61,7 @@@ import org.onap.portalapp.authenticatio import org.onap.portalapp.authentication.SimpleLoginStrategy; import org.onap.portalapp.controller.core.LogoutController; import org.onap.portalapp.controller.core.SDKLoginController; +import org.onap.portalapp.music.conf.MusicSessionConfig; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.domain.EPUserApp; @@@ -101,7 -100,6 +101,7 @@@ import org.springframework.context.anno import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; @@@ -121,24 -119,24 +121,24 @@@ import com.google.gson.Gson @Profile("src") @EnableAsync @EnableScheduling - +@Import({ MusicSessionConfig.class }) public class ExternalAppConfig extends AppConfig implements Configurable { private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAppConfig.class); @Autowired private DataAccessService dataAccessService; - + @Autowired private UserRolesService userRolesService; - + @Autowired private ExternalAccessRolesService externalAccessRolesService; private RegistryAdapter schedulerRegistryAdapter; - String UEB_APP_KEY = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY); - + String uebAppKey = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY); + public ViewResolver viewResolver() { return super.viewResolver(); } @@@ -162,14 -160,14 +162,14 @@@ MDC.put(MDC_SERVICE_INSTANCE_ID, ""); MDC.put(MDC_ALERT_SEVERITY, AlarmSeverityEnum.INFORMATIONAL.severity()); MDC.put(MDC_INSTANCE_UUID, SystemProperties.getProperty(SystemProperties.INSTANCE_UUID)); - if(remotecentralizedsystemaccess.equalsIgnoreCase("true")){ + if("true".equalsIgnoreCase(remotecentralizedsystemaccess)){ importFromExternalAuth(); } } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "init failed", e); } } - + /** * Does a sync on functions, roles and role functions based on namespace * for all the centralized applications between AAF and ONAP, updates @@@ -182,7 -180,7 +182,7 @@@ List appList; //to get all centralized apps List centralizedAppList = dataAccessService.executeNamedQuery("getCentralizedApps", null, null); - if(centralizedAppList != null && centralizedAppList.size() > 0){ + if(centralizedAppList != null && !centralizedAppList.isEmpty()){ for(int i = 0; i < centralizedAppList.size(); i++){ //syncRoles(does a sync on functions, roles and role functions) externalAccessRolesService.syncApplicationRolesWithEcompDB(centralizedAppList.get(i)); @@@ -199,7 -197,7 +199,7 @@@ for(int k = 0; k < aafUserList.length(); k++){ EPUser user = null; List usersList = null; - List userRolesList = new ArrayList(); + List userRolesList = new ArrayList<>(); JSONObject userRole = (JSONObject) aafUserList.get(k); Gson gson = new Gson(); ExternalAuthUserRole userRoleObj = gson.fromJson(userRole.toString(), ExternalAuthUserRole.class); @@@ -210,36 -208,32 +210,32 @@@ Map orgUserId = new HashMap<>(); orgUserId.put("orgUserIdValue", userRoleObj.getUser()); usersList = dataAccessService.executeNamedQuery("epUserAppId", orgUserId, null); - if(usersList != null && usersList.size() > 0){ + if(usersList != null && !usersList.isEmpty()){ user = usersList.get(0); } if(user == null){ // add user to fn_user(needs to be revisited after getting user info from AAF PORTAL-172) } - //for each role and user in that role, check if user exists in fn_user_role. If not, add - /*userRolesList = userRolesService.getUserRolesList(centralizedAppList.get(0).getId(), user.getId(), Long.valueOf(externalRoleDescription.getId())); - if(userRolesList == null || userRolesList.isEmpty()){ - // add userRole to fn_user_role(needs to be revisited after getting user info from AAF PORTAL-172) - }*/ } } - + } } } } } - + public DataAccessService dataAccessService() { return super.dataAccessService(); } + @Override public String[] tileDefinitions() { return super.tileDefinitions(); } public List addTileDefinitions() { - List definitions = new ArrayList(); + List definitions = new ArrayList<>(); definitions.add("/WEB-INF/defs/definitions.xml"); return definitions; } @@@ -266,7 -260,7 +262,7 @@@ @Bean public org.onap.portalsdk.core.auth.LoginStrategy coreLoginStrategy() { - if (SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) + if ("OIDC".equalsIgnoreCase(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim())) return new OpenIdConnectLoginStrategy(); else return new SimpleLoginStrategy(); @@@ -275,7 -269,7 +271,7 @@@ @Bean public LoginStrategy loginStrategy() { - if (SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim().equalsIgnoreCase("OIDC")) + if ("OIDC".equalsIgnoreCase(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM).trim())) return new OpenIdConnectLoginStrategy(); else return new SimpleLoginStrategy(); @@@ -287,13 -281,6 +283,6 @@@ @Override public void addInterceptors(InterceptorRegistry registry) { - // registry.addInterceptor(new - // StaticResourcesInterceptor()).addPathPatterns("/index.htm", - // "/applicationsHome", "/widgetsHome", "/admins", "/users", - // "/applications", "/widgets"); - // Excludes login/logout pages and REST endpoints used by other - // application servers. - registry.addInterceptor(sessionTimeoutInterceptor()).excludePathPatterns("/oid-login", "/portalApi/healthCheck", "/portalApi/healthCheck/", "/portalApi/healthCheckSuspend", "/portalApi/healthCheckSuspend/", "/portalApi/healthCheckResume", "/portalApi/healthCheckResume/", "/login_external",