diff options
Diffstat (limited to 'ecomp-portal-BE-common/src/main/java')
2 files changed, 17 insertions, 9 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ExternalAccessRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ExternalAccessRolesServiceImpl.java index 17d9ceb0..491743f5 100644 --- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ExternalAccessRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/ExternalAccessRolesServiceImpl.java @@ -444,15 +444,15 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic List <EPRole> getRoleCreated = null; if (!app.getId().equals(PortalConstants.PORTAL_APP_ID)) { List<EPRole> roleCreated = dataAccessService.getList(EPRole.class, - " where role_name = '" + addRoleInDB.getName() +"'", null, null); + " where role_name = '" + addRoleInDB.getName() +"' and app_id = "+ app.getId(), null, null); EPRole epUpdateRole = roleCreated.get(0); epUpdateRole.setAppRoleId(epUpdateRole.getId()); dataAccessService.saveDomainObject(epUpdateRole, null); getRoleCreated = dataAccessService.getList(EPRole.class, - " where role_name = '" + addRoleInDB.getName() +"'", null, null); + " where role_name = '" + addRoleInDB.getName() +"' and app_id = "+ app.getId() , null, null); } else{ getRoleCreated = dataAccessService.getList(EPRole.class, - " where role_name = '" + addRoleInDB.getName() +"'", null, null); + " where role_name = '" + addRoleInDB.getName() +"' and app_id is null", null, null); } // Add role in External Access system boolean response = addNewRoleInExternalSystem(getRoleCreated, app); @@ -611,7 +611,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic if (((epApp.getId().equals(app.getId())) && (!userApp.getRole().getId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID))) || ((epApp.getId().equals(PortalConstants.PORTAL_APP_ID)) - && (globalRole.startsWith("global_")))) { + && (globalRole.toLowerCase().startsWith("global_")))) { CentralUserApp cua = new CentralUserApp(); cua.setUserId(null); CentralApp cenApp = new CentralApp(1L, epApp.getCreated(), epApp.getModified(), @@ -633,7 +633,13 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic roleFunc.getCode(), roleFunc.getName(), null, null); roleFunctionSet.add(cenRoleFunc); } - CentralRole cenRole = new CentralRole(userApp.getRole().getAppRoleId(), + Long userRoleId = null; + if(globalRole.toLowerCase().startsWith("global_") && epApp.getId().equals(PortalConstants.PORTAL_APP_ID)){ + userRoleId = userApp.getRole().getId(); + } else{ + userRoleId = userApp.getRole().getAppRoleId(); + } + CentralRole cenRole = new CentralRole(userRoleId, userApp.getRole().getCreated(), userApp.getRole().getModified(), userApp.getRole().getCreatedId(), userApp.getRole().getModifiedId(), userApp.getRole().getRowNum(), userApp.getRole().getName(), @@ -750,7 +756,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "getRoleFunction failed", e); - throw new Exception("getRoleFunction failed"); + throw new Exception("getRoleFunction failed", e); } return getRoleFuncList.get(0); } diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java index 1315c5e9..7e7a55a1 100644 --- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/UserRolesCommonServiceImpl.java @@ -771,9 +771,10 @@ public class UserRolesCommonServiceImpl { * @param mapper * @param searchService * @param applicationsRestClientService + * @return * @throws Exception */ - private void addRemoteUser(List<RoleInAppForUser> roleInAppForUserList, String userId, EPApp app, ObjectMapper mapper, SearchService searchService, ApplicationsRestClientService applicationsRestClientService) throws Exception{ + private EPUser addRemoteUser(List<RoleInAppForUser> roleInAppForUserList, String userId, EPApp app, ObjectMapper mapper, SearchService searchService, ApplicationsRestClientService applicationsRestClientService) throws Exception{ EPUser addRemoteUser = null; if (remoteUserShouldBeCreated(roleInAppForUserList)) { @@ -787,6 +788,7 @@ public class UserRolesCommonServiceImpl { // return null; } } + return addRemoteUser; } /** @@ -882,7 +884,7 @@ public class UserRolesCommonServiceImpl { remoteAppUser = checkIfRemoteUserExits(userId, app, applicationsRestClientService); if (remoteAppUser == null) { - addRemoteUser(roleInAppForUserList, userId, app, mapper, searchService, applicationsRestClientService); + remoteAppUser = addRemoteUser(roleInAppForUserList, userId, app, mapper, searchService, applicationsRestClientService); } if (remoteAppUser != null) { Set<EcompRole> userRolesInRemoteApp = postUsersRolesToRemoteApp(roleInAppForUserList, mapper, @@ -1336,7 +1338,7 @@ public class UserRolesCommonServiceImpl { EPUser remoteAppUser = null; remoteAppUser = checkIfRemoteUserExits(userId.getOrgUserId(), app, applicationsRestClientService); if (remoteAppUser == null) { - addRemoteUser(roleInAppForUserList, userId.getOrgUserId(), app, mapper, searchService, applicationsRestClientService); + remoteAppUser = addRemoteUser(roleInAppForUserList, userId.getOrgUserId(), app, mapper, searchService, applicationsRestClientService); reqMessage = "Saved Successfully"; } if (remoteAppUser != null) { |