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) {
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);
}
}
&& (globalRole.toLowerCase().startsWith("global_")))) {
CentralV2UserApp cua = new CentralV2UserApp();
cua.setUserId(null);
- CentralApp cenApp = new CentralApp(1L, epApp.getCreated(), epApp.getModified(),
- epApp.getCreatedId(), epApp.getModifiedId(), epApp.getRowNum(), epApp.getName(),
- epApp.getImageUrl(), epApp.getDescription(), epApp.getNotes(), epApp.getUrl(),
- epApp.getAlternateUrl(), epApp.getAppRestEndpoint(), epApp.getMlAppName(),
- epApp.getMlAppAdminId(), String.valueOf(epApp.getMotsId()), epApp.getAppPassword(),
- String.valueOf(epApp.getOpen()), String.valueOf(epApp.getEnabled()),
- epApp.getThumbnail(), epApp.getUsername(), epApp.getUebKey(), epApp.getUebSecret(),
- epApp.getUebTopicName());
+ CentralApp cenApp = new CentralApp.CentralAppBuilder().setId(1L).setCreated(epApp.getCreated())
+ .setModified(epApp.getModified()).setCreatedId(epApp.getCreatedId())
+ .setModifiedId(epApp.getModifiedId()).setRowNum(epApp.getRowNum())
+ .setName(epApp.getName()).setImageUrl(epApp.getImageUrl())
+ .setDescription(epApp.getAppDescription()).setNotes(epApp.getAppNotes())
+ .setUrl(epApp.getLandingPage()).setAlternateUrl(epApp.getLandingPage())
+ .setRestEndpoint(epApp.getAppRestEndpoint()).setMlAppName(epApp.getMlAppName())
+ .setMlAppAdminId(epApp.getMlAppAdminId()).setMotsId(String.valueOf(epApp.getMotsId()))
+ .setAppPassword(epApp.getAppBasicAuthPassword()).setOpen(String.valueOf(epApp.getOpen()))
+ .setEnabled(String.valueOf(epApp.getEnabled())).setThumbnail(epApp.getThumbnail())
+ .setUsername(epApp.getAppBasicAuthUsername()).setUebKey(epApp.getUebKey())
+ .setUebSecret(epApp.getUebSecret()).setUebTopicName(epApp.getUebTopicName())
+ .createCentralApp();
cenApp.setAppPassword(EPCommonSystemProperties.APP_DISPLAY_PASSWORD);
cua.setApp(cenApp);
Long appId = null;
} else {
userRoleId = userApp.getRole().getAppRoleId();
}
- CentralV2Role cenRole = new CentralV2Role(userRoleId, userApp.getRole().getCreated(),
- userApp.getRole().getModified(), userApp.getRole().getCreatedId(),
- userApp.getRole().getModifiedId(), userApp.getRole().getRowNum(),
- userApp.getRole().getName(), userApp.getRole().getActive(),
- userApp.getRole().getPriority(), roleFunctionSet, null, null);
+ CentralV2Role cenRole = new CentralV2Role.CentralV2RoleBuilder().setId(userRoleId)
+ .setCreated(userApp.getRole().getCreated()).setModified(userApp.getRole().getModified())
+ .setCreatedId(userApp.getRole().getCreatedId())
+ .setModifiedId(userApp.getRole().getModifiedId())
+ .setRowNum(userApp.getRole().getRowNum()).setName(userApp.getRole().getName())
+ .setActive(userApp.getRole().getActive()).setPriority(userApp.getRole().getPriority())
+ .setRoleFunctions(roleFunctionSet).setChildRoles(null).setParentRoles(null)
+ .createCentralV2Role();
cua.setRole(cenRole);
userAppList.getUserApps().add(cua);
}
public CentralV2Role getRoleInfo(Long roleId, String uebkey) throws Exception {
final Map<String, Long> params = new HashMap<>();
List<CentralV2Role> roleList = new ArrayList<>();
- CentralV2Role cenRole = new CentralV2Role();
+ CentralV2Role cenRole = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role();
List<EPRole> roleInfo = null;
List<EPApp> app = null;
try {
return roleInfo;
}
+ @Override
@SuppressWarnings("unchecked")
- private List<EPRole> getPortalAppRoleInfo(Long roleId) {
+ public List<EPRole> getPortalAppRoleInfo(Long roleId) {
List<EPRole> roleInfo;
final Map<String, Long> getPortalAppRoleParams = new HashMap<>();
getPortalAppRoleParams.put("roleId", roleId);
SortedSet<CentralV2Role> childRoles = new TreeSet<>();
SortedSet<CentralV2Role> parentRoles = new TreeSet<>();
CentralV2Role cenRole = null;
- if (role.getAppRoleId() == null) {
- cenRole = new CentralV2Role(role.getId(), role.getCreated(), role.getModified(), role.getCreatedId(),
- role.getModifiedId(), role.getRowNum(), role.getName(), role.getActive(), role.getPriority(),
- roleFunctionSet, childRoles, parentRoles);
- } else {
- cenRole = new CentralV2Role(role.getAppRoleId(), role.getCreated(), role.getModified(),
- role.getCreatedId(), role.getModifiedId(), role.getRowNum(), role.getName(), role.getActive(),
- role.getPriority(), roleFunctionSet, childRoles, parentRoles);
- }
+ if (role.getAppRoleId() == null) {
+ cenRole = new CentralV2Role.CentralV2RoleBuilder().setId(role.getId()).setCreated(role.getCreated())
+ .setModified(role.getModified()).setCreatedId(role.getCreatedId())
+ .setModifiedId(role.getModifiedId()).setRowNum(role.getRowNum()).setName(role.getName())
+ .setActive(role.getActive()).setPriority(role.getPriority()).setRoleFunctions(roleFunctionSet)
+ .setChildRoles(childRoles).setParentRoles(parentRoles).createCentralV2Role();
+ } else {
+ cenRole = new CentralV2Role.CentralV2RoleBuilder().setId(role.getAppRoleId())
+ .setCreated(role.getCreated()).setModified(role.getModified()).setCreatedId(role.getCreatedId())
+ .setModifiedId(role.getModifiedId()).setRowNum(role.getRowNum()).setName(role.getName())
+ .setActive(role.getActive()).setPriority(role.getPriority()).setRoleFunctions(roleFunctionSet)
+ .setChildRoles(childRoles).setParentRoles(parentRoles).createCentralV2Role();
+ }
roleList.add(cenRole);
}
return roleList;
.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
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);
}
}
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)) {
roleFunction = dataAccessService.executeNamedQuery("getAppFunctionOnCodeAndAppId",
appFuncsParams, null);
}
- if (!roleFunction.isEmpty()) {
+ if (!roleFunction.isEmpty() && roleId != null) {
EPAppRoleFunction apRoleFunction = new EPAppRoleFunction();
apRoleFunction.setAppId(app.getId());
apRoleFunction.setRoleId(roleId);
params.put("uebKey", app.getUebKey());
List<BulkUploadUserRoles> userRolesList = null;
Integer userRolesAdded = 0;
- if (app.getCentralAuth()) {
+ if (app.getRolesInAAF()) {
userRolesList = dataAccessService.executeNamedQuery("getBulkUserRoles", params, null);
for (BulkUploadUserRoles userRolesUpload : userRolesList) {
if (!userRolesUpload.getOrgUserId().equals("su1234")) {
}
}
if (!found) {
- CentralV2Role cenrole = new CentralV2Role();
+ CentralV2Role cenrole = new CentralV2Role.CentralV2RoleBuilder().createCentralV2Role();
cenrole.setName(role.getRoleName());
cenrole.setId(role.getRoleId());
cenrole.setActive(role.isActive());
}
private CentralV2Role convertRoleToCentralV2Role(EPRole role) {
- return new CentralV2Role(role.getId(), role.getCreated(), role.getModified(), role.getCreatedId(),
- role.getModifiedId(), role.getRowNum(), role.getName(), role.getActive(), role.getPriority(),
- new TreeSet<>(), new TreeSet<>(), new TreeSet<>());
+ return new CentralV2Role.CentralV2RoleBuilder().setId(role.getId()).setCreated(role.getCreated())
+ .setModified(role.getModified()).setCreatedId(role.getCreatedId()).setModifiedId(role.getModifiedId())
+ .setRowNum(role.getRowNum()).setName(role.getName()).setActive(role.getActive())
+ .setPriority(role.getPriority()).setRoleFunctions(new TreeSet<>()).setChildRoles(new TreeSet<>())
+ .setParentRoles(new TreeSet<>()).createCentralV2Role();
}
@Override
params.put("roleId", String.valueOf(roleId));
List<BulkUploadUserRoles> userRolesList = null;
Integer userRolesAdded = 0;
- if (app.getCentralAuth()) {
+ if (app.getRolesInAAF()) {
userRolesList = dataAccessService.executeNamedQuery("getBulkUsersForSingleRole", params, null);
for (BulkUploadUserRoles userRolesUpload : userRolesList) {
userRolesUpload.setRoleName(modifiedRoleName);