1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.profiles.service;
35
36 import fr.paris.lutece.plugins.profiles.business.Profile;
37 import fr.paris.lutece.plugins.profiles.business.ProfileHome;
38 import fr.paris.lutece.portal.service.plugin.Plugin;
39 import fr.paris.lutece.portal.service.plugin.PluginService;
40 import fr.paris.lutece.portal.service.rbac.Permission;
41 import fr.paris.lutece.portal.service.rbac.ResourceIdService;
42 import fr.paris.lutece.portal.service.rbac.ResourceType;
43 import fr.paris.lutece.portal.service.rbac.ResourceTypeManager;
44 import fr.paris.lutece.util.ReferenceList;
45
46 import java.util.Locale;
47
48
49
50
51
52
53 public class ProfilesResourceIdService extends ResourceIdService
54 {
55 public static final String PERMISSION_CREATE_PROFILE = "CREATE_PROFILE";
56 public static final String PERMISSION_MODIFY_PROFILE = "MODIFY_PROFILE";
57 public static final String PERMISSION_DELETE_PROFILE = "DELETE_PROFILE";
58 public static final String PERMISSION_MANAGE_USERS_ASSIGNMENT = "MANAGE_USERS_ASSIGNMENT";
59 public static final String PERMISSION_MANAGE_RIGHTS_ASSIGNMENT = "MANAGE_RIGHTS_ASSIGNMENT";
60 public static final String PERMISSION_MANAGE_ROLES_ASSIGNMENT = "MANAGE_ROLES_ASSIGNMENT";
61 public static final String PERMISSION_MANAGE_WORKGROUPS_ASSIGNMENT = "MANAGE_WORKGROUPS_ASSIGNMENT";
62 public static final String PERMISSION_MANAGE_VIEW_ASSIGNMENT = "MANAGE_VIEW_ASSIGNMENT";
63 private static final String PROPERTY_LABEL_RESOURCE_TYPE = "profiles.permission.label.resource_type_profile";
64 private static final String PROPERTY_LABEL_CREATE_PROFILE = "profiles.permission.label.create_profile";
65 private static final String PROPERTY_LABEL_MODIFY_PROFILE = "profiles.permission.label.modify_profile";
66 private static final String PROPERTY_LABEL_DELETE_PROFILE = "profiles.permission.label.delete_profile";
67 private static final String PROPERTY_LABEL_MANAGE_USERS_ASSIGNMENT = "profiles.permission.label.manage_users_assignment";
68 private static final String PROPERTY_LABEL_MANAGE_RIGHTS_ASSIGNMENT = "profiles.permission.label.manage_rights_assignment";
69 private static final String PROPERTY_LABEL_MANAGE_ROLES_ASSIGNMENT = "profiles.permission.label.manage_roles_assignment";
70 private static final String PROPERTY_LABEL_MANAGE_WORKGROUPS_ASSIGNMENT = "profiles.permission.label.manage_workgroups_assignment";
71 private static final String PROPERTY_LABEL_MANAGE_VIEW_ASSIGNMENT = "profiles.permission.label.manage_view_assignment";
72
73
74
75
76 public ProfilesResourceIdService( )
77 {
78 setPluginName( ProfilesPlugin.PLUGIN_NAME );
79 }
80
81
82
83
84 public void register( )
85 {
86 ResourceType rt = new ResourceType( );
87 rt.setResourceIdServiceClass( ProfilesResourceIdService.class.getName( ) );
88 rt.setResourceTypeKey( Profile.RESOURCE_TYPE );
89 rt.setResourceTypeLabelKey( PROPERTY_LABEL_RESOURCE_TYPE );
90
91 Permission p = new Permission( );
92 p.setPermissionKey( PERMISSION_CREATE_PROFILE );
93 p.setPermissionTitleKey( PROPERTY_LABEL_CREATE_PROFILE );
94 rt.registerPermission( p );
95
96 p = new Permission( );
97 p.setPermissionKey( PERMISSION_MODIFY_PROFILE );
98 p.setPermissionTitleKey( PROPERTY_LABEL_MODIFY_PROFILE );
99 rt.registerPermission( p );
100
101 p = new Permission( );
102 p.setPermissionKey( PERMISSION_DELETE_PROFILE );
103 p.setPermissionTitleKey( PROPERTY_LABEL_DELETE_PROFILE );
104 rt.registerPermission( p );
105
106 p = new Permission( );
107 p.setPermissionKey( PERMISSION_MANAGE_USERS_ASSIGNMENT );
108 p.setPermissionTitleKey( PROPERTY_LABEL_MANAGE_USERS_ASSIGNMENT );
109 rt.registerPermission( p );
110
111 p = new Permission( );
112 p.setPermissionKey( PERMISSION_MANAGE_RIGHTS_ASSIGNMENT );
113 p.setPermissionTitleKey( PROPERTY_LABEL_MANAGE_RIGHTS_ASSIGNMENT );
114 rt.registerPermission( p );
115
116 p = new Permission( );
117 p.setPermissionKey( PERMISSION_MANAGE_ROLES_ASSIGNMENT );
118 p.setPermissionTitleKey( PROPERTY_LABEL_MANAGE_ROLES_ASSIGNMENT );
119 rt.registerPermission( p );
120
121 p = new Permission( );
122 p.setPermissionKey( PERMISSION_MANAGE_WORKGROUPS_ASSIGNMENT );
123 p.setPermissionTitleKey( PROPERTY_LABEL_MANAGE_WORKGROUPS_ASSIGNMENT );
124 rt.registerPermission( p );
125
126 p = new Permission( );
127 p.setPermissionKey( PERMISSION_MANAGE_VIEW_ASSIGNMENT );
128 p.setPermissionTitleKey( PROPERTY_LABEL_MANAGE_VIEW_ASSIGNMENT );
129 rt.registerPermission( p );
130
131 ResourceTypeManager.registerResourceType( rt );
132 }
133
134
135
136
137
138
139
140
141 public ReferenceList getResourceIdList( Locale locale )
142 {
143 Plugin plugin = PluginService.getPlugin( ProfilesPlugin.PLUGIN_NAME );
144
145 return ProfileHome.getProfilesList( plugin );
146 }
147
148
149
150
151
152
153
154
155
156
157 public String getTitle( String strProfileKey, Locale locale )
158 {
159 return strProfileKey;
160 }
161 }