Search in sources :

Example 6 with SecurityRequestRole

use of edu.cornell.kfs.ksr.businessobject.SecurityRequestRole in project cu-kfs by CU-CommunityApps.

the class SecurityRequestPostProcessingServiceImpl method postProcessSecurityRequest.

public void postProcessSecurityRequest(SecurityRequestDocument document) {
    String principalId = document.getPrincipalId();
    LOG.info("postProcessSecurityRequest() Processing security request document: " + document.getDocumentNumber() + " for principal id: " + principalId);
    for (SecurityRequestRole requestRole : document.getSecurityRequestRoles()) {
        if (requestRole.isActive()) {
            if (requestRole.isQualifiedRole()) {
                assignUpdatePrincipalRoleQualifications(requestRole, principalId);
            } else if (!requestRole.isCurrentActive()) {
                assignPrincipalToRole(requestRole, principalId);
            }
        } else if (requestRole.isCurrentActive()) {
            removePrincipalFromRole(requestRole, principalId);
        }
    }
}
Also used : SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)

Example 7 with SecurityRequestRole

use of edu.cornell.kfs.ksr.businessobject.SecurityRequestRole in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentAction method deleteQualificationLine.

public ActionForward deleteQualificationLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    SecurityRequestDocumentForm documentForm = (SecurityRequestDocumentForm) form;
    SecurityRequestDocument document = (SecurityRequestDocument) documentForm.getDocument();
    int roleRequestIndex = -1;
    int qualificationIndex = -1;
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName) && StringUtils.contains(parameterName, ".roleRequestIndex") && StringUtils.contains(parameterName, ".qualificationIndex")) {
        String roleRequestIndexStr = StringUtils.substringBetween(parameterName, ".roleRequestIndex", ".");
        roleRequestIndex = Integer.parseInt(roleRequestIndexStr);
        String qualificationIndexStr = StringUtils.substringBetween(parameterName, ".qualificationIndex", ".");
        qualificationIndex = Integer.parseInt(qualificationIndexStr);
    } else {
        LOG.error("deleteQualificationLine() Unable to find qualification index for line to delete");
        throw new RuntimeException("Unable to find qualification index for line to delete");
    }
    SecurityRequestRole securityRequestRole = document.getSecurityRequestRoles().get(roleRequestIndex);
    if (securityRequestRole == null) {
        LOG.error("deleteQualificationLine() Security request role not found for index: " + roleRequestIndex);
        throw new RuntimeException("Security request role not found for index: " + roleRequestIndex);
    }
    securityRequestRole.getRequestRoleQualifications().remove(qualificationIndex);
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 8 with SecurityRequestRole

use of edu.cornell.kfs.ksr.businessobject.SecurityRequestRole in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentAction method addQualificationLine.

public ActionForward addQualificationLine(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    SecurityRequestDocumentForm documentForm = (SecurityRequestDocumentForm) form;
    SecurityRequestDocument document = (SecurityRequestDocument) documentForm.getDocument();
    int roleRequestIndex = -1;
    String parameterName = (String) request.getAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE);
    if (StringUtils.isNotBlank(parameterName) && StringUtils.contains(parameterName, ".roleRequestIndex")) {
        String roleRequestIndexStr = StringUtils.substringBetween(parameterName, ".roleRequestIndex", ".");
        roleRequestIndex = Integer.parseInt(roleRequestIndexStr);
    } else {
        LOG.error("addQualificationLine() Unable to find role request index for new qualification line");
        throw new RuntimeException("Unable to find role request index for new qualification line");
    }
    SecurityRequestRole securityRequestRole = document.getSecurityRequestRoles().get(roleRequestIndex);
    if (securityRequestRole == null) {
        LOG.error("addQualificationLine() Security request role not found for index: " + roleRequestIndex);
        throw new RuntimeException("Security request role not found for index: " + roleRequestIndex);
    }
    String errorPath = "document.securityRequestRoles[" + roleRequestIndex + "].newRequestRoleQualification";
    boolean rulePassed = KRADServiceLocatorWeb.getKualiRuleService().applyRules(new AddQualificationLineEvent(errorPath, document, securityRequestRole.getNewRequestRoleQualification()));
    if (rulePassed) {
        securityRequestRole.getRequestRoleQualifications().add(securityRequestRole.getNewRequestRoleQualification());
        SecurityRequestRoleQualification newRequestRoleQualification = SpringContext.getBean(SecurityRequestDocumentService.class).buildRoleQualificationLine(securityRequestRole, null);
        securityRequestRole.setNewRequestRoleQualification(newRequestRoleQualification);
    }
    return mapping.findForward(KFSConstants.MAPPING_BASIC);
}
Also used : SecurityRequestRoleQualification(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification) AddQualificationLineEvent(edu.cornell.kfs.ksr.document.validation.impl.AddQualificationLineEvent) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) SecurityRequestDocumentService(edu.cornell.kfs.ksr.service.SecurityRequestDocumentService) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 9 with SecurityRequestRole

use of edu.cornell.kfs.ksr.businessobject.SecurityRequestRole 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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SecurityProvisioningGroupDependentRoles(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles) SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) ArrayList(java.util.ArrayList) List(java.util.List) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Aggregations

SecurityRequestRole (edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)9 SecurityRequestDocument (edu.cornell.kfs.ksr.document.SecurityRequestDocument)6 SecurityRequestRoleQualification (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification)3 ArrayList (java.util.ArrayList)3 SecurityProvisioningGroup (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup)2 SecurityGroupTab (edu.cornell.kfs.ksr.businessobject.SecurityGroupTab)1 SecurityProvisioningGroupDependentRoles (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles)1 SecurityRequestRoleQualificationDetail (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail)1 AddQualificationLineEvent (edu.cornell.kfs.ksr.document.validation.impl.AddQualificationLineEvent)1 SecurityRequestDocumentService (edu.cornell.kfs.ksr.service.SecurityRequestDocumentService)1 HashMap (java.util.HashMap)1 List (java.util.List)1 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)1 RoleMembership (org.kuali.kfs.kim.api.role.RoleMembership)1 KimType (org.kuali.kfs.kim.impl.type.KimType)1