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 java.util.HashMap; |
19 | |
import java.util.HashSet; |
20 | |
import java.util.Map; |
21 | |
import java.util.Set; |
22 | |
|
23 | |
import org.kuali.rice.kim.bo.Person; |
24 | |
import org.kuali.rice.kim.util.KimConstants; |
25 | |
import org.kuali.rice.kns.document.Document; |
26 | |
import org.kuali.rice.kns.util.KNSConstants; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | 0 | public class TransactionalDocumentAuthorizerBase extends DocumentAuthorizerBase |
32 | |
implements TransactionalDocumentAuthorizer { |
33 | |
public final Set<String> getEditModes(Document document, Person user, |
34 | |
Set<String> editModes) { |
35 | 0 | Set<String> unauthorizedEditModes = new HashSet<String>(); |
36 | 0 | for (String editMode : editModes) { |
37 | 0 | Map<String, String> additionalPermissionDetails = new HashMap<String, String>(); |
38 | 0 | additionalPermissionDetails.put(KimConstants.AttributeConstants.EDIT_MODE, editMode); |
39 | 0 | if (permissionExistsByTemplate( |
40 | |
document, |
41 | |
KNSConstants.KNS_NAMESPACE, |
42 | |
KimConstants.PermissionTemplateNames.USE_TRANSACTIONAL_DOCUMENT, |
43 | |
additionalPermissionDetails) |
44 | |
&& !isAuthorizedByTemplate( |
45 | |
document, |
46 | |
KNSConstants.KNS_NAMESPACE, |
47 | |
KimConstants.PermissionTemplateNames.USE_TRANSACTIONAL_DOCUMENT, |
48 | |
user.getPrincipalId(), additionalPermissionDetails, |
49 | |
null)) { |
50 | 0 | unauthorizedEditModes.add(editMode); |
51 | |
} |
52 | 0 | } |
53 | 0 | editModes.removeAll(unauthorizedEditModes); |
54 | 0 | return editModes; |
55 | |
} |
56 | |
} |