Commit ac304ea9 authored by Tom Evans's avatar Tom Evans

Merge pull request #92 from akrherz/of832

OF-832 Monitoring plugin fixes
parents f690dc69 23c4d8e4
......@@ -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));
......
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