Clearspace API (2.5.29) Core Javadocs

com.jivesoftware.community
Class JiveGlobals

java.lang.Object
  extended by com.jivesoftware.community.JiveGlobals

public class JiveGlobals
extends Object

This class controls access to a number of global propeties in the applcation.

Additionally, this class controls access to Jive properties. If the application is on, property manipulation must be done through this class and not the database or xml files directly.

Properties come in 3 types:

  1. Local properties - these are set in jiveHome/jive_startup.xml
  2. Database properties - these are stored in the jiveProperty database table
  3. Localized properties - these are stored in the jiveLocalizedProp database table.

As mentioned above, local (or startup) properties are stored in the jive_startup.xml file in the jiveHome directory. These properties bootstrap the application and start things like database access and cache settings. Jive needs to know the physical location of the jiveHome directory. This can be set in a number of ways:

All Jive property names must be in the form prop.name - parts of the name must be separated by ".". The value can be any valid String, including strings with line breaks.

Methods to control local properties (in jive_startup.xml):

Methods to control database properties (in the jiveProperty table): Methods to control localized properties (in the jiveLocalizedProp table): For Clearspace 2.0, this class was refactored to remove non-configuration behaviors. See:

See Also:
JiveResourceResolver

Nested Class Summary
static class JiveGlobals.ResetLocalizationSettingsClusterTask
           
 
Field Summary
static String JIVE_INSTANCE_ID
          The universally unique instance of the application cluster.
static String JIVE_NODE_ID
          The universally unique id of an instance node.
static String jiveHome
          Location of the jiveHome directory.
 
Method Summary
static void deleteJiveProperty(String name)
          Deletes a Jive property.
static void deleteLocalizedJiveProperty(String name, Locale locale)
          Deletes a localized Jive property.
static void deleteLocalProperty(String name)
          Deletes a local property.
static String formatDate(Date date)
          Formats a Date object and returns a formatted String.
static String formatDateTime(Date date)
          Formats a Date object to return a date and time using the global locale.
static String getBuildProperty(String name)
          Returns a build-level property.
static String getCharacterEncoding()
          Returns the character set that Jive uses for encoding.
static String getDefaultBaseURL()
          Returns the base URL of this Jive installation - usually:

http://[yoursite]/[webapp-path]

This uses the Jive property of jiveURL which is settable through the config file or admin console.

static boolean getJiveBooleanProperty(String name)
          Returns the specified Jive property as a boolean or returns false if the property doesn't exist or isn't parseable.
static boolean getJiveBooleanProperty(String name, boolean defaultValue)
          Returns the specified Jive property as a boolean or returns defaultValue if the property doesn't exist or isn't parseable.
static String getJiveHome()
          Returns the location of the jiveHome directory.
static int getJiveIntProperty(String name, int defaultValue)
          Returns the specified Jive property as an integer or returns the defaultValue if the property does't exist or the value isn't a number.
static List<String> getJiveProperties(String parent)
          Return all immediate children property values of a parent Jive property as a list of strings, or an empty list if there are no children.
static String getJiveProperty(String name)
          Returns the value of the specified property or null if the value doesn't exist.
static String getJiveProperty(String name, String defaultValue)
          Returns a Jive property.
static List<String> getJivePropertyNames()
          Returns all Jive property names.
static List<String> getJivePropertyNames(String parent)
          Return all immediate children property names of a parent Jive property as a list of strings, or an empty list if there are no children.
static Locale getLocale()
          Returns the global Locale used by Jive.
static String getLocalizedJiveProperty(String name, Locale locale)
          Returns a localized Jive property given its name and locale.
static List<Locale> getLocalizedPropertyLocales(String name)
          Returns a list of locales where this property is set.
static List<String> getLocalProperties(String parent)
          Return all immediate children property values of a parent local property as a list of strings, or an empty list if there are no children.
static String getLocalProperty(String name)
          Returns a local property.
static int getLocalProperty(String name, int defaultValue)
          Returns a local property as an integer.
static String getLocalProperty(String name, String defaultValue)
          Returns a local property.
static String getPluginDirectory()
          Returns the directory that plugins are locally cached for a particular clearspace instance.
static Map<String,String> getSpiProperties(String spiClass)
           
static String getSpiProperty(String spiClass, String name)
           
static Date getStartupDate()
          Returns the date the Jive system was started.
static TimeZone getTimeZone()
          Returns the global TimeZone used by Jive.
static Map<String,String> getUnmodifiableMap()
           
static boolean isDebugMode()
           
static boolean isHidden(String propName)
          Determine if a property should be hidden.
static boolean isSetup()
          Returns true if the application has been set up, false otherwise.
