1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.authorization;
17
18 import org.kuali.ole.module.purap.businessobject.SensitiveData;
19 import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
20 import org.kuali.ole.module.purap.identity.PurapKimAttributes;
21 import org.kuali.ole.module.purap.service.SensitiveDataService;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.ole.sys.document.authorization.AccountingDocumentAuthorizerBase;
24 import org.kuali.rice.kim.api.KimConstants;
25 import org.kuali.rice.kim.api.identity.Person;
26 import org.kuali.rice.krad.document.Document;
27 import org.kuali.rice.krad.util.KRADConstants;
28 import org.kuali.rice.krad.util.ObjectUtils;
29
30 import java.util.List;
31 import java.util.Map;
32
33 public class PurchasingAccountsPayableTransactionalDocumentAuthorizerBase extends AccountingDocumentAuthorizerBase {
34
35 @Override
36 protected void addRoleQualification(Object businessObject, Map<String, String> attributes) {
37 super.addRoleQualification(businessObject, attributes);
38 attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "false");
39 PurchasingAccountsPayableDocument purapDoc = (PurchasingAccountsPayableDocument) businessObject;
40 if (purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier() != null) {
41 List<SensitiveData> sensitiveDataList = SpringContext.getBean(SensitiveDataService.class).getSensitiveDatasAssignedByRelatedDocId(purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier());
42 if (ObjectUtils.isNotNull(sensitiveDataList) && !sensitiveDataList.isEmpty()) {
43 StringBuffer sensitiveDataCodes = new StringBuffer();
44 for (SensitiveData sensitiveData : sensitiveDataList) {
45 if (ObjectUtils.isNotNull(sensitiveData)) {
46 sensitiveDataCodes.append(sensitiveData.getSensitiveDataCode()).append(";");
47 }
48 }
49 if (sensitiveDataCodes.length() > 0) {
50 attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "true");
51 attributes.put(PurapKimAttributes.SENSITIVE_DATA_CODE, sensitiveDataCodes.toString().substring(0, sensitiveDataCodes.length() - 1));
52 attributes.put(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER, purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier().toString());
53 }
54 }
55 }
56 }
57
58 @Override
59 public boolean canEditDocumentOverview(Document document, Person user) {
60 return isAuthorizedByTemplate(document, KRADConstants.KNS_NAMESPACE,
61 KimConstants.PermissionTemplateNames.EDIT_DOCUMENT, user.getPrincipalId());
62 }
63
64 }