use of org.kuali.kfs.kns.document.authorization.TransactionalDocumentAuthorizer in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherAction method hasFullEdit.
protected boolean hasFullEdit(CuDisbursementVoucherDocument document) {
final Person user = GlobalVariables.getUserSession().getPerson();
final TransactionalDocumentPresentationController documentPresentationController = (TransactionalDocumentPresentationController) getDocumentHelperService().getDocumentPresentationController(document);
final TransactionalDocumentAuthorizer documentAuthorizer = (TransactionalDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(document);
Set<String> documentActions = documentPresentationController.getDocumentActions(document);
documentActions = documentAuthorizer.getDocumentActions(document, user, documentActions);
Set<String> editModes = documentPresentationController.getEditModes(document);
editModes = documentAuthorizer.getEditModes(document, user, editModes);
return documentActions.contains(KRADConstants.KUALI_ACTION_CAN_EDIT) && editModes.contains("fullEntry");
}
use of org.kuali.kfs.kns.document.authorization.TransactionalDocumentAuthorizer in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherDocument method refreshPayeeTypeSuffixIfPaymentIsEditable.
public void refreshPayeeTypeSuffixIfPaymentIsEditable() {
TransactionalDocumentAuthorizer docAuthorizer = getDvDocumentAuthorizer();
if (docAuthorizer.canEdit(this, GlobalVariables.getUserSession().getPerson())) {
Set<String> editModes = getDvDocumentPresentationController().getEditModes(this);
editModes = docAuthorizer.getEditModes(this, GlobalVariables.getUserSession().getPerson(), editModes);
if (editModes.contains(KfsAuthorizationConstants.DisbursementVoucherEditMode.PAYEE_ENTRY)) {
String newSuffix;
if (getDvPayeeDetail().isVendor()) {
VendorDetail vendor = getVendorService().getByVendorNumber(getDvPayeeDetail().getDisbVchrPayeeIdNumber());
if (ObjectUtils.isNotNull(vendor)) {
newSuffix = createVendorPayeeTypeSuffix(vendor.getVendorHeader().getVendorType());
} else {
newSuffix = StringUtils.EMPTY;
}
} else {
newSuffix = StringUtils.EMPTY;
}
((CuDisbursementVoucherPayeeDetailExtension) getDvPayeeDetail().getExtension()).setPayeeTypeSuffix(newSuffix);
}
}
}
use of org.kuali.kfs.kns.document.authorization.TransactionalDocumentAuthorizer in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherAction method hasFullEdit.
/**
* Determines if the current user has full edit permissions on the document, which would allow them to repopulate the payee
*
* @param document the document to check for full edit permissions on
* @return true if full edit is allowed on the document, false otherwise
*/
protected boolean hasFullEdit(DisbursementVoucherDocument document) {
final Person user = GlobalVariables.getUserSession().getPerson();
final TransactionalDocumentPresentationController documentPresentationController = (TransactionalDocumentPresentationController) getDocumentHelperService().getDocumentPresentationController(document);
final TransactionalDocumentAuthorizer documentAuthorizer = (TransactionalDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(document);
Set<String> documentActions = documentPresentationController.getDocumentActions(document);
documentActions = documentAuthorizer.getDocumentActions(document, user, documentActions);
Set<String> editModes = documentPresentationController.getEditModes(document);
editModes = documentAuthorizer.getEditModes(document, user, editModes);
return documentActions.contains(KRADConstants.KUALI_ACTION_CAN_EDIT) && editModes.contains("fullEntry");
}
use of org.kuali.kfs.kns.document.authorization.TransactionalDocumentAuthorizer in project cu-kfs by CU-CommunityApps.
the class CuRequisitionAction method createReqFromIWantDoc.
/**
* Creates a requisition document based on information from an I Want document.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
@SuppressWarnings("deprecation")
public ActionForward createReqFromIWantDoc(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String iWantDocumentNumber = request.getParameter(KRADConstants.PARAMETER_DOC_ID);
RequisitionForm requisitionForm = (RequisitionForm) form;
IWantDocument iWantDocument = (IWantDocument) getDocumentService().getByDocumentHeaderId(iWantDocumentNumber);
if (iWantDocument == null) {
throw new WorkflowException("Could not find IWantDocument with ID '" + iWantDocumentNumber + "'");
}
// Make sure the user is authorized to create the req in this manner.
TransactionalDocumentPresentationController pControl = (TransactionalDocumentPresentationController) getDocumentHelperService().getDocumentPresentationController(iWantDocument);
TransactionalDocumentAuthorizer authorizer = (TransactionalDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(iWantDocument);
Set<String> iwntEditModes = authorizer.getEditModes(iWantDocument, GlobalVariables.getUserSession().getPerson(), pControl.getEditModes(iWantDocument));
if (!iwntEditModes.contains(CUPurapConstants.IWNT_DOC_CREATE_REQ)) {
throw new AuthorizationException(GlobalVariables.getUserSession().getPrincipalId(), CUPurapConstants.IWNT_DOC_CREATE_REQ, CuRequisitionDocument.class.getSimpleName(), "user is not authorized to create requisitions from IWantDocument '" + iWantDocumentNumber + "'", Collections.<String, Object>emptyMap());
}
// Do not allow the req to be created if the IWNT doc is already associated with another req.
if (iWantDocument != null && (StringUtils.isNotBlank(iWantDocument.getReqsDocId()) || StringUtils.isNotBlank(iWantDocument.getDvDocId()))) {
throw new WorkflowException("Cannot create requisition from IWantDocument '" + iWantDocumentNumber + "' because a DV or Requisition has already been created from that document");
}
IWantDocumentService iWantDocumentService = SpringContext.getBean(IWantDocumentService.class);
createDocument(requisitionForm);
RequisitionDocument requisitionDocument = requisitionForm.getRequisitionDocument();
iWantDocumentService.setUpRequisitionDetailsFromIWantDoc(iWantDocument, requisitionDocument, requisitionForm);
// Set the requisition doc ID reference on the IWantDocument.
iWantDocument.setReqsDocId(requisitionDocument.getDocumentNumber());
SpringContext.getBean(PurapService.class).saveDocumentNoValidation(iWantDocument);
return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
Aggregations