View Javadoc

1   /*
2    * Copyright 2000-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.jetspeed.services.resources;
18  
19  import org.apache.turbine.services.resources.TurbineResources;
20  
21  /***
22   * This class defines the Jetspeed properties keys.
23   * All properties can be retrieved using TurbineResources or JetspeedResources
24   * directly.
25   *
26   * This class also overrides the covers for many of the get routines.  It handles the cases
27   * where we want a single value, perhaps as a boolean or float, but the configuration may have
28   * an array of values.  In these cases, we let the first value override all the others and use it.
29   *
30   * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
31   * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>
32   * @author <a href="mailto:tom@PIsoftware.com">Tom Adams</a>
33   * @author <a href="mailto:kimptoc_mail@yahoo.com">Chris Kimpton</a>
34   * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>
35   * @version $Id: JetspeedResources.java,v 1.19 2004/02/23 03:29:53 jford Exp $
36   */
37  public class JetspeedResources extends TurbineResources {
38  
39      //Added by sbelt for GenericNavigation.class
40      public static final String SITE_HEADER_LOGO_KEY = "site.header.logo";
41      public static final String SITE_HEADER_WELCOME_KEY = "site.header.welcome";
42      public static final String SITE_FOOTER_LOGO_KEY = "site.footer.logo";
43  
44      //Keys for use within external code
45      
46      public static final String PROFILER_DEFAULT_CLASSNAME_KEY = "profiler.default.classname";
47      public static final String PROFILER_CONFIGURATION_KEY = "profiler.configuration";
48      public static final String SKIN_DEFAULT_KEY = "skin.default";
49      public static final String PORTLETCONTROL_DEFAULT_CLASSNAME_KEY = "portletcontrol.default.classname";
50      public static final String PORTLETCONTROL_MAXIMIZED_CLASSNAME_KEY = "portletcontrol.maximized.classname";
51      public static final String PORTLETCONTROLLER_DEFAULT_CLASSNAME_KEY = "portletcontroller.default.classname";
52  
53      //Disk Cache (URLManager) parameters
54      public static final String CACHE_DIRECTORY_KEY = "cache.directory";
55      public static final String CACHE_REQUIRE_CACHED_KEY = "cache.require.cached";
56      public static final String DEFAULT_DCE_EXPIRATION_TIME_KEY = "cache.default.expiration";
57  
58      public static final String DEFAULTPORTLETCONTROL_WIDTH_KEY = "defaultportletcontrol.width";
59      public static final String DEFAULTPORTLETCONTROLLER_NUMCOLUMNS_KEY = "defaultportletcontroller.numcolumns";
60      public static final String DEFAULTPORTLETCONTROLLER_WIDTH_KEY = "defaultportletcontroller.width";
61      public static final String XMLPORTLETCONTROLLER_WIDTH_KEY = "xmlportletcontroller.width";
62      public static final String XMLPORTLETCONTROLLER_STYLESHEET_KEY = "xmlportletcontroller.stylesheet";
63      public static final String PORTLETMARKUP_ALL_KEY = "portletmarkup.all";
64      public static final String CONTENTFEEDS_STYLESHEET_URL_KEY = "contentfeeds.stylesheet.url";
65      public static final String CONTENTFEEDS_FETCHALL_KEY = "contentfeeds.fetchall";
66      public static final String CONTENTFEEDS_PORTLETBROWSER_PREVIEW_MAXPORTLETS_KEY = "contentfeeds.portletbrowser.preview.maxportlets";
67      public static final String CONTENTFEEDS_PORTLETBROWSER_OVERVIEW_MAXPORTLETS_KEY = "contentfeeds.portletbrowser.overview.maxportlets";
68      public static final String CONFIGURATION_DIRECTORY_KEY = "configuration.directory";
69      public static final String CONTENT_ROOT_URL_KEY = "content.root.url";
70      public static final String TEMP_DIRECTORY_KEY = "temp.directory";
71      public static final String ADMIN_PORTLET_NAME_KEY = "admin.portlet.name";
72      public static final String ADMIN_USERNAME_KEY = "admin.username";
73      public static final String ADMIN_PASSWORD_KEY = "admin.password";
74      public static final String DAEMON_ENTRY = "daemon.entry";
75      public static final String PSML_REGISTRY_URL_KEY = "psml.registry.url";
76      public static final String NAVIGATIONS_TOP_KEY = "navigations.top";
77      public static final String NAVIGATIONS_BOTTOM_KEY = "navigations.bottom";
78      public static final String AUTOCREATE_PORTLETS_KEY = "autocreate.portlets";
79      public static final String CONTENT_PROVIDER_LIST_KEY = "content.provider.list";
80      public static final String DEFAULT_TITLE_KEY = "metadata.default.title";
81      public static final String DEFAULT_DESCRIPTION_KEY = "metadata.default.description";
82      public static final String DEFAULT_IMAGE_KEY = "metadata.default.image";
83      public static final String JETSPEED_CONFIG_KEY = "jetspeed.config";
84  
85      public static final String CONTENT_ENCODING_KEY = "content.defaultencoding";
86          
87      public static final String CUSTOMIZATION_RESOURCE_KEY = "customization.psml";
88      public static final String CUSTOMIZATION_MAX_NUMBER   = "customization.display.maxNumberOfPortlets";
89  
90      // glucode customizer
91      public static final String HTML_HEX_COLOR_KEY = "html.hex.color.";
92      public static final String HTML_COLOR_NAME_KEY = "html.color.name.";
93      public static final String MANDATORY_PORTLET = "portlet.mandatory";
94  
95      public static final String CHANGE_PASSWORD_TEMPLATE = "template.change.password";
96  
97      // Images for the portal
98      
99      public static final String MAX_IMAGE = getString( CONTENT_ROOT_URL_KEY, "" ) + "images/max.gif";
100     public static final String INFO_IMAGE = getString( CONTENT_ROOT_URL_KEY, "" ) + "images/info.gif";
101     public static final String EDIT_IMAGE = getString( CONTENT_ROOT_URL_KEY, "" ) + "images/edit.gif";
102     public static final String TRANSPARENT_IMAGE = getString( CONTENT_ROOT_URL_KEY, "" ) + "images/dot.gif";
103     public static final String RESTORE_IMAGE = getString( CONTENT_ROOT_URL_KEY, "" ) + "images/restore.gif";
104     public static final String SITE_HEADER_LOGO = getString( CONTENT_ROOT_URL_KEY, "" ) + getString( SITE_HEADER_LOGO_KEY, "images/jetspeed-logo.gif" );
105     public static final String SITE_FOOTER_LOGO = getString( CONTENT_ROOT_URL_KEY, "" ) + getString( SITE_FOOTER_LOGO_KEY, "images/feather.gif");
106     public static final String SITE_WELCOME = getString( SITE_HEADER_WELCOME_KEY, "Welcome to Jetspeed" );
107     public static final String SITE_STYLESHEET = getString( CONTENT_ROOT_URL_KEY, "" ) + getString( "site.stylesheet" );
108 
109     // this is the value that is stored in the database for confirmed users
110     public static final String CONFIRM_VALUE = "CONFIRMED";
111     public static final String CONFIRM_VALUE_PENDING = "PENDING";
112     public static final String CONFIRM_VALUE_REJECTED = "REJECTED";
113 
114     // parameter names for the Jetspeed path framework elements    
115     public static final String PATH_ACTION_KEY = "action";
116     public static final String PATH_PANEID_KEY = "js_pane";        
117     public static final String PATH_PANENAME_KEY = "js_panename";
118     public static final String PATH_PORTLETID_KEY = "js_peid";
119     public static final String PATH_SCREEN_KEY = "screen";
120     public static final String PATH_TEMPLATE_KEY = "template";
121     public static final String PATH_PORTLET_KEY = "portlet";
122     public static final String PATH_SUBPANE_SEPARATOR = ",";
123 
124     // product information
125     public static final String JETSPEED_NAME_KEY = "jetspeed.name";
126     public static final String JETSPEED_VERSION_KEY = "jetspeed.version";
127     
128     /***
129      * Special portlet registry parameter used to override default portlet cache expiration value
130      */
131     public static final String TIME_TO_LIVE = "_TimeToLive";
132 
133     /***
134      * @depracated Use PATH_PANEID_KEY or PATH_PANENAME_KEY
135      */
136     public static final String PATH_PANEL_KEY = "select-panel";        
137 
138     /***
139      * The purpose of this method is to get the configuration resource
140      * with the given name as a boolean value.
141      *
142      * @param name The resource name.
143      * @return The value of the named resource as a boolean.
144      */
145     public static boolean getBoolean(String name)
146     {
147         try
148         {
149             return TurbineResources.getBoolean (name);
150         }
151         catch (ClassCastException e)
152         {
153             // get the possible list
154             String[] values = getStringArray(name);
155             
156             // try again with the first
157             if ((values != null) && (values.length > 0))
158                 return new Boolean(values[0]).booleanValue();
159 
160             // otherwise, just throw the exception
161             throw e;
162         }
163     }
164 
165     /***
166      * The purppose of this method is to get the configuration
167      * resource with the given name as a boolean value, or a default
168      * value.
169      *
170      * @param name The resource name.
171      * @param def The default value of the resource.
172      * @return The value of the named resource as a boolean.
173      */
174     public static boolean getBoolean(String name,
175                                      boolean def)
176     {
177         try
178         {
179             return TurbineResources.getBoolean(name, def);
180         }
181         catch (ClassCastException e)
182         {
183             // get the possible list
184             String[] values = getStringArray(name);
185             
186             // try again with the first
187             if ((values != null) && (values.length > 0))
188                 return new Boolean(values[0]).booleanValue();
189 
190             // otherwise, just throw the exception
191             throw e;
192         }
193     }
194 
195     /***
196      * The purpose of this method is to get the configuration resource
197      * with the given name as a double.
198      *
199      * @param name The resoource name.
200      * @return The value of the named resource as double.
201      */
202     public static double getDouble(String name)
203     {
204         try
205         {
206             return TurbineResources.getDouble(name);
207         }
208         catch (ClassCastException e)
209         {
210             // get the possible list
211             String[] values = getStringArray(name);
212             
213             // try again with the first
214             if ((values != null) && (values.length > 0))
215                 return Double.parseDouble(values[0]);
216 
217             // otherwise, just throw the exception
218             throw e;
219         }
220     }
221 
222     /***
223      * The purpose of this method is to get the configuration resource
224      * with the given name as a double, or a default value.
225      *
226      * @param name The resource name.
227      * @param def The default value of the resource.
228      * @return The value of the named resource as a double.
229      */
230     public static double getDouble(String name,
231                                    double def)
232     {
233         try
234         {
235             return TurbineResources.getDouble(name, def);
236         }
237         catch (ClassCastException e)
238         {
239             // get the possible list
240             String[] values = getStringArray(name);
241             
242             // try again with the first
243             if ((values != null) && (values.length > 0))
244                 return Double.parseDouble(values[0]);
245 
246             // otherwise, just throw the exception
247             throw e;
248         }
249     }
250 
251     /***
252      * The purpose of this method is to get the configuration resource
253      * with the given name as a float.
254      *
255      * @param name The resource name.
256      * @return The value of the resource as a float.
257      */
258     public static float getFloat(String name)
259     {
260         try
261         {
262             return TurbineResources.getFloat(name);
263         }
264         catch (ClassCastException e)
265         {
266             // get the possible list
267             String[] values = getStringArray(name);
268             
269             // try again with the first
270             if ((values != null) && (values.length > 0))
271                 return Float.parseFloat(values[0]);
272 
273             // otherwise, just throw the exception
274             throw e;
275         }
276     }
277 
278     /***
279      * The purpose of this method is to get the configuration resource
280      * with the given name as a float, or a default value.
281      *
282      * @param name The resource name.
283      * @param def The default value of the resource.
284      * @return The value of the resource as a float.
285      */
286     public static float getFloat(String name,
287                                  float def)
288     {
289         try
290         {
291             return TurbineResources.getFloat(name, def);
292         }
293         catch (ClassCastException e)
294         {
295             // get the possible list
296             String[] values = getStringArray(name);
297             
298             // try again with the first
299             if ((values != null) && (values.length > 0))
300                 return Float.parseFloat(values[0]);
301 
302             // otherwise, just throw the exception
303             throw e;
304         }
305     }
306 
307     /***
308      * The purpose of this method is to get the configuration resource
309      * with the given name as an integer.
310      *
311      * @param name The resource name.
312      * @return The value of the resource as an integer.
313      */
314     public static int getInt(String name)
315     {
316         try
317         {
318             return TurbineResources.getInt(name);
319         }
320         catch (ClassCastException e)
321         {
322             // get the possible list
323             String[] values = getStringArray(name);
324             
325             // try again with the first
326             if ((values != null) && (values.length > 0))
327                 return Integer.parseInt(values[0]);
328 
329             // otherwise, just throw the exception
330             throw e;
331         }
332     }
333 
334     /***
335      * The purpose of this method is to get the configuration resource
336      * with the given name as an integer, or a default value.
337      *
338      * @param name The resource name.
339      * @param def The default value of the resource.
340      * @return The value of the resource as an integer.
341      */
342     public static int getInt(String name,
343                              int def)
344     {
345         try
346         {
347             return TurbineResources.getInt(name, def);
348         }
349         catch (ClassCastException e)
350         {
351             // get the possible list
352             String[] values = getStringArray(name);
353             
354             // try again with the first
355             if ((values != null) && (values.length > 0))
356                 return Integer.parseInt(values[0]);
357 
358             // otherwise, just throw the exception
359             throw e;
360         }
361     }
362 
363     /***
364      * The purpose of this method is to get the configuration resource
365      * with the given name as a long.
366      *
367      * @param name The resource name.
368      * @return The value of the resource as a long.
369      */
370     public static long getLong(String name)
371     {
372         try
373         {
374             return TurbineResources.getLong(name);
375         }
376         catch (ClassCastException e)
377         {
378             // get the possible list
379             String[] values = getStringArray(name);
380             
381             // try again with the first
382             if ((values != null) && (values.length > 0))
383                 return Long.parseLong(values[0]);
384 
385             // otherwise, just throw the exception
386             throw e;
387         }
388     }
389 
390     /***
391      * The purpose of this method is to get the configuration resource
392      * with the given name as a long, or a default value.
393      *
394      * @param name The resource name.
395      * @param def The default value of the resource.
396      * @return The value of the resource as a long.
397      */
398     public static long getLong(String name,
399                                long def)
400     {
401         try
402         {
403             return TurbineResources.getLong(name, def);
404         }
405         catch (ClassCastException e)
406         {
407             // get the possible list
408             String[] values = getStringArray(name);
409             
410             // try again with the first
411             if ((values != null) && (values.length > 0))
412                 return Long.parseLong(values[0]);
413 
414             // otherwise, just throw the exception
415             throw e;
416         }
417     }
418 
419     /***
420      * The purpose of this method is to get the configuration resource
421      * with the given name as a string.
422      *
423      * @param name The resource name.
424      * @return The value of the resource as a string.
425      */
426     public static String getString(String name)
427     {
428         // get the possible list
429         String[] values = getStringArray(name);
430         if ((values != null) && (values.length > 0))
431             return values[0];
432 
433         return TurbineResources.getString(name);
434     }
435 
436     /***
437      * The purpose of this method is to get the configuration resource
438      * with the given name as a string, or a default value.
439      *
440      * @param name The resource name.
441      * @param def The default value of the resource.
442      * @return The value of the resource as a string.
443      */
444     public static String getString(String name,
445                                    String def)
446     {
447         // get the possible list
448         String[] values = getStringArray(name);
449         if ((values != null) && (values.length > 0))
450             return values[0];
451 
452         return TurbineResources.getString(name, def);
453     }
454 }
455