diff options
Diffstat (limited to 'ecomp-portal-BE-common')
3 files changed, 33 insertions, 12 deletions
diff --git a/ecomp-portal-BE-common/pom.xml b/ecomp-portal-BE-common/pom.xml index d36d740b..19d32431 100644 --- a/ecomp-portal-BE-common/pom.xml +++ b/ecomp-portal-BE-common/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.portal</groupId> <artifactId>onap-portal-parent</artifactId> - <version>3.2.0</version> + <version>3.3.0</version> </parent> <artifactId>portal-be-common</artifactId> diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java index 4e83b921..241468c3 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java @@ -311,8 +311,8 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic boolean isRoleNameChanged = false; if (!desc.equals(updateExtRole.getName())) { isRoleNameChanged = true; + addRole(updateExtRole, app.getUebKey()); //interchange 314 -315 deleteRoleInExtSystem(mapper, name); - addRole(updateExtRole, app.getUebKey()); // add partner functions to the global role in External // Auth System if (!list.isEmpty() && isGlobalRole) { @@ -348,7 +348,7 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic roleFunc.getCode(), roleFunc.getAction()); extAddRolePerms = new ExternalAccessRolePerms(extAddPerms, app.getNameSpace() + "." + updateExtRole.getName().replaceAll( - EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_")); + EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_")); response = addRoleFuncExtSysRestAPI(mapper, extAddRolePerms, headers); } } @@ -1973,14 +1973,29 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic .containsKey(extAuthrole.substring(app.getNameSpace().length() + 1))) { EPRole localAddFuntionRole = currentRolesInDB .get(extAuthrole.substring(app.getNameSpace().length() + 1)); + + String key = extAuthrole.substring(app.getNameSpace().length() + 1); + Boolean isaddAppRoleFuncRequired = true; + if(localAddFuntionRole == null && key.contains("-")) { + key = key.replaceAll(EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_"); + localAddFuntionRole = currentRolesInDB.get(key); + if(localAddFuntionRole !=null) { + isaddAppRoleFuncRequired = false; + } + } + + logger.info("key >>>>>"+key); + logger.info("localAddFuntionRole >>>>>"+localAddFuntionRole); if (localAddFuntionRole == null) { checkAndAddRoleInDB(app, currentRolesInDB, roleFunctionList, extAuthrole); } else { - EPAppRoleFunction addAppRoleFunc = new EPAppRoleFunction(); - addAppRoleFunc.setAppId(app.getId()); - addAppRoleFunc.setCode(roleFunctionList.get(0).getCode()); - addAppRoleFunc.setRoleId(localAddFuntionRole.getId()); - dataAccessService.saveDomainObject(addAppRoleFunc, null); + if(isaddAppRoleFuncRequired) { + EPAppRoleFunction addAppRoleFunc = new EPAppRoleFunction(); + addAppRoleFunc.setAppId(app.getId()); + addAppRoleFunc.setCode(roleFunctionList.get(0).getCode()); + addAppRoleFunc.setRoleId(localAddFuntionRole.getId()); + dataAccessService.saveDomainObject(addAppRoleFunc, null); + } } } // This block is to save global role function if exists @@ -2684,11 +2699,11 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic applicationRolesList = getAppRoles(app.getId()); List<String> applicationRoleIdList = new ArrayList<>(); for (EPRole applicationRole : applicationRolesList) { - applicationRoleIdList.add(applicationRole.getName()); + applicationRoleIdList.add(applicationRole.getName().trim()); } List<EPRole> roleListToBeAddInEcompDB = new ArrayList<>(); for (EPRole aafRole : finalRoleList) { - if (!applicationRoleIdList.contains(aafRole.getName())) { + if (!applicationRoleIdList.contains(aafRole.getName().trim())) { roleListToBeAddInEcompDB.add(aafRole); } } @@ -2822,7 +2837,12 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic String name = extRole.getJSONObject(i).getString(ROLE_NAME); String actualRoleName = name.substring(app.getNameSpace().length() + 1); if (extRole.getJSONObject(i).has(EXTERNAL_AUTH_ROLE_DESCRIPTION)) { - actualRoleName = extRole.getJSONObject(i).getString(EXTERNAL_AUTH_ROLE_DESCRIPTION); + String description = extRole.getJSONObject(i).getString(EXTERNAL_AUTH_ROLE_DESCRIPTION); + + if(actualRoleName.replaceAll(EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS_EXCLUDE_HYPHEN,"_") + .equalsIgnoreCase(description.replaceAll(EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS_EXCLUDE_HYPHEN,"_"))){ + actualRoleName = description; + } } SortedSet<ExternalAccessPerms> externalAccessPermsOfRole = new TreeSet<>(); if (extRole.getJSONObject(i).has(EXTERNAL_AUTH_PERMS)) { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java index 7c9aa76b..e5543a36 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java @@ -81,7 +81,8 @@ public class EcompPortalUtils { // It is a regular expression used for while creating a External Central Auth // Role - public static final String EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS = "([^A-Z^a-z^0-9^\\.^%^(^)^=^:])"; + public static final String EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS = "([^A-Z^a-z^0-9^\\.^%^(^)^=^:^-])"; + public static final String EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS_EXCLUDE_HYPHEN = "([^A-Z^a-z^0-9^\\.^%^(^)^=^:])"; public static final String slash = "/"; |