1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.document.authorization;
17
18 import org.kuali.rice.kim.api.KimConstants;
19 import org.kuali.rice.kim.api.identity.Person;
20 import org.kuali.rice.krad.document.Document;
21 import org.kuali.rice.krad.util.KRADConstants;
22
23 import java.util.HashMap;
24 import java.util.HashSet;
25 import java.util.Map;
26 import java.util.Set;
27
28
29
30
31 public class TransactionalDocumentAuthorizerBase extends DocumentAuthorizerBase
32 implements TransactionalDocumentAuthorizer {
33 public final Set<String> getEditModes(Document document, Person user,
34 Set<String> editModes) {
35 Set<String> unauthorizedEditModes = new HashSet<String>();
36 for (String editMode : editModes) {
37 Map<String, String> additionalPermissionDetails = new HashMap<String, String>();
38 additionalPermissionDetails.put(KimConstants.AttributeConstants.EDIT_MODE, editMode);
39 if (permissionExistsByTemplate(
40 document,
41 KRADConstants.KRAD_NAMESPACE,
42 KimConstants.PermissionTemplateNames.USE_TRANSACTIONAL_DOCUMENT,
43 additionalPermissionDetails)
44 && !isAuthorizedByTemplate(
45 document,
46 KRADConstants.KRAD_NAMESPACE,
47 KimConstants.PermissionTemplateNames.USE_TRANSACTIONAL_DOCUMENT,
48 user.getPrincipalId(), additionalPermissionDetails,
49 null)) {
50 unauthorizedEditModes.add(editMode);
51 }
52 }
53 editModes.removeAll(unauthorizedEditModes);
54 return editModes;
55 }
56 }