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.portal.service.insert;
35
36 import fr.paris.lutece.portal.service.i18n.I18nService;
37 import fr.paris.lutece.portal.service.rbac.Permission;
38 import fr.paris.lutece.portal.service.rbac.ResourceIdService;
39 import fr.paris.lutece.portal.service.rbac.ResourceType;
40 import fr.paris.lutece.portal.service.rbac.ResourceTypeManager;
41 import fr.paris.lutece.util.ReferenceList;
42
43 import java.util.Locale;
44
45
46
47
48
49 public class InsertResourceIdService extends ResourceIdService
50 {
51 public static final String PERMISSION_USE = "USE";
52 private static final String PROPERTY_LABEL_RESOURCE_TYPE = "portal.insert.insertService.resourceType";
53 private static final String PROPERTY_LABEL_USE = "portal.insert.permission.use";
54
55
56
57
58 public void register( )
59 {
60 ResourceType rt = new ResourceType( );
61 rt.setResourceIdServiceClass( InsertResourceIdService.class.getName( ) );
62 rt.setResourceTypeKey( InsertService.RESOURCE_TYPE );
63 rt.setResourceTypeLabelKey( PROPERTY_LABEL_RESOURCE_TYPE );
64
65 Permission p = new Permission( );
66 p.setPermissionKey( PERMISSION_USE );
67 p.setPermissionTitleKey( PROPERTY_LABEL_USE );
68 rt.registerPermission( p );
69
70 ResourceTypeManager.registerResourceType( rt );
71 }
72
73
74
75
76
77
78 public ReferenceList getResourceIdList( Locale locale )
79 {
80 ReferenceList list = new ReferenceList( );
81
82 for ( InsertService service : InsertServiceManager.getInsertServicesList( ) )
83 {
84 list.addItem( service.getId( ), I18nService.getLocalizedString( service.getNameKey( ), locale ) );
85 }
86
87 return list;
88 }
89
90
91
92
93
94
95
96 public String getTitle( String strInsertServiceId, Locale locale )
97 {
98 InsertService service = InsertServiceManager.getInsertService( strInsertServiceId );
99
100 return I18nService.getLocalizedString( service.getNameKey( ), locale );
101 }
102 }