use of edu.cornell.kfs.ksr.document.SecurityRequestDocument in project cu-kfs by CU-CommunityApps.
the class SecurityRequestDocumentAction method loadDocument.
@Override
protected void loadDocument(KualiDocumentFormBase kualiDocumentFormBase) throws WorkflowException {
super.loadDocument(kualiDocumentFormBase);
SecurityRequestDocumentForm documentForm = (SecurityRequestDocumentForm) kualiDocumentFormBase;
SecurityRequestDocument document = (SecurityRequestDocument) kualiDocumentFormBase.getDocument();
documentForm.setCurrentPrincipalId(document.getPrincipalId());
SpringContext.getBean(SecurityRequestDocumentService.class).prepareSecurityRequestDocument(document);
((SecurityRequestDocumentForm) kualiDocumentFormBase).setTabRoleIndexes(buildTabRoleIndexes(document));
}
use of edu.cornell.kfs.ksr.document.SecurityRequestDocument in project cu-kfs by CU-CommunityApps.
the class SecurityRequestDocumentAction method approve.
public ActionForward approve(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
final SecurityRequestDocumentForm documentForm = (SecurityRequestDocumentForm) form;
StringBuilder annotation = new StringBuilder();
final SecurityRequestDocument document = (SecurityRequestDocument) documentForm.getDocument();
if (documentForm.getMethodToCall().indexOf("approve") > -1) {
final String principalId = GlobalVariables.getUserSession().getPerson().getPrincipalId();
for (final SecurityRequestRole securityRequestRole : document.getSecurityRequestRoles()) {
LOG.info("approve() Checking if " + principalId + " has access");
if (canApproveRequestForRole(securityRequestRole, principalId, document)) {
annotation.append(securityRequestRole.getRoleInfo().getNamespaceCode()).append(" - ").append(securityRequestRole.getRoleInfo().getName()).append("\n");
}
}
}
documentForm.setAnnotation(annotation.toString());
return super.approve(mapping, form, request, response);
}
use of edu.cornell.kfs.ksr.document.SecurityRequestDocument in project cu-kfs by CU-CommunityApps.
the class SecurityRequestDocumentRule method isDocumentAttributesValid.
@Override
public boolean isDocumentAttributesValid(Document document, boolean validateRequired) {
boolean success = true;
SecurityRequestDocument securityRequestDocument = (SecurityRequestDocument) document;
for (int i = 0; i < securityRequestDocument.getSecurityRequestRoles().size(); i++) {
SecurityRequestRole securityRequestRole = securityRequestDocument.getSecurityRequestRoles().get(i);
KimType tempTypeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(securityRequestRole.getRoleInfo().getKimTypeId());
if (!securityRequestRole.isActive()) {
continue;
} else if (!securityRequestRole.isQualifiedRole()) {
continue;
} else {
String[] requiredQualifications = getRequiredQualificationsMap().get(tempTypeInfo.getServiceName());
if (requiredQualifications != null && requiredQualifications.length > 0) {
boolean qualsValid = true;
boolean[] hasQuals = new boolean[requiredQualifications.length];
for (SecurityRequestRoleQualification roleQualification : securityRequestRole.getRequestRoleQualifications()) {
Arrays.fill(hasQuals, false);
for (SecurityRequestRoleQualificationDetail qualDetail : roleQualification.getRoleQualificationDetails()) {
for (int j = requiredQualifications.length - 1; j >= 0; j--) {
if (requiredQualifications[j].equals(qualDetail.getAttributeName()) && StringUtils.isNotBlank(qualDetail.getAttributeValue())) {
hasQuals[j] = true;
}
}
}
for (boolean hasQual : hasQuals) {
qualsValid &= hasQual;
}
}
if (!qualsValid || securityRequestRole.getRequestRoleQualifications().size() == 0) {
success = false;
GlobalVariables.getMessageMap().putError(KSRPropertyConstants.SECURITY_REQUEST_DOC_REQUEST_ROLE + "[" + i + "].active", KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_QUALIFIER_MULTI_MISSING, new String[] { securityRequestRole.getRoleInfo().getName() });
}
} else if (securityRequestRole.getRequestRoleQualifications().size() == 0) {
securityRequestRole.getRequestRoleQualifications().add(SpringContext.getBean(SecurityRequestDocumentService.class).buildRoleQualificationLine(securityRequestRole, null));
}
}
for (int j = 0; j < securityRequestRole.getRequestRoleQualifications().size(); j++) {
SecurityRequestRoleQualification requestRoleQualification = securityRequestRole.getRequestRoleQualifications().get(j);
String typeId = securityRequestRole.getRoleInfo().getKimTypeId();
KimType typeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(typeId);
String fieldKeyPrefix = KSRPropertyConstants.SECURITY_REQUEST_DOC_REQUEST_ROLE + "[" + i + "]." + KSRPropertyConstants.SECURITY_REQUEST_DOC_ROLE_QUAL + "[" + j + "].";
success &= validateQualification(typeInfo, requestRoleQualification, fieldKeyPrefix);
}
}
return super.isDocumentAttributesValid(document, validateRequired) && success;
}
use of edu.cornell.kfs.ksr.document.SecurityRequestDocument in project cu-kfs by CU-CommunityApps.
the class SecurityRequestDocumentRule method processCustomSaveDocumentBusinessRules.
@Override
protected boolean processCustomSaveDocumentBusinessRules(Document document) {
boolean success = true;
SecurityRequestDocument securityRequestDocument = (SecurityRequestDocument) document;
if (StringUtils.isEmpty(securityRequestDocument.getPrincipalId())) {
success = false;
String input = KSRPropertyConstants.SECURITY_REQUEST_DOC_PRINCIPAL_ID;
GlobalVariables.getMessageMap().putErrorForSectionId(input, KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_PRINCIPAL_ID_MISSING);
}
return super.processCustomSaveDocumentBusinessRules(document) && success;
}
use of edu.cornell.kfs.ksr.document.SecurityRequestDocument in project cu-kfs by CU-CommunityApps.
the class SecurityRequestDerivedRoleTypeServiceImpl method getRoleMembersFromDerivedRole.
@Override
public List<RoleMembership> getRoleMembersFromDerivedRole(String namespaceCode, String roleName, Map<String, String> qualification) {
final List<RoleMembership> members = new ArrayList<RoleMembership>();
LOG.info("getRoleMembersFromDerivedRole() Generating role membership for role: " + roleName + " with qualification " + qualification);
String documentNumber = qualification.get(AttributeConstants.DOCUMENT_NUMBER);
SecurityRequestDocument document = null;
try {
document = (SecurityRequestDocument) KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(documentNumber);
} catch (WorkflowException e) {
LOG.error("getRoleMembersFromDerivedRole() Unable to retrieve security request document: " + documentNumber, e);
throw new RuntimeException("Unable to retrieve security request document: " + documentNumber, e);
}
for (final SecurityRequestRole requestRole : document.getSecurityRequestRoles()) {
members.addAll(getRoleMembersFromDerivedRole(roleName, document, requestRole));
}
LOG.info("getRoleMembersFromDerivedRole() Returning " + members.size() + " members");
return members;
}
Aggregations