Commit b41dc3f6 authored by Dele Olajide's avatar Dele Olajide
parents 7fbc49b8 ac304ea9
......@@ -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