Class JiveGlobals
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 setHomePath(Path)
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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Path
static String
Returns the name of the local config file.static double
getDoubleProperty
(String name, double defaultValue) Returns a double value Jive property.static <E extends Enum<E>>
EgetEnumProperty
(String name, Class<E> enumType, E defaultValue) Returns an enum constant Jive property.static Path
Returns the location of thehome
directory.static int
getIntProperty
(String name, int defaultValue) Returns an integer value Jive property.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
Returns the global Locale used by Jive.static long
getLongProperty
(String name, long defaultValue) Returns a long value Jive property.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
Fetches the current property encryptor.static Encryptor
getPropertyEncryptor
(boolean useNewEncryptor) Fetches the property encryptor.Returns all Jive property names.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 Path
static String
Returns the name of the local security config file.static TimeZone
Returns the global TimeZone used by Jive.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.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 boolean
isXMLPropertyEncrypted
(String name) Determines whether an XML property is configured for encryption.static void
migrateProperty
(String name) Convenience routine to migrate an XML property into the database storage method.static void
migratePropertyTree
(String name) Convenience routine to migrate a tree of XML propertis into the database storage method.static void
setConfigName
(String configName) Allows the name of the local config file name to be changed.static void
setHomePath
(Path homeDir) Sets the location of thehome
directory.static void
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, String value) Sets a Jive property.static void
setProperty
(String name, String value, boolean encrypt) Sets a Jive property.static void
setProperty
(String name, List<String> values) Sets a Jive property with a list of values.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
This method is called early during the setup process to set the algorithm for encrypting property valuesstatic void
This method is called early during the setup process to set a custom key for encrypting property valuesstatic void
setXMLProperties
(Map<String, String> propertyMap) Sets multiple local properties at once.static boolean
setXMLProperty
(String name, String value) Sets a local property.
-
Field Details
-
setupExcludePaths
-
-
Constructor Details
-
JiveGlobals
public JiveGlobals()
-
-
Method Details
-
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 dependent - Locale.getDefault().- Returns:
- the global locale used by Jive.
-
setLocale
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 is Locale.US.- Parameters:
newLocale
- the global Locale for Jive.
-
getTimeZone
Returns the global TimeZone used by Jive. The default is the VM's default time zone.- Returns:
- the global time zone used by Jive.
-
setTimeZone
Sets the global time zone used by Jive. The default time zone is the VM's time zone.- Parameters:
newTimeZone
- Time zone to set.
-
formatTime
Formats a Date object to return a time using the global locale.- Parameters:
date
- the Date to format.- Returns:
- a String representing the time.
-
formatDate
Formats a Date object to return a date using the global locale.- Parameters:
date
- the Date to format.- Returns:
- a String representing the date.
-
formatDateTime
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.
-
getHomePath
Returns the location of thehome
directory.- Returns:
- the location of the home dir.
-
setHomePath
Sets the location of thehome
directory. The directory must exist and the user running the application must have read and write permissions over the specified directory.- Parameters:
homeDir
- the location of the home dir.
-
getXMLProperty
Returns a local property. Local properties are stored in the file defined inJIVE_CONFIG_FILENAME
that exists in thehome
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.
-
getXMLProperty
Returns a local property. Local properties are stored in the file defined inJIVE_CONFIG_FILENAME
that exists in thehome
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>
If the specified property can't be found, thedefaultValue
will be returned.- Parameters:
name
- the name of the property to return.defaultValue
- the default value for the property.- Returns:
- the property value specified by name.
-
getXMLProperty
Returns an integer value local property. Local properties are stored in the file defined inJIVE_CONFIG_FILENAME
that exists in thehome
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>
If the specified property can't be found, or if the value is not a number, thedefaultValue
will be returned.- Parameters:
name
- the name of the property to return.defaultValue
- value returned if the property could not be loaded or was not a number.- Returns:
- the property value specified by name or
defaultValue
.
-
getXMLProperty
Returns a boolean value local property. Local properties are stored in the file defined inJIVE_CONFIG_FILENAME
that exists in thehome
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>
If the specified property can't be found, thedefaultValue
will be returned. If the property is found, it will be parsed usingBoolean.valueOf(String)
.- Parameters:
name
- the name of the property to return.defaultValue
- value returned if the property could not be loaded or was not a number.- Returns:
- the property value specified by name or
defaultValue
.
-
setXMLProperty
Sets a local property. If the property doesn't already exists, a new one will be created. Local properties are stored in the file defined inJIVE_CONFIG_FILENAME
that exists in thehome
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 being set.value
- the value of the property being set.- Returns:
true
if the property was correctly saved to file, otherwisefalse
-
setXMLProperties
Sets multiple local properties at once. If a property doesn't already exists, a new one will be created. Local properties are stored in the file defined inJIVE_CONFIG_FILENAME
that exists in thehome
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:
propertyMap
- a map of properties, keyed on property name.
-
getXMLProperties
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 propertiesX.Y.A
,X.Y.B
,X.Y.C
andX.Y.C.D
, then the immediate child properties ofX.Y
areA
,B
, andC
(the value ofC.D
would not be returned using this method).Local properties are stored in the file defined in
JIVE_CONFIG_FILENAME
that exists in thehome
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:
parent
- the name of the parent property to return the children for.- Returns:
- all child property values for the given parent.
-
getXMLPropertyNames
Return all property names as a list of strings, or an empty list if jiveHome has not been loaded.- Returns:
- all child property for the given parent.
-
deleteXMLProperty
Deletes a locale property. If the property doesn't exist, the method does nothing.- Parameters:
name
- the name of the property to delete.
-
getProperty
Returns a Jive property.- Parameters:
name
- the name of the property to return.- Returns:
- the property value specified by name.
-
getProperty
Returns a Jive property. If the specified property doesn't exist, thedefaultValue
will be returned.- Parameters:
name
- the name of the property to return.defaultValue
- value returned if the property doesn't exist.- Returns:
- the property value specified by name.
-
getEnumProperty
Returns an enum constant Jive property. If the specified property doesn't exist, or if it's value cannot be parsed as an enum constant, thedefaultValue
will be returned.- Type Parameters:
E
- The enum type whose constant is to be returned.- Parameters:
name
- the name of the property to return.enumType
- theClass
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.- Returns:
- the property value (as an enum constant) or
defaultValue
.
-
getIntProperty
Returns an integer value Jive property. If the specified property doesn't exist, thedefaultValue
will be returned.- Parameters:
name
- the name of the property to return.defaultValue
- value returned if the property doesn't exist or was not a number.- Returns:
- the property value specified by name or
defaultValue
.
-
getLongProperty
Returns a long value Jive property. If the specified property doesn't exist, thedefaultValue
will be returned.- Parameters:
name
- the name of the property to return.defaultValue
- value returned if the property doesn't exist or was not a number.- Returns:
- the property value specified by name or
defaultValue
.
-
getDoubleProperty
Returns a double value Jive property. If the specified property doesn't exist, thedefaultValue
will be returned.- Parameters:
name
- the name of the property to return.defaultValue
- value returned if the property doesn't exist or was not a number.- Returns:
- the property value specified by name or
defaultValue
.
-
getBooleanProperty
Returns a boolean value Jive property.- Parameters:
name
- the name of the property to return.- Returns:
- true if the property value exists and is set to
"true"
(ignoring case). Otherwisefalse
is returned.
-
getBooleanProperty
Returns a boolean value Jive property. If the property doesn't exist, thedefaultValue
will be returned. If the specified property can't be found, or if the value is not a number, thedefaultValue
will be returned.- Parameters:
name
- the name of the property to return.defaultValue
- value returned if the property doesn't exist.- Returns:
- true if the property value exists and is set to
"true"
(ignoring case). Otherwisefalse
is returned.
-
getPropertyNames
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 propertiesX.Y.A
,X.Y.B
,X.Y.C
andX.Y.C.D
, then the immediate child properties ofX.Y
areA
,B
, andC
(C.D
would not be returned using this method).- Parameters:
parent
- Parent "node" to find the children of.- Returns:
- a List of all immediate children property names (Strings).
-
getProperties
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 propertiesX.Y.A
,X.Y.B
,X.Y.C
andX.Y.C.D
, then the immediate child properties ofX.Y
areX.Y.A
,X.Y.B
, andX.Y.C
(the value ofX.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.
-
getListProperty
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. This implementation ignores child property values that are empty (these are excluded from the result). When all child properties are empty, an empty collection (and explicitly not the default values) is returned. This allows a property to override a default non-empty collection with an empty one. The child properties that are evaluated in this method are the same child properties as those used bygetProperties(String)
.- Parameters:
parent
- the name of the parent property to return the children for.defaultValues
- values returned if the property doesn't exist.- Returns:
- all child property values for the given parent.
-
getPropertyNames
Returns all Jive property names.- Returns:
- a List of all property names (Strings).
-
setProperty
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.
-
setProperty
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.encrypt
-true
to encrypt the property in the database, otherfalse
-
setProperty
Sets a Jive property with a list of values. If the property doesn't already exists, a new one will be created. Empty or null values in the collection are ignored. Each value is stored as a direct child property of the property name provided as an argument to this method. When this method is used, all previous children of the property will be deleted. When the provided value is null, any previously stored collection will be removed. If it is an empty collection (or a collection that consists of null and empty values onlu), it is stored as an empty collection (represented by a child property that has an empty value). The naming convention used by this method to define child properties is subject to change, and should not be depended on. This method differs fromsetProperties(Map)
, which is used to set multiple properties. This method sets one property with multiple values.- Parameters:
name
- the name of the property being set.values
- the values of the property.
-
setProperties
Sets multiple Jive properties at once. If a property doesn't already exists, a new one will be created. This method differs fromsetProperty(String, List)
, which is used to one property with multiple values. This method sets multiple properties, each with one value.- Parameters:
propertyMap
- a map of properties, keyed on property name.
-
deleteProperty
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.
-
migrateProperty
Convenience routine to migrate an XML property into the database storage method. Will check for the XML property being null before migrating.- Parameters:
name
- the name of the property to migrate.
-
migratePropertyTree
Convenience routine to migrate a tree of XML propertis into the database storage method.- Parameters:
name
- the name of the base property to migrate.
-
isPropertySensitive
Flags certain properties as being sensitive, based on property naming conventions. Values for matching property names are hidden from the Openfire console.- Parameters:
name
- The name of the property- Returns:
- True if the property is considered sensitive, otherwise false
-
isXMLPropertyEncrypted
Determines whether an XML property is configured for encryption.- Parameters:
name
- The name of the property- Returns:
true
if the property is stored using encryption, otherwisefalse
-
isPropertyEncrypted
Determines whether a property is configured for encryption.- Parameters:
name
- The name of the property- Returns:
true
if the property is stored using encryption, otherwisefalse
-
setPropertyEncrypted
Set the encryption status for the given property.- Parameters:
name
- The name of the propertyencrypt
- True to encrypt the property, false to decrypt- Returns:
- True if the property's encryption status changed, otherwise false
-
getPropertyEncryptor
Fetches the property encryptor.- Parameters:
useNewEncryptor
- Should use the new encryptor- Returns:
- The property encryptor
-
getPropertyEncryptor
Fetches the current property encryptor.- Returns:
- The current property encryptor
-
setupPropertyEncryptionAlgorithm
This method is called early during the setup process to set the algorithm for encrypting property values- Parameters:
alg
- the algorithm used to encrypt properties
-
setupPropertyEncryptionKey
This method is called early during the setup process to set a custom key for encrypting property values- Parameters:
key
- the key used to encrypt properties
-
setConfigName
Allows the name of the local config file name to be changed. The default is "openfire.xml".- Parameters:
configName
- the name of the config file.
-
getConfigName
Returns the name of the local config file.- Returns:
- the name of the config file.
-
getSecurityConfigName
Returns the name of the local security config file.- Returns:
- the name of the security config file.
-
getConfigLocation
-
getSecurityConfigLocation
-