Commit 9d8fec8f authored by Daryl Herzmann's avatar Daryl Herzmann Committed by akrherz

OF-755 Monitoring plugin database fixes, especially sqlserver

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13986 b35dd754-fafc-0310-a699-88a17e54d16e
parent 171c364d
......@@ -43,6 +43,14 @@
<h1>
Monitoring Plugin Changelog
</h1>
<p><b>1.4.1</b> -- Feb 26, 2014</p>
<ul>
<li>Plugin was not working with MS SQL Server (Now work with MS SQL Server 2005+).</li>
<li>Fixed request conversations and messages in reverse order.</li>
<li>Fixed request conversations and messages in reverse order.</li>
<li>Plugin does not return the correct number of conversations at the request history.</li>
</ul>
<p><b>1.4.0</b> -- Sep 13, 2013</p>
<ul>
<li>Requires Openfire 3.9.0.</li>
......
......@@ -5,11 +5,11 @@
<name>Monitoring Service</name>
<description>Monitors conversations and statistics of the server.</description>
<author>Jive Software</author>
<version>1.4.0</version>
<date>09/13/2013</date>
<version>1.4.1</version>
<date>02/26/2014</date>
<minServerVersion>3.9.0</minServerVersion>
<databaseKey>monitoring</databaseKey>
<databaseVersion>1</databaseVersion>
<databaseVersion>2</databaseVersion>
<adminconsole>
<tab id="tab-server">
......
-- $Revision$
-- $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation (
conversationID INTEGER NOT NULL,
......
// $Revision$
// $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation (
conversationID BIGINT NOT NULL,
......
# $Revision$
# $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation (
conversationID BIGINT NOT NULL,
......
-- $Revision$
-- $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation (
conversationID INTEGER NOT NULL,
......
-- $Revision$
-- $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation (
conversationID INTEGER NOT NULL,
......
/* $Revision$ */
/* $Date$ */
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation (
conversationID BIGINT NOT NULL,
......@@ -34,7 +34,7 @@ CREATE TABLE ofMessageArchive (
toJID NVARCHAR(1024) NOT NULL,
toJIDResource NVARCHAR(1024) NULL,
sentDate BIGINT NOT NULL,
body NTEXT
body NVARCHAR(MAX)
);
CREATE INDEX ofMessageArchive_con_idx ON ofMessageArchive (conversationID);
......
......@@ -50,8 +50,10 @@ public class JdbcPersistenceManager implements PersistenceManager {
public static final String SELECT_CONVERSATIONS = "SELECT DISTINCT " + "ofConversation.conversationID, " + "ofConversation.room, "
+ "ofConversation.isExternal, " + "ofConversation.startDate, " + "ofConversation.lastActivity, " + "ofConversation.messageCount, "
+ "ofConParticipant.joinedDate, " + "ofConParticipant.leftDate, " + "ofConParticipant.bareJID, " + "ofConParticipant.jidResource, "
+ "ofConParticipant.nickname, " + "ofMessageArchive.fromJID, " + "ofMessageArchive.toJID, " + "ofMessageArchive.sentDate, "
+ "ofMessageArchive.body " + "FROM ofConversation "
+ "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 "
+ "FROM ofConversation "
+ "INNER JOIN ofConParticipant ON ofConversation.conversationID = ofConParticipant.conversationID "
+ "INNER JOIN ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID";
......@@ -193,15 +195,27 @@ public class JdbcPersistenceManager implements PersistenceManager {
}
firstIndex = firstIndex != null ? firstIndex : 0;
limitSB.append(" LIMIT ").append(max);
limitSB.append(" OFFSET ").append(firstIndex);
if (DbConnectionManager.getDatabaseType() == DbConnectionManager.DatabaseType.sqlserver) {
limitSB.append(" BETWEEN ").append(firstIndex+1);
limitSB.append(" AND ").append(firstIndex+max);
}
else {
limitSB.append(" LIMIT ").append(max);
limitSB.append(" OFFSET ").append(firstIndex);
}
xmppResultSet.setFirstIndex(firstIndex);
}
if (whereSB.length() != 0) {
querySB.append(" WHERE ").append(whereSB);
}
querySB.append(" ORDER BY ").append(CONVERSATION_ID);
if (DbConnectionManager.getDatabaseType() == DbConnectionManager.DatabaseType.sqlserver) {
querySB.insert(0,"SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY "+CONVERSATION_ID+") AS RowNum FROM ( ");
querySB.append(") ofConversation ) t2 WHERE RowNum");
}
else {
querySB.append(" ORDER BY ").append(CONVERSATION_ID);
}
querySB.append(limitSB);
Connection con = null;
......
......@@ -45,6 +45,12 @@ public class XmppResultSet
before = null;
}
}
catch (NumberFormatException e)
{
if (setElement.elementText("before").isEmpty()) {
this.before = Long.valueOf(9223372036854775807L);
}
}
catch (Exception e)
{
// swallow
......
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