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);
}
}
@SuppressWarnings("unchecked")
private CentralV2User createEPUser(EPUser userInfo, Set<EPUserApp> userAppSet, EPApp app) throws Exception {
final Map<String, Long> params = new HashMap<>();
- CentralV2User userAppList = new CentralV2User();
+ CentralV2User userAppList = new CentralV2User.CentralV2UserBuilder().createCentralV2User();
CentralV2User user1 = null;
final Map<String, Long> params1 = new HashMap<>();
List<EPRole> globalRoleList = new ArrayList<>();
&& (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);
}
}
}
- user1 = new CentralV2User(null, userInfo.getCreated(), userInfo.getModified(), userInfo.getCreatedId(),
- userInfo.getModifiedId(), userInfo.getRowNum(), userInfo.getOrgId(), userInfo.getManagerId(),
- userInfo.getFirstName(), userInfo.getMiddleInitial(), userInfo.getLastName(), userInfo.getPhone(),
- userInfo.getFax(), userInfo.getCellular(), userInfo.getEmail(), userInfo.getAddressId(),
- userInfo.getAlertMethodCd(), userInfo.getHrid(), userInfo.getOrgUserId(), userInfo.getOrgCode(),
- userInfo.getAddress1(), userInfo.getAddress2(), userInfo.getCity(), userInfo.getState(),
- userInfo.getZipCode(), userInfo.getCountry(), userInfo.getOrgManagerUserId(),
- userInfo.getLocationClli(), userInfo.getBusinessCountryCode(), userInfo.getBusinessCountryName(),
- userInfo.getBusinessUnit(), userInfo.getBusinessUnitName(), userInfo.getDepartment(),
- userInfo.getDepartmentName(), userInfo.getCompanyCode(), userInfo.getCompany(),
- userInfo.getZipCodeSuffix(), userInfo.getJobTitle(), userInfo.getCommandChain(),
- userInfo.getSiloStatus(), userInfo.getCostCenter(), userInfo.getFinancialLocCode(),
- userInfo.getLoginId(), userInfo.getLoginPwd(), userInfo.getLastLoginDate(), userInfo.getActive(),
- userInfo.getInternal(), userInfo.getSelectedProfileId(), userInfo.getTimeZoneId(),
- userInfo.isOnline(), userInfo.getChatId(), userAppList.getUserApps(), null);
+ user1 = new CentralV2User.CentralV2UserBuilder().setId(null).setCreated(userInfo.getCreated())
+ .setModified(userInfo.getModified()).setCreatedId(userInfo.getCreatedId())
+ .setModifiedId(userInfo.getModifiedId()).setRowNum(userInfo.getRowNum())
+ .setOrgId(userInfo.getOrgId()).setManagerId(userInfo.getManagerId())
+ .setFirstName(userInfo.getFirstName()).setMiddleInitial(userInfo.getMiddleInitial())
+ .setLastName(userInfo.getLastName()).setPhone(userInfo.getPhone()).setFax(userInfo.getFax())
+ .setCellular(userInfo.getCellular()).setEmail(userInfo.getEmail())
+ .setAddressId(userInfo.getAddressId()).setAlertMethodCd(userInfo.getAlertMethodCd())
+ .setHrid(userInfo.getHrid()).setOrgUserId(userInfo.getOrgUserId()).setOrgCode(userInfo.getOrgCode())
+ .setAddress1(userInfo.getAddress1()).setAddress2(userInfo.getAddress2()).setCity(userInfo.getCity())
+ .setState(userInfo.getState()).setZipCode(userInfo.getZipCode()).setCountry(userInfo.getCountry())
+ .setOrgManagerUserId(userInfo.getOrgManagerUserId()).setLocationClli(userInfo.getLocationClli())
+ .setBusinessCountryCode(userInfo.getBusinessCountryCode())
+ .setBusinessCountryName(userInfo.getBusinessCountryName())
+ .setBusinessUnit(userInfo.getBusinessUnit()).setBusinessUnitName(userInfo.getBusinessUnitName())
+ .setDepartment(userInfo.getDepartment()).setDepartmentName(userInfo.getDepartmentName())
+ .setCompanyCode(userInfo.getCompanyCode()).setCompany(userInfo.getCompany())
+ .setZipCodeSuffix(userInfo.getZipCodeSuffix()).setJobTitle(userInfo.getJobTitle())
+ .setCommandChain(userInfo.getCommandChain()).setSiloStatus(userInfo.getSiloStatus())
+ .setCostCenter(userInfo.getCostCenter()).setFinancialLocCode(userInfo.getFinancialLocCode())
+ .setLoginId(userInfo.getLoginId()).setLoginPwd(userInfo.getLoginPwd())
+ .setLastLoginDate(userInfo.getLastLoginDate()).setActive(userInfo.getActive())
+ .setInternal(userInfo.getInternal()).setSelectedProfileId(userInfo.getSelectedProfileId())
+ .setTimeZoneId(userInfo.getTimeZoneId()).setOnline(userInfo.isOnline())
+ .setChatId(userInfo.getChatId()).setUserApps(userAppList.getUserApps()).setPseudoRoles(null)
+ .createCentralV2User();
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "createEPUser: createEPUser failed", e);
throw e;
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 {
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);