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 @@ ...@@ -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));
......
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