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;
}
Aggregations