static boolean isWhiteLabel()
          Returns true if the application is running in white label mode, false otherwise.
static JiveContainer jiveContainerFor(JiveObject source)
           
static void reset()
          For testing purposes only!
static void resetLocalization()
          Resets locale specific settings so they will be reread from properties.
static void setCharacterEncoding(String characterEncoding)
          Sets the character set that Jive uses for encoding.
static void setConfigName(String configName)
          Allows the name of the local config file name to be changed.
static void setJiveHome(String jHome)
          Sets the location of the jiveHome directory.
static void setJiveProperties(Map<String,String> propertyMap)
          Sets multiple Jive properties at once.
static void setJiveProperty(String name, String value)
          Sets a Jive property.
static void setLocale(Locale newLocale)
          Sets the global locale used by Jive.
static void setLocalizedJiveProperty(String name, String value, Locale locale)
          Sets a localized Jive property.
static void setLocalProperties(Map<String,String> propertyMap)
          Sets multiple local properties at once.
static void setLocalProperty(String name, String value)
          Sets a local property.
static void setSpiProperties(String spiClass, Map<String,String> config)
           
static void setSpiProperty(String clazz, String name, String value)
           
static void setTimeZone(TimeZone newTimeZone)
          Sets the global time zone used by Jive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JIVE_INSTANCE_ID

public static final String JIVE_INSTANCE_ID
The universally unique instance of the application cluster.

See Also:
Constant Field Values

JIVE_NODE_ID

public static final String JIVE_NODE_ID
The universally unique id of an instance node.

See Also:
Constant Field Values

jiveHome

public static String jiveHome
Location of the jiveHome directory.

Method Detail

reset

public static void reset()
For testing purposes only! This method will reset JiveGlobals to a "pristine" state.


resetLocalization

public static void resetLocalization()
Resets locale specific settings so they will be reread from properties.


getStartupDate

public static Date getStartupDate()
Returns the date the Jive system was started. This value can be used to calculate uptime.

Returns:
the date the Jive system was started.

getLocale

public static Locale getLocale()
Returns the global Locale used by Jive. A locale specifies language and country codes, and is used for internationalization. The default locale is system dependant and is determined by calling Locale.getDefault().

Returns:
the global locale used by Jive.

setLocale

public static void setLocale(Locale newLocale)
Sets the global locale used by Jive. A locale specifies language and country codes, and is used for formatting dates and numbers. The default locale comes from the JDK's Locale.getDefault().

Parameters:
newLocale - the global locale for Jive.

getCharacterEncoding

public static String getCharacterEncoding()
Returns the character set that Jive uses for encoding. This is used for displaying content in skins, sending email watch updates, etc. The default encoding is UTF-8, which is a Unicode encoding which supports double byte character sets such as Chinese or Japanese. Unicode offers simultaneous support for a large number of languages and is easy to convert into native charsets as necessary. You may also specify any other charset that is supported by your JVM. A list of encodings supported by the Sun JVM can be found here.

In order for a particular encoding to work (such as Unicode), your application server and database may need to be specially configured. Please consult your server documentation for more information. For example, SQLServer has a special column type for Unicode text, and the Resin application server can be configured to use a custom charset by adding a <character-encoding> element to the web.xml/resin.conf file. Any Servlet 2.3 compliant application servers also supports the method HttpServletRequest.setCharacterEncoding(String). A Servlet 2.3 filter called com.jivesoftware.community.web.filter.SetResponseCharacterEncodingFilter is installed in this application's web.xml file, which will set the incoming character encoding to the one reported by this method.

Returns:
the global Jive character encoding.

setCharacterEncoding

public static void setCharacterEncoding(String characterEncoding)
                                 throws UnsupportedEncodingException
Sets the character set that Jive uses for encoding. For a more complete description of the character encoding in this applcation, see getCharacterEncoding().

Parameters:
characterEncoding - the global Jive character encoding.
Throws:
UnsupportedEncodingException - if the specified character encoding is invalid.

getTimeZone

public static TimeZone getTimeZone()
Returns the global TimeZone used by Jive. The default is the JDK's default time zone.

Returns:
the global time zone used by Jive.

setTimeZone

public static void setTimeZone(TimeZone newTimeZone)
Sets the global time zone used by Jive.

Parameters:
newTimeZone - the new global time zone used by this application.

formatDate

public static String formatDate(Date date)
Formats a Date object and returns a formatted String. This uses the date formatter which in turn uses the default locale.

Parameters:
date - the Date to format.
Returns:
a String representing the date.

formatDateTime

public static String formatDateTime(Date date)
Formats a Date object to return a date and time using the global locale.

