Commit 8028f7db authored by Guus der Kinderen's avatar Guus der Kinderen

OF-1486: Monitoring plugin - MUC MAM should allow for backwards-paging RSM.

parent 5ff3a19e
......@@ -43,6 +43,12 @@
<h1>
Monitoring Plugin Changelog
</h1>
<p><b>1.6.0</b> -- Feb 16, 2018</p>
<ul>
<li>[<a href='https://issues.igniterealtime.org/browse/OF-1486'>OF-1486</a>] - MAM RSM queries for MUC should allow for 'backwards-paging'.</li>
</ul>
<p><b>1.5.9</b> -- Feb 13, 2018</p>
<ul>
<li>[<a href='https://issues.igniterealtime.org/browse/OF-1482'>OF-1482</a>] - MAM query response for MUC should have a 'from'.</li>
......
......@@ -5,8 +5,8 @@
<name>Monitoring Service</name>
<description>Monitors conversations and statistics of the server.</description>
<author>IgniteRealtime // Jive Software</author>
<version>1.5.9</version>
<date>2/13/2018</date>
<version>1.6.0</version>
<date>2/16/2018</date>
<minServerVersion>4.1.0</minServerVersion>
<databaseKey>monitoring</databaseKey>
<databaseVersion>4</databaseVersion>
......
......@@ -8,7 +8,7 @@
</parent>
<groupId>org.igniterealtime.openfire.plugins</groupId>
<artifactId>monitoring</artifactId>
<version>1.5.9</version>
<version>1.6.0</version>
<name>Monitoring Plugin</name>
<description>Monitors conversations and statistics of the server.</description>
......
......@@ -6,39 +6,28 @@ import com.reucon.openfire.plugin.archive.model.ArchivedMessage;
import com.reucon.openfire.plugin.archive.model.Conversation;
import com.reucon.openfire.plugin.archive.model.Participant;
import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet;
import org.dom4j.Attribute;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.io.SAXReader;
import org.eclipse.jdt.internal.compiler.apt.util.Archive;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.muc.MUCRoom;
import org.jivesoftware.openfire.muc.MultiUserChatManager;
import org.jivesoftware.openfire.muc.MultiUserChatService;
import org.jivesoftware.openfire.muc.NotAllowedException;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.util.XMPPDateTimeFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import java.io.StringReader;
import java.math.BigInteger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
/**
* Created by dwd on 25/07/16.
*/
public class MucMamPersistenceManager implements PersistenceManager {
private final static Logger Log = LoggerFactory.getLogger( MucMamPersistenceManager.class );
private static final String LOAD_HISTORY =
"SELECT sender, nickname, logTime, subject, body, stanza, messageId FROM ofMucConversationLog " +
"WHERE messageId IS NOT NULL AND logTime>? AND logTime <= ? AND roomID=? AND (nickname IS NOT NULL OR subject IS NOT NULL) ";
......@@ -83,6 +72,7 @@ public class MucMamPersistenceManager implements PersistenceManager {
@Override
public Collection<ArchivedMessage> findMessages(Date startDate, Date endDate, String owner, String with, XmppResultSet xmppResultSet) {
Log.debug( "Finding messages of owner '{}' with start date '{}', end date '{}' with '{}' and resultset '{}'.", new Object[] { owner, startDate, endDate, with, xmppResultSet } );
JID mucRoom = new JID(owner);
MultiUserChatManager manager = XMPPServer.getInstance().getMultiUserChatManager();
MultiUserChatService service = manager.getMultiUserChatService(mucRoom);
......@@ -166,12 +156,19 @@ public class MucMamPersistenceManager implements PersistenceManager {
}
// TODO - Not great, really should be done by suitable LIMIT stuff.
// Would need to reverse ordering in some cases and then reverse results.
boolean pagingBackwards = xmppResultSet.getBefore() != null && xmppResultSet.getAfter() == null;
if ( pagingBackwards ) {
Collections.reverse(msgs);
}
boolean complete = true;
xmppResultSet.setCount(msgs.size());
while (msgs.size() > max) {
msgs.remove(msgs.size() - 1);
complete = false;
}
if ( pagingBackwards ) {
Collections.reverse(msgs);
}
xmppResultSet.setComplete(complete);
if (msgs.size() > 0) {
xmppResultSet.setFirst(msgs.get(0).getId());
......
......@@ -212,4 +212,20 @@ public class XmppResultSet
return set;
}
@Override
public String toString()
{
return "XmppResultSet{" +
"after=" + after +
", before=" + before +
", index=" + index +
", max=" + max +
", first=" + first +
", firstIndex=" + firstIndex +
", last=" + last +
", count=" + count +
", complete=" + complete +
'}';
}
}
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