use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles in project cu-kfs by CU-CommunityApps.
the class SecurityProvisioningMaintainable method prepareForSave.
/**
* Updates the security group IDs and provisioning IDs on the related
* provisioning-group and dependent-role objects accordingly.
*/
@Override
public void prepareForSave() {
super.prepareForSave();
SecurityProvisioning provisioning = (SecurityProvisioning) getDataObject();
for (SecurityProvisioningGroup provisioningGroup : provisioning.getSecurityProvisioningGroups()) {
provisioningGroup.setSecurityGroupId(provisioning.getSecurityGroupId());
if (CollectionUtils.isNotEmpty(provisioningGroup.getDependentRoles())) {
for (SecurityProvisioningGroupDependentRoles dependentRole : provisioningGroup.getDependentRoles()) {
dependentRole.setProvisioningId(provisioningGroup.getProvisioningId());
}
}
}
}
use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles in project cu-kfs by CU-CommunityApps.
the class SecurityProvisioningGroupRule method isDependentRoleUniqueForGroup.
private boolean isDependentRoleUniqueForGroup(MaintenanceDocument document, SecurityProvisioningGroupDependentRoles dependentRole, int index, int indexRole) {
boolean success = true;
SecurityProvisioning securityProvisioning = (SecurityProvisioning) document.getDocumentDataObject();
List<SecurityProvisioningGroup> securityProvisioningGroupList = securityProvisioning.getSecurityProvisioningGroups();
SecurityProvisioningGroup securityProvisioningGroup = securityProvisioningGroupList.get(index);
for (int i = 0; i < securityProvisioningGroup.getDependentRoles().size(); i++) {
SecurityProvisioningGroupDependentRoles tempDependentRole = securityProvisioningGroup.getDependentRoles().get(i);
if (i == indexRole || StringUtils.isBlank(tempDependentRole.getRoleId())) {
continue;
}
if (StringUtils.equals(tempDependentRole.getRoleId(), dependentRole.getRoleId())) {
success = false;
String errorPath = (indexRole < 0 || index < 0) ? KSRPropertyConstants.PROVISIONING_ROLE_ID : buildPropertyPath(buildIndexedProperty(KSRConstants.SECURITY_PROVISIONING_GROUPS, index), buildIndexedProperty(KSRConstants.DEPENDENT_ROLES, indexRole), KSRPropertyConstants.PROVISIONING_ROLE_ID);
if ((indexRole == -1) || (indexRole > i)) {
GlobalVariables.getMessageMap().putError(errorPath, KSRKeyConstants.ERROR_SECURITY_PROVISIONING_GROUP_DEPENDENT_ROLE_UNIQUE, getRoleNameForErrorMessage(dependentRole.getRole()));
}
}
}
return success;
}
use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles in project cu-kfs by CU-CommunityApps.
the class SecurityProvisioningGroupRule method buildDependentString.
private String buildDependentString(String roleID, Map<String, SecurityProvisioningGroup> provisioningMap) {
String temp = "|" + roleID + "|";
SecurityProvisioningGroup securityProvisioningGroup = provisioningMap.get(roleID);
provisioningMap.remove(roleID);
if ((securityProvisioningGroup != null) && (securityProvisioningGroup.getDependentRoles().size() > 0)) {
for (SecurityProvisioningGroupDependentRoles dependentRole : securityProvisioningGroup.getDependentRoles()) {
if (dependentRole.isActive() && StringUtils.isNotBlank(dependentRole.getRoleId())) {
String dependentRoleID = dependentRole.getRoleId();
temp += buildDependentString(dependentRoleID, provisioningMap);
}
}
}
return "," + temp;
}
use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles in project cu-kfs by CU-CommunityApps.
the class SecurityProvisioningGroupRule method processCustomAddCollectionLineBusinessRules.
@Override
public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject line) {
boolean success = true;
if (line instanceof SecurityProvisioningGroupDependentRoles) {
SecurityProvisioningGroupDependentRoles dependentRole = (SecurityProvisioningGroupDependentRoles) line;
success = validateDependentRole(dependentRole);
} else if (line instanceof SecurityProvisioningGroup) {
SecurityProvisioningGroup securityProvisioningGroup = (SecurityProvisioningGroup) line;
success = validateSecurityProvisioningGroup(document, securityProvisioningGroup);
if (success && securityProvisioningGroup.isActive()) {
success = isDuplicateSecurityProvisioningGroup(document, (SecurityProvisioningGroup) line);
}
}
success &= super.processCustomAddCollectionLineBusinessRules(document, collectionName, line);
return success;
}
use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles in project cu-kfs by CU-CommunityApps.
the class SecurityRequestDocumentRule method processCustomRouteDocumentBusinessRules.
@Override
protected boolean processCustomRouteDocumentBusinessRules(Document document) {
boolean success = true;
SecurityRequestDocument securityRequestDocument = (SecurityRequestDocument) document;
if (!isDocumentChanged(securityRequestDocument)) {
success = false;
String input = KRADConstants.DOCUMENT_PROPERTY_NAME + "." + KRADConstants.DOCUMENT_HEADER_PROPERTY_NAME;
GlobalVariables.getMessageMap().putError(input, KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_CHANGE_MISSING);
} else {
List<SecurityRequestRole> activeRoles = new ArrayList<SecurityRequestRole>();
Map<String, String> indexes = new HashMap<String, String>();
for (int i = 0; i < securityRequestDocument.getSecurityRequestRoles().size(); i++) {
SecurityRequestRole securityRequestRole = securityRequestDocument.getSecurityRequestRoles().get(i);
indexes.put(securityRequestRole.getRoleId(), Integer.toString(i));
if (securityRequestRole.isActive()) {
activeRoles.add(securityRequestRole);
}
}
for (int i = 0; i < activeRoles.size(); i++) {
List<String> rolesNeeded = new ArrayList<String>();
SecurityRequestRole securityRequestRole = activeRoles.get(i);
Map<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put(KSRPropertyConstants.PROVISIONING_ROLE_ID, securityRequestRole.getRoleId());
hashMap.put(KSRPropertyConstants.SECURITY_GROUP_ID, securityRequestDocument.getSecurityGroupId());
hashMap.put(KSRPropertyConstants.SECURITY_GROUP_ACTIVE_INDICATOR, Boolean.TRUE);
List<SecurityProvisioningGroup> objList = (List<SecurityProvisioningGroup>) KRADServiceLocator.getBusinessObjectService().findMatching(SecurityProvisioningGroup.class, hashMap);
SecurityProvisioningGroup securityProvisioningGroup = null;
if ((objList != null) && (objList.size() != 0)) {
securityProvisioningGroup = objList.get(0);
}
if (securityProvisioningGroup != null) {
for (int j = 0; j < securityProvisioningGroup.getDependentRoles().size(); j++) {
SecurityProvisioningGroupDependentRoles dependentRole = securityProvisioningGroup.getDependentRoles().get(j);
if (!dependentRole.isActive()) {
continue;
}
boolean found = false;
for (int k = 0; k < activeRoles.size(); k++) {
if (activeRoles.get(k).getRoleId().equals(dependentRole.getRoleId())) {
found = true;
}
}
if (!found) {
String index = indexes.get(dependentRole.getRoleId());
String input = KSRPropertyConstants.SECURITY_REQUEST_DOC_REQUEST_ROLE + "[" + index + "].active";
GlobalVariables.getMessageMap().putError(input, KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_DEPENDENT_ROLE_MISSING, new String[] { securityRequestRole.getRoleInfo().getName(), dependentRole.getRole().getName() });
rolesNeeded.add(dependentRole.getRole().getName());
success = false;
}
}
}
}
}
return super.processCustomRouteDocumentBusinessRules(document) && success;
}
Aggregations