View Javadoc
1   /*
2    * Copyright (c) 2002-2022, City of 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.portal.business.portlet;
35  
36  import fr.paris.lutece.portal.service.i18n.I18nService;
37  import fr.paris.lutece.portal.service.i18n.Localizable;
38  import fr.paris.lutece.portal.service.rbac.RBACResource;
39  
40  import java.util.Locale;
41  
42  /**
43   * This class represents business objects PortletType
44   */
45  public class PortletType implements RBACResource, Localizable
46  {
47      // ///////////////////////////////////////////////////////////////////////////////
48      // Constants
49      public static final String RESOURCE_TYPE = "PORTLET_TYPE";
50      private static final String EMPTY_STRING = "";
51      private String _strId;
52      private String _strNameKey;
53      private String _strUrlCreation;
54      private String _strUrlUpdate;
55      private String _strHomeClass;
56      private String _strIconName;
57      private String _strPluginName;
58      private String _strDoCreateUrl;
59      private String _strCreateScriptTemplate;
60      private String _strCreateSpecificTemplate;
61      private String _strCreateSpecificFormTemplate;
62      private String _strDoModifyUrl;
63      private String _strModifyScriptTemplate;
64      private String _strModifySpecificTemplate;
65      private String _strModifySpecificFormTemplate;
66      private Locale _locale;
67  
68      /**
69       * Returns the identifier of the Portlet type
70       *
71       * @return the Portlet Type identifier
72       */
73      public String getId( )
74      {
75          return _strId;
76      }
77  
78      /**
79       * Sets the identifier of the portlet type
80       *
81       * @param strId
82       *            the Portlet Type identifier
83       */
84      public void setId( String strId )
85      {
86          _strId = ( strId == null ) ? EMPTY_STRING : strId;
87      }
88  
89      /**
90       * Sets the name key of the Portlet Type
91       *
92       * @param strNameKey
93       *            the Portlet type Name key
94       */
95      public void setNameKey( String strNameKey )
96      {
97          _strNameKey = strNameKey;
98      }
99  
100     /**
101      * Returns the name key of the Portlet Type
102      *
103      * @return the Portlet type name key
104      */
105     public String getNameKey( )
106     {
107         return _strNameKey;
108     }
109 
110     /**
111      * Returns the name of the Portlet Type
112      *
113      * @return the Portlet type name
114      */
115     public String getName( )
116     {
117         return I18nService.getLocalizedString( _strNameKey, _locale );
118     }
119 
120     /**
121      * Sets the url of the program which manages the creation of this portlet type
122      *
123      * @param strUrlCreation
124      *            the url to create the current portlet type
125      */
126     public void setUrlCreation( String strUrlCreation )
127     {
128         _strUrlCreation = strUrlCreation;
129     }
130 
131     /**
132      * Returns the url of the program which manages the creation of this portlet type
133      *
134      * @return the url of creation
135      */
136     public String getUrlCreation( )
137     {
138         return _strUrlCreation;
139     }
140 
141     /**
142      * Sets the url of the program which manages the update of this portlet type
143      *
144      * @param strUrlUpdate
145      *            the url to update the current portlet type
146      */
147     public void setUrlUpdate( String strUrlUpdate )
148     {
149         _strUrlUpdate = strUrlUpdate;
150     }
151 
152     /**
153      * Returns the url of the program which manages the update of this portlet type
154      *
155      * @return the url of update
156      */
157     public String getUrlUpdate( )
158     {
159         return _strUrlUpdate;
160     }
161 
162     /**
163      * Sets the home class path of the program which manages the update of this portlet type
164      *
165      * @param strHomeClass
166      *            the path to update the current portlet type
167      */
168     public void setHomeClass( String strHomeClass )
169     {
170         _strHomeClass = strHomeClass;
171     }
172 
173     /**
174      * Returns the path of the home class which manages the update of this portlet type
175      *
176      * @return the home class path of update
177      */
178     public String getHomeClass( )
179     {
180         return _strHomeClass;
181     }
182 
183     /**
184      * Sets the plugin name of the Portlet Type
185      *
186      * @param strPluginName
187      *            the Portlet type Plugin Name
188      */
189     public void setPluginName( String strPluginName )
190     {
191         _strPluginName = strPluginName;
192     }
193 
194     /**
195      * Returns the plugin name of the Portlet Type
196      *
197      * @return the Portlet type plugin name
198      */
199     public String getPluginName( )
200     {
201         return _strPluginName;
202     }
203     
204     /**
205      * Sets the icon name of the Portlet Type
206      *
207      * @param strIconName
208      *            the Portlet type Plugin Name
209      */
210     public void setIconName( String strIconName )
211     {
212         _strIconName = strIconName;
213     }
214         /**
215      * Returns the plugin name of the Portlet Type
216      *
217      * @return the Portlet type plugin name
218      */
219     public String getIconName( )
220     {
221         return _strIconName;
222     }
223 
224 
225     // //////////////////////////////////////////////////////////////////////////
226     // RBAC Resource implementation
227 
228     /**
229      * Returns the Resource Type Code that identify the resource type
230      * 
231      * @return The Resource Type Code
232      */
233     public String getResourceTypeCode( )
234     {
235         return RESOURCE_TYPE;
236     }
237 
238     /**
239      * Returns the resource Id of the current object
240      * 
241      * @return The resource Id of the current object
242      */
243     public String getResourceId( )
244     {
245         return "" + getId( );
246     }
247 
248     /**
249      * Return the DoCreate Url
250      * 
251      * @return The DoCreate Url
252      */
253     public String getDoCreateUrl( )
254     {
255         return _strDoCreateUrl;
256     }
257 
258     /**
259      * Sets the DoCreate Url
260      * 
261      * @param strDoCreateUrl
262      *            The DoCreate Url
263      */
264     public void setDoCreateUrl( String strDoCreateUrl )
265     {
266         _strDoCreateUrl = strDoCreateUrl;
267     }
268 
269     /**
270      * Sets the CreateScript
271      * 
272      * @param strCreateScript
273      *            The CreateScript
274      */
275     public void setCreateScriptTemplate( String strCreateScript )
276     {
277         _strCreateScriptTemplate = strCreateScript;
278     }
279 
280     /**
281      * Sets the CreateSpecific
282      * 
283      * @param strCreateSpecific
284      *            The CreateSpecific
285      */
286     public void setCreateSpecificTemplate( String strCreateSpecific )
287     {
288         _strCreateSpecificTemplate = strCreateSpecific;
289     }
290 
291     /**
292      * Sets the CreateSpecificForm
293      * 
294      * @param strCreateSpecificForm
295      *            The CreateSpecificForm
296      */
297     public void setCreateSpecificFormTemplate( String strCreateSpecificForm )
298     {
299         _strCreateSpecificFormTemplate = strCreateSpecificForm;
300     }
301 
302     /**
303      * Return a script to include in the create form
304      * 
305      * @return the script to include in the create form
306      */
307     public String getCreateScriptTemplate( )
308     {
309         return _strCreateScriptTemplate;
310     }
311 
312     /**
313      * Return html code to include in the create form
314      * 
315      * @return html code to include in the create form
316      */
317     public String getCreateSpecificTemplate( )
318     {
319         return _strCreateSpecificTemplate;
320     }
321 
322     /**
323      * Return html code to add another form to the create page
324      * 
325      * @return html code to add another form to the create page
326      */
327     public String getCreateSpecificFormTemplate( )
328     {
329         return _strCreateSpecificFormTemplate;
330     }
331 
332     /**
333      * Return the Modify Url
334      * 
335      * @return The Modify Url
336      */
337     public String getDoModifyUrl( )
338     {
339         return _strDoModifyUrl;
340     }
341 
342     /**
343      * Return a script to include in the modify form
344      * 
345      * @return the script to include in the modify form
346      */
347     public String getModifyScriptTemplate( )
348     {
349         return _strModifyScriptTemplate;
350     }
351 
352     /**
353      * Return html code to include in the modify form
354      * 
355      * @return html code to include in the modify form
356      */
357     public String getModifySpecificTemplate( )
358     {
359         return _strModifySpecificTemplate;
360     }
361 
362     /**
363      * Return html code to add another form to the modify page
364      * 
365      * @return html code to add another form to the modify page
366      */
367     public String getModifySpecificFormTemplate( )
368     {
369         return _strModifySpecificFormTemplate;
370     }
371 
372     /**
373      * Sets the DoModify Url
374      * 
375      * @param strDoModifyUrl
376      *            The DoModify Url
377      */
378     public void setDoModifyUrl( String strDoModifyUrl )
379     {
380         _strDoModifyUrl = strDoModifyUrl;
381     }
382 
383     /**
384      * Sets the ModifyScript
385      * 
386      * @param strModifyScript
387      *            The ModifyScript
388      */
389     public void setModifyScriptTemplate( String strModifyScript )
390     {
391         _strModifyScriptTemplate = strModifyScript;
392     }
393 
394     /**
395      * Sets the ModifySpecific
396      * 
397      * @param strModifySpecific
398      *            The ModifySpecific
399      */
400     public void setModifySpecificTemplate( String strModifySpecific )
401     {
402         _strModifySpecificTemplate = strModifySpecific;
403     }
404 
405     /**
406      * Sets the ModifySpecificForm
407      * 
408      * @param strModifySpecificForm
409      *            The ModifySpecificForm
410      */
411     public void setModifySpecificFormTemplate( String strModifySpecificForm )
412     {
413         _strModifySpecificFormTemplate = strModifySpecificForm;
414     }
415 
416     /**
417      * Implements Localizable
418      * 
419      * @param locale
420      *            The current locale
421      */
422     public void setLocale( Locale locale )
423     {
424         _locale = locale;
425     }
426 }