View Javadoc
1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.extend.modules.actionbar.service;
35  
36  import fr.paris.lutece.plugins.extend.modules.actionbar.business.ActionButton;
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   * ActionbarResourceIdService
48   */
49  public class ActionbarResourceIdService extends ResourceIdService
50  {
51      /**
52       * Permission key to create action buttons
53       */
54      public static final String PERMISSION_ADD_ACTION_BUTTON = "ADD_ACTION_BUTTON";
55      /**
56       * Permission key to modify action buttons
57       */
58      public static final String PERMISSION_MODIFY_ACTION_BUTTON = "MODIFY_ACTION_BUTTON";
59      /**
60       * Permission key to remove action buttons
61       */
62      public static final String PERMISSION_REMOVE_ACTION_BUTTON = "REMOVE_ACTION_BUTTON";
63  
64      private static final String PROPERTY_LABEL_RESOURCE_TYPE = "module.extend.actionbar.resourceType.label";
65      private static final String PROPERTY_LABEL_ADD_ACTION_BUTTON = "module.extend.actionbar.permission.label.addActionButton";
66      private static final String PROPERTY_LABEL_MODIFY_ACTION_BUTTON = "module.extend.actionbar.permission.label.modifyActionButton";
67      private static final String PROPERTY_LABEL_REMOVE_ACTION_BUTTON = "module.extend.actionbar.permission.label.removeActionButton";
68  
69      /**
70       * Instantiates a new resource type resource id service.
71       */
72      public ActionbarResourceIdService( )
73      {
74          setPluginName( ActionbarPlugin.PLUGIN_NAME );
75      }
76  
77      /**
78       * {@inheritDoc}
79       */
80      @Override
81      public void register( )
82      {
83          ResourceType rt = new ResourceType( );
84          rt.setResourceIdServiceClass( ActionbarResourceIdService.class.getName( ) );
85          rt.setPluginName( ActionbarPlugin.PLUGIN_NAME );
86          rt.setResourceTypeKey( ActionButton.RESOURCE_TYPE );
87          rt.setResourceTypeLabelKey( PROPERTY_LABEL_RESOURCE_TYPE );
88  
89          Permission p = new Permission( );
90          p.setPermissionKey( PERMISSION_ADD_ACTION_BUTTON );
91          p.setPermissionTitleKey( PROPERTY_LABEL_ADD_ACTION_BUTTON );
92          rt.registerPermission( p );
93  
94          p = new Permission( );
95          p.setPermissionKey( PERMISSION_MODIFY_ACTION_BUTTON );
96          p.setPermissionTitleKey( PROPERTY_LABEL_MODIFY_ACTION_BUTTON );
97          rt.registerPermission( p );
98  
99          p = new Permission( );
100         p.setPermissionKey( PERMISSION_REMOVE_ACTION_BUTTON );
101         p.setPermissionTitleKey( PROPERTY_LABEL_REMOVE_ACTION_BUTTON );
102         rt.registerPermission( p );
103 
104         ResourceTypeManager.registerResourceType( rt );
105     }
106 
107     /**
108      * {@inheritDoc}
109      */
110     @Override
111     public ReferenceList getResourceIdList( Locale locale )
112     {
113         return null;
114     }
115 
116     /**
117      * {@inheritDoc}
118      */
119     @Override
120     public String getTitle( String strId, Locale locale )
121     {
122         return null;
123     }
124 }