Parameters:
date - the Date to format.
Returns:
a String representing the date and time.

getDefaultBaseURL

public static String getDefaultBaseURL()
Returns the base URL of this Jive installation - usually:

This uses the Jive property of jiveURL which is settable through the config file or admin console.

Returns:
the base URL of this Jive installation.

getJiveHome

public static String getJiveHome()
Returns the location of the jiveHome directory.

Returns:
the location of the jiveHome directory.

getPluginDirectory

public static String getPluginDirectory()
Returns the directory that plugins are locally cached for a particular clearspace instance.

Returns:
the directory that plugins are locally cached for a particular clearspace instance.

setJiveHome

public static void setJiveHome(String jHome)
Sets the location of the jiveHome directory. This method is only intended to be used during setup and should not set called in normal operations.

Parameters:
jHome - the path to jiveHome

setConfigName

public static void setConfigName(String configName)
Allows the name of the local config file name to be changed. The default is jive_startup.xml. Note, this is used for setup, upgrade or testing purposes and is not needed in normal operation.

Parameters:
configName - the name of the config file.

isSetup

public static boolean isSetup()
Returns true if the application has been set up, false otherwise.

Returns:
true if the application has been set up, false otherwise.

getLocalProperty

public static String getLocalProperty(String name)
Returns a local property. Local properties are stored in the file jive_startup.xml which exists in the jiveHome directory. Properties are always specified as "foo.bar.prop", which would map to the following entry in the XML file:
 <foo>
     <bar>
         <prop>some value</prop>
     </bar>
 </foo>
 

Parameters:
name - the name of the property to return.
Returns:
the property value specified by name.

getLocalProperty

public static int getLocalProperty(String name,
                                   int defaultValue)
Returns a local property as an integer. If the specified property can't be found, or if the value is not a number, the defaultValue will be returned.

Parameters:
name - the name of the property to return.
defaultValue - the value returned if the property could not be loaded or was not a number.
Returns:
the property value specified by name or defaultValue.

getLocalProperty

public static String getLocalProperty(String name,
                                      String defaultValue)
Returns a local property. If the specified property can't be found the defaultValue will be returned.

Parameters:
name - the name of the property to return.
defaultValue - the value returned if the property could not be loaded.
Returns:
the property value specified by name or defaultValue.

getLocalProperties

public static List<String> getLocalProperties(String parent)
Return all immediate children property values of a parent local property as a list of strings, or an empty list if there are no children. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are A, B, and C (the value of C.D would not be returned using this method).

Parameters:
parent - the name of the parent property to return the children for.
Returns:
all child property values for the given parent.

setLocalProperty

public static void setLocalProperty(String name,
                                    String value)
Sets a local property. If the property doesn't already exists, a new one will be created.

Parameters:
name - the name of the property being set.
value - the value of the property being set.

setLocalProperties

public static void setLocalProperties(Map<String,String> propertyMap)
Sets multiple local properties at once. If a property doesn't already exists, a new one will be created.

Parameters:
propertyMap - a map of properties, keyed on property name.

deleteLocalProperty

public static void deleteLocalProperty(String name)
Deletes a local property. If the property doesn't exist, the method does nothing.

Parameters:
name - the name of the property to delete.

getJiveProperty

public static String getJiveProperty(String name)
Returns the value of the specified property or null if the value doesn't exist.

Parameters:
name - the name of the property to return.
Returns:
the property value specified by name or null if it doesn't exist.

getJiveProperty

public static String getJiveProperty(String name,
                                     String defaultValue)
Returns a Jive property. If the specified property doesn't exist, the defaultValue will be returned.

Parameters:
name - the name of the property.
defaultValue - value returned if the property doesn't exist.
Returns:
the property value specified by name or the defaultValue if the property doesn't exist.

getJivePropertyNames

public static List<String> getJivePropertyNames()
Returns all Jive property names.

Returns:
a List of all property names (Strings).

getJivePropertyNames

public static List<String> getJivePropertyNames(String parent)
Return all immediate children property names of a parent Jive property as a list of strings, or an empty list if there are no children. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are A, B, and C (C.D would not be returned using this method).

Parameters:
parent - the parent property to return all child properties for
Returns:
a List of all immediate children property names

getJiveProperties

public static List<String> getJiveProperties(String parent)
Return all immediate children property values of a parent Jive property as a list of strings, or an empty list if there are no children. For example, given the properties X.Y.A, X.Y.B, X.Y.C and X.Y.C.D, then the immediate child properties of X.Y are X.Y.A, X.Y.B, and X.Y.C (the value of X.Y.C.D would not be returned using this method).

