Commit b41dc3f6 authored by Dele Olajide's avatar Dele Olajide
parents 7fbc49b8 ac304ea9
......@@ -63,7 +63,25 @@ import org.jivesoftware.openfire.disco.UserItemsProvider;
import org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager;
import org.jivesoftware.openfire.filetransfer.FileTransferManager;
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.mediaproxy.MediaProxyService;
import org.jivesoftware.openfire.muc.MultiUserChatManager;
......@@ -90,6 +108,7 @@ import org.jivesoftware.util.CertificateManager;
import org.jivesoftware.util.InitializationException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.TaskEngine;
import org.jivesoftware.util.Version;
import org.jivesoftware.util.cache.CacheFactory;
......@@ -128,7 +147,7 @@ import org.xmpp.packet.JID;
*/
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;
......@@ -337,7 +356,7 @@ public class XMPPServer {
host = InetAddress.getLocalHost().getHostName();
}
catch (UnknownHostException ex) {
Log.warn("Unable to determine local hostname.", ex);
logger.warn("Unable to determine local hostname.", ex);
}
if (host == null) {
host = "127.0.0.1";
......@@ -349,7 +368,7 @@ public class XMPPServer {
}
if (isStandAlone()) {
Log.info("Registering shutdown hook (standalone mode)");
logger.info("Registering shutdown hook (standalone mode)");
Runtime.getRuntime().addShutdownHook(new ShutdownHookThread());
TaskEngine.getInstance().schedule(new Terminator(), 1000, 1000);
}
......@@ -360,18 +379,18 @@ public class XMPPServer {
CacheFactory.initialize();
} catch (InitializationException e) {
e.printStackTrace();
Log.error(e.getMessage(), e);
logger.error(e.getMessage(), e);
}
JiveGlobals.migrateProperty("xmpp.domain");
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
xmppServerInfo = new XMPPServerInfoImpl(name, host, version, startDate);
initialized = true;
}
......@@ -420,7 +439,7 @@ public class XMPPServer {
}
} 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)
......@@ -454,7 +473,7 @@ public class XMPPServer {
}
catch (Exception e) {
e.printStackTrace();
Log.error(e.getMessage(), e);
logger.error(e.getMessage(), e);
shutdownServer();
}
}
......@@ -495,7 +514,7 @@ public class XMPPServer {
// Log that the server has been started
String startupBanner = LocaleUtils.getLocalizedString("short.title") + " " + version.getVersionString() +
" [" + JiveGlobals.formatDateTime(new Date()) + "]";
Log.info(startupBanner);
logger.info(startupBanner);
System.out.println(startupBanner);
started = true;
......@@ -507,7 +526,7 @@ public class XMPPServer {
}
catch (Exception e) {
e.printStackTrace();
Log.error(e.getMessage(), e);
logger.error(e.getMessage(), e);
System.out.println(LocaleUtils.getLocalizedString("startup.error"));
shutdownServer();
}
......@@ -588,7 +607,7 @@ public class XMPPServer {
}
catch (Exception e) {
e.printStackTrace();
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
logger.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
}
......@@ -607,7 +626,7 @@ public class XMPPServer {
module.stop();
module.destroy();
}
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
logger.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
}
}
......@@ -628,7 +647,7 @@ public class XMPPServer {
module.stop();
module.destroy();
}
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
logger.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
}
}
......@@ -645,7 +664,7 @@ public class XMPPServer {
restartMethod.invoke(null, (Object []) null);
}
catch (Exception e) {
Log.error("Could not restart container", e);
logger.error("Could not restart container", e);
}
}
}
......@@ -685,7 +704,7 @@ public class XMPPServer {
* inside of another server.
*/
public void stop() {
Log.info("Initiating shutdown ...");
logger.info("Initiating shutdown ...");
// Only do a system exit if we're running standalone
if (isStandAlone()) {
// if we're in a wrapper, we have to tell the wrapper to shut us down
......@@ -696,7 +715,7 @@ public class XMPPServer {
stopMethod.invoke(null, 0);
}
catch (Exception e) {
Log.error("Could not stop container", e);
logger.error("Could not stop container", e);
}
}
else {
......@@ -763,7 +782,7 @@ public class XMPPServer {
System.err.println("Database setup or configuration error: " +
"Please verify your database settings and check the " +
"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);
}
finally {
......@@ -900,7 +919,7 @@ public class XMPPServer {
}
}
} catch (IOException ioe) {
Log.error("Error reading console input", ioe);
logger.error("Error reading console input", ioe);
}
}
}
......@@ -920,7 +939,7 @@ public class XMPPServer {
@Override
public void run() {
shutdownServer();
Log.info("Server halted");
logger.info("Server halted");
System.err.println("Server halted");
}
}
......@@ -962,30 +981,30 @@ public class XMPPServer {
try {
listener.serverStopping();
} 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 (modules.isEmpty()) {
return;
}
Log.info("Shutting down " + modules.size() + " modules ...");
logger.info("Shutting down " + modules.size() + " modules ...");
// Get all modules and stop and destroy them
for (Module module : modules.values()) {
try {
module.stop();
module.destroy();
} catch (Exception ex) {
Log.error("Exception during module shutdown", ex);
logger.error("Exception during module shutdown", ex);
}
}
// Stop all plugins
Log.info("Shutting down plugins ...");
logger.info("Shutting down plugins ...");
if (pluginManager != null) {
try {
pluginManager.shutdown();
} catch (Exception ex) {
Log.error("Exception during plugin shutdown", ex);
logger.error("Exception during plugin shutdown", ex);
}
}
modules.clear();
......@@ -993,14 +1012,14 @@ public class XMPPServer {
try {
DbConnectionManager.destroyConnectionProvider();
} catch (Exception ex) {
Log.error("Exception during DB shutdown", ex);
logger.error("Exception during DB shutdown", ex);
}
// Shutdown the task engine.
TaskEngine.getInstance().shutdown();
// hack to allow safe stopping
Log.info("Openfire stopped");
logger.info("Openfire stopped");
}
/**
......
......@@ -972,6 +972,7 @@ public class LdapManager {
}
constraints.setReturningAttributes(new String[] { usernameField });
// NOTE: this assumes that the username has already been JID-unescaped
NamingEnumeration<SearchResult> answer = ctx.search("", getSearchFilter(),
new String[] {sanitizeSearchFilter(username)},
constraints);
......@@ -1117,7 +1118,7 @@ public class LdapManager {
}
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);
if (debug) {
......@@ -1841,6 +1842,28 @@ public class LdapManager {
* @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) {
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>();
int pageSize = -1;
String pageSizeStr = properties.get("ldap.pagedResultsSize");
......@@ -1923,7 +1946,7 @@ public class LdapManager {
result = result.substring(0,result.length()-suffixToTrim.length());
}
// Add this to the result.
results.add(JID.escapeNode(result));
results.add(escapeJIDs ? JID.escapeNode(result) : result);
}
// Examine the paged results control response
Control[] controls = ctx.getResponseControls();
......@@ -1980,7 +2003,7 @@ public class LdapManager {
result = result.substring(0,result.length()-suffixToTrim.length());
}
// Add this to the result.
results.add(JID.escapeNode(result));
results.add(escapeJIDs ? JID.escapeNode(result) : result);
}
// Examine the paged results control response
Control[] controls = ctx2.getResponseControls();
......
......@@ -179,7 +179,8 @@ public class LdapUserProvider implements UserProvider {
MessageFormat.format(manager.getSearchFilter(), "*"),
-1,
-1,
null
null,
true
);
}
......@@ -193,7 +194,8 @@ public class LdapUserProvider implements UserProvider {
MessageFormat.format(manager.getSearchFilter(), "*"),
startIndex,
numResults,
manager.getUsernameSuffix()
manager.getUsernameSuffix(),
true
);
return new UserCollection(userlist.toArray(new String[userlist.size()]));
}
......@@ -280,7 +282,8 @@ public class LdapUserProvider implements UserProvider {
filter.toString(),
startIndex,
numResults,
manager.getUsernameSuffix()
manager.getUsernameSuffix(),
true
);
return new UserCollection(userlist.toArray(new String[userlist.size()]));
}
......
......@@ -28,6 +28,7 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Openfire makes use of a logging facade (slf4j) to manage its log output. The
......@@ -46,17 +47,32 @@ import java.util.List;
public class Log {
private static final org.slf4j.Logger Logger = org.slf4j.LoggerFactory.getLogger(Log.class);
// TODO deprecate these properties
// JiveGlobals.getXMLProperty("log.debug.format");
// JiveGlobals.getXMLProperty("log.info.format");
// JiveGlobals.getXMLProperty("log.warn.format");
// JiveGlobals.getXMLProperty("log.error.format");
// JiveGlobals.getXMLProperty("log.debug.size");
// JiveGlobals.getXMLProperty("log.info.size");
// JiveGlobals.getXMLProperty("log.warn.size");
// JiveGlobals.getXMLProperty("log.error.size");
// JiveGlobals.getXMLProperty("log.debug.enabled");
public static final String LOG_DEBUG_ENABLED = "log.debug.enabled";
// listen for changes to the log.debug.enabled property
static {
PropertyEventDispatcher.addListener(new PropertyEventListener() {
public void propertySet(String property, Map<String, Object> params) {
enableDebugLog(property, Boolean.parseBoolean(params.get("value").toString()));
}
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()}.
......
......@@ -152,6 +152,8 @@ public class CacheFactory {
cacheProps.put("cache.lockOutCache.maxLifetime", JiveConstants.MINUTE * 15);
cacheProps.put("cache.groupMeta.size", 512 * 1024l);
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.maxLifetime", 3600 * 24 * 10l);
cacheProps.put("cache.ldap.size", 512 * 1024l);
......
......@@ -44,6 +44,12 @@
Monitoring Plugin Changelog
</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>
<ul>
<li>OF-812 properly handle the start attribute in list requests</li>
......
......@@ -5,8 +5,8 @@
<name>Monitoring Service</name>
<description>Monitors conversations and statistics of the server.</description>
<author>Jive Software</author>
<version>1.4.3</version>
<date>10/27/2014</date>
<version>1.4.4</version>
<date>10/28/2014</date>
<minServerVersion>3.9.0</minServerVersion>
<databaseKey>monitoring</databaseKey>
<databaseVersion>2</databaseVersion>
......
......@@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.HashSet;
import java.util.List;
......@@ -51,11 +51,13 @@ public class JdbcPersistenceManager implements PersistenceManager {
+ "ofConversation.isExternal, " + "ofConversation.startDate, " + "ofConversation.lastActivity, " + "ofConversation.messageCount, "
+ "ofConParticipant.joinedDate, " + "ofConParticipant.leftDate, " + "ofConParticipant.bareJID, " + "ofConParticipant.jidResource, "
+ "ofConParticipant.nickname, "
+ "case when ofConParticipant.bareJID=ofMessageArchive.fromJID then ofMessageArchive.fromJID else ofMessageArchive.toJID end as fromJID, "
+ "case when ofConParticipant.bareJID=ofMessageArchive.toJID then ofMessageArchive.fromJID else ofMessageArchive.toJID end as toJID "
+ "ofConParticipant.bareJID as fromJID, "
+ "ofMessageArchive.toJID "
+ "FROM ofConversation "
+ "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 =
// "SELECT c.conversationId,c.startTime,c.endTime,c.ownerJid,c.ownerResource,c.withJid,c.withResource,"
......@@ -63,7 +65,9 @@ public class JdbcPersistenceManager implements PersistenceManager {
public static final String COUNT_CONVERSATIONS = "SELECT COUNT(DISTINCT ofConversation.conversationID) FROM ofConversation "
+ "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 =
// "SELECT count(*) FROM archiveConversations AS c";
......@@ -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 = "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 SELECT_ACTIVE_CONVERSATIONS = "SELECT DISTINCT " + "ofConversation.conversationID, " + "ofConversation.room, "
......@@ -153,12 +157,12 @@ public class JdbcPersistenceManager implements PersistenceManager {
}
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 whereSB;
final StringBuilder limitSB;
conversations = new HashMap<Long, Conversation>();
conversations = new TreeMap<Long, Conversation>();
querySB = new StringBuilder(SELECT_CONVERSATIONS);
whereSB = new StringBuilder();
......@@ -175,7 +179,7 @@ public class JdbcPersistenceManager implements PersistenceManager {
appendWhere(whereSB, CONVERSATION_OWNER_JID, " = ?");
}
if (withJid != null) {
appendWhere(whereSB, CONVERSATION_WITH_JID);
appendWhere(whereSB, CONVERSATION_WITH_JID, " = ?");
}
if (xmppResultSet != null) {
......@@ -240,10 +244,8 @@ public class JdbcPersistenceManager implements PersistenceManager {
}
if (xmppResultSet != null && conversations.size() > 0) {
ArrayList<Long> sortedConvKeys = new ArrayList<Long>(conversations.keySet());
Collections.sort(sortedConvKeys);
xmppResultSet.setFirst(sortedConvKeys.get(0));
xmppResultSet.setLast(sortedConvKeys.get(sortedConvKeys.size() - 1));
xmppResultSet.setFirst(conversations.firstKey());
xmppResultSet.setLast(conversations.lastKey());
}
return conversations.values();
}
......@@ -336,7 +338,6 @@ public class JdbcPersistenceManager implements PersistenceManager {
}
if (withJid != null) {
pstmt.setString(parameterIndex++, withJid);
pstmt.setString(parameterIndex++, withJid);
}
return parameterIndex;
}
......@@ -439,7 +440,7 @@ public class JdbcPersistenceManager implements PersistenceManager {
querySB.append(CONVERSATION_OWNER_JID).append(" = ?");
if (withJid != null) {
querySB.append(" AND ");
querySB.append(CONVERSATION_WITH_JID);
querySB.append(CONVERSATION_WITH_JID).append(" = ? ");
}
if (start != null) {
querySB.append(" AND ");
......@@ -458,7 +459,6 @@ public class JdbcPersistenceManager implements PersistenceManager {
pstmt.setString(i++, ownerJid);
if (withJid != null) {
pstmt.setString(i++, withJid);
pstmt.setString(i++, withJid);
}
if (start != null) {
pstmt.setLong(i++, dateToMillis(start));
......
......@@ -129,11 +129,10 @@
boolean saveLog = ParamUtils.getBooleanParameter(request,"saveLog");
boolean emailLog = ParamUtils.getBooleanParameter(request,"emailLog");
boolean debugEnabled = ParamUtils.getBooleanParameter(request,"debugEnabled");
boolean wasDebugEnabled = ParamUtils.getBooleanParameter(request,"wasDebugEnabled");
// Enable/disable debugging
if (request.getParameter("wasDebugEnabled") != null && wasDebugEnabled != debugEnabled) {
Log.setDebugEnabled(debugEnabled);
if (request.getParameter("debugEnabled") != null && debugEnabled != Log.isDebugEnabled()) {
JiveGlobals.setProperty(Log.LOG_DEBUG_ENABLED, String.valueOf(debugEnabled));
// Log the event
admin.logEvent((debugEnabled ? "enabled" : "disabled")+" debug logging", null);
response.sendRedirect("logviewer.jsp?log=debug");
......@@ -409,19 +408,18 @@ IFRAME {
<fmt:message key="logviewer.debug_log" />: &nbsp;
</td>
<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 width="1%" nowrap>
<label for="de01"><fmt:message key="logviewer.enabled" /></label> &nbsp;
</td>
<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 width="1%" nowrap>
<label for="de02">Disabled</label> &nbsp;
</td>
<td width="1%">
<input type="hidden" name="wasDebugEnabled" value="<%= debugEnabled %>">
<input type="submit" name="" value="<fmt:message key="global.save_changes" />">
</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