Search in sources :

Example 1 with DocumentAuthorizer

use of org.kuali.kfs.krad.document.DocumentAuthorizer in project cu-kfs by CU-CommunityApps.

the class SubmitTripWebServiceImpl method canViewKfsDocument.

/**
 * @param viewerNetId
 * @param docID
 * @return
 * @throws Exception
 */
public boolean canViewKfsDocument(String viewerNetId, String docID) throws Exception {
    Person viewer = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(viewerNetId);
    Document document = SpringContext.getBean(DocumentService.class).getByDocumentHeaderIdSessionless(docID);
    DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(document);
    return documentAuthorizer.canOpen(document, viewer);
}
Also used : PersonService(org.kuali.kfs.kim.api.identity.PersonService) DocumentAuthorizer(org.kuali.kfs.krad.document.DocumentAuthorizer) Document(org.kuali.kfs.krad.document.Document) DistributionOfIncomeAndExpenseDocument(org.kuali.kfs.fp.document.DistributionOfIncomeAndExpenseDocument) CuDistributionOfIncomeAndExpenseDocument(edu.cornell.kfs.fp.document.CuDistributionOfIncomeAndExpenseDocument) DisbursementVoucherDocument(org.kuali.kfs.fp.document.DisbursementVoucherDocument) CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) Person(org.kuali.kfs.kim.api.identity.Person) DocumentService(org.kuali.kfs.krad.service.DocumentService) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Example 2 with DocumentAuthorizer

use of org.kuali.kfs.krad.document.DocumentAuthorizer in project cu-kfs by CU-CommunityApps.

the class CuVendorCreditMemoAction method calculate.

@Override
public ActionForward calculate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    VendorCreditMemoForm cmForm = (VendorCreditMemoForm) form;
    CuVendorCreditMemoDocument creditMemoDocument = (CuVendorCreditMemoDocument) cmForm.getDocument();
    if (creditMemoDocument.getDocumentHeader().getWorkflowDocument().isInitiated() || creditMemoDocument.getDocumentHeader().getWorkflowDocument().isSaved()) {
        // need to check whether the user has the permission to edit the bank code
        // if so, don't synchronize since we can't tell whether the value coming in
        // was entered by the user or not.
        DocumentAuthorizer docAuth = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(creditMemoDocument);
        if (!docAuth.isAuthorizedByTemplate(creditMemoDocument, KFSConstants.CoreModuleNamespaces.KFS, KFSConstants.PermissionTemplate.EDIT_BANK_CODE.name, GlobalVariables.getUserSession().getPrincipalId())) {
            creditMemoDocument.synchronizeBankCodeWithPaymentMethod();
        } else {
            // ensure that the name is updated properly
            creditMemoDocument.refreshReferenceObject("bank");
        }
    }
    return super.calculate(mapping, form, request, response);
}
Also used : CuVendorCreditMemoDocument(edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument) DocumentAuthorizer(org.kuali.kfs.krad.document.DocumentAuthorizer) VendorCreditMemoForm(org.kuali.kfs.module.purap.document.web.struts.VendorCreditMemoForm) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Example 3 with DocumentAuthorizer

use of org.kuali.kfs.krad.document.DocumentAuthorizer in project cu-kfs by CU-CommunityApps.

the class SubmitTripWebServiceImpl method isValidDocumentInitiator.

/**
 * NOTE: The current document names that are supported by KFS are
 * - Disbursement Voucher
 * - Distribution of Income and Expense
 */
public boolean isValidDocumentInitiator(String initiatorNetId, String documentName) throws Exception {
    Person initiator = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(initiatorNetId);
    Class docClass;
    if (StringUtils.equalsIgnoreCase(documentName, "Disbursement Voucher")) {
        docClass = DisbursementVoucherDocument.class;
    } else if (StringUtils.equalsIgnoreCase(documentName, "Distribution of Income and Expense")) {
        docClass = CuDistributionOfIncomeAndExpenseDocument.class;
    }
    String documentTypeName = SpringContext.getBean(DataDictionaryService.class).getDocumentTypeNameByClass(DisbursementVoucherDocument.class);
    DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(documentTypeName);
    return documentAuthorizer.canInitiate(documentTypeName, initiator);
}
Also used : PersonService(org.kuali.kfs.kim.api.identity.PersonService) DocumentAuthorizer(org.kuali.kfs.krad.document.DocumentAuthorizer) Person(org.kuali.kfs.kim.api.identity.Person) DataDictionaryService(org.kuali.kfs.datadictionary.legacy.DataDictionaryService) CuDistributionOfIncomeAndExpenseDocument(edu.cornell.kfs.fp.document.CuDistributionOfIncomeAndExpenseDocument) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Example 4 with DocumentAuthorizer

use of org.kuali.kfs.krad.document.DocumentAuthorizer in project cu-kfs by CU-CommunityApps.

the class MenuService method canInitiateDocument.

private boolean canInitiateDocument(String documentTypeName, Person person) {
    DocumentAuthorizer documentAuthorizer = documentDictionaryService.getDocumentAuthorizer(documentTypeName);
    DocumentType documentType = documentTypeService.getDocumentTypeByName(documentTypeName);
    return documentType != null && documentType.isActive() && documentAuthorizer.canInitiate(documentTypeName, person);
}
Also used : DocumentAuthorizer(org.kuali.kfs.krad.document.DocumentAuthorizer) DocumentType(org.kuali.kfs.kew.doctype.bo.DocumentType)

Aggregations

DocumentAuthorizer (org.kuali.kfs.krad.document.DocumentAuthorizer)4 DocumentHelperService (org.kuali.kfs.kns.service.DocumentHelperService)3 CuDistributionOfIncomeAndExpenseDocument (edu.cornell.kfs.fp.document.CuDistributionOfIncomeAndExpenseDocument)2 Person (org.kuali.kfs.kim.api.identity.Person)2 PersonService (org.kuali.kfs.kim.api.identity.PersonService)2 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)1 CuVendorCreditMemoDocument (edu.cornell.kfs.module.purap.document.CuVendorCreditMemoDocument)1 DataDictionaryService (org.kuali.kfs.datadictionary.legacy.DataDictionaryService)1 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)1 DistributionOfIncomeAndExpenseDocument (org.kuali.kfs.fp.document.DistributionOfIncomeAndExpenseDocument)1 DocumentType (org.kuali.kfs.kew.doctype.bo.DocumentType)1 Document (org.kuali.kfs.krad.document.Document)1 DocumentService (org.kuali.kfs.krad.service.DocumentService)1 VendorCreditMemoForm (org.kuali.kfs.module.purap.document.web.struts.VendorCreditMemoForm)1