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.forms.business.action;
35
36 import java.util.Locale;
37
38 import org.apache.commons.lang3.StringUtils;
39
40 import fr.paris.lutece.plugins.forms.service.FormsPlugin;
41 import fr.paris.lutece.portal.service.rbac.Permission;
42 import fr.paris.lutece.portal.service.rbac.ResourceIdService;
43 import fr.paris.lutece.portal.service.rbac.ResourceType;
44 import fr.paris.lutece.portal.service.rbac.ResourceTypeManager;
45 import fr.paris.lutece.util.ReferenceList;
46
47 public class GlobalFormsActionIdService extends ResourceIdService
48 {
49
50
51
52
53 @Override
54 public void register( )
55 {
56 ResourceType rt = new ResourceType( );
57 rt.setResourceIdServiceClass( GlobalFormsActionIdService.class.getName( ) );
58 rt.setPluginName( FormsPlugin.PLUGIN_NAME );
59 rt.setResourceTypeKey( GlobalFormsAction.RESOURCE_TYPE_CODE );
60 rt.setResourceTypeLabelKey( GlobalFormsAction.RESOURCE_TYPE_LABEL_KEY );
61
62 Permission p = new Permission( );
63 p.setPermissionKey( GlobalFormsAction.PERMISSION_PERFORM_ACTION );
64 p.setPermissionTitleKey( GlobalFormsAction.PERMISSION_PERFORM_ACTION_LABEL_KEY );
65 rt.registerPermission( p );
66
67 ResourceTypeManager.registerResourceType( rt );
68 }
69
70
71
72
73 @Override
74 public ReferenceList getResourceIdList( Locale locale )
75 {
76 ReferenceList referenceList = new ReferenceList( );
77 GlobalFormsActionHome.selectAllFormActions( FormsPlugin.getPlugin( ), locale ).stream( )
78 .forEach( ( GlobalFormsAction action ) -> referenceList.addItem( action.getCode( ), action.getName( ) ) );
79 return referenceList;
80 }
81
82
83
84
85 @Override
86 public String getTitle( String strCode, Locale locale )
87 {
88 GlobalFormsAction action = GlobalFormsActionHome.selectGlobalFormActionByCode( strCode, FormsPlugin.getPlugin( ), locale );
89 return ( action != null ) ? action.getName( ) : StringUtils.EMPTY;
90 }
91
92 }