Commit 74bfd449 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Moved JiveGlobals to org.jivesoftware.util and made it more generic. JM-248


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1217 b35dd754-fafc-0310-a699-88a17e54d16e
parent e3fc7827
......@@ -13,8 +13,8 @@
package org.jivesoftware.database;
import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.JiveGlobals;
import java.io.*;
import java.sql.*;
......
......@@ -11,8 +11,8 @@
package org.jivesoftware.database;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.JiveGlobals;
import java.io.IOException;
import java.sql.Connection;
......
......@@ -11,20 +11,22 @@
package org.jivesoftware.database;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.JiveGlobals;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.sql.*;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
/**
* A connection provider for the embedded hsqlDB database. The database file is stored at
* <tt>messengerHome/database</tt>. The log file for this connection provider is stored at
* <tt>[messengerHome]/logs/EmbeddedConnectionProvider.log</tt>, so you should ensure
* that the <tt>[messengerHome]/logs</tt> directory exists.
* <tt>home/database</tt>. The log file for this connection provider is stored at
* <tt>[home]/logs/EmbeddedConnectionProvider.log</tt>, so you should ensure
* that the <tt>[home]/logs</tt> directory exists.
*
* @author Matt Tucker
*/
......@@ -57,7 +59,7 @@ public class EmbeddedConnectionProvider implements ConnectionProvider {
synchronized (initLock) {
try {
String driver = "org.hsqldb.jdbcDriver";
File databaseDir = new File(JiveGlobals.getMessengerHome(), File.separator +
File databaseDir = new File(JiveGlobals.getHomeDirectory(), File.separator +
"embedded-db");
boolean initData = false;
// If the database doesn't exist, create it.
......
......@@ -11,15 +11,15 @@
package org.jivesoftware.database;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.JiveGlobals;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
/**
* An implementation of ConnectionProvider that utilizes a JDBC 2.0 DataSource
......
......@@ -13,6 +13,7 @@ package org.jivesoftware.messenger;
import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.PacketError;
......
......@@ -15,6 +15,7 @@ import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.JiveGlobals;
import org.dom4j.Element;
import org.dom4j.Document;
import org.dom4j.io.SAXReader;
......
......@@ -33,6 +33,7 @@ import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.messenger.handler.PresenceUpdateHandler;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
......
......@@ -31,6 +31,7 @@ import org.jivesoftware.messenger.net.MulticastDNSService;
import org.jivesoftware.util.Version;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.database.DbConnectionManager;
import org.dom4j.io.SAXReader;
import org.dom4j.Document;
......@@ -77,7 +78,7 @@ public class XMPPServer {
private Map<Class,Module> modules = new HashMap<Class,Module>();
/**
* Location of the messengerHome directory. All configuration files should be
* Location of the home directory. All configuration files should be
* located here.
*/
private File messengerHome;
......@@ -161,6 +162,9 @@ public class XMPPServer {
}
private void initialize() throws FileNotFoundException {
// Set the name of the config file
JiveGlobals.setConfigName("jive-messenger.xml");
locateMessenger();
name = JiveGlobals.getProperty("xmpp.domain");
......@@ -463,7 +467,7 @@ public class XMPPServer {
*/
private void locateMessenger() throws FileNotFoundException {
String jiveConfigName = "conf" + File.separator + "jive-messenger.xml";
// First, try to load it jiveHome as a system property.
// First, try to load it messengerHome as a system property.
if (messengerHome == null) {
String homeProperty = System.getProperty("messengerHome");
try {
......@@ -476,8 +480,8 @@ public class XMPPServer {
}
}
// If we still don't have messengerHome, let's assume this is standalone
// and just look for messengerHome in a standard sub-dir location and verify
// If we still don't have home, let's assume this is standalone
// and just look for home in a standard sub-dir location and verify
// by looking for the config file
if (messengerHome == null) {
try {
......@@ -489,7 +493,7 @@ public class XMPPServer {
}
}
// If messengerHome is still null, no outside process has set it and
// If home 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 (messengerHome == null) {
......@@ -511,7 +515,7 @@ public class XMPPServer {
}
}
catch (Exception e) {
System.err.println("Error loading messenger_init.xml to find messengerHome.");
System.err.println("Error loading messenger_init.xml to find home.");
e.printStackTrace();
}
finally {
......@@ -524,11 +528,11 @@ public class XMPPServer {
}
if (messengerHome == null) {
System.err.println("Could not locate messengerHome");
System.err.println("Could not locate home");
throw new FileNotFoundException();
}
else {
JiveGlobals.messengerHome = messengerHome.toString();
JiveGlobals.home = messengerHome.toString();
}
}
......
......@@ -11,7 +11,6 @@
package org.jivesoftware.messenger.audit.spi;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.messenger.Session;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.audit.AuditManager;
......@@ -19,6 +18,7 @@ import org.jivesoftware.messenger.audit.Auditor;
import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.interceptor.InterceptorManager;
import org.jivesoftware.messenger.interceptor.PacketInterceptor;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.Packet;
import java.util.Iterator;
......
......@@ -11,18 +11,19 @@
package org.jivesoftware.messenger.audit.spi;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.*;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;
import org.jivesoftware.messenger.Session;
import org.jivesoftware.messenger.audit.AuditManager;
import org.jivesoftware.messenger.audit.Auditor;
import org.xmpp.packet.Packet;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence;
import org.xmpp.packet.IQ;
import org.dom4j.io.XMLWriter;
import org.dom4j.Element;
import org.dom4j.DocumentFactory;
import java.io.*;
import java.util.Date;
......@@ -138,7 +139,7 @@ public class AuditorImpl implements Auditor {
int i;
// Find the next available log file name
for (i = 0; maxCount < 1 || i < maxCount; i++) {
currentAuditFile = new File(JiveGlobals.getMessengerHome() + File.separator + "logs",
currentAuditFile = new File(JiveGlobals.getHomeDirectory() + File.separator + "logs",
"jive.audit-" + i + ".log");
if (!currentAuditFile.exists()) {
break;
......@@ -158,10 +159,10 @@ public class AuditorImpl implements Auditor {
// Rotate the files
for (i--; i >= 0; i--) {
String previousName = "jive.audit-" + i + ".log";
File previousFile = new File(JiveGlobals.getMessengerHome() + File.separator + "logs",
File previousFile = new File(JiveGlobals.getHomeDirectory() + File.separator + "logs",
previousName);
previousFile.renameTo(currentAuditFile);
currentAuditFile = new File(JiveGlobals.getMessengerHome() + File.separator + "logs",
currentAuditFile = new File(JiveGlobals.getHomeDirectory() + File.separator + "logs",
previousName);
}
}
......
......@@ -11,11 +11,8 @@
package org.jivesoftware.messenger.auth;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.util.*;
import org.jivesoftware.util.JiveGlobals;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
......
......@@ -20,8 +20,8 @@
package org.jivesoftware.messenger.container;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.mortbay.http.SunJsseListener;
......@@ -73,7 +73,7 @@ public class AdminConsolePlugin implements Plugin {
try {
// Configure logging to a file, creating log dir if needed
System.setProperty("org.apache.commons.logging.LogFactory", "org.mortbay.log.Factory");
File logDir = new File(JiveGlobals.getMessengerHome(), "logs");
File logDir = new File(JiveGlobals.getHomeDirectory(), "logs");
if (!logDir.exists()) {
logDir.mkdirs();
}
......@@ -107,7 +107,7 @@ public class AdminConsolePlugin implements Plugin {
// Get the keystore location. The default location is security/keystore
String keyStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.keystore",
"resources" + File.separator + "security" + File.separator + "keystore");
keyStoreLocation = JiveGlobals.getMessengerHome() + File.separator + keyStoreLocation;
keyStoreLocation = JiveGlobals.getHomeDirectory() + File.separator + keyStoreLocation;
// Get the keystore password. The default password is "changeit".
String keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass", "changeit");
......@@ -116,7 +116,7 @@ public class AdminConsolePlugin implements Plugin {
// Get the truststore location; default at security/truststore
String trustStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.truststore",
"resources" + File.separator + "security" + File.separator + "truststore");
trustStoreLocation = JiveGlobals.getMessengerHome() + File.separator +
trustStoreLocation = JiveGlobals.getHomeDirectory() + File.separator +
trustStoreLocation;
// Get the truststore passwprd; default is "changeit".
......
......@@ -22,7 +22,7 @@ import java.io.File;
* <li>Use the Jive Messenger API to add new functionality to server.
* </ul>
*
* Plugins live in the <tt>plugins</tt> directory of <tt>messengerHome</tt>. Plugins
* Plugins live in the <tt>plugins</tt> directory of <tt>home</tt>. Plugins
* that are packaged as JAR files will be automatically expanded into directories. A
* plugin directory should have the following structure:
*
......
......@@ -20,39 +20,27 @@
package org.jivesoftware.messenger.container;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.Version;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.admin.AdminConsole;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Attribute;
import org.dom4j.io.SAXReader;
import org.jivesoftware.admin.AdminConsole;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.Version;
import java.io.*;
import java.io.File;
import java.io.FileFilter;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.*;
import java.util.jar.JarFile;
import java.util.jar.JarEntry;
import java.util.zip.ZipFile;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.ZipFile;
/**
* Loads and manages plugins. The <tt>plugins</tt> directory is monitored for any
......
......@@ -14,7 +14,7 @@ package org.jivesoftware.messenger.container;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import javax.servlet.ServletConfig;
......@@ -23,12 +23,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -59,7 +54,7 @@ public class PluginServlet extends HttpServlet {
static {
servlets = new ConcurrentHashMap<String, HttpServlet>();
pluginDirectory = new File(JiveGlobals.getMessengerHome(), "plugins");
pluginDirectory = new File(JiveGlobals.getHomeDirectory(), "plugins");
}
public void init(ServletConfig config) throws ServletException {
......
......@@ -11,12 +11,9 @@
package org.jivesoftware.messenger.group;
import org.jivesoftware.util.Cache;
import org.jivesoftware.util.CacheManager;
import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.*;
import org.jivesoftware.messenger.user.User;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.messenger.event.GroupEventDispatcher;
import java.util.Collection;
......
......@@ -22,6 +22,7 @@ import org.jivesoftware.messenger.user.UserManager;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.stringprep.Stringprep;
import org.jivesoftware.stringprep.StringprepException;
import org.xmpp.packet.IQ;
......
......@@ -28,6 +28,7 @@ import org.jivesoftware.messenger.user.UserAlreadyExistsException;
import org.jivesoftware.messenger.user.UserManager;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError;
......
......@@ -13,34 +13,18 @@ package org.jivesoftware.messenger.launcher;
import org.jdesktop.jdic.tray.SystemTray;
import org.jdesktop.jdic.tray.TrayIcon;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.util.XMLProperties;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.WebManager;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import org.jivesoftware.util.XMLProperties;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
* Graphical launcher for Jive Messenger.
......@@ -50,7 +34,7 @@ import java.io.IOException;
public class Launcher {
private Process messengerd;
private String configFile = JiveGlobals.getMessengerHome() + File.separator + "conf" + File.separator + "jive-messenger.xml";
private String configFile = JiveGlobals.getHomeDirectory() + File.separator + "conf" + File.separator + "jive-messenger.xml";
private JPanel toolbar = new JPanel();
private ImageIcon offIcon;
......@@ -352,7 +336,7 @@ public class Launcher {
final SwingWorker installerThread = new SwingWorker() {
public Object construct() {
File pluginsDir = new File(JiveGlobals.getMessengerHome(), "plugins");
File pluginsDir = new File(JiveGlobals.getHomeDirectory(), "plugins");
String tempName = plugin.getName() + ".part";
File tempPluginsFile = new File(pluginsDir, tempName);
......
......@@ -13,9 +13,9 @@ package org.jivesoftware.messenger.ldap;
import org.jivesoftware.messenger.auth.AuthProvider;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.util.Cache;
import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.StringUtils;
/**
......
......@@ -11,16 +11,21 @@
package org.jivesoftware.messenger.ldap;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import java.util.Hashtable;
import java.net.URLEncoder;
import javax.naming.*;
import javax.naming.ldap.LdapContext;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.directory.*;
import javax.naming.ldap.LdapContext;
import java.net.URLEncoder;
import java.util.Hashtable;
/**
* Centralized administration of LDAP connections. The getInstance() method
......
......@@ -11,8 +11,8 @@
package org.jivesoftware.messenger.muc;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.JiveGlobals;
import org.xmpp.packet.Message;
import java.util.Iterator;
......
......@@ -40,6 +40,7 @@ import org.jivesoftware.messenger.muc.NotAllowedException;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.*;
import org.xmpp.component.ComponentManager;
......
......@@ -11,8 +11,9 @@
package org.jivesoftware.messenger.net;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.JiveGlobals;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
......@@ -46,7 +47,7 @@ public class SSLConfig {
// Get the keystore location. The default location is security/keystore
keyStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.keystore",
"resources" + File.separator + "security" + File.separator + "keystore");
keyStoreLocation = JiveGlobals.getMessengerHome() + File.separator + keyStoreLocation;
keyStoreLocation = JiveGlobals.getHomeDirectory() + File.separator + keyStoreLocation;
// Get the keystore password. The default password is "changeit".
keypass = JiveGlobals.getProperty("xmpp.socket.ssl.keypass", "changeit");
......@@ -55,7 +56,7 @@ public class SSLConfig {
// Get the truststore location; default at security/truststore
trustStoreLocation = JiveGlobals.getProperty("xmpp.socket.ssl.truststore",
"resources" + File.separator + "security" + File.separator + "truststore");
trustStoreLocation = JiveGlobals.getMessengerHome() + File.separator + trustStoreLocation;
trustStoreLocation = JiveGlobals.getHomeDirectory() + File.separator + trustStoreLocation;
// Get the truststore passwprd; default is "changeit".
trustpass = JiveGlobals.getProperty("xmpp.socket.ssl.trustpass", "changeit");
......
......@@ -13,6 +13,7 @@ package org.jivesoftware.messenger.net;
import com.sun.net.ssl.KeyManager;
import com.sun.net.ssl.KeyManagerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyStore;
......@@ -38,7 +39,7 @@ public class SSLJiveKeyManagerFactory {
/**
* Creates a KeyManager list which is null if the storeType is null, or
* is a standard KeyManager that uses a KeyStore of type storeType,
* located at 'keystore' location under messengerHome, and uses 'keypass' as
* located at 'keystore' location under home, and uses 'keypass' as
* the password for the keystore password and key password. The default
* Jive keystore contains a self-signed X509 certificate pair under the
* alias '127.0.0.1' in a Java KeyStore (JKS) with initial password 'changeit'.
......@@ -47,7 +48,7 @@ public class SSLJiveKeyManagerFactory {
* the Jive XMPP server security documentation for more information.
*
* @param storeType The type of keystore (e.g. "JKS") to use or null to indicate no keystore should be used
* @param keystore The relative location of the keystore under messengerHome
* @param keystore The relative location of the keystore under home
* @param keypass The password for the keystore and key
* @return An array of relevant KeyManagers (may be null indicating a default KeyManager should be created)
* @throws NoSuchAlgorithmException If the keystore type doesn't exist (not provided or configured with your JVM)
......
......@@ -12,14 +12,15 @@
package org.jivesoftware.messenger.net;
import org.jivesoftware.util.Log;
import com.sun.net.ssl.KeyManagerFactory;
import com.sun.net.ssl.SSLContext;
import com.sun.net.ssl.TrustManagerFactory;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.TrustManagerFactory;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.security.KeyStore;
import javax.net.ssl.SSLServerSocketFactory;
/**
* Securue socket factory wrapper allowing simple setup of all security
......
......@@ -13,6 +13,7 @@ package org.jivesoftware.messenger.net;
import com.sun.net.ssl.TrustManager;
import com.sun.net.ssl.TrustManagerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.KeyStore;
......@@ -39,7 +40,7 @@ public class SSLJiveTrustManagerFactory {
/**
* Creates a TrustManager list which is null if the storeType is null, or
* is a standard TrustManager that uses a KeyStore of type storeType,
* located at 'keystore' location under messengerHome, and uses 'keypass' as
* located at 'keystore' location under home, and uses 'keypass' as
* the password for the keystore password and key password (note that
* trust managers typically don't need a key password as public keys
* are stored in the clear and can be obtained without a key password).
......@@ -47,7 +48,7 @@ public class SSLJiveTrustManagerFactory {
* as it is not needed (the server does not require client authentication).
*
* @param storeType The type of keystore (e.g. "JKS") to use or null to indicate no keystore should be used
* @param truststore The relative location of the keystore under messengerHome
* @param truststore The relative location of the keystore under home
* @param trustpass The password for the keystore and key
* @return An array of relevant KeyManagers (may be null indicating a default KeyManager should be created)
* @throws NoSuchAlgorithmException If the keystore type doesn't exist (not provided or configured with your JVM)
......
......@@ -14,7 +14,7 @@ package org.jivesoftware.messenger.net;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.ConnectionManager;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.util.JiveGlobals;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
......
......@@ -11,10 +11,11 @@
package org.jivesoftware.messenger.net;
import org.jivesoftware.messenger.ConnectionManager;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.ConnectionManager;
import org.jivesoftware.messenger.JiveGlobals;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
......
......@@ -19,6 +19,7 @@ import org.jivesoftware.messenger.net.SocketConnection;
import org.jivesoftware.messenger.net.SocketReadThread;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import java.io.IOException;
import java.net.InetAddress;
......
......@@ -13,7 +13,7 @@ package org.jivesoftware.messenger.spi;
import org.jivesoftware.util.Version;
import org.jivesoftware.messenger.XMPPServerInfo;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.util.JiveGlobals;
import java.util.Date;
import java.util.Iterator;
......
......@@ -11,18 +11,14 @@
package org.jivesoftware.messenger.user;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.messenger.event.UserEventDispatcher;
import org.jivesoftware.util.Cache;
import org.jivesoftware.util.CacheManager;
import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.stringprep.Stringprep;
import org.jivesoftware.stringprep.StringprepException;
import org.jivesoftware.util.*;
import java.util.Collection;
import java.util.Set;
import java.util.Collections;
import java.util.Set;
/**
* Manages users, including loading, creating and deleting.
......
......@@ -10,8 +10,6 @@
*/
package org.jivesoftware.util;
import org.jivesoftware.messenger.JiveGlobals;
import java.util.*;
/**
......
......@@ -11,7 +11,6 @@
package org.jivesoftware.util;
import org.jivesoftware.messenger.JiveGlobals;
import java.beans.*;
import java.util.Enumeration;
import java.util.Locale;
......
......@@ -9,38 +9,35 @@
* a copy of which is included in this distribution.
*/
package org.jivesoftware.messenger;
package org.jivesoftware.util;
import org.jivesoftware.util.*;
import org.dom4j.Document;
import org.dom4j.io.SAXReader;
import javax.naming.InitialContext;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
import java.util.*;
import org.dom4j.Document;
import org.dom4j.io.SAXReader;
import javax.naming.InitialContext;
/**
* Controls Jive properties. Jive properties are only meant to be set and retrieved
* by core Jive classes.
* <p/>
* The location of the messengerHome directory should be specified one of
* The location of the home directory should be specified one of
* three ways:
* <ol>
* <li>Set a Java system property named <tt>messengerHome</tt> with the full path to your
* messengerHome directory.
* <li>Set a Java system property named <tt>home</tt> with the full path to your
* home directory.
* <li>Indicate its value in the <tt>messenger_init.xml</tt> file. This
* is a simple xml file that should look something like:<br>
* <tt><messengerHome>c:\JiveMessenger</messengerHome></tt> (Windows) <br>
* <tt><home>c:\JiveMessenger</home></tt> (Windows) <br>
* or <br>
* <tt><messengerHome>/var/JiveMessenger</messengerHome></tt> (Unix) <p>
* <tt><home>/var/JiveMessenger</home></tt> (Unix) <p>
* <p/>
* The file must be in your classpath so that it can be loaded by Java's classloader.
* <li>Use another class in your VM to set the <tt>JiveGlobals.messengerHome</tt> variable.
* <li>Use another class in your VM to set the <tt>JiveGlobals.home</tt> variable.
* This must be done before the rest of Jive starts up, for example: in a servlet that
* is set to run as soon as the appserver starts up.
* </ol>
......@@ -50,13 +47,13 @@ import javax.naming.InitialContext;
*/
public class JiveGlobals {
private static String JIVE_CONFIG_FILENAME = "jive-messenger.xml";
private static String JIVE_CONFIG_FILENAME = null;
/**
* Location of the jiveHome directory. All configuration files should be
* located here.
*/
public static String messengerHome = null;
public static String home = null;
public static boolean failedLoading = false;
......@@ -210,41 +207,20 @@ public class JiveGlobals {
}
/**
* Returns the location of the <code>messengerHome</code> directory.
* Returns the location of the <code>home</code> directory.
*
* @return the location of the messengerHome dir.
* @return the location of the home dir.
*/
public static String getMessengerHome() {
if (messengerHome == null) {
public static String getHomeDirectory() {
if (home == null) {
loadSetupProperties();
}
return messengerHome;
}
/**
* Sets the location of the <code>messengerHome</code> directory. This method
* is only intended to be used during setup and should <b>not</b> set called
* in normal Messenger operations.
*/
public static void setMessengerHome(String mHome) {
properties = null;
xmlProperties = null;
failedLoading = false;
messengerHome = mHome;
locale = null;
timeZone = null;
dateFormat = null;
dateTimeFormat = null;
loadSetupProperties();
System.err.println("Warning - messengerHome is being reset to " + mHome +
"! Resetting the messengerHome is a normal part of the setup process, " +
"however it should not occur during the normal operations of Jive Messenger.");
return home;
}
/**
* Returns a local property. Local properties are stored in the file
* <tt>jive-messenger.xml</tt> that exists in the <tt>jiveMessenger/conf</tt> directory.
* Returns a local property. Local properties are stored in the file defined in
* <tt>JIVE_CONFIG_FILENAME</tt> that exists in the <tt>home</tt> directory.
* Properties are always specified as "foo.bar.prop", which would map to
* the following entry in the XML file:
* <pre>
......@@ -263,7 +239,7 @@ public class JiveGlobals {
loadSetupProperties();
}
// messengerHome not loaded?
// home not loaded?
if (xmlProperties == null) {
return null;
}
......@@ -272,8 +248,8 @@ public class JiveGlobals {
}
/**
* Returns a local property. Local properties are stored in the file
* <tt>jive-messenger.xml</tt> that exists in the <tt>jiveMessenger/conf</tt> directory.
* Returns a local property. Local properties are stored in the file defined in
* <tt>JIVE_CONFIG_FILENAME</tt> that exists in the <tt>home</tt> directory.
* Properties are always specified as "foo.bar.prop", which would map to
* the following entry in the XML file:
* <pre>
......@@ -295,7 +271,7 @@ public class JiveGlobals {
loadSetupProperties();
}
// messengerHome not loaded?
// home not loaded?
if (xmlProperties == null) {
return null;
}
......@@ -308,8 +284,8 @@ public class JiveGlobals {
}
/**
* Returns an integer value local property. Local properties are stored in the file
* <tt>jive_forums.xml</tt> that exists in the <tt>jiveHome</tt> directory.
* Returns an integer value local property. Local properties are stored in the file defined in
* <tt>JIVE_CONFIG_FILENAME</tt> that exists in the <tt>home</tt> directory.
* Properties are always specified as "foo.bar.prop", which would map to
* the following entry in the XML file:
* <pre>
......@@ -341,8 +317,8 @@ public class JiveGlobals {
/**
* 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.
* one will be created. Local properties are stored in the file defined in
* <tt>JIVE_CONFIG_FILENAME</tt> that exists in the <tt>home</tt> directory.
* Properties are always specified as "foo.bar.prop", which would map to
* the following entry in the XML file:
* <pre>
......@@ -369,8 +345,8 @@ public class JiveGlobals {
/**
* 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.
* one will be created. Local properties are stored in the file defined in
* <tt>JIVE_CONFIG_FILENAME</tt> that exists in the <tt>home</tt> directory.
* Properties are always specified as "foo.bar.prop", which would map to
* the following entry in the XML file:
* <pre>
......@@ -400,8 +376,8 @@ public class JiveGlobals {
* 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",
* Local properties are stored in the file defined in <tt>JIVE_CONFIG_FILENAME</tt> that exists
* in the <tt>home</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;
......@@ -669,6 +645,19 @@ public class JiveGlobals {
JIVE_CONFIG_FILENAME = configName;
}
/**
* Returns the name of the local config file name.
*
* @return the name of the config file.
*/
static String getConfigName() {
if (JIVE_CONFIG_FILENAME == null) {
throw new IllegalStateException("Need to set the configuration filename to use " +
"before sending this message");
};
return JIVE_CONFIG_FILENAME;
}
/**
* Returns true if in setup mode.
*
......@@ -680,7 +669,7 @@ public class JiveGlobals {
/**
* Loads properties if necessary. Property loading must be done lazily so
* that we give outside classes a chance to set <tt>messengerHome</tt>.
* that we give outside classes a chance to set <tt>home</tt>.
*/
private synchronized static void loadSetupProperties() {
if (failedLoading) {
......@@ -690,27 +679,27 @@ public class JiveGlobals {
// 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 (messengerHome == null) {
messengerHome = new InitPropLoader().getMessengerHome();
if (home == null) {
home = new InitPropLoader().getHome();
}
// If that failed, try loading it from JNDI
if (messengerHome == null) {
if (home == null) {
try {
InitialContext context = new InitialContext();
messengerHome = (String)context.lookup("java:comp/env/messengerHome");
home = (String)context.lookup("java:comp/env/home");
}
catch (Exception e) { }
}
// Finally, try to load it jiveHome as a system property.
if (messengerHome == null) {
messengerHome = System.getProperty("messengerHome");
if (home == null) {
home = System.getProperty("home");
}
if(messengerHome == null){
if(home == null){
try {
messengerHome = new File("..").getCanonicalPath();
if(!new File(messengerHome, "conf/jive-messenger.xml").exists()){
messengerHome = null;
home = new File("..").getCanonicalPath();
if(!new File(home, "conf/" + getConfigName()).exists()){
home = null;
}
}
catch (IOException e) {
......@@ -718,11 +707,11 @@ public class JiveGlobals {
}
}
if(messengerHome == null){
if(home == null){
try {
messengerHome = new File("").getCanonicalPath();
if(!new File(messengerHome, "conf/jive-messenger.xml").exists()){
messengerHome = null;
home = new File("").getCanonicalPath();
if(!new File(home, "conf/" + getConfigName()).exists()){
home = null;
}
}
catch (IOException e) {
......@@ -730,20 +719,20 @@ public class JiveGlobals {
}
}
// If still null, finding messengerHome failed.
if (messengerHome == null) {
// If still null, finding home failed.
if (home == null) {
failedLoading = true;
StringBuilder msg = new StringBuilder();
msg.append("Critical Error! The messengerHome directory could not be loaded, \n");
msg.append("Critical Error! The home directory could not be loaded, \n");
msg.append("which will prevent the application from working correctly.\n\n");
msg.append("You must set messengerHome in one of four ways:\n");
msg.append(" 1) Set a servlet init parameter named messengerHome.\n");
msg.append("You must set home in one of four ways:\n");
msg.append(" 1) Set a servlet init parameter named home.\n");
msg.append(" 2) Add a messenger_init.xml file to your classpath, which points \n ");
msg.append(" to messengerHome. Normally, this file will be in WEB-INF/classes.\n");
msg.append(" 3) Set the JNDI value \"java:comp/env/messengerHome\" with a String \n");
msg.append(" that points to your messengerHome directory. \n");
msg.append(" 4) Set the Java system property \"messengerHome\".\n\n");
msg.append("Further instructions for setting messengerHome can be found in the \n");
msg.append(" to home. Normally, this file will be in WEB-INF/classes.\n");
msg.append(" 3) Set the JNDI value \"java:comp/env/home\" with a String \n");
msg.append(" that points to your home directory. \n");
msg.append(" 4) Set the Java system property \"home\".\n\n");
msg.append("Further instructions for setting home can be found in the \n");
msg.append("installation documentation.");
System.err.println(msg.toString());
return;
......@@ -751,19 +740,19 @@ public class JiveGlobals {
// Create a manager with the full path to the xml config file.
try {
// Do a permission check on the jiveHome directory:
File mh = new File(messengerHome);
File mh = new File(home);
if (!mh.exists()) {
Log.error("Error - the specified messengerHome directory does not exist (" + messengerHome + ")");
Log.error("Error - the specified home directory does not exist (" + home + ")");
}
else {
if (!mh.canRead() || !mh.canWrite()) {
Log.error("Error - the user running this Jive application can not read and write to the "
+ "specified jiveHome directory (" + messengerHome + "). Please grant the executing user "
+ "specified jiveHome directory (" + home + "). Please grant the executing user "
+ "read and write perms.");
}
}
xmlProperties = new XMLProperties(messengerHome + File.separator + "conf" +
File.separator + JIVE_CONFIG_FILENAME);
xmlProperties = new XMLProperties(home + File.separator + "conf" +
File.separator + getConfigName());
}
catch (IOException ioe) {
Log.error(ioe);
......@@ -775,40 +764,40 @@ public class JiveGlobals {
}
/**
* A very small class to load the messenger_init.properties file. The class is
* A very small class to load the file defined in JiveGlobals.JIVE_CONFIG_FILENAME. The class is
* needed since loading files from the classpath in a static context often
* fails.
*/
class InitPropLoader {
public String getMessengerHome() {
String messengerHome = null;
public String getHome() {
String home = null;
InputStream in = null;
try {
in = getClass().getResourceAsStream("/messenger_init.xml");
in = getClass().getResourceAsStream("/" + JiveGlobals.getConfigName());
if (in != null) {
SAXReader reader = new SAXReader();
Document doc = reader.read(in);
messengerHome = doc.getRootElement().getText();
home = doc.getRootElement().getText();
}
}
catch (Exception e) {
Log.error("Error loading messenger_init.xml to find messengerHome.", e);
Log.error("Error loading messenger_init.xml to find home.", e);
}
finally {
try { if (in != null) { in.close(); } }
catch (Exception e) { }
}
if (messengerHome != null) {
messengerHome = messengerHome.trim();
if (home != null) {
home = home.trim();
// Remove trailing slashes.
while (messengerHome.endsWith("/") || messengerHome.endsWith("\\")) {
messengerHome = messengerHome.substring(0, messengerHome.length() - 1);
while (home.endsWith("/") || home.endsWith("\\")) {
home = home.substring(0, home.length() - 1);
}
}
if ("".equals(messengerHome)) {
messengerHome = null;
if ("".equals(home)) {
home = null;
}
return messengerHome;
return home;
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.sql.*;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.messenger.event.PropertyEventDispatcher;
/**
* Retrieves and stores Jive properties. Properties are stored in the database.
......
......@@ -11,8 +11,6 @@
package org.jivesoftware.util;
import org.jivesoftware.messenger.JiveGlobals;
import javax.servlet.*;
import javax.servlet.jsp.jstl.core.Config;
import java.io.IOException;
......
......@@ -11,7 +11,6 @@
package org.jivesoftware.util;
import org.jivesoftware.messenger.JiveGlobals;
import java.text.*;
import java.util.*;
......
......@@ -11,7 +11,6 @@
package org.jivesoftware.util;
import org.jivesoftware.messenger.JiveGlobals;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
......
......@@ -11,12 +11,14 @@
package org.jivesoftware.util;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import java.io.*;
import java.util.*;
import org.dom4j.Element;
import org.dom4j.Document;
import org.dom4j.io.*;
import org.jivesoftware.messenger.event.PropertyEventDispatcher;
/**
* Provides the the ability to use simple XML property files. Each property is
......
......@@ -14,13 +14,14 @@ package org.jivesoftware.messenger.plugin;
import org.jivesoftware.messenger.container.Plugin;
import org.jivesoftware.messenger.container.PluginManager;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.event.PropertyEventListener;
import org.jivesoftware.messenger.event.PropertyEventDispatcher;
import org.jivesoftware.util.PropertyEventListener;
import org.jivesoftware.util.PropertyEventDispatcher;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.group.GroupManager;
import org.jivesoftware.messenger.group.Group;
import org.jivesoftware.messenger.group.GroupNotFoundException;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError;
......
......@@ -6,7 +6,7 @@
<%@ page import="java.io.*,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.messenger.auth.UnauthorizedException,
org.jivesoftware.messenger.user.UserNotFoundException,
org.jivesoftware.messenger.group.GroupNotFoundException"
......
......@@ -147,7 +147,7 @@
<tr>
<td class="c1"><fmt:message key="index.home" /></td>
<td class="c2">
<%= JiveGlobals.getMessengerHome() %>
<%= JiveGlobals.getHomeDirectory() %>
</td>
</tr>
<tr>
......
......@@ -9,9 +9,10 @@
org.jivesoftware.messenger.auth.AuthToken,
org.jivesoftware.messenger.auth.AuthFactory,
org.jivesoftware.messenger.auth.UnauthorizedException,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.util.Log,
org.jivesoftware.admin.AdminConsole"
org.jivesoftware.admin.AdminConsole,
org.jivesoftware.util.JiveGlobals"
errorPage="error.jsp"
%>
......
......@@ -14,7 +14,7 @@
java.text.*,
org.jivesoftware.util.log.Logger,
org.jivesoftware.messenger.auth.UnauthorizedException,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.messenger.user.*,
java.util.*,
org.jivesoftware.admin.AdminPageBean"
......@@ -150,16 +150,16 @@
}
else if (markLog && log != null) {
if ("error".equals(log)) {
Log.markErrorLogFile(pageUser);
Log.markErrorLogFile(pageUser.getUsername());
}
else if ("warn".equals(log)) {
Log.markWarnLogFile(pageUser);
Log.markWarnLogFile(pageUser.getUsername());
}
else if ("info".equals(log)) {
Log.markInfoLogFile(pageUser);
Log.markInfoLogFile(pageUser.getUsername());
}
else if ("debug".equals(log)) {
Log.markDebugLogFile(pageUser);
Log.markDebugLogFile(pageUser.getUsername());
}
response.sendRedirect("logviewer.jsp?log=" + log);
return;
......@@ -431,7 +431,7 @@ IFRAME {
<br>
<span class="jive-description" style="color:#666;">
Log dir: <%= JiveGlobals.getMessengerHome() %><%= File.separator %>logs
Log dir: <%= JiveGlobals.getHomeDirectory() %><%= File.separator %>logs
</span>
<br><br>
......
......@@ -14,7 +14,7 @@
org.jivesoftware.messenger.XMPPServerInfo,
org.jivesoftware.messenger.muc.MultiUserChatServer,
org.jivesoftware.admin.*,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
java.util.*,
org.jivesoftware.util.LocaleUtils"
errorPage="error.jsp"
......
......@@ -13,7 +13,7 @@
java.util.*,
org.jivesoftware.util.*,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.admin.AdminPageBean"
errorPage="error.jsp"
%>
......
......@@ -16,7 +16,7 @@
java.util.*,
org.jivesoftware.messenger.XMPPServer,
java.net.InetAddress,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.messenger.net.SSLSocketAcceptThread,
org.jivesoftware.messenger.net.SocketAcceptThread"
%>
......
......@@ -13,7 +13,7 @@
org.jivesoftware.messenger.auth.UnauthorizedException,
org.jivesoftware.messenger.auth.AuthFactory,
org.jivesoftware.messenger.auth.AuthToken,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.messenger.auth.DefaultAuthProvider" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
......
......@@ -12,7 +12,7 @@
javax.naming.NamingEnumeration,
javax.naming.InitialContext,
javax.naming.Binding,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.database.JNDIDataSourceProvider,
org.jivesoftware.database.DbConnectionManager,
org.jivesoftware.database.JNDIDataSourceProvider" %>
......
......@@ -7,7 +7,7 @@
--%>
<%@ page import="org.jivesoftware.util.ParamUtils,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.database.EmbeddedConnectionProvider,
org.jivesoftware.database.DbConnectionManager,
org.jivesoftware.database.ConnectionProvider,
......@@ -61,7 +61,7 @@
// Defaults
if (mode == null) {
// If the "embedded-database" directory exists, select to the embedded db as the default.
if (new File(JiveGlobals.getMessengerHome(), "embedded-db").exists()) {
if (new File(JiveGlobals.getHomeDirectory(), "embedded-db").exists()) {
mode = EMBEDDED;
}
// Otherwise default to standard.
......
......@@ -11,7 +11,7 @@
java.beans.BeanInfo,
java.beans.Introspector,
java.beans.PropertyDescriptor,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
java.sql.Connection,
java.io.File,
......@@ -100,7 +100,7 @@
}
catch (Exception e) {
errors.put("general","Setting connection properties failed - please see the error "
+ "log located in messengerHome/logs for more details.");
+ "log located in home/logs for more details.");
Log.error(e);
}
// No errors setting the properties, so test the connection
......
<%--
- $RCSfile$
- $Revision$
- $Date$
--%>
<%@ page import="java.lang.reflect.Method,
java.io.File,
org.jivesoftware.util.LocaleUtils" %>
<%-- note, the loadClass method is defined in setup-global.jspf --%>
<% // Check the user's environment for minimum requirements.
boolean jdk13Installed = false;
boolean servlet22Installed = false;
boolean jsp11Installed = false;
boolean jiveJarsInstalled = false;
boolean messengerHomeExists = false;
File messengerHome = null;
// Check for JDK 1.5
try {
loadClass("java.util.concurrent.ConcurrentHashMap");
jdk13Installed = true;
}
catch (ClassNotFoundException cnfe) {}
// Check for Servlet 2.3:
try {
Class c = loadClass("javax.servlet.http.HttpSession");
Method m = c.getMethod("getAttribute",new Class[]{String.class});
servlet22Installed = true;
}
catch (ClassNotFoundException cnfe) {}
// Check for JSP 1.1:
try {
loadClass("javax.servlet.jsp.tagext.Tag");
jsp11Installed = true;
}
catch (ClassNotFoundException cnfe) {}
// Check that the Messenger jar are installed:
try {
loadClass("org.jivesoftware.messenger.XMPPServer");
jiveJarsInstalled = true;
}
catch (ClassNotFoundException cnfe) {}
// Try to determine what the jiveHome directory is:
try {
Class jiveGlobalsClass = loadClass("org.jivesoftware.messenger.JiveGlobals");
Method getMessengerHomeMethod = jiveGlobalsClass.getMethod("getMessengerHome", (Class[])null);
Class jiveGlobalsClass = loadClass("org.jivesoftware.util.JiveGlobals");
Method getMessengerHomeMethod = jiveGlobalsClass.getMethod("getHomeDirectory", (Class[])null);
String messengerHomeProp = (String)getMessengerHomeMethod.invoke(jiveGlobalsClass, (Object[])null);
if (messengerHomeProp != null) {
messengerHome = new File(messengerHomeProp);
if (messengerHome.exists()) {
messengerHomeExists = true;
}
}
}
catch (Exception e) {
e.printStackTrace();
}
// If there were no errors, redirect to the main setup page
if (!jdk13Installed || !servlet22Installed || !jsp11Installed || !jiveJarsInstalled
|| !messengerHomeExists)
{
%>
<html>
<head>
<title><fmt:message key="title" /> <fmt:message key="setup.title" /></title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<p class="jive-setup-page-header">
<fmt:message key="title" /> <fmt:message key="setup.title" />
</p>
<p class="jive-setup-error-text">
<fmt:message key="setup.env.check.error" /> <fmt:message key="title" /> <fmt:message key="setup.title" />.
</p>
<p>
<fmt:message key="setup.env.check.error_info">
<fmt:param value="<%= LocaleUtils.getLocalizedString("title") %>" />
</fmt:message>
</p>
<ul>
<table cellpadding="3" cellspacing="2" border="0">
<% if (jdk13Installed) { %>
<tr>
<td><img src="images/check.gif" width="13" height="13" border="0"></td>
<td>
<fmt:message key="setup.env.check.jdk" />
</td>
</tr>
<% } else { %>
<tr>
<td><img src="images/x.gif" width="13" height="13" border="0"></td>
<td>
<span class="jive-setup-error-text">
<fmt:message key="setup.env.check.jdk" />
</span>
</td>
</tr>
<% }
if (servlet22Installed) {
%>
<tr>
<td><img src="images/check.gif" width="13" height="13" border="0"></td>
<td>
<fmt:message key="setup.env.check.servlet" />
</td>
</tr>
<% } else { %>
<tr>
<td><img src="images/x.gif" width="13" height="13" border="0"></td>
<td>
<span class="jive-setup-error-text">
<fmt:message key="setup.env.check.servlet" />
</span>
</td>
</tr>
<% }
if (jsp11Installed) {
%>
<tr>
<td><img src="images/check.gif" width="13" height="13" border="0"></td>
<td>
<fmt:message key="setup.env.check.jsp" />
</td>
</tr>
<% } else { %>
<tr>
<td><img src="images/x.gif" width="13" height="13" border="0"></td>
<td>
<span class="jive-setup-error-text">
<fmt:message key="setup.env.check.jsp" />
</span>
</td>
</tr>
<% }
if (jiveJarsInstalled) {
%>
<tr>
<td><img src="images/check.gif" width="13" height="13" border="0"></td>
<td>
<fmt:message key="title" /> <fmt:message key="setup.env.check.class" />
</td>
</tr>
<% } else { %>
<tr>
<td><img src="images/x.gif" width="13" height="13" border="0"></td>
<td>
<span class="jive-setup-error-text">
<fmt:message key="title" /> <fmt:message key="setup.env.check.class" />
</span>
</td>
</tr>
<% }
if (messengerHomeExists) {
%>
<tr>
<td><img src="images/x.gif" width="13" height="13" border="0"></td>
<td>
<span class="jive-setup-error-text">
<fmt:message key="setup.env.check.jive" /> (<%= messengerHome.toString() %>)
</span>
</td>
</tr>
<% } else { %>
<tr>
<td><img src="images/x.gif" width="13" height="13" border="0"></td>
<td>
<span class="jive-setup-error-text">
<fmt:message key="setup.env.check.not_home" />
</span>
</td>
</tr>
<% } %>
</table>
</ul>
<p>
<fmt:message key="setup.env.check.doc" />
</p>
</body>
</html>
<% // return so we stop showing the page:
return;
}
%>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<%@ page import="org.jivesoftware.util.ParamUtils,
org.jivesoftware.messenger.auth.UnauthorizedException,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
java.util.Map,
java.util.Iterator,
org.jivesoftware.messenger.ConnectionManager,
......
......@@ -5,7 +5,7 @@
--%>
<%@ page import="org.jivesoftware.util.ParamUtils,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
java.util.Map,
java.util.HashMap,
java.net.InetAddress"
......
......@@ -7,7 +7,7 @@
--%>
<%@ page import="org.jivesoftware.util.ParamUtils,
org.jivesoftware.messenger.JiveGlobals,
org.jivesoftware.util.JiveGlobals,
java.util.*" %>
<%! // Global vars, methods, etc
......
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