public class JiveGlobals extends Object
When starting up the application this class needs to be configured so that the initial
configuration of the application may be loaded from the configuration file. The configuration
file holds properties stored in XML format, database configuration and user authentication
configuration. Use setHomeDirectory(String)
and setConfigName(String)
for
setting the home directory and path to the configuration file.
XML 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.
Modifier and Type | Field and Description |
---|---|
static boolean |
failedLoading |
Constructor and Description |
---|
JiveGlobals() |
Modifier and Type | Method and Description |
---|---|
static void |
deleteProperty(String name)
Deletes a Jive property.
|
static void |
deleteXMLProperty(String name)
Deletes a locale property.
|
static String |
formatDate(Date date)
Formats a Date object to return a date using the global locale.
|
static String |
formatDateTime(Date date)
Formats a Date object to return a date and time using the global locale.
|
static String |
formatTime(Date date)
Formats a Date object to return a time using the global locale.
|
static boolean |
getBooleanProperty(String name)
Returns a boolean value Jive property.
|
static boolean |
getBooleanProperty(String name,
boolean defaultValue)
Returns a boolean value Jive property.
|
static <E extends Enum<E>> |
getEnumProperty(String name,
Class<E> enumType,
E defaultValue)
Returns an enum constant Jive property.
|
static String |
getHomeDirectory()
Returns the location of the
home directory. |
static int |
getIntProperty(String name,
int defaultValue)
Returns an integer value Jive property.
|
static List<String> |
getListProperty(String parent,
List<String> defaultValues)
Return all immediate children property values of a parent Jive property as a list of strings, or an default list
if the property does not exist.
|
static Locale |
getLocale()
Returns the global Locale used by Jive.
|
static long |
getLongProperty(String name,
long defaultValue)
Returns a long value Jive property.
|
static List<String> |
getProperties(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 |
getProperty(String name)
Returns a Jive property.
|
static String |
getProperty(String name,
String defaultValue)
Returns a Jive property.
|
static Encryptor |
getPropertyEncryptor()
Fetches the current value of the property encryption key.
|
static List<String> |
getPropertyNames()
Returns all Jive property names.
|
static List<String> |
getPropertyNames(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 TimeZone |
getTimeZone()
Returns the global TimeZone used by Jive.
|
static List |
getXMLProperties(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 |
getXMLProperty(String name)
Returns a local property.
|
static boolean |
getXMLProperty(String name,
boolean defaultValue)
Returns a boolean value local property.
|
static int |
getXMLProperty(String name,
int defaultValue)
Returns an integer value local property.
|
static String |
getXMLProperty(String name,
String defaultValue)
Returns a local property.
|
static List<String> |
getXMLPropertyNames()
Return all property names as a list of strings, or an empty list if jiveHome has not been loaded.
|
static boolean |
isPropertyEncrypted(String name)
Determines whether a property is configured for encryption.
|
static boolean |
isPropertySensitive(String name)
Flags certain properties as being sensitive, based on
property naming conventions.
|
static void |
migrateProperty(String name)
Convenience routine to migrate an XML property into the database
storage method.
|
static void |
setConfigName(String configName)
Allows the name of the local config file name to be changed.
|
static void |
setHomeDirectory(String pathname)
Sets the location of the
home directory. |
static void |
setLocale(Locale newLocale)
Sets the global locale used by Jive.
|
static void |
setProperties(Map<String,String> propertyMap)
Sets multiple Jive properties at once.
|
static void |
setProperty(String name,
List<String> values)
Sets a Jive property with a list of values.
|
static void |
setProperty(String name,
String value)
Sets a Jive property.
|
static void |
setProperty(String name,
String value,
boolean encrypt)
Sets a Jive property.
|
static boolean |
setPropertyEncrypted(String name,
boolean encrypt)
Set the encryption status for the given property.
|
static void |
setTimeZone(TimeZone newTimeZone)
Sets the global time zone used by Jive.
|
static void |
setupPropertyEncryptionAlgorithm(String alg)
This method is called early during the setup process to
set the algorithm for encrypting property values
|
static void |
setupPropertyEncryptionKey(String key)
This method is called early during the setup process to
set a custom key for encrypting property values
|
static void |
setXMLProperties(Map<String,String> propertyMap)
Sets multiple local properties at once.
|
static void |
setXMLProperty(String name,
String value)
Sets a local property.
|
public static Locale getLocale()
public static void setLocale(Locale newLocale)
newLocale
- the global Locale for Jive.public static TimeZone getTimeZone()
public static void setTimeZone(TimeZone newTimeZone)
newTimeZone
- Time zone to set.public static String formatTime(Date date)
date
- the Date to format.public static String formatDate(Date date)
date
- the Date to format.public static String formatDateTime(Date date)
date
- the Date to format.public static String getHomeDirectory()
home
directory.public static void setHomeDirectory(String pathname)
home
directory. The directory must exist and the
user running the application must have read and write permissions over the specified
directory.pathname
- the location of the home dir.public static String getXMLProperty(String name)
<foo> <bar> <prop>some value</prop> </bar> </foo>
name
- the name of the property to return.public static String getXMLProperty(String name, String defaultValue)
<foo> <bar> <prop>some value</prop> </bar> </foo>If the specified property can't be found, the defaultValue will be returned.
name
- the name of the property to return.defaultValue
- the default value for the property.public static int getXMLProperty(String name, int defaultValue)
<foo> <bar> <prop>some value</prop> </bar> </foo>If the specified property can't be found, or if the value is not a number, the defaultValue will be returned.
name
- the name of the property to return.defaultValue
- value returned if the property could not be loaded or was not
a number.public static boolean getXMLProperty(String name, boolean defaultValue)
<foo> <bar> <prop>some value</prop> </bar> </foo>If the specified property can't be found, the defaultValue will be returned. If the property is found, it will be parsed using
Boolean.valueOf(String)
.name
- the name of the property to return.defaultValue
- value returned if the property could not be loaded or was not
a number.public static void setXMLProperty(String name, String value)
<foo> <bar> <prop>some value</prop> </bar> </foo>
name
- the name of the property being set.value
- the value of the property being set.public static void setXMLProperties(Map<String,String> propertyMap)
<foo> <bar> <prop>some value</prop> </bar> </foo>
propertyMap
- a map of properties, keyed on property name.public static List getXMLProperties(String parent)
Local properties are stored in the file defined in JIVE_CONFIG_FILENAME that exists in the home 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>
parent
- the name of the parent property to return the children for.public static List<String> getXMLPropertyNames()
public static void deleteXMLProperty(String name)
name
- the name of the property to delete.public static String getProperty(String name)
name
- the name of the property to return.public static String getProperty(String name, String defaultValue)
name
- the name of the property to return.defaultValue
- value returned if the property doesn't exist.public static <E extends Enum<E>> E getEnumProperty(String name, Class<E> enumType, E defaultValue)
E
- The enum type whose constant is to be returned.name
- the name of the property to return.enumType
- the Class
object of the enum type from which to return a constant.defaultValue
- value returned if the property doesn't exist or it's value could not be parsed.public static int getIntProperty(String name, int defaultValue)
name
- the name of the property to return.defaultValue
- value returned if the property doesn't exist or was not
a number.public static long getLongProperty(String name, long defaultValue)
name
- the name of the property to return.defaultValue
- value returned if the property doesn't exist or was not
a number.public static boolean getBooleanProperty(String name)
name
- the name of the property to return.public static boolean getBooleanProperty(String name, boolean defaultValue)
name
- the name of the property to return.defaultValue
- value returned if the property doesn't exist.public static List<String> getPropertyNames(String parent)
parent
- Parent "node" to find the children of.public static List<String> getProperties(String parent)
parent
- the name of the parent property to return the children for.public static List<String> getListProperty(String parent, List<String> defaultValues)
getProperties(String)
.parent
- the name of the parent property to return the children for.defaultValues
- values returned if the property doesn't exist.public static List<String> getPropertyNames()
public static void setProperty(String name, String value)
name
- the name of the property being set.value
- the value of the property being set.public static void setProperty(String name, String value, boolean encrypt)
name
- the name of the property being set.value
- the value of the property being set.encrypt
- true
to encrypt the property in the database, other false
public static void setProperty(String name, List<String> values)
setProperties(Map)
, which is used to set multiple properties. This method sets
one property with multiple values.name
- the name of the property being set.values
- the values of the property.public static void setProperties(Map<String,String> propertyMap)
setProperty(String, List)
, which is used to one property with multiple
values. This method sets multiple properties, each with one value.propertyMap
- a map of properties, keyed on property name.public static void deleteProperty(String name)
name
- the name of the property to delete.public static void migrateProperty(String name)
name
- the name of the property to migrate.public static boolean isPropertySensitive(String name)
name
- The name of the propertypublic static boolean isPropertyEncrypted(String name)
name
- The name of the propertytrue
if the property is stored using encryption, otherwise false
public static boolean setPropertyEncrypted(String name, boolean encrypt)
name
- The name of the propertyencrypt
- True to encrypt the property, false to decryptpublic static Encryptor getPropertyEncryptor()
public static void setupPropertyEncryptionAlgorithm(String alg)
public static void setupPropertyEncryptionKey(String key)
public static void setConfigName(String configName)
configName
- the name of the config file.Copyright © 2003-2008 Jive Software.