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 @@ ...@@ -43,6 +43,14 @@
<h1> <h1>
Monitoring Plugin Changelog Monitoring Plugin Changelog
</h1> </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> <p><b>1.4.0</b> -- Sep 13, 2013</p>
<ul> <ul>
<li>Requires Openfire 3.9.0.</li> <li>Requires Openfire 3.9.0.</li>
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
<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.0</version> <version>1.4.1</version>
<date>09/13/2013</date> <date>02/26/2014</date>
<minServerVersion>3.9.0</minServerVersion> <minServerVersion>3.9.0</minServerVersion>
<databaseKey>monitoring</databaseKey> <databaseKey>monitoring</databaseKey>
<databaseVersion>1</databaseVersion> <databaseVersion>2</databaseVersion>
<adminconsole> <adminconsole>
<tab id="tab-server"> <tab id="tab-server">
......
-- $Revision$ -- $Revision$
-- $Date$ -- $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1); INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation ( CREATE TABLE ofConversation (
conversationID INTEGER NOT NULL, conversationID INTEGER NOT NULL,
......
// $Revision$ // $Revision$
// $Date$ // $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1); INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation ( CREATE TABLE ofConversation (
conversationID BIGINT NOT NULL, conversationID BIGINT NOT NULL,
......
# $Revision$ # $Revision$
# $Date$ # $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1); INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation ( CREATE TABLE ofConversation (
conversationID BIGINT NOT NULL, conversationID BIGINT NOT NULL,
......
-- $Revision$ -- $Revision$
-- $Date$ -- $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1); INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation ( CREATE TABLE ofConversation (
conversationID INTEGER NOT NULL, conversationID INTEGER NOT NULL,
......
-- $Revision$ -- $Revision$
-- $Date$ -- $Date$
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1); INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation ( CREATE TABLE ofConversation (
conversationID INTEGER NOT NULL, conversationID INTEGER NOT NULL,
......
/* $Revision$ */ /* $Revision$ */
/* $Date$ */ /* $Date$ */
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 1); INSERT INTO ofVersion (name, version) VALUES ('monitoring', 2);
CREATE TABLE ofConversation ( CREATE TABLE ofConversation (
conversationID BIGINT NOT NULL, conversationID BIGINT NOT NULL,
...@@ -34,7 +34,7 @@ CREATE TABLE ofMessageArchive ( ...@@ -34,7 +34,7 @@ CREATE TABLE ofMessageArchive (
toJID NVARCHAR(1024) NOT NULL, toJID NVARCHAR(1024) NOT NULL,
toJIDResource NVARCHAR(1024) NULL, toJIDResource NVARCHAR(1024) NULL,
sentDate BIGINT NOT NULL, sentDate BIGINT NOT NULL,
body NTEXT body NVARCHAR(MAX)
); );
CREATE INDEX ofMessageArchive_con_idx ON ofMessageArchive (conversationID); CREATE INDEX ofMessageArchive_con_idx ON ofMessageArchive (conversationID);
......
...@@ -50,8 +50,10 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -50,8 +50,10 @@ public class JdbcPersistenceManager implements PersistenceManager {
public static final String SELECT_CONVERSATIONS = "SELECT DISTINCT " + "ofConversation.conversationID, " + "ofConversation.room, " public static final String SELECT_CONVERSATIONS = "SELECT DISTINCT " + "ofConversation.conversationID, " + "ofConversation.room, "
+ "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, " + "ofMessageArchive.fromJID, " + "ofMessageArchive.toJID, " + "ofMessageArchive.sentDate, " + "ofConParticipant.nickname, "
+ "ofMessageArchive.body " + "FROM ofConversation " + "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 ofConParticipant ON ofConversation.conversationID = ofConParticipant.conversationID "
+ "INNER JOIN ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID"; + "INNER JOIN ofMessageArchive ON ofConParticipant.conversationID = ofMessageArchive.conversationID";
...@@ -193,15 +195,27 @@ public class JdbcPersistenceManager implements PersistenceManager { ...@@ -193,15 +195,27 @@ public class JdbcPersistenceManager implements PersistenceManager {
} }
firstIndex = firstIndex != null ? firstIndex : 0; firstIndex = firstIndex != null ? firstIndex : 0;
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(" LIMIT ").append(max);
limitSB.append(" OFFSET ").append(firstIndex); limitSB.append(" OFFSET ").append(firstIndex);
}
xmppResultSet.setFirstIndex(firstIndex); xmppResultSet.setFirstIndex(firstIndex);
} }
if (whereSB.length() != 0) { if (whereSB.length() != 0) {
querySB.append(" WHERE ").append(whereSB); querySB.append(" WHERE ").append(whereSB);
} }
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(" ORDER BY ").append(CONVERSATION_ID);
}
querySB.append(limitSB); querySB.append(limitSB);
Connection con = null; Connection con = null;
......
...@@ -45,6 +45,12 @@ public class XmppResultSet ...@@ -45,6 +45,12 @@ public class XmppResultSet
before = null; before = null;
} }
} }
catch (NumberFormatException e)
{
if (setElement.elementText("before").isEmpty()) {
this.before = Long.valueOf(9223372036854775807L);
}
}
catch (Exception e) catch (Exception e)
{ {
// swallow // 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