Search in sources :

Example 1 with MaintenanceDocumentBase

use of org.kuali.kfs.kns.document.MaintenanceDocumentBase in project cu-kfs by CU-CommunityApps.

the class UserProcurementProfileAuthorizer method getDocumentActions.

@Override
public Set<String> getDocumentActions(Document document, Person user, Set<String> documentActions) {
    Set<String> documentActions1 = super.getDocumentActions(document, user, documentActions);
    if (documentActions1.contains(KRADConstants.KUALI_ACTION_CAN_EDIT) && !documentActions1.contains(KRADConstants.KUALI_ACTION_CAN_SAVE)) {
        documentActions1.add(KRADConstants.KUALI_ACTION_CAN_SAVE);
    }
    if (documentActions1.contains(KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE)) {
        documentActions1.remove(KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE);
    }
    if (documentActions1.contains(KRADConstants.KUALI_ACTION_CAN_EDIT)) {
        MaintenanceDocumentBase maintDoc = (MaintenanceDocumentBase) document;
        if (StringUtils.equals(maintDoc.getNewMaintainableObject().getMaintenanceAction(), KRADConstants.MAINTENANCE_EDIT_ACTION) || StringUtils.equals(maintDoc.getNewMaintainableObject().getMaintenanceAction(), KRADConstants.MAINTENANCE_COPY_ACTION)) {
            boolean hasRole = SpringContext.getBean(UserProcurementProfileValidationService.class).canMaintainUserProcurementProfile();
            UserProcurementProfile userProfile = (UserProcurementProfile) maintDoc.getNewMaintainableObject().getBusinessObject();
            if (!hasRole && (!StringUtils.equals(userProfile.getPrincipalId(), GlobalVariables.getUserSession().getPrincipalId()) || StringUtils.equals(maintDoc.getNewMaintainableObject().getMaintenanceAction(), KRADConstants.MAINTENANCE_COPY_ACTION))) {
                throw new AuthorizationException(user.getName(), maintDoc.getNewMaintainableObject().getMaintenanceAction(), " UserProcurementProfile");
            }
        }
    }
    return documentActions1;
}
Also used : AuthorizationException(org.kuali.kfs.krad.exception.AuthorizationException) MaintenanceDocumentBase(org.kuali.kfs.kns.document.MaintenanceDocumentBase) UserProcurementProfile(edu.cornell.kfs.sys.businessobject.UserProcurementProfile) UserProcurementProfileValidationService(edu.cornell.kfs.sys.service.UserProcurementProfileValidationService)

Aggregations

UserProcurementProfile (edu.cornell.kfs.sys.businessobject.UserProcurementProfile)1 UserProcurementProfileValidationService (edu.cornell.kfs.sys.service.UserProcurementProfileValidationService)1 MaintenanceDocumentBase (org.kuali.kfs.kns.document.MaintenanceDocumentBase)1 AuthorizationException (org.kuali.kfs.krad.exception.AuthorizationException)1