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