Commit b41dc3f6 authored by Dele Olajide's avatar Dele Olajide
parents 7fbc49b8 ac304ea9
...@@ -63,7 +63,25 @@ import org.jivesoftware.openfire.disco.UserItemsProvider; ...@@ -63,7 +63,25 @@ import org.jivesoftware.openfire.disco.UserItemsProvider;
import org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager; import org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager;
import org.jivesoftware.openfire.filetransfer.FileTransferManager; import org.jivesoftware.openfire.filetransfer.FileTransferManager;
import org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy; import org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy;
import org.jivesoftware.openfire.handler.*; import org.jivesoftware.openfire.handler.IQAuthHandler;
import org.jivesoftware.openfire.handler.IQBindHandler;
import org.jivesoftware.openfire.handler.IQEntityTimeHandler;
import org.jivesoftware.openfire.handler.IQHandler;
import org.jivesoftware.openfire.handler.IQLastActivityHandler;
import org.jivesoftware.openfire.handler.IQMessageCarbonsHandler;
import org.jivesoftware.openfire.handler.IQOfflineMessagesHandler;
import org.jivesoftware.openfire.handler.IQPingHandler;
import org.jivesoftware.openfire.handler.IQPrivacyHandler;
import org.jivesoftware.openfire.handler.IQPrivateHandler;
import org.jivesoftware.openfire.handler.IQRegisterHandler;
import org.jivesoftware.openfire.handler.IQRosterHandler;
import org.jivesoftware.openfire.handler.IQSessionEstablishmentHandler;
import org.jivesoftware.openfire.handler.IQSharedGroupHandler;
import org.jivesoftware.openfire.handler.IQTimeHandler;
import org.jivesoftware.openfire.handler.IQVersionHandler;
import org.jivesoftware.openfire.handler.IQvCardHandler;
import org.jivesoftware.openfire.handler.PresenceSubscribeHandler;
import org.jivesoftware.openfire.handler.PresenceUpdateHandler;
import org.jivesoftware.openfire.lockout.LockOutManager; import org.jivesoftware.openfire.lockout.LockOutManager;
import org.jivesoftware.openfire.mediaproxy.MediaProxyService; import org.jivesoftware.openfire.mediaproxy.MediaProxyService;
import org.jivesoftware.openfire.muc.MultiUserChatManager; import org.jivesoftware.openfire.muc.MultiUserChatManager;
...@@ -90,6 +108,7 @@ import org.jivesoftware.util.CertificateManager; ...@@ -90,6 +108,7 @@ import org.jivesoftware.util.CertificateManager;
import org.jivesoftware.util.InitializationException; import org.jivesoftware.util.InitializationException;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.TaskEngine; import org.jivesoftware.util.TaskEngine;
import org.jivesoftware.util.Version; import org.jivesoftware.util.Version;
import org.jivesoftware.util.cache.CacheFactory; import org.jivesoftware.util.cache.CacheFactory;
...@@ -128,7 +147,7 @@ import org.xmpp.packet.JID; ...@@ -128,7 +147,7 @@ import org.xmpp.packet.JID;
*/ */
public class XMPPServer { public class XMPPServer {
private static final Logger Log = LoggerFactory.getLogger(XMPPServer.class); private static final Logger logger = LoggerFactory.getLogger(XMPPServer.class);
private static XMPPServer instance; private static XMPPServer instance;
...@@ -337,7 +356,7 @@ public class XMPPServer { ...@@ -337,7 +356,7 @@ public class XMPPServer {
host = InetAddress.getLocalHost().getHostName(); host = InetAddress.getLocalHost().getHostName();
} }
catch (UnknownHostException ex) { catch (UnknownHostException ex) {
Log.warn("Unable to determine local hostname.", ex); logger.warn("Unable to determine local hostname.", ex);
} }
if (host == null) { if (host == null) {
host = "127.0.0.1"; host = "127.0.0.1";
...@@ -349,7 +368,7 @@ public class XMPPServer { ...@@ -349,7 +368,7 @@ public class XMPPServer {
} }
if (isStandAlone()) { if (isStandAlone()) {
Log.info("Registering shutdown hook (standalone mode)"); logger.info("Registering shutdown hook (standalone mode)");
Runtime.getRuntime().addShutdownHook(new ShutdownHookThread()); Runtime.getRuntime().addShutdownHook(new ShutdownHookThread());
TaskEngine.getInstance().schedule(new Terminator(), 1000, 1000); TaskEngine.getInstance().schedule(new Terminator(), 1000, 1000);
} }
...@@ -360,18 +379,18 @@ public class XMPPServer { ...@@ -360,18 +379,18 @@ public class XMPPServer {
CacheFactory.initialize(); CacheFactory.initialize();
} catch (InitializationException e) { } catch (InitializationException e) {
e.printStackTrace(); e.printStackTrace();
Log.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} }
JiveGlobals.migrateProperty("xmpp.domain"); JiveGlobals.migrateProperty("xmpp.domain");
name = JiveGlobals.getProperty("xmpp.domain", host).toLowerCase(); name = JiveGlobals.getProperty("xmpp.domain", host).toLowerCase();
org.jivesoftware.util.Log.setDebugEnabled(JiveGlobals.getXMLProperty("log.debug.enabled", false)); JiveGlobals.migrateProperty(Log.LOG_DEBUG_ENABLED);
Log.setDebugEnabled(JiveGlobals.getBooleanProperty(Log.LOG_DEBUG_ENABLED, false));
// Update server info // Update server info
xmppServerInfo = new XMPPServerInfoImpl(name, host, version, startDate); xmppServerInfo = new XMPPServerInfoImpl(name, host, version, startDate);
initialized = true; initialized = true;
} }
...@@ -420,7 +439,7 @@ public class XMPPServer { ...@@ -420,7 +439,7 @@ public class XMPPServer {
} }
} catch (Exception e) { } catch (Exception e) {
Log.error("Error generating self-signed certificates", e); logger.error("Error generating self-signed certificates", e);
} }
// Initialize list of admins now (before we restart Jetty) // Initialize list of admins now (before we restart Jetty)
...@@ -454,7 +473,7 @@ public class XMPPServer { ...@@ -454,7 +473,7 @@ public class XMPPServer {
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.error(e.getMessage(), e); logger.error(e.getMessage(), e);
shutdownServer(); shutdownServer();
} }
} }
...@@ -495,7 +514,7 @@ public class XMPPServer { ...@@ -495,7 +514,7 @@ public class XMPPServer {
// Log that the server has been started // Log that the server has been started
String startupBanner = LocaleUtils.getLocalizedString("short.title") + " " + version.getVersionString() + String startupBanner = LocaleUtils.getLocalizedString("short.title") + " " + version.getVersionString() +
" [" + JiveGlobals.formatDateTime(new Date()) + "]"; " [" + JiveGlobals.formatDateTime(new Date()) + "]";
Log.info(startupBanner); logger.info(startupBanner);
System.out.println(startupBanner); System.out.println(startupBanner);
started = true; started = true;
...@@ -507,7 +526,7 @@ public class XMPPServer { ...@@ -507,7 +526,7 @@ public class XMPPServer {
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.error(e.getMessage(), e); logger.error(e.getMessage(), e);
System.out.println(LocaleUtils.getLocalizedString("startup.error")); System.out.println(LocaleUtils.getLocalizedString("startup.error"));
shutdownServer(); shutdownServer();
} }
...@@ -588,7 +607,7 @@ public class XMPPServer { ...@@ -588,7 +607,7 @@ public class XMPPServer {
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.error(LocaleUtils.getLocalizedString("admin.error"), e); logger.error(LocaleUtils.getLocalizedString("admin.error"), e);
} }
} }
...@@ -607,7 +626,7 @@ public class XMPPServer { ...@@ -607,7 +626,7 @@ public class XMPPServer {
module.stop(); module.stop();
module.destroy(); module.destroy();
} }
Log.error(LocaleUtils.getLocalizedString("admin.error"), e); logger.error(LocaleUtils.getLocalizedString("admin.error"), e);
} }
} }
} }
...@@ -628,7 +647,7 @@ public class XMPPServer { ...@@ -628,7 +647,7 @@ public class XMPPServer {
module.stop(); module.stop();
module.destroy(); module.destroy();
} }
Log.error(LocaleUtils.getLocalizedString("admin.error"), e); logger.error(LocaleUtils.getLocalizedString("admin.error"), e);
} }
} }
} }
...@@ -645,7 +664,7 @@ public class XMPPServer { ...@@ -645,7 +664,7 @@ public class XMPPServer {
restartMethod.invoke(null, (Object []) null); restartMethod.invoke(null, (Object []) null);
} }
catch (Exception e) { catch (Exception e) {
Log.error("Could not restart container", e); logger.error("Could not restart container", e);
} }
} }
} }
...@@ -685,7 +704,7 @@ public class XMPPServer { ...@@ -685,7 +704,7 @@ public class XMPPServer {
* inside of another server. * inside of another server.
*/ */
public void stop() { public void stop() {
Log.info("Initiating shutdown ..."); logger.info("Initiating shutdown ...");
// Only do a system exit if we're running standalone // Only do a system exit if we're running standalone
if (isStandAlone()) { if (isStandAlone()) {
// if we're in a wrapper, we have to tell the wrapper to shut us down // if we're in a wrapper, we have to tell the wrapper to shut us down
...@@ -696,7 +715,7 @@ public class XMPPServer { ...@@ -696,7 +715,7 @@ public class XMPPServer {
stopMethod.invoke(null, 0); stopMethod.invoke(null, 0);
} }
catch (Exception e) { catch (Exception e) {
Log.error("Could not stop container", e); logger.error("Could not stop container", e);
} }
} }
else { else {
...@@ -763,7 +782,7 @@ public class XMPPServer { ...@@ -763,7 +782,7 @@ public class XMPPServer {
System.err.println("Database setup or configuration error: " + System.err.println("Database setup or configuration error: " +
"Please verify your database settings and check the " + "Please verify your database settings and check the " +
"logs/error.log file for detailed error messages."); "logs/error.log file for detailed error messages.");
Log.error("Database could not be accessed", e); logger.error("Database could not be accessed", e);
throw new IllegalArgumentException(e); throw new IllegalArgumentException(e);
} }
finally { finally {
...@@ -900,7 +919,7 @@ public class XMPPServer { ...@@ -900,7 +919,7 @@ public class XMPPServer {
} }
} }
} catch (IOException ioe) { } catch (IOException ioe) {
Log.error("Error reading console input", ioe); logger.error("Error reading console input", ioe);
} }
} }
} }
...@@ -920,7 +939,7 @@ public class XMPPServer { ...@@ -920,7 +939,7 @@ public class XMPPServer {
@Override @Override
public void run() { public void run() {
shutdownServer(); shutdownServer();
Log.info("Server halted"); logger.info("Server halted");
System.err.println("Server halted"); System.err.println("Server halted");
} }
} }
...@@ -962,30 +981,30 @@ public class XMPPServer { ...@@ -962,30 +981,30 @@ public class XMPPServer {
try { try {
listener.serverStopping(); listener.serverStopping();
} catch (Exception ex) { } catch (Exception ex) {
Log.error("Exception during listener shutdown", ex); logger.error("Exception during listener shutdown", ex);
} }
} }
// If we don't have modules then the server has already been shutdown // If we don't have modules then the server has already been shutdown
if (modules.isEmpty()) { if (modules.isEmpty()) {
return; return;
} }
Log.info("Shutting down " + modules.size() + " modules ..."); logger.info("Shutting down " + modules.size() + " modules ...");
// Get all modules and stop and destroy them // Get all modules and stop and destroy them
for (Module module : modules.values()) { for (Module module : modules.values()) {
try { try {
module.stop(); module.stop();
module.destroy(); module.destroy();
} catch (Exception ex) { } catch (Exception ex) {
Log.error("Exception during module shutdown", ex); logger.error("Exception during module shutdown", ex);
} }
} }
// Stop all plugins // Stop all plugins
Log.info("Shutting down plugins ..."); logger.info("Shutting down plugins ...");
if (pluginManager != null) { if (pluginManager != null) {
try { try {
pluginManager.shutdown(); pluginManager.shutdown();
} catch (Exception ex) { } catch (Exception ex) {
Log.error("Exception during plugin shutdown", ex); logger.error("Exception during plugin shutdown", ex);
} }
} }
modules.clear(); modules.clear();
...@@ -993,14 +1012,14 @@ public class XMPPServer { ...@@ -993,14 +1012,14 @@ public class XMPPServer {
try { try {
DbConnectionManager.destroyConnectionProvider(); DbConnectionManager.destroyConnectionProvider();
} catch (Exception ex) { } catch (Exception ex) {
Log.error("Exception during DB shutdown", ex); logger.error("Exception during DB shutdown", ex);
} }
// Shutdown the task engine. // Shutdown the task engine.
TaskEngine.getInstance().shutdown(); TaskEngine.getInstance().shutdown();
// hack to allow safe stopping // hack to allow safe stopping
Log.info("Openfire stopped"); logger.info("Openfire stopped");
} }
/** /**
......
...@@ -972,6 +972,7 @@ public class LdapManager { ...@@ -972,6 +972,7 @@ public class LdapManager {
} }
constraints.setReturningAttributes(new String[] { usernameField }); constraints.setReturningAttributes(new String[] { usernameField });
// NOTE: this assumes that the username has already been JID-unescaped
NamingEnumeration<SearchResult> answer = ctx.search("", getSearchFilter(), NamingEnumeration<SearchResult> answer = ctx.search("", getSearchFilter(),
new String[] {sanitizeSearchFilter(username)}, new String[] {sanitizeSearchFilter(username)},
constraints); constraints);
...@@ -1117,7 +1118,7 @@ public class LdapManager { ...@@ -1117,7 +1118,7 @@ public class LdapManager {
} }
constraints.setReturningAttributes(new String[] { groupNameField }); constraints.setReturningAttributes(new String[] { groupNameField });
String filter = MessageFormat.format(getGroupSearchFilter(), sanitizeSearchFilter(JID.unescapeNode(groupname))); String filter = MessageFormat.format(getGroupSearchFilter(), sanitizeSearchFilter(groupname));
NamingEnumeration<SearchResult> answer = ctx.search("", filter, constraints); NamingEnumeration<SearchResult> answer = ctx.search("", filter, constraints);
if (debug) { if (debug) {
...@@ -1841,6 +1842,28 @@ public class LdapManager { ...@@ -1841,6 +1842,28 @@ public class LdapManager {
* @return A simple list of strings (that should be sorted) of the results. * @return A simple list of strings (that should be sorted) of the results.
*/ */
public List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim) { public List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim) {
return retrieveList(attribute, searchFilter, startIndex, numResults, suffixToTrim, false);
}
/**
* Generic routine for retrieving a list of results from the LDAP server. It's meant to be very
* flexible so that just about any query for a list of results can make use of it without having
* to reimplement their own calls to LDAP. This routine also accounts for sorting settings,
* paging settings, any other global settings, and alternate DNs.
*
* The passed in filter string needs to be pre-prepared! In other words, nothing will be changed
* in the string before it is used as a string.
*
* @param attribute LDAP attribute to be pulled from each result and placed in the return results.
* Typically pulled from this manager.
* @param searchFilter Filter to use to perform the search. Typically pulled from this manager.
* @param startIndex Number/index of first result to include in results. (-1 for no limit)
* @param numResults Number of results to include. (-1 for no limit)
* @param suffixToTrim An arbitrary string to trim from the end of every attribute returned. null to disable.
* @param escapeJIDs Use JID-escaping for returned results (e.g. usernames)
* @return A simple list of strings (that should be sorted) of the results.
*/
public List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim, boolean escapeJIDs) {
List<String> results = new ArrayList<String>(); List<String> results = new ArrayList<String>();
int pageSize = -1; int pageSize = -1;
String pageSizeStr = properties.get("ldap.pagedResultsSize"); String pageSizeStr = properties.get("ldap.pagedResultsSize");
...@@ -1923,7 +1946,7 @@ public class LdapManager { ...@@ -1923,7 +1946,7 @@ public class LdapManager {
result = result.substring(0,result.length()-suffixToTrim.length()); result = result.substring(0,result.length()-suffixToTrim.length());
} }
// Add this to the result. // Add this to the result.
results.add(JID.escapeNode(result)); results.add(escapeJIDs ? JID.escapeNode(result) : result);
} }
// Examine the paged results control response // Examine the paged results control response
Control[] controls = ctx.getResponseControls(); Control[] controls = ctx.getResponseControls();
...@@ -1980,7 +2003,7 @@ public class LdapManager { ...@@ -1980,7 +2003,7 @@ public class LdapManager {
result = result.substring(0,result.length()-suffixToTrim.length()); result = result.substring(0,result.length()-suffixToTrim.length());
} }
// Add this to the result. // Add this to the result.
results.add(JID.escapeNode(result)); results.add(escapeJIDs ? JID.escapeNode(result) : result);
} }
// Examine the paged results control response // Examine the paged results control response
Control[] controls = ctx2.getResponseControls(); Control[] controls = ctx2.getResponseControls();
......
...@@ -179,7 +179,8 @@ public class LdapUserProvider implements UserProvider { ...@@ -179,7 +179,8 @@ public class LdapUserProvider implements UserProvider {
MessageFormat.format(manager.getSearchFilter(), "*"), MessageFormat.format(manager.getSearchFilter(), "*"),
-1, -1,
-1, -1,
null null,
true
); );
} }
...@@ -193,7 +194,8 @@ public class LdapUserProvider implements UserProvider { ...@@ -193,7 +194,8 @@ public class LdapUserProvider implements UserProvider {
MessageFormat.format(manager.getSearchFilter(), "*"), MessageFormat.format(manager.getSearchFilter(), "*"),
startIndex, startIndex,
numResults, numResults,
manager.getUsernameSuffix() manager.getUsernameSuffix(),
true
); );
return new UserCollection(userlist.toArray(new String[userlist.size()])); return new UserCollection(userlist.toArray(new String[userlist.size()]));
} }
...@@ -280,7 +282,8 @@ public class LdapUserProvider implements UserProvider { ...@@ -280,7 +282,8 @@ public class LdapUserProvider implements UserProvider {
filter.toString(), filter.toString(),
startIndex, startIndex,
numResults, numResults,
manager.getUsernameSuffix() manager.getUsernameSuffix(),
true
); );
return new UserCollection(userlist.toArray(new String[userlist.size()])); return new UserCollection(userlist.toArray(new String[userlist.size()]));
} }
......
...@@ -28,6 +28,7 @@ import java.io.PrintWriter; ...@@ -28,6 +28,7 @@ import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* Openfire makes use of a logging facade (slf4j) to manage its log output. The * Openfire makes use of a logging facade (slf4j) to manage its log output. The
...@@ -46,17 +47,32 @@ import java.util.List; ...@@ -46,17 +47,32 @@ import java.util.List;
public class Log { public class Log {
private static final org.slf4j.Logger Logger = org.slf4j.LoggerFactory.getLogger(Log.class); private static final org.slf4j.Logger Logger = org.slf4j.LoggerFactory.getLogger(Log.class);
public static final String LOG_DEBUG_ENABLED = "log.debug.enabled";
// TODO deprecate these properties
// JiveGlobals.getXMLProperty("log.debug.format"); // listen for changes to the log.debug.enabled property
// JiveGlobals.getXMLProperty("log.info.format"); static {
// JiveGlobals.getXMLProperty("log.warn.format"); PropertyEventDispatcher.addListener(new PropertyEventListener() {
// JiveGlobals.getXMLProperty("log.error.format");
// JiveGlobals.getXMLProperty("log.debug.size"); public void propertySet(String property, Map<String, Object> params) {
// JiveGlobals.getXMLProperty("log.info.size"); enableDebugLog(property, Boolean.parseBoolean(params.get("value").toString()));
// JiveGlobals.getXMLProperty("log.warn.size"); }
// JiveGlobals.getXMLProperty("log.error.size");
// JiveGlobals.getXMLProperty("log.debug.enabled"); public void propertyDeleted(String property, Map<String, Object> params) {
enableDebugLog(property, false);
}
// ignore these events
public void xmlPropertySet(String property, Map<String, Object> params) { }
public void xmlPropertyDeleted(String property, Map<String, Object> params) { }
private void enableDebugLog(String property, boolean enabled) {
if ((LOG_DEBUG_ENABLED).equals(property)) {
Log.setDebugEnabled(enabled);
}
}
});
}
/** /**
* @deprecated replaced by {@link org.slf4j.Logger#isErrorEnabled()}. * @deprecated replaced by {@link org.slf4j.Logger#isErrorEnabled()}.
......
...@@ -152,6 +152,8 @@ public class CacheFactory { ...@@ -152,6 +152,8 @@ public class CacheFactory {
cacheProps.put("cache.lockOutCache.maxLifetime", JiveConstants.MINUTE * 15); cacheProps.put("cache.lockOutCache.maxLifetime", JiveConstants.MINUTE * 15);
cacheProps.put("cache.groupMeta.size", 512 * 1024l); cacheProps.put("cache.groupMeta.size", 512 * 1024l);
cacheProps.put("cache.groupMeta.maxLifetime", JiveConstants.MINUTE * 15); cacheProps.put("cache.groupMeta.maxLifetime", JiveConstants.MINUTE * 15);
cacheProps.put("cache.username2roster.size", 1024 * 1024l);
cacheProps.put("cache.username2roster.maxLifetime", JiveConstants.MINUTE * 30);
cacheProps.put("cache.javascript.size", 128 * 1024l); cacheProps.put("cache.javascript.size", 128 * 1024l);
cacheProps.put("cache.javascript.maxLifetime", 3600 * 24 * 10l); cacheProps.put("cache.javascript.maxLifetime", 3600 * 24 * 10l);
cacheProps.put("cache.ldap.size", 512 * 1024l); cacheProps.put("cache.ldap.size", 512 * 1024l);
......
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
Monitoring Plugin Changelog Monitoring Plugin Changelog
</h1> </h1>
<p><b>1.4.4</b> -- Oct 28, 2014</p>
<ul>
<li>Fixed request conversations and messages</li>
<li>Now conversations list is sorted</li>
</ul>
<p><b>1.4.3</b> -- Oct 27, 2014</p> <p><b>1.4.3</b> -- Oct 27, 2014</p>
<ul> <ul>
<li>OF-812 properly handle the start attribute in list requests</li> <li>OF-812 properly handle the start attribute in list requests</li>
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<name>Monitoring Service</name> <name>Monitoring Service</name>
<description>Monitors conversations and statistics of the server.</description> <description>Monitors conversations and statistics of the server.</description>
<author>Jive Software</author> <author>Jive Software</author>
<version>1.4.3</version> <version>1.4.4</version>
<date>10/27/2014</date> <date>10/28/2014</date>
<minServerVersion>3.9.0</minServerVersion> <minServerVersion>3.9.0</minServerVersion>
<databaseKey>monitoring</databaseKey> <databaseKey>monitoring</databaseKey>
<databaseVersion>2</databaseVersion> <databaseVersion>2</databaseVersion>
......
...@@ -9,7 +9,7 @@ import java.util.ArrayList; ...@@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.TreeMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -51,11 +51,13 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -51,11 +51,13 @@ public class JdbcPersistenceManager implements PersistenceManager {
+ "ofConversation.isExternal, " + "ofConversation.startDate, " + "ofConversation.lastActivity, " + "ofConversation.messageCount, " + "ofConversation.isExternal, " + "ofConversation.startDate, " + "ofConversation.lastActivity, " + "ofConversation.messageCount, "
+ "ofConParticipant.joinedDate, " + "ofConParticipant.leftDate, " + "ofConParticipant.bareJID, " + "ofConParticipant.jidResource, " + "ofConParticipant.joinedDate, " + "ofConParticipant.leftDate, " + "ofConParticipant.bareJID, " + "ofConParticipant.jidResource, "
+ "ofConParticipant.nickname, " + "ofConParticipant.nickname, "
+ "case when ofConParticipant.bareJID=ofMessageArchive.fromJID then ofMessageArchive.fromJID else ofMessageArchive.toJID end as fromJID, " + "ofConParticipant.bareJID as fromJID, "
+ "case when ofConParticipant.bareJID=ofMessageArchive.toJID then ofMessageArchive.fromJID else ofMessageArchive.toJID end as toJID " + "ofMessageArchive.toJID "
+ "FROM ofConversation " + "FROM ofConversation "
+ "INNER JOIN ofConParticipant ON ofConversation.conversationID = ofConParticipant.conversationID " + "INNER JOIN ofConParticipant ON ofConversation.conversationID = ofConParticipant.conversationID "
+ "INNER JOIN ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID"; + "INNER JOIN (SELECT conversationID, toJID FROM ofMessageArchive "
+ "union all "
+ "SELECT conversationID, fromJID as toJID FROM ofMessageArchive) ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID";
// public static final String SELECT_CONVERSATIONS = // public static final String SELECT_CONVERSATIONS =
// "SELECT c.conversationId,c.startTime,c.endTime,c.ownerJid,c.ownerResource,c.withJid,c.withResource," // "SELECT c.conversationId,c.startTime,c.endTime,c.ownerJid,c.ownerResource,c.withJid,c.withResource,"
...@@ -63,7 +65,9 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -63,7 +65,9 @@ public class JdbcPersistenceManager implements PersistenceManager {
public static final String COUNT_CONVERSATIONS = "SELECT COUNT(DISTINCT ofConversation.conversationID) FROM ofConversation " public static final String COUNT_CONVERSATIONS = "SELECT COUNT(DISTINCT ofConversation.conversationID) FROM ofConversation "
+ "INNER JOIN ofConParticipant ON ofConversation.conversationID = ofConParticipant.conversationID " + "INNER JOIN ofConParticipant ON ofConversation.conversationID = ofConParticipant.conversationID "
+ "INNER JOIN ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID"; + "INNER JOIN (SELECT conversationID, toJID FROM ofMessageArchive "
+ "union all "
+ "SELECT conversationID, fromJID as toJID FROM ofMessageArchive) ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID";
// public static final String COUNT_CONVERSATIONS = // public static final String COUNT_CONVERSATIONS =
// "SELECT count(*) FROM archiveConversations AS c"; // "SELECT count(*) FROM archiveConversations AS c";
...@@ -80,7 +84,7 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -80,7 +84,7 @@ public class JdbcPersistenceManager implements PersistenceManager {
public static final String CONVERSATION_OWNER_JID = "ofConParticipant.bareJID"; public static final String CONVERSATION_OWNER_JID = "ofConParticipant.bareJID";
// public static final String CONVERSATION_OWNER_JID = "c.ownerJid"; // public static final String CONVERSATION_OWNER_JID = "c.ownerJid";
public static final String CONVERSATION_WITH_JID = "(ofMessageArchive.toJID = ? OR ofMessageArchive.fromJID = ?)"; public static final String CONVERSATION_WITH_JID = "ofMessageArchive.toJID";
// public static final String CONVERSATION_WITH_JID = "c.withJid"; // public static final String CONVERSATION_WITH_JID = "c.withJid";
public static final String SELECT_ACTIVE_CONVERSATIONS = "SELECT DISTINCT " + "ofConversation.conversationID, " + "ofConversation.room, " public static final String SELECT_ACTIVE_CONVERSATIONS = "SELECT DISTINCT " + "ofConversation.conversationID, " + "ofConversation.room, "
...@@ -153,12 +157,12 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -153,12 +157,12 @@ public class JdbcPersistenceManager implements PersistenceManager {
} }
public Collection<Conversation> findConversations(Date startDate, Date endDate, String ownerJid, String withJid, XmppResultSet xmppResultSet) { public Collection<Conversation> findConversations(Date startDate, Date endDate, String ownerJid, String withJid, XmppResultSet xmppResultSet) {
final HashMap<Long, Conversation> conversations; final TreeMap<Long, Conversation> conversations;
final StringBuilder querySB; final StringBuilder querySB;
final StringBuilder whereSB; final StringBuilder whereSB;
final StringBuilder limitSB; final StringBuilder limitSB;
conversations = new HashMap<Long, Conversation>(); conversations = new TreeMap<Long, Conversation>();
querySB = new StringBuilder(SELECT_CONVERSATIONS); querySB = new StringBuilder(SELECT_CONVERSATIONS);
whereSB = new StringBuilder(); whereSB = new StringBuilder();
...@@ -175,7 +179,7 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -175,7 +179,7 @@ public class JdbcPersistenceManager implements PersistenceManager {
appendWhere(whereSB, CONVERSATION_OWNER_JID, " = ?"); appendWhere(whereSB, CONVERSATION_OWNER_JID, " = ?");
} }
if (withJid != null) { if (withJid != null) {
appendWhere(whereSB, CONVERSATION_WITH_JID); appendWhere(whereSB, CONVERSATION_WITH_JID, " = ?");
} }
if (xmppResultSet != null) { if (xmppResultSet != null) {
...@@ -240,10 +244,8 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -240,10 +244,8 @@ public class JdbcPersistenceManager implements PersistenceManager {
} }
if (xmppResultSet != null && conversations.size() > 0) { if (xmppResultSet != null && conversations.size() > 0) {
ArrayList<Long> sortedConvKeys = new ArrayList<Long>(conversations.keySet()); xmppResultSet.setFirst(conversations.firstKey());
Collections.sort(sortedConvKeys); xmppResultSet.setLast(conversations.lastKey());
xmppResultSet.setFirst(sortedConvKeys.get(0));
xmppResultSet.setLast(sortedConvKeys.get(sortedConvKeys.size() - 1));
} }
return conversations.values(); return conversations.values();
} }
...@@ -336,7 +338,6 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -336,7 +338,6 @@ public class JdbcPersistenceManager implements PersistenceManager {
} }
if (withJid != null) { if (withJid != null) {
pstmt.setString(parameterIndex++, withJid); pstmt.setString(parameterIndex++, withJid);
pstmt.setString(parameterIndex++, withJid);
} }
return parameterIndex; return parameterIndex;
} }
...@@ -439,7 +440,7 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -439,7 +440,7 @@ public class JdbcPersistenceManager implements PersistenceManager {
querySB.append(CONVERSATION_OWNER_JID).append(" = ?"); querySB.append(CONVERSATION_OWNER_JID).append(" = ?");
if (withJid != null) { if (withJid != null) {
querySB.append(" AND "); querySB.append(" AND ");
querySB.append(CONVERSATION_WITH_JID); querySB.append(CONVERSATION_WITH_JID).append(" = ? ");
} }
if (start != null) { if (start != null) {
querySB.append(" AND "); querySB.append(" AND ");
...@@ -458,7 +459,6 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -458,7 +459,6 @@ public class JdbcPersistenceManager implements PersistenceManager {
pstmt.setString(i++, ownerJid); pstmt.setString(i++, ownerJid);
if (withJid != null) { if (withJid != null) {
pstmt.setString(i++, withJid); pstmt.setString(i++, withJid);
pstmt.setString(i++, withJid);
} }
if (start != null) { if (start != null) {
pstmt.setLong(i++, dateToMillis(start)); pstmt.setLong(i++, dateToMillis(start));
......
...@@ -129,11 +129,10 @@ ...@@ -129,11 +129,10 @@
boolean saveLog = ParamUtils.getBooleanParameter(request,"saveLog"); boolean saveLog = ParamUtils.getBooleanParameter(request,"saveLog");
boolean emailLog = ParamUtils.getBooleanParameter(request,"emailLog"); boolean emailLog = ParamUtils.getBooleanParameter(request,"emailLog");
boolean debugEnabled = ParamUtils.getBooleanParameter(request,"debugEnabled"); boolean debugEnabled = ParamUtils.getBooleanParameter(request,"debugEnabled");
boolean wasDebugEnabled = ParamUtils.getBooleanParameter(request,"wasDebugEnabled");
// Enable/disable debugging // Enable/disable debugging
if (request.getParameter("wasDebugEnabled") != null && wasDebugEnabled != debugEnabled) { if (request.getParameter("debugEnabled") != null && debugEnabled != Log.isDebugEnabled()) {
Log.setDebugEnabled(debugEnabled); JiveGlobals.setProperty(Log.LOG_DEBUG_ENABLED, String.valueOf(debugEnabled));
// Log the event // Log the event
admin.logEvent((debugEnabled ? "enabled" : "disabled")+" debug logging", null); admin.logEvent((debugEnabled ? "enabled" : "disabled")+" debug logging", null);
response.sendRedirect("logviewer.jsp?log=debug"); response.sendRedirect("logviewer.jsp?log=debug");
...@@ -409,19 +408,18 @@ IFRAME { ...@@ -409,19 +408,18 @@ IFRAME {
<fmt:message key="logviewer.debug_log" />: &nbsp; <fmt:message key="logviewer.debug_log" />: &nbsp;
</td> </td>
<td width="1%"> <td width="1%">
<input type="radio" name="debugEnabled" value="true"<%= ((debugEnabled) ? " checked" : "") %> id="de01"> <input id="de01" type="radio" name="debugEnabled" value="true" <%= debugEnabled ? " checked" : "" %>>
</td> </td>
<td width="1%" nowrap> <td width="1%" nowrap>
<label for="de01"><fmt:message key="logviewer.enabled" /></label> &nbsp; <label for="de01"><fmt:message key="logviewer.enabled" /></label> &nbsp;
</td> </td>
<td width="1%"> <td width="1%">
<input type="radio" name="debugEnabled" value="false"<%= ((!debugEnabled) ? " checked" : "") %> id="de02"> <input id="de02" type="radio" name="debugEnabled" value="false" <%= debugEnabled ? "" : " checked" %>>
</td> </td>
<td width="1%" nowrap> <td width="1%" nowrap>
<label for="de02">Disabled</label> &nbsp; <label for="de02">Disabled</label> &nbsp;
</td> </td>
<td width="1%"> <td width="1%">
<input type="hidden" name="wasDebugEnabled" value="<%= debugEnabled %>">
<input type="submit" name="" value="<fmt:message key="global.save_changes" />"> <input type="submit" name="" value="<fmt:message key="global.save_changes" />">
</td> </td>
<td width="94%">&nbsp;</td> <td width="94%">&nbsp;</td>
......
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