Parameters:
parent - the name of the parent property to return the children for.
Returns:
all child property values for the given parent.

getJiveIntProperty

public static int getJiveIntProperty(String name,
                                     int defaultValue)
Returns the specified Jive property as an integer or returns the defaultValue if the property does't exist or the value isn't a number.

Parameters:
name - the name of the property.
defaultValue - value returned if the property doesn't exist or was not a number.
Returns:
the property value specified by name or defaultValue.

getJiveBooleanProperty

public static boolean getJiveBooleanProperty(String name)
Returns the specified Jive property as a boolean or returns false if the property doesn't exist or isn't parseable.

Parameters:
name - the name of the property to return.
Returns:
true if the property value exists and is set to "true" (ignoring case). Otherwise false is returned.

getJiveBooleanProperty

public static boolean getJiveBooleanProperty(String name,
                                             boolean defaultValue)
Returns the specified Jive property as a boolean or returns defaultValue if the property doesn't exist or isn't parseable.

Parameters:
name - the name of the property.
defaultValue - value returned if the property doesn't exist.
Returns:
true if the property value exists and is set to "true" or false if the property value is "false" (ignoring case). If the value isn't set or isn't parseable then defaultValue is returned.

setJiveProperty

public static void setJiveProperty(String name,
                                   String value)
Sets a Jive property. If the property doesn't already exists, a new one will be created.

Parameters:
name - the name of the property being set.
value - the value of the property being set.

setJiveProperties

public static void setJiveProperties(Map<String,String> propertyMap)
Sets multiple Jive properties at once. If a property doesn't already exists, a new one will be created.

Parameters:
propertyMap - a map of properties, keyed on property name.

deleteJiveProperty

public static void deleteJiveProperty(String name)
Deletes a Jive property. If the property doesn't exist, the method does nothing. All children of the property will be deleted as well.

Parameters:
name - the name of the property to delete.

getLocalizedJiveProperty

public static String getLocalizedJiveProperty(String name,
                                              Locale locale)
Returns a localized Jive property given its name and locale. If the property doesn't exist then null will be returned.

Parameters:
name - the name of the property
locale - the locale this property applies to
Returns:
the property value specified by name and locale or null if it doesn't exist.

getLocalizedPropertyLocales

public static List<Locale> getLocalizedPropertyLocales(String name)
Returns a list of locales where this property is set. If the property doesn't exist or is not set then an empty list is returned.

Parameters:
name - the name of the property to check.
Returns:
a list of Locale objects where this property is set or an empty list if the property doesn't exist.

setLocalizedJiveProperty

public static void setLocalizedJiveProperty(String name,
                                            String value,
                                            Locale locale)
Sets a localized Jive property. If the property doesn't already exists, a new one will be created.

Parameters:
name - the name of the property being set.
value - the value of the property being set.
locale - the locale of the property

deleteLocalizedJiveProperty

public static void deleteLocalizedJiveProperty(String name,
                                               Locale locale)
Deletes a localized Jive property. If the property doesn't exist, the method does nothing. All children of the property will be deleted as well.

Parameters:
name - the name of the property to delete.
locale - the locale of the property

isWhiteLabel

public static boolean isWhiteLabel()
Returns true if the application is running in white label mode, false otherwise. false is the default. White Label mode strips all Jive and Clearspace Branding from the application for OEM purposes.

Returns:
true if we're in white label mode, false otherwise. False is the default.

getBuildProperty

public static String getBuildProperty(String name)
Returns a build-level property. These are properties that are part of the build itself and can not be overridden or changed at runtime.

Note, this method will be generally less performant that other property accessors, so it's best to cache the answer from this method.

Parameters:
name - the name of the proeprty
Returns:
the value of the property if it is set or null if the property is blank or if the prop doesn't exist.

getUnmodifiableMap

public static Map<String,String> getUnmodifiableMap()

setSpiProperty

public static void setSpiProperty(String clazz,
                                  String name,
                                  String value)

getSpiProperty

public static String getSpiProperty(String spiClass,
                                    String name)

getSpiProperties

public static Map<String,String> getSpiProperties(String spiClass)

setSpiProperties

public static void setSpiProperties(String spiClass,
                                    Map<String,String> config)

isHidden

public static boolean isHidden(String propName)
Determine if a property should be hidden.

Parameters:
propName - the name of the property.
Returns:
true if the key should be hidden, false otherwise.

jiveContainerFor

public static JiveContainer jiveContainerFor(JiveObject source)

isDebugMode

public static boolean isDebugMode()

Clearspace Project Page

Copyright © 1999-2007 Jive Software.