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.ReceivingDocument;
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.rice.kim.api.KimConstants;
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 import java.util.List;
30 import java.util.Map;
31
32 public class ReceivingDocumentAuthorizerBase extends TransactionalDocumentAuthorizerBase {
33
34 @Override
35 protected void addRoleQualification(Object businessObject, Map<String, String> attributes) {
36 super.addRoleQualification(businessObject, attributes);
37 attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "false");
38 ReceivingDocument purapDoc = (ReceivingDocument) businessObject;
39 if (purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier() != null) {
40 List<SensitiveData> sensitiveDataList = SpringContext.getBean(SensitiveDataService.class).getSensitiveDatasAssignedByRelatedDocId(purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier());
41 StringBuffer sensitiveDataCodes = new StringBuffer();
42 for (SensitiveData sensitiveData : sensitiveDataList) {
43 sensitiveDataCodes.append(sensitiveData.getSensitiveDataCode()).append(";");
44 }
45 if (sensitiveDataCodes.length() > 0) {
46 attributes.put(PurapKimAttributes.DOCUMENT_SENSITIVE, "true");
47 attributes.put(PurapKimAttributes.SENSITIVE_DATA_CODE, sensitiveDataCodes.toString().substring(0, sensitiveDataCodes.length() - 1));
48 attributes.put(PurapKimAttributes.ACCOUNTS_PAYABLE_PURCHASING_DOCUMENT_LINK_IDENTIFIER, purapDoc.getAccountsPayablePurchasingDocumentLinkIdentifier().toString());
49 }
50 }
51 }
52
53 @Override
54 public boolean canEditDocumentOverview(Document document, Person user) {
55 return isAuthorizedByTemplate(document,
56 KRADConstants.KNS_NAMESPACE,
57 KimConstants.PermissionTemplateNames.EDIT_DOCUMENT,
58 user.getPrincipalId());
59 }
60
61 }