Commit dcffb573 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Jive properties are now broken into two types -- XML properties from a local...

Jive properties are now broken into two types -- XML properties from a local config file and normal properties that are stored in the database.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@73 b35dd754-fafc-0310-a699-88a17e54d16e
parent dc2a48fd
...@@ -69,7 +69,7 @@ public class DbConnectionManager { ...@@ -69,7 +69,7 @@ public class DbConnectionManager {
if (connectionProvider == null) { if (connectionProvider == null) {
// Attempt to load the connection provider classname as // Attempt to load the connection provider classname as
// a Jive property. // a Jive property.
String className = JiveGlobals.getJiveProperty("connectionProvider.className"); String className = JiveGlobals.getXMLProperty("connectionProvider.className");
if (className != null) { if (className != null) {
// Attempt to load the class. // Attempt to load the class.
try { try {
...@@ -268,7 +268,7 @@ public class DbConnectionManager { ...@@ -268,7 +268,7 @@ public class DbConnectionManager {
} }
} }
// Remember what connection provider we want to use for restarts. // Remember what connection provider we want to use for restarts.
JiveGlobals.setJiveProperty("connectionProvider.className", JiveGlobals.setProperty("connectionProvider.className",
provider.getClass().getName()); provider.getClass().getName());
} }
......
...@@ -13,8 +13,6 @@ package org.jivesoftware.database; ...@@ -13,8 +13,6 @@ package org.jivesoftware.database;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.JiveGlobals; import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.database.ConnectionPool;
import org.jivesoftware.database.ConnectionProvider;
import java.io.IOException; import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
...@@ -276,15 +274,15 @@ public class DefaultConnectionProvider implements ConnectionProvider { ...@@ -276,15 +274,15 @@ public class DefaultConnectionProvider implements ConnectionProvider {
* Load properties that already exist from Jive properties. * Load properties that already exist from Jive properties.
*/ */
private void loadProperties() { private void loadProperties() {
driver = JiveGlobals.getJiveProperty("database.defaultProvider.driver"); driver = JiveGlobals.getXMLProperty("database.defaultProvider.driver");
serverURL = JiveGlobals.getJiveProperty("database.defaultProvider.serverURL"); serverURL = JiveGlobals.getXMLProperty("database.defaultProvider.serverURL");
username = JiveGlobals.getJiveProperty("database.defaultProvider.username"); username = JiveGlobals.getXMLProperty("database.defaultProvider.username");
password = JiveGlobals.getJiveProperty("database.defaultProvider.password"); password = JiveGlobals.getXMLProperty("database.defaultProvider.password");
String minCons = JiveGlobals.getJiveProperty("database.defaultProvider.minConnections"); String minCons = JiveGlobals.getXMLProperty("database.defaultProvider.minConnections");
String maxCons = JiveGlobals.getJiveProperty("database.defaultProvider.maxConnections"); String maxCons = JiveGlobals.getXMLProperty("database.defaultProvider.maxConnections");
String conTimeout = JiveGlobals.getJiveProperty("database.defaultProvider.connectionTimeout"); String conTimeout = JiveGlobals.getXMLProperty("database.defaultProvider.connectionTimeout");
// See if we should use Unicode under MySQL // See if we should use Unicode under MySQL
mysqlUseUnicode = Boolean.valueOf(JiveGlobals.getJiveProperty("database.mysql.useUnicode")).booleanValue(); mysqlUseUnicode = Boolean.valueOf(JiveGlobals.getXMLProperty("database.mysql.useUnicode")).booleanValue();
try { try {
if (minCons != null) { if (minCons != null) {
minConnections = Integer.parseInt(minCons); minConnections = Integer.parseInt(minCons);
...@@ -307,16 +305,16 @@ public class DefaultConnectionProvider implements ConnectionProvider { ...@@ -307,16 +305,16 @@ public class DefaultConnectionProvider implements ConnectionProvider {
*/ */
private void saveProperties() { private void saveProperties() {
JiveGlobals.setJiveProperty("database.defaultProvider.driver", driver); JiveGlobals.setXMLProperty("database.defaultProvider.driver", driver);
JiveGlobals.setJiveProperty("database.defaultProvider.serverURL", serverURL); JiveGlobals.setXMLProperty("database.defaultProvider.serverURL", serverURL);
JiveGlobals.setJiveProperty("database.defaultProvider.username", username); JiveGlobals.setXMLProperty("database.defaultProvider.username", username);
JiveGlobals.setJiveProperty("database.defaultProvider.password", password); JiveGlobals.setXMLProperty("database.defaultProvider.password", password);
JiveGlobals.setJiveProperty("database.defaultProvider.minConnections", JiveGlobals.setXMLProperty("database.defaultProvider.minConnections",
Integer.toString(minConnections)); Integer.toString(minConnections));
JiveGlobals.setJiveProperty("database.defaultProvider.maxConnections", JiveGlobals.setXMLProperty("database.defaultProvider.maxConnections",
Integer.toString(maxConnections)); Integer.toString(maxConnections));
JiveGlobals.setJiveProperty("database.defaultProvider.connectionTimeout", JiveGlobals.setXMLProperty("database.defaultProvider.connectionTimeout",
Double.toString(connectionTimeout)); Double.toString(connectionTimeout));
} }
} }
...@@ -64,7 +64,7 @@ public class JNDIDataSourceProvider implements ConnectionProvider { ...@@ -64,7 +64,7 @@ public class JNDIDataSourceProvider implements ConnectionProvider {
* Initialize. * Initialize.
*/ */
public JNDIDataSourceProvider() { public JNDIDataSourceProvider() {
dataSourceName = JiveGlobals.getJiveProperty("database.JNDIProvider.name"); dataSourceName = JiveGlobals.getXMLProperty("database.JNDIProvider.name");
} }
public String getName() { public String getName() {
...@@ -103,7 +103,7 @@ public class JNDIDataSourceProvider implements ConnectionProvider { ...@@ -103,7 +103,7 @@ public class JNDIDataSourceProvider implements ConnectionProvider {
Properties contextProperties = new Properties(); Properties contextProperties = new Properties();
for (int i = 0; i < jndiPropertyKeys.length; i++) { for (int i = 0; i < jndiPropertyKeys.length; i++) {
String k = jndiPropertyKeys[i]; String k = jndiPropertyKeys[i];
String v = JiveGlobals.getJiveProperty(k); String v = JiveGlobals.getXMLProperty(k);
if (v != null) { if (v != null) {
contextProperties.setProperty(k, v); contextProperties.setProperty(k, v);
} }
...@@ -157,7 +157,7 @@ public class JNDIDataSourceProvider implements ConnectionProvider { ...@@ -157,7 +157,7 @@ public class JNDIDataSourceProvider implements ConnectionProvider {
public void setProperty(String name, String value) { public void setProperty(String name, String value) {
if ("name".equals(name)) { if ("name".equals(name)) {
this.dataSourceName = value; this.dataSourceName = value;
JiveGlobals.setJiveProperty("database.JNDIProvider.name", value); JiveGlobals.setXMLProperty("database.JNDIProvider.name", value);
} }
} }
...@@ -185,4 +185,4 @@ public class JNDIDataSourceProvider implements ConnectionProvider { ...@@ -185,4 +185,4 @@ public class JNDIDataSourceProvider implements ConnectionProvider {
private final void error(String msg, Exception e) { private final void error(String msg, Exception e) {
Log.error(msg, e); Log.error(msg, e);
} }
} }
\ No newline at end of file
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
package org.jivesoftware.messenger; package org.jivesoftware.messenger;
import org.jivesoftware.util.Log; import org.jivesoftware.util.*;
import org.jivesoftware.util.XMLProperties;
import org.jivesoftware.util.XPPReader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.Date; import java.util.*;
import java.util.Locale;
import java.util.TimeZone;
import org.dom4j.Document; import org.dom4j.Document;
import javax.naming.InitialContext;
/** /**
* This class controls Jive properties. Jive properties are only meant to be set and retrieved * This class controls Jive properties. Jive properties are only meant to be set and retrieved
* by core Jive classes.<p> * by core Jive classes.<p>
...@@ -53,7 +53,9 @@ import org.dom4j.Document; ...@@ -53,7 +53,9 @@ import org.dom4j.Document;
*/ */
public class JiveGlobals { public class JiveGlobals {
private static final String JIVE_CONFIG_FILENAME = "jive-messenger.xml"; private static String JIVE_CONFIG_FILENAME = "jive-messenger.xml";
private static final String DEFAULT_CHAR_ENCODING = "UTF-8";
/** /**
* Location of the jiveHome directory. All configuration files should be * Location of the jiveHome directory. All configuration files should be
...@@ -63,10 +65,8 @@ public class JiveGlobals { ...@@ -63,10 +65,8 @@ public class JiveGlobals {
public static boolean failedLoading = false; public static boolean failedLoading = false;
/** private static XMLProperties xmlProperties = null;
* XML properties to actually get and set the Jive properties. private static JiveProperties properties = null;
*/
private static XMLProperties properties = null;
private static Locale locale = null; private static Locale locale = null;
private static TimeZone timeZone = null; private static TimeZone timeZone = null;
...@@ -83,16 +83,28 @@ public class JiveGlobals { ...@@ -83,16 +83,28 @@ public class JiveGlobals {
*/ */
public static Locale getLocale() { public static Locale getLocale() {
if (locale == null) { if (locale == null) {
loadProperties(); if (properties != null) {
} String language = (String)properties.get("locale.language");
if (language == null) {
if (locale != null) { language = "";
return locale; }
} String country = (String)properties.get("locale.country");
else { if (country == null) {
// we don't want the locale to be null ever so just return the system default locale country = "";
return Locale.getDefault(); }
// If no locale info is specified, return the system default Locale.
if (language.equals("") && country.equals("")) {
locale = Locale.getDefault();
}
else {
locale = new Locale(language, country);
}
}
else {
return Locale.getDefault();
}
} }
return locale;
} }
/** /**
...@@ -105,8 +117,8 @@ public class JiveGlobals { ...@@ -105,8 +117,8 @@ public class JiveGlobals {
public static void setLocale(Locale newLocale) { public static void setLocale(Locale newLocale) {
locale = newLocale; locale = newLocale;
// Save values to Jive properties. // Save values to Jive properties.
setJiveProperty("locale.country", locale.getCountry()); setProperty("locale.country", locale.getCountry());
setJiveProperty("locale.language", locale.getLanguage()); setProperty("locale.language", locale.getLanguage());
// Reset the date formatter objects // Reset the date formatter objects
dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
...@@ -127,7 +139,7 @@ public class JiveGlobals { ...@@ -127,7 +139,7 @@ public class JiveGlobals {
* by your JVM. A list of encodings supported by the Sun JVM can be found * by your JVM. A list of encodings supported by the Sun JVM can be found
* <a href="http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html"> * <a href="http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html">
* here.</a><p> * here.</a><p>
* <p/> *
* In order for a particular encoding to work (such as Unicode), your * In order for a particular encoding to work (such as Unicode), your
* application server and database may need to be specially configured. * application server and database may need to be specially configured.
* Please consult your server documentation for more information. For * Please consult your server documentation for more information. For
...@@ -143,8 +155,21 @@ public class JiveGlobals { ...@@ -143,8 +155,21 @@ public class JiveGlobals {
* @return the global Jive character encoding. * @return the global Jive character encoding.
*/ */
public static String getCharacterEncoding() { public static String getCharacterEncoding() {
if (locale == null) { if (characterEncoding == null) {
loadProperties(); if (properties != null) {
String charEncoding = (String)properties.get("locale.characterEncoding");
if (charEncoding != null) {
characterEncoding = charEncoding;
}
else {
// The default encoding is ISO-8859-1. We use the version of
// the encoding name that seems to be most widely compatible.
characterEncoding = DEFAULT_CHAR_ENCODING;
}
}
else {
return DEFAULT_CHAR_ENCODING;
}
} }
return characterEncoding; return characterEncoding;
} }
...@@ -161,7 +186,7 @@ public class JiveGlobals { ...@@ -161,7 +186,7 @@ public class JiveGlobals {
* by your JVM. A list of encodings supported by the Sun JVM can be found * by your JVM. A list of encodings supported by the Sun JVM can be found
* <a href="http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html"> * <a href="http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html">
* here.</a><p> * here.</a><p>
* <p/> *
* In order for a particular encoding to work (such as Unicode), your * In order for a particular encoding to work (such as Unicode), your
* application server and database may need to be specially configured. * application server and database may need to be specially configured.
* Please consult your server documentation for more information. For * Please consult your server documentation for more information. For
...@@ -178,7 +203,7 @@ public class JiveGlobals { ...@@ -178,7 +203,7 @@ public class JiveGlobals {
*/ */
public static void setCharacterEncoding(String characterEncoding) { public static void setCharacterEncoding(String characterEncoding) {
JiveGlobals.characterEncoding = characterEncoding; JiveGlobals.characterEncoding = characterEncoding;
setJiveProperty("locale.characterEncoding", characterEncoding); setProperty("locale.characterEncoding", characterEncoding);
} }
/** /**
...@@ -188,8 +213,19 @@ public class JiveGlobals { ...@@ -188,8 +213,19 @@ public class JiveGlobals {
* @return the global time zone used by Jive. * @return the global time zone used by Jive.
*/ */
public static TimeZone getTimeZone() { public static TimeZone getTimeZone() {
if (locale == null) { if (timeZone == null) {
loadProperties(); if (properties != null) {
String timeZoneID = (String)properties.get("locale.timeZone");
if (timeZoneID == null) {
timeZone = TimeZone.getDefault();
}
else {
timeZone = TimeZone.getTimeZone(timeZoneID);
}
}
else {
return TimeZone.getDefault();
}
} }
return timeZone; return timeZone;
} }
...@@ -202,7 +238,7 @@ public class JiveGlobals { ...@@ -202,7 +238,7 @@ public class JiveGlobals {
timeZone = newTimeZone; timeZone = newTimeZone;
dateFormat.setTimeZone(timeZone); dateFormat.setTimeZone(timeZone);
dateTimeFormat.setTimeZone(timeZone); dateTimeFormat.setTimeZone(timeZone);
setJiveProperty("locale.timeZone", timeZone.getID()); setProperty("locale.timeZone", timeZone.getID());
} }
/** /**
...@@ -212,8 +248,16 @@ public class JiveGlobals { ...@@ -212,8 +248,16 @@ public class JiveGlobals {
* @return a String representing the date. * @return a String representing the date.
*/ */
public static String formatDate(Date date) { public static String formatDate(Date date) {
if (locale == null) { if (dateFormat == null) {
loadProperties(); if (properties != null) {
dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale());
dateFormat.setTimeZone(getTimeZone());
}
else {
DateFormat instance = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale());
instance.setTimeZone(getTimeZone());
return instance.format(date);
}
} }
return dateFormat.format(date); return dateFormat.format(date);
} }
...@@ -225,8 +269,18 @@ public class JiveGlobals { ...@@ -225,8 +269,18 @@ public class JiveGlobals {
* @return a String representing the date and time. * @return a String representing the date and time.
*/ */
public static String formatDateTime(Date date) { public static String formatDateTime(Date date) {
if (locale == null) { if (dateTimeFormat == null) {
loadProperties(); if (properties != null) {
dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
DateFormat.MEDIUM, getLocale());
dateTimeFormat.setTimeZone(getTimeZone());
}
else {
DateFormat instance = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
DateFormat.MEDIUM, getLocale());
instance.setTimeZone(getTimeZone());
return instance.format(date);
}
} }
return dateTimeFormat.format(date); return dateTimeFormat.format(date);
} }
...@@ -238,14 +292,35 @@ public class JiveGlobals { ...@@ -238,14 +292,35 @@ public class JiveGlobals {
*/ */
public static String getJiveHome() { public static String getJiveHome() {
if (jiveHome == null) { if (jiveHome == null) {
loadProperties(); loadSetupProperties();
} }
return jiveHome; return jiveHome;
} }
/** /**
* Returns a Jive property. Jive properties are stored in the file * Sets the location of the <code>jiveHome</code> directory. This method is only intended to be
* <tt>jive_config.xml</tt> that exists in the <tt>jiveHome</tt> directory. * used during setup and should <b>not</b> set called in normal Jive operations.
*/
public static void setJiveHome(String jHome) {
properties = null;
xmlProperties = null;
failedLoading = false;
jiveHome = jHome;
locale = null;
timeZone = null;
characterEncoding = null;
dateFormat = null;
dateTimeFormat = null;
loadSetupProperties();
System.err.println("Warning - jiveHome is being reset to " + jHome +
"! Resetting the jiveHome is a normal part of the setup process, " +
"however it should not occur during the normal operations of Jive.");
}
/**
* Returns a local property. Local properties are stored in the file
* <tt>jive_forums.xml</tt> that exists in the <tt>jiveHome</tt> directory.
* Properties are always specified as "foo.bar.prop", which would map to * Properties are always specified as "foo.bar.prop", which would map to
* the following entry in the XML file: * the following entry in the XML file:
* <pre> * <pre>
...@@ -259,23 +334,22 @@ public class JiveGlobals { ...@@ -259,23 +334,22 @@ public class JiveGlobals {
* @param name the name of the property to return. * @param name the name of the property to return.
* @return the property value specified by name. * @return the property value specified by name.
*/ */
public static String getJiveProperty(String name) { public static String getXMLProperty(String name) {
if (properties == null) { if (xmlProperties == null) {
loadProperties(); loadSetupProperties();
} }
// jiveHome not loaded? // jiveHome not loaded?
if (properties == null) { if (xmlProperties == null) {
return null; return null;
} }
return properties.getProperty(name); return xmlProperties.getProperty(name);
} }
/** /**
* Sets a Jive property. If the property doesn't already exists, a new * Returns an integer value local property. Local properties are stored in the file
* one will be created. Jive properties are stored in the file * <tt>jive_forums.xml</tt> that exists in the <tt>jiveHome</tt> directory.
* <tt>jive_config.xml</tt> that exists in the <tt>jiveHome</tt> directory.
* Properties are always specified as "foo.bar.prop", which would map to * Properties are always specified as "foo.bar.prop", which would map to
* the following entry in the XML file: * the following entry in the XML file:
* <pre> * <pre>
...@@ -286,128 +360,400 @@ public class JiveGlobals { ...@@ -286,128 +360,400 @@ public class JiveGlobals {
* &lt;/foo&gt; * &lt;/foo&gt;
* </pre> * </pre>
* *
* @param name the name of the property being set. * If the specified property can't be found, or if the value is not a number, the
* <tt>defaultValue</tt> will be returned.
*
* @param name the name of the property to return.
* @param defaultValue value returned if the property could not be loaded or was not
* a number.
* @return the property value specified by name or <tt>defaultValue</tt>.
*/
public static int getXMLProperty(String name, int defaultValue) {
String value = getProperty(name);
if (value != null) {
try {
return Integer.parseInt(value);
}
catch (NumberFormatException nfe) { }
}
return defaultValue;
}
/**
* Sets a local property. If the property doesn't already exists, a new
* one will be created. Local properties are stored in the file
* <tt>jive_forums.xml</tt> that exists in the <tt>jiveHome</tt> directory.
* Properties are always specified as "foo.bar.prop", which would map to
* the following entry in the XML file:
* <pre>
* &lt;foo&gt;
* &lt;bar&gt;
* &lt;prop&gt;some value&lt;/prop&gt;
* &lt;/bar&gt;
* &lt;/foo&gt;
* </pre>
*
* @param name the name of the property being set.
* @param value the value of the property being set. * @param value the value of the property being set.
*/ */
public static void setJiveProperty(String name, String value) { public static void setXMLProperty(String name, String value) {
if (properties == null) { if (xmlProperties == null) {
loadProperties(); loadSetupProperties();
} }
if (properties != null) { // jiveHome not loaded?
properties.setProperty(name, value); if (xmlProperties != null) {
xmlProperties.setProperty(name, value);
} }
} }
/** /**
* Deletes a Jive property. If the property doesn't exist, the method * 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
* <tt>jive_forums.xml</tt> that exists in the <tt>jiveHome</tt> directory.
* Properties are always specified as "foo.bar.prop", which would map to
* the following entry in the XML file:
* <pre>
* &lt;foo&gt;
* &lt;bar&gt;
* &lt;prop&gt;some value&lt;/prop&gt;
* &lt;/bar&gt;
* &lt;/foo&gt;
* </pre>
*
* @param propertyMap a map of properties, keyed on property name.
*/
public static void setXMLProperties(Map propertyMap) {
if (xmlProperties == null) {
loadSetupProperties();
}
if (xmlProperties != null) {
xmlProperties.setProperties(propertyMap);
}
}
/**
* 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 <tt>X.Y.A</tt>, <tt>X.Y.B</tt>, <tt>X.Y.C</tt> and <tt>X.Y.C.D</tt>, then
* the immediate child properties of <tt>X.Y</tt> are <tt>A</tt>, <tt>B</tt>, and
* <tt>C</tt> (the value of <tt>C.D</tt> would not be returned using this method).<p>
*
* Local properties are stored in the file <tt>jive_forums.xml</tt> that exists
* in the <tt>jiveHome</tt> directory. Properties are always specified as "foo.bar.prop",
* which would map to the following entry in the XML file:
* <pre>
* &lt;foo&gt;
* &lt;bar&gt;
* &lt;prop&gt;some value&lt;/prop&gt;
* &lt;/bar&gt;
* &lt;/foo&gt;
* </pre>
*
*
* @param parent the name of the parent property to return the children for.
* @return all child property values for the given parent.
*/
public static List getXMLProperties(String parent) {
if (xmlProperties == null) {
loadSetupProperties();
}
// jiveHome not loaded?
if (xmlProperties == null) {
return Collections.EMPTY_LIST;
}
String[] propNames = xmlProperties.getChildrenProperties(parent);
List values = new ArrayList();
for (int i = 0; i < propNames.length; i++) {
String propName = propNames[i];
String value = getProperty(parent + "." + propName);
if (value != null) {
values.add(value);
}
}
return values;
}
/**
* Deletes a locale property. If the property doesn't exist, the method
* does nothing. * does nothing.
* *
* @param name the name of the property to delete. * @param name the name of the property to delete.
*/ */
public static void deleteJiveProperty(String name) { public static void deleteXMLProperty(String name) {
if (xmlProperties == null) {
loadSetupProperties();
}
xmlProperties.deleteProperty(name);
}
/**
* Returns a Jive property.
*
* @param name the name of the property to return.
* @return the property value specified by name.
*/
public static String getProperty(String name) {
if (properties == null) {
properties = JiveProperties.getInstance();
}
return (String)properties.get(name);
}
/**
* Returns a Jive property. If the specified property doesn't exist, the
* <tt>defaultValue</tt> will be returned.
*
* @param name the name of the property to return.
* @param defaultValue value returned if the property doesn't exist.
* @return the property value specified by name.
*/
public static String getProperty(String name, String defaultValue) {
if (properties == null) {
properties = JiveProperties.getInstance();
}
String value = (String)properties.get(name);
if (value != null) {
return value;
}
else {
return defaultValue;
}
}
/**
* Returns an integer value Jive property. If the specified property doesn't exist, the
* <tt>defaultValue</tt> will be returned.
*
* @param name the name of the property to return.
* @param defaultValue value returned if the property doesn't exist or was not
* a number.
* @return the property value specified by name or <tt>defaultValue</tt>.
*/
public static int getIntProperty(String name, int defaultValue) {
String value = getProperty(name);
if (value != null) {
try {
return Integer.parseInt(value);
}
catch (NumberFormatException nfe) { }
}
return defaultValue;
}
/**
* Returns a boolean value Jive property.
*
* @param name the name of the property to return.
* @return true if the property value exists and is set to <tt>"true"</tt> (ignoring case).
* Otherwise <tt>false</tt> is returned.
*/
public static boolean getBooleanProperty(String name) {
return Boolean.valueOf(getProperty(name)).booleanValue();
}
/**
* Returns a boolean value Jive property. If the property doesn't exist, the <tt>defaultValue</tt>
* will be returned.
*
* If the specified property can't be found, or if the value is not a number, the
* <tt>defaultValue</tt> will be returned.
*
* @param name the name of the property to return.
* @param defaultValue value returned if the property doesn't exist.
* @return true if the property value exists and is set to <tt>"true"</tt> (ignoring case).
* Otherwise <tt>false</tt> is returned.
*/
public static boolean getBooleanProperty(String name, boolean defaultValue) {
String value = getProperty(name);
if (value != null) {
return Boolean.valueOf(getProperty(name)).booleanValue();
}
else {
return defaultValue;
}
}
/**
* 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 <tt>X.Y.A</tt>, <tt>X.Y.B</tt>, <tt>X.Y.C</tt> and <tt>X.Y.C.D</tt>, then
* the immediate child properties of <tt>X.Y</tt> are <tt>A</tt>, <tt>B</tt>, and
* <tt>C</tt> (<tt>C.D</tt> would not be returned using this method).<p>
*
* @return a List of all immediate children property names (Strings).
*/
public static List getPropertyNames(String parent) {
if (properties == null) {
properties = JiveProperties.getInstance();
}
return new ArrayList(properties.getChildrenNames(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 <tt>X.Y.A</tt>, <tt>X.Y.B</tt>, <tt>X.Y.C</tt> and <tt>X.Y.C.D</tt>, then
* the immediate child properties of <tt>X.Y</tt> are <tt>X.Y.A</tt>, <tt>X.Y.B</tt>, and
* <tt>X.Y.C</tt> (the value of <tt>X.Y.C.D</tt> would not be returned using this method).<p>
*
* @param parent the name of the parent property to return the children for.
* @return all child property values for the given parent.
*/
public static List getProperties(String parent) {
if (properties == null) { if (properties == null) {
loadProperties(); properties = JiveProperties.getInstance();
}
Collection propertyNames = properties.getChildrenNames(parent);
List values = new ArrayList();
for (Iterator i=propertyNames.iterator(); i.hasNext(); ) {
String propName = (String)i.next();
String value = getProperty(propName);
if (value != null) {
values.add(value);
}
} }
if (properties != null) {
properties.deleteProperty(name); return values;
}
/**
* Returns all Jive property names.
*
* @return a List of all property names (Strings).
*/
public static List getPropertyNames() {
if (properties == null) {
properties = JiveProperties.getInstance();
} }
return new ArrayList(properties.getPropertyNames());
}
/**
* Sets a Jive property. If the property doesn't already exists, a new
* one will be created.
*
* @param name the name of the property being set.
* @param value the value of the property being set.
*/
public static void setProperty(String name, String value) {
if (properties == null) {
properties = JiveProperties.getInstance();
}
properties.put(name, value);
}
/**
* Sets multiple Jive properties at once. If a property doesn't already exists, a new
* one will be created.
*
* @param propertyMap a map of properties, keyed on property name.
*/
public static void setProperties(Map propertyMap) {
if (properties == null) {
properties = JiveProperties.getInstance();
}
properties.putAll(propertyMap);
}
/**
* Deletes a Jive property. If the property doesn't exist, the method
* does nothing. All children of the property will be deleted as well.
*
* @param name the name of the property to delete.
*/
public static void deleteProperty(String name) {
if (properties == null) {
properties = JiveProperties.getInstance();;
}
properties.remove(name);
}
/**
* Allows the name of the local config file name to be changed. The
* default is "jive_startup.xml".
*
* @param configName the name of the config file.
*/
public static void setConfigName(String configName) {
JIVE_CONFIG_FILENAME = configName;
} }
/** /**
* Loads properties if necessary. Property loading must be done lazily so * Loads properties if necessary. Property loading must be done lazily so
* that we give outside classes a chance to set <tt>jiveHome</tt>. * that we give outside classes a chance to set <tt>jiveHome</tt>.
*/ */
private synchronized static void loadProperties() { private synchronized static void loadSetupProperties() {
if (failedLoading) { if (failedLoading) {
return; return;
} }
if (properties == null) { if (xmlProperties == null) {
// First, try to load it jiveHome as a system property. // If jiveHome is still null, no outside process has set it and
// we have to attempt to load the value from jive_init.xml,
// which must be in the classpath.
if (jiveHome == null) { if (jiveHome == null) {
jiveHome = System.getProperty("jiveHome"); jiveHome = new InitPropLoader().getJiveHome();
} }
// If that failed, try loading it from JNDI
// If we still don't have jiveHome, let's assume this is standalone
// and just look for jiveHome in a standard sub-dir location and verify
// by looking for the config file
if (jiveHome == null) { if (jiveHome == null) {
jiveHome = "..";
// Create a manager with the full path to the xml config file.
try { try {
properties = new XMLProperties(jiveHome + File.separator + InitialContext context = new InitialContext();
"config" + File.separator + jiveHome = (String)context.lookup("java:comp/env/jiveHome");
JIVE_CONFIG_FILENAME);
}
catch (IOException ioe) {
jiveHome = null;
} }
catch (Exception e) { }
} }
// Finally, try to load it jiveHome as a system property.
// If jiveHome is still null, no outside process has set it and
// we have to attempt to load the value from messenger_init.xml,
// which must be in the classpath.
if (jiveHome == null) { if (jiveHome == null) {
jiveHome = new InitPropLoader().getJiveHome(); jiveHome = System.getProperty("jiveHome");
} }
// If still null, finding jiveHome failed.
if (jiveHome == null) { if (jiveHome == null) {
Log.error("Jive Home was never set. In order to continue, Jive Home will need to be set");
failedLoading = true; failedLoading = true;
StringBuffer msg = new StringBuffer();
msg.append("Critical Error! The jiveHome directory could not be loaded, \n");
msg.append("which will prevent the application from working correctly.\n\n");
msg.append("You must set jiveHome in one of four ways:\n");
msg.append(" 1) Set a servlet init parameter named jiveHome.\n");
msg.append(" 2) Add a jive_init.xml file to your classpath, which points \n ");
msg.append(" to jiveHome. Normally, this file will be in WEB-INF/classes.\n");
msg.append(" 3) Set the JNDI value \"java:comp/env/jiveHome\" with a String \n");
msg.append(" that points to your jiveHome directory. \n");
msg.append(" 4) Set the Java system property \"jiveHome\".\n\n");
msg.append("Further instructions for setting jiveHome can be found in the \n");
msg.append("installation documentation.");
System.err.println(msg.toString());
return; return;
} }
else { // Create a manager with the full path to the xml config file.
// Create a manager with the full path to the xml config file. try {
try { // Do a permission check on the jiveHome directory:
properties = new XMLProperties(jiveHome + File.separator + File jh = new File(jiveHome);
"config" + File.separator + if (!jh.exists()) {
JIVE_CONFIG_FILENAME); Log.error("Error - the specified jiveHome directory does not exist (" + jiveHome + ")");
} }
catch (IOException ioe) { else {
Log.error(ioe); if (!jh.canRead() || !jh.canWrite()) {
failedLoading = true; Log.error("Error - the user running this Jive application can not read and write to the "
return; + "specified jiveHome directory (" + jiveHome + "). Please grant the executing user "
+ "read and write perms.");
}
} }
xmlProperties = new XMLProperties(jiveHome + File.separator +
JIVE_CONFIG_FILENAME);
} }
} catch (IOException ioe) {
Log.error(ioe);
if (locale == null) { failedLoading = true;
String language = properties.getProperty("locale.language"); return;
if (language == null) {
language = "";
}
String country = properties.getProperty("locale.country");
if (country == null) {
country = "";
}
// If no locale info is specified, default to system default Locale
if (language.equals("") && country.equals("")) {
locale = Locale.getDefault();
}
else {
locale = new Locale(language, country);
}
String charEncoding = properties.getProperty("locale.characterEncoding");
if (charEncoding != null) {
characterEncoding = charEncoding;
}
else {
// The default encoding is ISO-8859-1. We use the version of
// the encoding name that seems to be most widely compatible.
characterEncoding = "ISO-8859-1";
}
String timeZoneID = properties.getProperty("locale.timeZone");
if (timeZoneID == null) {
timeZone = TimeZone.getDefault();
}
else {
timeZone = TimeZone.getTimeZone(timeZoneID);
} }
dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
DateFormat.MEDIUM, locale);
dateFormat.setTimeZone(timeZone);
dateTimeFormat.setTimeZone(timeZone);
} }
} }
} }
...@@ -453,4 +799,4 @@ class InitPropLoader { ...@@ -453,4 +799,4 @@ class InitPropLoader {
} }
return jiveHome; return jiveHome;
} }
} }
\ No newline at end of file
...@@ -68,10 +68,10 @@ public abstract class AuthFactory { ...@@ -68,10 +68,10 @@ public abstract class AuthFactory {
// Get the cookie password, stored as a Jive property. Obviously, // Get the cookie password, stored as a Jive property. Obviously,
// protecting your jive_config.xml file is critical for making cookie // protecting your jive_config.xml file is critical for making cookie
// encryption secure. // encryption secure.
String keyString = JiveGlobals.getJiveProperty("cookieKey"); String keyString = JiveGlobals.getProperty("cookieKey");
if (keyString == null) { if (keyString == null) {
keyString = StringUtils.randomString(15); keyString = StringUtils.randomString(15);
JiveGlobals.setJiveProperty("cookieKey", keyString); JiveGlobals.setProperty("cookieKey", keyString);
} }
try { try {
sha = MessageDigest.getInstance("SHA"); sha = MessageDigest.getInstance("SHA");
......
...@@ -70,7 +70,7 @@ public class AuthProviderFactory { ...@@ -70,7 +70,7 @@ public class AuthProviderFactory {
if (authProvider == null) { if (authProvider == null) {
//See if the classname has been set as a Jive property. //See if the classname has been set as a Jive property.
String classNameProp = String classNameProp =
JiveGlobals.getJiveProperty("AuthProvider.className"); JiveGlobals.getProperty("AuthProvider.className");
if (classNameProp != null) { if (classNameProp != null) {
authClassName = classNameProp; authClassName = classNameProp;
} }
...@@ -103,7 +103,7 @@ public class AuthProviderFactory { ...@@ -103,7 +103,7 @@ public class AuthProviderFactory {
if (groupProvider == null) { if (groupProvider == null) {
//See if the classname has been set as a Jive property. //See if the classname has been set as a Jive property.
String classNameProp = String classNameProp =
JiveGlobals.getJiveProperty("GroupProvider.className"); JiveGlobals.getProperty("GroupProvider.className");
if (classNameProp != null) { if (classNameProp != null) {
groupClassName = classNameProp; groupClassName = classNameProp;
} }
......
...@@ -73,7 +73,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo { ...@@ -73,7 +73,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
probeResponse.add(DocumentHelper.createElement("digest")); probeResponse.add(DocumentHelper.createElement("digest"));
} }
probeResponse.add(DocumentHelper.createElement("resource")); probeResponse.add(DocumentHelper.createElement("resource"));
anonymousAllowed = "true".equals(JiveGlobals.getJiveProperty("xmpp.auth.anonymous")); anonymousAllowed = "true".equals(JiveGlobals.getProperty("xmpp.auth.anonymous"));
} }
public synchronized IQ handleIQ(IQ packet) throws public synchronized IQ handleIQ(IQ packet) throws
...@@ -239,7 +239,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo { ...@@ -239,7 +239,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
public void setAllowAnonymous(boolean isAnonymous) throws UnauthorizedException { public void setAllowAnonymous(boolean isAnonymous) throws UnauthorizedException {
anonymousAllowed = isAnonymous; anonymousAllowed = isAnonymous;
JiveGlobals.setJiveProperty("xmpp.auth.anonymous", anonymousAllowed ? "true" : "false"); JiveGlobals.setProperty("xmpp.auth.anonymous", anonymousAllowed ? "true" : "false");
} }
public UserManager userManager; public UserManager userManager;
......
...@@ -148,7 +148,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -148,7 +148,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
} }
// Check for the default case where no inband property is set and // Check for the default case where no inband property is set and
// make the default true (allowing inband registration) // make the default true (allowing inband registration)
String inband = JiveGlobals.getJiveProperty("register.inband"); String inband = JiveGlobals.getProperty("register.inband");
if (inband == null || "".equals(inband)) { if (inband == null || "".equals(inband)) {
setInbandRegEnabled(true); setInbandRegEnabled(true);
} }
...@@ -367,7 +367,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -367,7 +367,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
public void setInbandRegEnabled(boolean allowed) { public void setInbandRegEnabled(boolean allowed) {
enabled = allowed; enabled = allowed;
JiveGlobals.setJiveProperty("register.inband", enabled ? "true" : "false"); JiveGlobals.setProperty("register.inband", enabled ? "true" : "false");
} }
private IQHandler getDelegate(XMPPAddress recipientJID) { private IQHandler getDelegate(XMPPAddress recipientJID) {
......
...@@ -90,8 +90,8 @@ public class LdapManager { ...@@ -90,8 +90,8 @@ public class LdapManager {
* constructor is private. * constructor is private.
*/ */
private LdapManager() { private LdapManager() {
this.host = JiveGlobals.getJiveProperty("ldap.host"); this.host = JiveGlobals.getProperty("ldap.host");
String portStr = JiveGlobals.getJiveProperty("ldap.port"); String portStr = JiveGlobals.getProperty("ldap.port");
if (portStr != null) { if (portStr != null) {
try { try {
this.port = Integer.parseInt(portStr); this.port = Integer.parseInt(portStr);
...@@ -99,23 +99,23 @@ public class LdapManager { ...@@ -99,23 +99,23 @@ public class LdapManager {
catch (NumberFormatException nfe) { catch (NumberFormatException nfe) {
} }
} }
if (JiveGlobals.getJiveProperty("ldap.usernameField") != null) { if (JiveGlobals.getProperty("ldap.usernameField") != null) {
this.usernameField = JiveGlobals.getJiveProperty("ldap.usernameField"); this.usernameField = JiveGlobals.getProperty("ldap.usernameField");
} }
if (JiveGlobals.getJiveProperty("ldap.baseDN") != null) { if (JiveGlobals.getProperty("ldap.baseDN") != null) {
this.baseDN = JiveGlobals.getJiveProperty("ldap.baseDN"); this.baseDN = JiveGlobals.getProperty("ldap.baseDN");
} }
if (JiveGlobals.getJiveProperty("ldap.nameField") != null) { if (JiveGlobals.getProperty("ldap.nameField") != null) {
this.nameField = JiveGlobals.getJiveProperty("ldap.nameField"); this.nameField = JiveGlobals.getProperty("ldap.nameField");
} }
if (JiveGlobals.getJiveProperty("ldap.emailField") != null) { if (JiveGlobals.getProperty("ldap.emailField") != null) {
this.emailField = JiveGlobals.getJiveProperty("ldap.emailField"); this.emailField = JiveGlobals.getProperty("ldap.emailField");
} }
this.adminDN = JiveGlobals.getJiveProperty("ldap.adminDN"); this.adminDN = JiveGlobals.getProperty("ldap.adminDN");
this.adminPassword = JiveGlobals.getJiveProperty("ldap.adminPassword"); this.adminPassword = JiveGlobals.getProperty("ldap.adminPassword");
this.debugEnabled = "true".equals(JiveGlobals.getJiveProperty("ldap.debugEnabled")); this.debugEnabled = "true".equals(JiveGlobals.getProperty("ldap.debugEnabled"));
this.sslEnabled = "true".equals(JiveGlobals.getJiveProperty("ldap.sslEnabled")); this.sslEnabled = "true".equals(JiveGlobals.getProperty("ldap.sslEnabled"));
String modeStr = JiveGlobals.getJiveProperty("ldap.mode"); String modeStr = JiveGlobals.getProperty("ldap.mode");
if (modeStr != null) { if (modeStr != null) {
try { try {
this.mode = Integer.parseInt(modeStr); this.mode = Integer.parseInt(modeStr);
...@@ -283,7 +283,7 @@ public class LdapManager { ...@@ -283,7 +283,7 @@ public class LdapManager {
*/ */
public void setHost(String host) { public void setHost(String host) {
this.host = host; this.host = host;
JiveGlobals.setJiveProperty("ldap.host", host); JiveGlobals.setProperty("ldap.host", host);
} }
/** /**
...@@ -304,7 +304,7 @@ public class LdapManager { ...@@ -304,7 +304,7 @@ public class LdapManager {
*/ */
public void setPort(int port) { public void setPort(int port) {
this.port = port; this.port = port;
JiveGlobals.setJiveProperty("ldap.port", "" + port); JiveGlobals.setProperty("ldap.port", "" + port);
} }
/** /**
...@@ -327,7 +327,7 @@ public class LdapManager { ...@@ -327,7 +327,7 @@ public class LdapManager {
*/ */
public void setDebugEnabled(boolean debugEnabled) { public void setDebugEnabled(boolean debugEnabled) {
this.debugEnabled = debugEnabled; this.debugEnabled = debugEnabled;
JiveGlobals.setJiveProperty("ldap.debuggingEnabled", "" + debugEnabled); JiveGlobals.setProperty("ldap.debuggingEnabled", "" + debugEnabled);
} }
/** /**
...@@ -368,10 +368,10 @@ public class LdapManager { ...@@ -368,10 +368,10 @@ public class LdapManager {
public void setUsernameField(String usernameField) { public void setUsernameField(String usernameField) {
this.usernameField = usernameField; this.usernameField = usernameField;
if (usernameField == null) { if (usernameField == null) {
JiveGlobals.deleteJiveProperty("ldap.usernameField"); JiveGlobals.deleteProperty("ldap.usernameField");
} }
else { else {
JiveGlobals.setJiveProperty("ldap.usernameField", usernameField); JiveGlobals.setProperty("ldap.usernameField", usernameField);
} }
} }
...@@ -394,10 +394,10 @@ public class LdapManager { ...@@ -394,10 +394,10 @@ public class LdapManager {
public void setNameField(String nameField) { public void setNameField(String nameField) {
this.nameField = nameField; this.nameField = nameField;
if (nameField == null) { if (nameField == null) {
JiveGlobals.deleteJiveProperty("ldap.nameField"); JiveGlobals.deleteProperty("ldap.nameField");
} }
else { else {
JiveGlobals.setJiveProperty("ldap.nameField", nameField); JiveGlobals.setProperty("ldap.nameField", nameField);
} }
} }
...@@ -422,10 +422,10 @@ public class LdapManager { ...@@ -422,10 +422,10 @@ public class LdapManager {
public void setEmailField(String emailField) { public void setEmailField(String emailField) {
this.emailField = emailField; this.emailField = emailField;
if (emailField == null) { if (emailField == null) {
JiveGlobals.deleteJiveProperty("ldap.emailField"); JiveGlobals.deleteProperty("ldap.emailField");
} }
else { else {
JiveGlobals.setJiveProperty("ldap.emailField", emailField); JiveGlobals.setProperty("ldap.emailField", emailField);
} }
} }
...@@ -447,7 +447,7 @@ public class LdapManager { ...@@ -447,7 +447,7 @@ public class LdapManager {
*/ */
public void setBaseDN(String baseDN) { public void setBaseDN(String baseDN) {
this.baseDN = baseDN; this.baseDN = baseDN;
JiveGlobals.setJiveProperty("ldap.baseDN", baseDN); JiveGlobals.setProperty("ldap.baseDN", baseDN);
} }
/** /**
...@@ -468,7 +468,7 @@ public class LdapManager { ...@@ -468,7 +468,7 @@ public class LdapManager {
*/ */
public void setAdminDN(String adminDN) { public void setAdminDN(String adminDN) {
this.adminDN = adminDN; this.adminDN = adminDN;
JiveGlobals.setJiveProperty("ldap.adminDN", adminDN); JiveGlobals.setProperty("ldap.adminDN", adminDN);
} }
/** /**
...@@ -489,7 +489,7 @@ public class LdapManager { ...@@ -489,7 +489,7 @@ public class LdapManager {
*/ */
public void setAdminPassword(String adminPassword) { public void setAdminPassword(String adminPassword) {
this.adminPassword = adminPassword; this.adminPassword = adminPassword;
JiveGlobals.setJiveProperty("ldap.adminPassword", adminPassword); JiveGlobals.setProperty("ldap.adminPassword", adminPassword);
} }
/** /**
...@@ -514,6 +514,6 @@ public class LdapManager { ...@@ -514,6 +514,6 @@ public class LdapManager {
*/ */
public void setMode(int mode) { public void setMode(int mode) {
this.mode = mode; this.mode = mode;
JiveGlobals.setJiveProperty("ldap.mode", "" + mode); JiveGlobals.setProperty("ldap.mode", "" + mode);
} }
} }
\ No newline at end of file
...@@ -40,36 +40,36 @@ public class SSLConfig { ...@@ -40,36 +40,36 @@ public class SSLConfig {
} }
static { static {
String algorithm = JiveGlobals.getJiveProperty("xmpp.socket.ssl.algorithm"); String algorithm = JiveGlobals.getProperty("xmpp.socket.ssl.algorithm");
if ("".equals(algorithm) || algorithm == null) { if ("".equals(algorithm) || algorithm == null) {
algorithm = "TLS"; algorithm = "TLS";
} }
String storeType = JiveGlobals.getJiveProperty("xmpp.socket.ssl.storeType"); String storeType = JiveGlobals.getProperty("xmpp.socket.ssl.storeType");
if ("".equals(storeType)) { if ("".equals(storeType)) {
storeType = null; storeType = null;
} }
keystore = JiveGlobals.getJiveProperty("xmpp.socket.ssl.keystore"); keystore = JiveGlobals.getProperty("xmpp.socket.ssl.keystore");
if ("".equals(keystore) || keystore == null) { if ("".equals(keystore) || keystore == null) {
keystore = null; keystore = null;
} }
else { else {
keystore = JiveGlobals.getJiveHome() + File.separator + keystore; keystore = JiveGlobals.getJiveHome() + File.separator + keystore;
} }
keypass = JiveGlobals.getJiveProperty("xmpp.socket.ssl.keypass"); keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass");
if (keypass == null) { if (keypass == null) {
keypass = ""; keypass = "";
} }
else { else {
keypass = keypass.trim(); keypass = keypass.trim();
} }
truststore = JiveGlobals.getJiveProperty("xmpp.socket.ssl.truststore"); truststore = JiveGlobals.getProperty("xmpp.socket.ssl.truststore");
if ("".equals(truststore) || truststore == null) { if ("".equals(truststore) || truststore == null) {
truststore = null; truststore = null;
} }
else { else {
truststore = JiveGlobals.getJiveHome() + File.separator + truststore; truststore = JiveGlobals.getJiveHome() + File.separator + truststore;
} }
trustpass = JiveGlobals.getJiveProperty("xmpp.socket.ssl.trustpass"); trustpass = JiveGlobals.getProperty("xmpp.socket.ssl.trustpass");
if (trustpass == null) { if (trustpass == null) {
trustpass = ""; trustpass = "";
} }
......
...@@ -69,12 +69,12 @@ public class SSLSocketAcceptThread extends Thread { ...@@ -69,12 +69,12 @@ public class SSLSocketAcceptThread extends Thread {
super("SSL accept"); super("SSL accept");
this.connManager = connManager; this.connManager = connManager;
int port = SSLSocketAcceptThread.DEFAULT_PORT; int port = SSLSocketAcceptThread.DEFAULT_PORT;
String portName = JiveGlobals.getJiveProperty("xmpp.socket.ssl.port"); String portName = JiveGlobals.getProperty("xmpp.socket.ssl.port");
if (portName != null) { if (portName != null) {
port = Integer.parseInt(portName); port = Integer.parseInt(portName);
} }
String interfaceName = JiveGlobals.getJiveProperty("xmpp.socket.ssl.interface"); String interfaceName = JiveGlobals.getProperty("xmpp.socket.ssl.interface");
bindInterface = null; bindInterface = null;
if (interfaceName != null) { if (interfaceName != null) {
try { try {
......
...@@ -59,11 +59,11 @@ public class SocketAcceptThread extends Thread { ...@@ -59,11 +59,11 @@ public class SocketAcceptThread extends Thread {
super("SAT accept"); super("SAT accept");
this.connManager = connManager; this.connManager = connManager;
port = SocketAcceptThread.DEFAULT_PORT; port = SocketAcceptThread.DEFAULT_PORT;
String portName = JiveGlobals.getJiveProperty("xmpp.socket.plain.port"); String portName = JiveGlobals.getProperty("xmpp.socket.plain.port");
if (portName != null) { if (portName != null) {
port = Integer.parseInt(portName); port = Integer.parseInt(portName);
} }
String interfaceName = JiveGlobals.getJiveProperty("xmpp.socket.plain.interface"); String interfaceName = JiveGlobals.getProperty("xmpp.socket.plain.interface");
bindInterface = null; bindInterface = null;
if (interfaceName != null) { if (interfaceName != null) {
try { try {
......
...@@ -67,7 +67,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -67,7 +67,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
} }
// Now start up the acceptor (and associated read selector) // Now start up the acceptor (and associated read selector)
if ("true".equals(JiveGlobals.getJiveProperty("xmpp.socket.plain.active"))) { if ("true".equals(JiveGlobals.getProperty("xmpp.socket.plain.active"))) {
socketThread = new SocketAcceptThread(this); socketThread = new SocketAcceptThread(this);
ports.add(new ServerPortImpl(socketThread.getPort(), ports.add(new ServerPortImpl(socketThread.getPort(),
serverName, serverName,
...@@ -81,11 +81,11 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -81,11 +81,11 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
params.add(Integer.toString(socketThread.getPort())); params.add(Integer.toString(socketThread.getPort()));
Log.info(LocaleUtils.getLocalizedString("startup.plain", params)); Log.info(LocaleUtils.getLocalizedString("startup.plain", params));
} }
if ("true".equals(JiveGlobals.getJiveProperty("xmpp.socket.ssl.active"))) { if ("true".equals(JiveGlobals.getProperty("xmpp.socket.ssl.active"))) {
try { try {
sslSocketThread = new SSLSocketAcceptThread(this); sslSocketThread = new SSLSocketAcceptThread(this);
String algorithm = String algorithm =
JiveGlobals.getJiveProperty("xmpp.socket.ssl.algorithm"); JiveGlobals.getProperty("xmpp.socket.ssl.algorithm");
if ("".equals(algorithm) || algorithm == null) { if ("".equals(algorithm) || algorithm == null) {
algorithm = "TLS"; algorithm = "TLS";
} }
......
...@@ -105,7 +105,7 @@ public class UserProviderFactory { ...@@ -105,7 +105,7 @@ public class UserProviderFactory {
for (int i = 0; i < classNames.length; i++) { for (int i = 0; i < classNames.length; i++) {
String className = classNames[i]; String className = classNames[i];
//See if the classname has been set as a Jive property. //See if the classname has been set as a Jive property.
String classNameProp = JiveGlobals.getJiveProperty(propNames[i]); String classNameProp = JiveGlobals.getProperty(propNames[i]);
if (classNameProp != null) { if (classNameProp != null) {
className = classNameProp; className = classNameProp;
} }
......
...@@ -63,7 +63,7 @@ public class Log { ...@@ -63,7 +63,7 @@ public class Log {
*/ */
public static void initLog() { public static void initLog() {
try { try {
logDirectory = JiveGlobals.getLocalProperty("log.directory"); logDirectory = JiveGlobals.getXMLProperty("log.directory");
if (logDirectory == null) { if (logDirectory == null) {
if (JiveGlobals.getJiveHome() != null) { if (JiveGlobals.getJiveHome() != null) {
File jiveHome = new File(JiveGlobals.getJiveHome()); File jiveHome = new File(JiveGlobals.getJiveHome());
...@@ -88,21 +88,21 @@ public class Log { ...@@ -88,21 +88,21 @@ public class Log {
logNameWarn = logDirectory + "jive.warn.log"; logNameWarn = logDirectory + "jive.warn.log";
logNameError = logDirectory + "jive.error.log"; logNameError = logDirectory + "jive.error.log";
debugPattern = JiveGlobals.getLocalProperty("log.debug.format"); debugPattern = JiveGlobals.getXMLProperty("log.debug.format");
infoPattern = JiveGlobals.getLocalProperty("log.info.format"); infoPattern = JiveGlobals.getXMLProperty("log.info.format");
warnPattern = JiveGlobals.getLocalProperty("log.warn.format"); warnPattern = JiveGlobals.getXMLProperty("log.warn.format");
errorPattern = JiveGlobals.getLocalProperty("log.error.format"); errorPattern = JiveGlobals.getXMLProperty("log.error.format");
try { maxDebugSize = Long.parseLong(JiveGlobals.getLocalProperty("log.debug.size")); } try { maxDebugSize = Long.parseLong(JiveGlobals.getXMLProperty("log.debug.size")); }
catch (NumberFormatException e) { /* ignore */ } catch (NumberFormatException e) { /* ignore */ }
try { maxInfoSize = Long.parseLong(JiveGlobals.getLocalProperty("log.info.size")); } try { maxInfoSize = Long.parseLong(JiveGlobals.getXMLProperty("log.info.size")); }
catch (NumberFormatException e) { /* ignore */ } catch (NumberFormatException e) { /* ignore */ }
try { maxWarnSize = Long.parseLong(JiveGlobals.getLocalProperty("log.warn.size")); } try { maxWarnSize = Long.parseLong(JiveGlobals.getXMLProperty("log.warn.size")); }
catch (NumberFormatException e) { /* ignore */ } catch (NumberFormatException e) { /* ignore */ }
try { maxErrorSize = Long.parseLong(JiveGlobals.getLocalProperty("log.error.size")); } try { maxErrorSize = Long.parseLong(JiveGlobals.getXMLProperty("log.error.size")); }
catch (NumberFormatException e) { /* ignore */ } catch (NumberFormatException e) { /* ignore */ }
debugEnabled = "true".equals(JiveGlobals.getLocalProperty("log.debug.enabled")); debugEnabled = "true".equals(JiveGlobals.getXMLProperty("log.debug.enabled"));
} }
catch (Exception e) { catch (Exception e) {
// we'll get an exception if jiveHome isn't setup yet - we ignore that since // we'll get an exception if jiveHome isn't setup yet - we ignore that since
...@@ -186,7 +186,7 @@ public class Log { ...@@ -186,7 +186,7 @@ public class Log {
} }
public static void setDebugEnabled(boolean enabled) { public static void setDebugEnabled(boolean enabled) {
JiveGlobals.setLocalProperty("log.debug.enabled", Boolean.toString(enabled)); JiveGlobals.setXMLProperty("log.debug.enabled", Boolean.toString(enabled));
debugEnabled = enabled; debugEnabled = enabled;
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
isErrorPage="true" isErrorPage="true"
%> %>
<% boolean debug = "true".equals(JiveGlobals.getJiveProperty("skin.default.debug")); <% boolean debug = "true".equals(JiveGlobals.getProperty("skin.default.debug"));
if (debug) { if (debug) {
exception.printStackTrace(); exception.printStackTrace();
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<%! // List of allowed usernames: <%! // List of allowed usernames:
static Map allowedUsernames = null; static Map allowedUsernames = null;
static String allowedUsernameProp = JiveGlobals.getJiveProperty("admin.login.allowedUsernames"); static String allowedUsernameProp = JiveGlobals.getProperty("admin.login.allowedUsernames");
static { static {
if (allowedUsernameProp != null) { if (allowedUsernameProp != null) {
StringTokenizer tokenizer = new StringTokenizer(allowedUsernameProp, ","); StringTokenizer tokenizer = new StringTokenizer(allowedUsernameProp, ",");
......
...@@ -343,12 +343,12 @@ String log = ParamUtils.getParameter(request, "log"); ...@@ -343,12 +343,12 @@ String log = ParamUtils.getParameter(request, "log");
// Enable/disable debugging // Enable/disable debugging
if (request.getParameter("wasDebugEnabled") != null && wasDebugEnabled != debugEnabled) { if (request.getParameter("wasDebugEnabled") != null && wasDebugEnabled != debugEnabled) {
JiveGlobals.setJiveProperty("log.debug.enabled",String.valueOf(debugEnabled)); JiveGlobals.setProperty("log.debug.enabled",String.valueOf(debugEnabled));
response.sendRedirect("logviewer.jsp?log=debug&debugAlert=true"); response.sendRedirect("logviewer.jsp?log=debug&debugAlert=true");
return; return;
} }
debugEnabled = "true".equals(JiveGlobals.getJiveProperty("log.debug.enabled")); debugEnabled = "true".equals(JiveGlobals.getProperty("log.debug.enabled"));
// Set defaults // Set defaults
if (log == null) { if (log == null) {
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<%! // Global vars, methods, etc <%! // Global vars, methods, etc
void setSetupFinished(HttpSession session) { void setSetupFinished(HttpSession session) {
JiveGlobals.setJiveProperty("setup","true"); JiveGlobals.setXMLProperty("setup","true");
// update the sidebar status // update the sidebar status
session.setAttribute("jive.setup.sidebar.4","done"); session.setAttribute("jive.setup.sidebar.4","done");
} }
......
...@@ -48,11 +48,11 @@ ...@@ -48,11 +48,11 @@
// if no errors, continue // if no errors, continue
if (errors.size() == 0) { if (errors.size() == 0) {
// Set the JNDI connection class property in the jive props file // Set the JNDI connection class property in the jive props file
JiveGlobals.setJiveProperty("connectionProvider.className", JiveGlobals.setProperty("connectionProvider.className",
"org.jivesoftware.database.JNDIDataSourceProvider"); "org.jivesoftware.database.JNDIDataSourceProvider");
// Save the name (must do this *first* before initializing // Save the name (must do this *first* before initializing
// the JNDIDataSourceProvider // the JNDIDataSourceProvider
JiveGlobals.setJiveProperty("database.JNDIProvider.name",lookupName); JiveGlobals.setProperty("database.JNDIProvider.name",lookupName);
// Use the Jive default connection provider // Use the Jive default connection provider
JNDIDataSourceProvider conProvider = new JNDIDataSourceProvider(); JNDIDataSourceProvider conProvider = new JNDIDataSourceProvider();
conProvider.setProperty("name", lookupName); conProvider.setProperty("name", lookupName);
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
} }
else if (EMBEDDED.equals(mode)) { else if (EMBEDDED.equals(mode)) {
// Set the classname of the provider in the config file: // Set the classname of the provider in the config file:
JiveGlobals.setJiveProperty("connectionProvider.className", JiveGlobals.setProperty("connectionProvider.className",
"org.jivesoftware.database.EmbeddedConnectionProvider"); "org.jivesoftware.database.EmbeddedConnectionProvider");
ConnectionProvider conProvider = new EmbeddedConnectionProvider(); ConnectionProvider conProvider = new EmbeddedConnectionProvider();
DbConnectionManager.setConnectionProvider(conProvider); DbConnectionManager.setConnectionProvider(conProvider);
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
// set properties, test connection, etc // set properties, test connection, etc
// Force the standard jive connection provider to be used by deleting the current setting: // Force the standard jive connection provider to be used by deleting the current setting:
JiveGlobals.setJiveProperty("connectionProvider.className", JiveGlobals.setProperty("connectionProvider.className",
"org.jivesoftware.database.DefaultConnectionProvider"); "org.jivesoftware.database.DefaultConnectionProvider");
DefaultConnectionProvider conProvider = new DefaultConnectionProvider(); DefaultConnectionProvider conProvider = new DefaultConnectionProvider();
try { try {
...@@ -86,16 +86,16 @@ ...@@ -86,16 +86,16 @@
conProvider.setUsername(username); conProvider.setUsername(username);
conProvider.setPassword(password); conProvider.setPassword(password);
JiveGlobals.setJiveProperty("database.defaultProvider.driver", driver); JiveGlobals.setProperty("database.defaultProvider.driver", driver);
JiveGlobals.setJiveProperty("database.defaultProvider.serverURL", serverURL); JiveGlobals.setProperty("database.defaultProvider.serverURL", serverURL);
JiveGlobals.setJiveProperty("database.defaultProvider.username", username); JiveGlobals.setProperty("database.defaultProvider.username", username);
JiveGlobals.setJiveProperty("database.defaultProvider.password", password); JiveGlobals.setProperty("database.defaultProvider.password", password);
JiveGlobals.setJiveProperty("database.defaultProvider.minConnections", JiveGlobals.setProperty("database.defaultProvider.minConnections",
Integer.toString(minConnections)); Integer.toString(minConnections));
JiveGlobals.setJiveProperty("database.defaultProvider.maxConnections", JiveGlobals.setProperty("database.defaultProvider.maxConnections",
Integer.toString(maxConnections)); Integer.toString(maxConnections));
JiveGlobals.setJiveProperty("database.defaultProvider.connectionTimeout", JiveGlobals.setProperty("database.defaultProvider.connectionTimeout",
Double.toString(connectionTimeout)); Double.toString(connectionTimeout));
} }
catch (Exception e) { catch (Exception e) {
...@@ -118,27 +118,27 @@ ...@@ -118,27 +118,27 @@
if (!doContinue) { if (!doContinue) {
// reset values of jdbc driver from props file // reset values of jdbc driver from props file
driver = JiveGlobals.getJiveProperty("database.defaultProvider.driver"); driver = JiveGlobals.getProperty("database.defaultProvider.driver");
serverURL = JiveGlobals.getJiveProperty("database.defaultProvider.serverURL"); serverURL = JiveGlobals.getProperty("database.defaultProvider.serverURL");
username = JiveGlobals.getJiveProperty("database.defaultProvider.username"); username = JiveGlobals.getProperty("database.defaultProvider.username");
password = JiveGlobals.getJiveProperty("database.defaultProvider.password"); password = JiveGlobals.getProperty("database.defaultProvider.password");
try { try {
minConnections = Integer.parseInt( minConnections = Integer.parseInt(
JiveGlobals.getJiveProperty("database.defaultProvider.minConnections")); JiveGlobals.getProperty("database.defaultProvider.minConnections"));
} }
catch (Exception e) { catch (Exception e) {
minConnections = 5; minConnections = 5;
} }
try { try {
maxConnections = Integer.parseInt( maxConnections = Integer.parseInt(
JiveGlobals.getJiveProperty("database.defaultProvider.maxConnections")); JiveGlobals.getProperty("database.defaultProvider.maxConnections"));
} }
catch (Exception e) { catch (Exception e) {
maxConnections = 15; maxConnections = 15;
} }
try { try {
connectionTimeout = Double.parseDouble( connectionTimeout = Double.parseDouble(
JiveGlobals.getJiveProperty("database.defaultProvider.connectionTimeout")); JiveGlobals.getProperty("database.defaultProvider.connectionTimeout"));
} }
catch (Exception e) { catch (Exception e) {
connectionTimeout = 1.0; connectionTimeout = 1.0;
......
...@@ -51,13 +51,13 @@ ...@@ -51,13 +51,13 @@
} }
// Continue if there were no errors // Continue if there were no errors
if (errors.size() == 0) { if (errors.size() == 0) {
JiveGlobals.setJiveProperty("xmpp.domain",domain); JiveGlobals.setProperty("xmpp.domain",domain);
JiveGlobals.setJiveProperty("xmpp.chat.domain",chatDomain); JiveGlobals.setProperty("xmpp.chat.domain",chatDomain);
JiveGlobals.setJiveProperty("xmpp.socket.plain.port",Integer.toString(port)); JiveGlobals.setProperty("xmpp.socket.plain.port",Integer.toString(port));
JiveGlobals.setJiveProperty("embedded-web.port",Integer.toString(embeddedPort)); JiveGlobals.setProperty("embedded-web.port",Integer.toString(embeddedPort));
JiveGlobals.setJiveProperty("xmpp.socket.ssl.active",""+sslEnabled); JiveGlobals.setProperty("xmpp.socket.ssl.active",""+sslEnabled);
JiveGlobals.setJiveProperty("xmpp.socket.ssl.port",Integer.toString(sslPort)); JiveGlobals.setProperty("xmpp.socket.ssl.port",Integer.toString(sslPort));
JiveGlobals.setJiveProperty("xmpp.auth.anonymous", "true" ); JiveGlobals.setProperty("xmpp.auth.anonymous", "true" );
// JiveGlobals.setProperty("xmpp.socket.ssl.storeType",storeType); // JiveGlobals.setProperty("xmpp.socket.ssl.storeType",storeType);
// JiveGlobals.setProperty("xmpp.socket.ssl.keystore",keystore); // JiveGlobals.setProperty("xmpp.socket.ssl.keystore",keystore);
// JiveGlobals.setProperty("xmpp.socket.ssl.keypass",keypass); // JiveGlobals.setProperty("xmpp.socket.ssl.keypass",keypass);
...@@ -76,23 +76,23 @@ ...@@ -76,23 +76,23 @@
// Load the current values: // Load the current values:
if (!doContinue) { if (!doContinue) {
domain = JiveGlobals.getJiveProperty("xmpp.domain"); domain = JiveGlobals.getProperty("xmpp.domain");
chatDomain = JiveGlobals.getJiveProperty("xmpp.chat.domain"); chatDomain = JiveGlobals.getProperty("xmpp.chat.domain");
// storeType = JiveGlobals.getProperty("xmpp.socket.ssl.storeType"); // storeType = JiveGlobals.getProperty("xmpp.socket.ssl.storeType");
// keystore = JiveGlobals.getProperty("xmpp.socket.ssl.keystore"); // keystore = JiveGlobals.getProperty("xmpp.socket.ssl.keystore");
// keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass"); // keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass");
// truststore = JiveGlobals.getProperty("xmpp.socket.ssl.truststore"); // truststore = JiveGlobals.getProperty("xmpp.socket.ssl.truststore");
// trustpass = JiveGlobals.getProperty("xmpp.socket.ssl.trustpass"); // trustpass = JiveGlobals.getProperty("xmpp.socket.ssl.trustpass");
try { try {
port = Integer.parseInt(JiveGlobals.getJiveProperty("xmpp.socket.plain.port")); port = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.plain.port"));
} catch (Exception ignored) {} } catch (Exception ignored) {}
try { try {
embeddedPort = Integer.parseInt(JiveGlobals.getJiveProperty("embedded-web.port")); embeddedPort = Integer.parseInt(JiveGlobals.getProperty("embedded-web.port"));
} catch (Exception ignored) {} } catch (Exception ignored) {}
try { try {
sslPort = Integer.parseInt(JiveGlobals.getJiveProperty("xmpp.socket.ssl.port")); sslPort = Integer.parseInt(JiveGlobals.getProperty("xmpp.socket.ssl.port"));
} catch (Exception ignored) {} } catch (Exception ignored) {}
sslEnabled = "true".equals(JiveGlobals.getJiveProperty("xmpp.socket.ssl.active")); sslEnabled = "true".equals(JiveGlobals.getProperty("xmpp.socket.ssl.active"));
// If the domain and chat domain are still blank, guess at their values: // If the domain and chat domain are still blank, guess at their values:
if (domain == null) { if (domain == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment