1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.authorization;
17
18 import java.util.Set;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.ole.sys.OLEConstants.PermissionTemplate;
24 import org.kuali.rice.kim.api.identity.Person;
25 import org.kuali.rice.kns.document.authorization.TransactionalDocumentAuthorizerBase;
26 import org.kuali.rice.krad.document.Document;
27 import org.kuali.rice.krad.util.KRADConstants;
28
29 public class FinancialSystemTransactionalDocumentAuthorizerBase extends TransactionalDocumentAuthorizerBase {
30 private static final Log LOG = LogFactory.getLog(FinancialSystemTransactionalDocumentAuthorizerBase.class);
31
32
33
34
35
36
37
38 @Override
39 public Set<String> getDocumentActions(Document document, Person user, Set<String> documentActionsFromPresentationController) {
40 Set<String> documentActionsToReturn = super.getDocumentActions(document, user, documentActionsFromPresentationController);
41
42 if (documentActionsToReturn.contains(OLEConstants.KFS_ACTION_CAN_ERROR_CORRECT)
43 && !(documentActionsToReturn.contains(KRADConstants.KUALI_ACTION_CAN_COPY)
44 && canErrorCorrect(document, user))) {
45 documentActionsToReturn.remove(OLEConstants.KFS_ACTION_CAN_ERROR_CORRECT);
46 }
47
48 if (documentActionsToReturn.contains(OLEConstants.KFS_ACTION_CAN_EDIT_BANK)
49 && !canEditBankCode(document, user)) {
50 documentActionsToReturn.remove(OLEConstants.KFS_ACTION_CAN_EDIT_BANK);
51 }
52
53
54
55 if (documentActionsToReturn.contains(KRADConstants.KUALI_ACTION_CAN_EDIT) && documentActionsToReturn.contains(OLEConstants.YEAR_END_ACCOUNTING_PERIOD_VIEW_DOCUMENT_ACTION)) {
56
57 if (!document.getDocumentHeader().getWorkflowDocument().isApprovalRequested() && !super.isAuthorized(document, OLEConstants.CoreModuleNamespaces.OLE, OLEConstants.YEAR_END_ACCOUNTING_PERIOD_VIEW_PERMISSION, user.getPrincipalId())) {
58 documentActionsToReturn.remove(OLEConstants.YEAR_END_ACCOUNTING_PERIOD_VIEW_DOCUMENT_ACTION);
59 }
60
61 else if (super.isAuthorized(document, OLEConstants.CoreModuleNamespaces.OLE, OLEConstants.YEAR_END_ACCOUNTING_PERIOD_EDIT_PERMISSION, user.getPrincipalId())) {
62 documentActionsToReturn.add(OLEConstants.YEAR_END_ACCOUNTING_PERIOD_EDIT_DOCUMENT_ACTION);
63 }
64 }
65
66
67 return documentActionsToReturn;
68 }
69
70
71
72
73
74
75
76
77 public boolean canErrorCorrect(Document document, Person user) {
78 return isAuthorizedByTemplate(document, OLEConstants.CoreModuleNamespaces.OLE, PermissionTemplate.ERROR_CORRECT_DOCUMENT.name, user.getPrincipalId());
79 }
80
81
82
83
84
85
86
87
88 public boolean canEditBankCode(Document document, Person user) {
89 return isAuthorizedByTemplate(document, OLEConstants.CoreModuleNamespaces.OLE, PermissionTemplate.EDIT_BANK_CODE.name, user.getPrincipalId());
90 }
91 }