1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.service.impl; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.kim.api.KimConstants; |
20 | |
import org.kuali.rice.kim.api.permission.Permission; |
21 | |
import org.kuali.rice.kim.impl.permission.PermissionBo; |
22 | |
|
23 | |
import java.util.ArrayList; |
24 | |
import java.util.List; |
25 | |
import java.util.Map; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | 0 | public class DocumentTypeAndNodeOrStatePermissionTypeServiceImpl extends DocumentTypePermissionTypeServiceImpl { |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
@Override |
45 | |
protected List<Permission> performPermissionMatches(Map<String, String> requestedDetails, |
46 | |
List<Permission> permissionsList) { |
47 | 0 | List<Permission> matchingPermissions = new ArrayList<Permission>(); |
48 | |
|
49 | 0 | for ( Permission kpi : permissionsList ) { |
50 | 0 | PermissionBo bo = PermissionBo.from(kpi); |
51 | 0 | if ( routeNodeMatches(requestedDetails, bo.getDetails()) && |
52 | |
routeStatusMatches(requestedDetails, bo.getDetails())) { |
53 | 0 | matchingPermissions.add( kpi ); |
54 | |
} |
55 | 0 | } |
56 | |
|
57 | 0 | matchingPermissions = super.performPermissionMatches( requestedDetails, matchingPermissions ); |
58 | 0 | return matchingPermissions; |
59 | |
} |
60 | |
|
61 | |
protected boolean routeNodeMatches(Map<String, String> requestedDetails, Map<String, String> permissionDetails) { |
62 | 0 | if ( StringUtils.isBlank( permissionDetails.get(KimConstants.AttributeConstants.ROUTE_NODE_NAME) ) ) { |
63 | 0 | return true; |
64 | |
} |
65 | 0 | return StringUtils.equals( requestedDetails.get(KimConstants.AttributeConstants.ROUTE_NODE_NAME), permissionDetails.get(KimConstants.AttributeConstants.ROUTE_NODE_NAME)); |
66 | |
} |
67 | |
|
68 | |
protected boolean routeStatusMatches(Map<String, String> requestedDetails, Map<String, String> permissionDetails) { |
69 | 0 | if ( StringUtils.isBlank( permissionDetails.get(KimConstants.AttributeConstants.ROUTE_STATUS_CODE) ) ) { |
70 | 0 | return true; |
71 | |
} |
72 | 0 | return StringUtils.equals( requestedDetails.get(KimConstants.AttributeConstants.ROUTE_STATUS_CODE), permissionDetails.get( |
73 | |
KimConstants.AttributeConstants.ROUTE_STATUS_CODE)); |
74 | |
} |
75 | |
|
76 | |
} |