Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
2249ae78
Commit
2249ae78
authored
Dec 13, 2016
by
Dave Cridland
Committed by
GitHub
Dec 13, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #672 from surevine/of-817
OF-817 Persist entire MUC stanza
parents
45fb7ff9
39511ec2
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
84 additions
and
14 deletions
+84
-14
openfire_db2.sql
src/database/openfire_db2.sql
+2
-1
openfire_hsqldb.sql
src/database/openfire_hsqldb.sql
+2
-1
openfire_mysql.sql
src/database/openfire_mysql.sql
+1
-0
openfire_oracle.sql
src/database/openfire_oracle.sql
+2
-1
openfire_postgresql.sql
src/database/openfire_postgresql.sql
+2
-1
openfire_sqlserver.sql
src/database/openfire_sqlserver.sql
+2
-1
openfire_sybase.sql
src/database/openfire_sybase.sql
+2
-1
openfire_db2.sql
src/database/upgrade/24/openfire_db2.sql
+4
-0
openfire_hsqldb.sql
src/database/upgrade/24/openfire_hsqldb.sql
+3
-0
openfire_mysql.sql
src/database/upgrade/24/openfire_mysql.sql
+3
-0
openfire_oracle.sql
src/database/upgrade/24/openfire_oracle.sql
+3
-0
openfire_postgresql.sql
src/database/upgrade/24/openfire_postgresql.sql
+3
-0
openfire_sqlserver.sql
src/database/upgrade/24/openfire_sqlserver.sql
+3
-0
openfire_sybase.sql
src/database/upgrade/24/openfire_sybase.sql
+3
-0
MUCRoomHistory.java
src/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java
+29
-1
ConversationLogEntry.java
...g/jivesoftware/openfire/muc/spi/ConversationLogEntry.java
+9
-0
MUCPersistenceManager.java
.../jivesoftware/openfire/muc/spi/MUCPersistenceManager.java
+11
-7
No files found.
src/database/openfire_db2.sql
View file @
2249ae78
...
...
@@ -265,7 +265,8 @@ CREATE TABLE ofMucConversationLog (
nickname
VARCHAR
(
255
),
logTime
CHAR
(
15
)
NOT
NULL
,
subject
VARCHAR
(
255
),
body
CLOB
body
CLOB
,
stanza
CLOB
);
CREATE
INDEX
ofMucConvLog_time_idx
ON
ofMucConversationLog
(
logTime
);
...
...
src/database/openfire_hsqldb.sql
View file @
2249ae78
...
...
@@ -257,7 +257,8 @@ CREATE TABLE ofMucConversationLog (
nickname
VARCHAR
(
255
)
NULL
,
logTime
CHAR
(
15
)
NOT
NULL
,
subject
VARCHAR
(
255
)
NULL
,
body
LONGVARCHAR
NULL
body
LONGVARCHAR
NULL
,
stanza
LONGVARCHAR
NULL
);
CREATE
INDEX
ofMucConversationLog_time_idx
ON
ofMucConversationLog
(
logTime
);
...
...
src/database/openfire_mysql.sql
View file @
2249ae78
...
...
@@ -247,6 +247,7 @@ CREATE TABLE ofMucConversationLog (
logTime
CHAR
(
15
)
NOT
NULL
,
subject
VARCHAR
(
255
)
NULL
,
body
TEXT
NULL
,
stanza
TEXT
NULL
,
INDEX
ofMucConversationLog_time_idx
(
logTime
)
);
...
...
src/database/openfire_oracle.sql
View file @
2249ae78
...
...
@@ -254,7 +254,8 @@ CREATE TABLE ofMucConversationLog (
nickname
VARCHAR2
(
255
)
NULL
,
logTime
CHAR
(
15
)
NOT
NULL
,
subject
VARCHAR2
(
255
)
NULL
,
body
VARCHAR2
(
4000
)
NULL
body
VARCHAR2
(
4000
)
NULL
,
stanza
VARCHAR2
(
4000
)
NULL
);
CREATE
INDEX
ofMucConversationLog_time_idx
ON
ofMucConversationLog
(
logTime
);
...
...
src/database/openfire_postgresql.sql
View file @
2249ae78
...
...
@@ -262,7 +262,8 @@ CREATE TABLE ofMucConversationLog (
nickname
VARCHAR
(
255
)
NULL
,
logTime
CHAR
(
15
)
NOT
NULL
,
subject
VARCHAR
(
255
)
NULL
,
body
TEXT
NULL
body
TEXT
NULL
,
stanza
TEXT
NULL
);
CREATE
INDEX
ofMucConversationLog_time_idx
ON
ofMucConversationLog
(
logTime
);
...
...
src/database/openfire_sqlserver.sql
View file @
2249ae78
...
...
@@ -260,7 +260,8 @@ CREATE TABLE ofMucConversationLog (
nickname
NVARCHAR
(
255
)
NULL
,
logTime
CHAR
(
15
)
NOT
NULL
,
subject
NVARCHAR
(
255
)
NULL
,
body
NTEXT
NULL
body
NTEXT
NULL
,
stanza
NTEXT
NULL
);
CREATE
INDEX
ofMucConversationLog_time_idx
ON
ofMucConversationLog
(
logTime
);
...
...
src/database/openfire_sybase.sql
View file @
2249ae78
...
...
@@ -260,7 +260,8 @@ CREATE TABLE ofMucConversationLog (
nickname
NVARCHAR
(
255
)
NULL
,
logTime
CHAR
(
15
)
NOT
NULL
,
subject
NVARCHAR
(
255
)
NULL
,
body
TEXT
NULL
body
TEXT
NULL
,
stanza
TEXT
NULL
);
CREATE
INDEX
ofMucConversationLog_time_idx
ON
ofMucConversationLog
(
logTime
);
...
...
src/database/upgrade/24/openfire_db2.sql
0 → 100644
View file @
2249ae78
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
stanza
CLOB
;
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
messageID
INTEGER
;
UPDATE
ofVersion
SET
version
=
24
WHERE
name
=
'openfire'
;
src/database/upgrade/24/openfire_hsqldb.sql
0 → 100644
View file @
2249ae78
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
stanza
LONGVARCHAR
NULL
;
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
messageID
BIGINT
NULL
;
UPDATE
ofVersion
SET
version
=
24
WHERE
name
=
'openfire'
;
\ No newline at end of file
src/database/upgrade/24/openfire_mysql.sql
0 → 100644
View file @
2249ae78
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
stanza
TEXT
NULL
;
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
messageID
BIGINT
NULL
;
UPDATE
ofVersion
SET
version
=
24
WHERE
name
=
'openfire'
;
\ No newline at end of file
src/database/upgrade/24/openfire_oracle.sql
0 → 100644
View file @
2249ae78
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
stanza
VARCHAR2
(
4000
)
NULL
;
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
messageID
INT
NULL
;
UPDATE
ofVersion
SET
version
=
24
WHERE
name
=
'openfire'
;
\ No newline at end of file
src/database/upgrade/24/openfire_postgresql.sql
0 → 100644
View file @
2249ae78
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
stanza
TEXT
NULL
;
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
messageID
INTEGER
NULL
;
UPDATE
ofVersion
SET
version
=
24
WHERE
name
=
'openfire'
;
\ No newline at end of file
src/database/upgrade/24/openfire_sqlserver.sql
0 → 100644
View file @
2249ae78
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
stanza
NTEXT
NULL
;
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
messageID
INT
NULL
;
UPDATE
ofVersion
SET
version
=
24
WHERE
name
=
'openfire'
;
\ No newline at end of file
src/database/upgrade/24/openfire_sybase.sql
0 → 100644
View file @
2249ae78
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
stanza
TEXT
NULL
;
ALTER
TABLE
ofMucConversationLog
ADD
COLUMN
messageID
INT
NULL
;
UPDATE
ofVersion
SET
version
=
24
WHERE
name
=
'openfire'
;
\ No newline at end of file
src/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java
View file @
2249ae78
...
...
@@ -20,14 +20,19 @@
package
org
.
jivesoftware
.
openfire
.
muc
;
import
org.dom4j.Attribute
;
import
org.dom4j.Element
;
import
org.dom4j.Namespace
;
import
org.dom4j.io.SAXReader
;
import
org.jivesoftware.openfire.user.UserNotFoundException
;
import
org.jivesoftware.util.XMPPDateTimeFormat
;
import
org.xmpp.packet.JID
;
import
org.xmpp.packet.Message
;
import
java.io.StringReader
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.ListIterator
;
/**
...
...
@@ -147,10 +152,33 @@ public final class MUCRoomHistory {
* @param body the body of the message.
*/
public
void
addOldMessage
(
String
senderJID
,
String
nickname
,
Date
sentDate
,
String
subject
,
String
body
)
String
body
,
String
stanza
)
{
Message
message
=
new
Message
();
message
.
setType
(
Message
.
Type
.
groupchat
);
if
(
stanza
!=
null
)
{
// payload initialized as XML string from DB
SAXReader
xmlReader
=
new
SAXReader
();
xmlReader
.
setEncoding
(
"UTF-8"
);
try
{
Element
element
=
xmlReader
.
read
(
new
StringReader
(
stanza
)).
getRootElement
();
for
(
Element
child
:
(
List
<
Element
>)
element
.
elements
())
{
Namespace
ns
=
child
.
getNamespace
();
if
(
ns
==
null
||
ns
.
getURI
().
equals
(
"jabber:client"
)
||
ns
.
getURI
().
equals
(
"jabber:server"
))
{
continue
;
}
Element
added
=
message
.
addChildElement
(
child
.
getName
(),
child
.
getNamespaceURI
());
for
(
Attribute
attr
:
(
List
<
Attribute
>)
child
.
attributes
())
{
added
.
add
(
attr
);
}
for
(
Element
el
:
(
List
<
Element
>)
child
.
elements
())
{
added
.
add
(
el
);
}
}
}
catch
(
Exception
ex
)
{
// log.error("Failed to parse payload XML", ex);
}
}
message
.
setSubject
(
subject
);
message
.
setBody
(
body
);
// Set the sender of the message
...
...
src/java/org/jivesoftware/openfire/muc/spi/ConversationLogEntry.java
View file @
2249ae78
...
...
@@ -45,6 +45,8 @@ class ConversationLogEntry {
private
final
JID
sender
;
private
final
String
nickname
;
private
final
String
stanza
;
private
final
long
roomID
;
...
...
@@ -61,6 +63,7 @@ class ConversationLogEntry {
this
.
date
=
date
;
this
.
subject
=
message
.
getSubject
();
this
.
body
=
message
.
getBody
();
this
.
stanza
=
message
.
toString
();
this
.
sender
=
sender
;
this
.
roomID
=
room
.
getID
();
this
.
nickname
=
message
.
getFrom
().
getResource
();
...
...
@@ -120,4 +123,10 @@ class ConversationLogEntry {
return
roomID
;
}
/**
* Returns the string representation of the message.
*
* @return string representation of the stanza.
*/
public
String
getStanza
()
{
return
stanza
;
}
}
\ No newline at end of file
src/java/org/jivesoftware/openfire/muc/spi/MUCPersistenceManager.java
View file @
2249ae78
...
...
@@ -69,7 +69,7 @@ public class MUCPersistenceManager {
private
static
final
String
LOAD_MEMBERS
=
"SELECT jid, nickname FROM ofMucMember WHERE roomID=?"
;
private
static
final
String
LOAD_HISTORY
=
"SELECT sender, nickname, logTime, subject, body FROM ofMucConversationLog "
+
"SELECT sender, nickname, logTime, subject, body
, stanza
FROM ofMucConversationLog "
+
"WHERE logTime>? AND roomID=? AND (nickname IS NOT NULL OR subject IS NOT NULL) ORDER BY logTime"
;
private
static
final
String
LOAD_ALL_ROOMS
=
"SELECT roomID, creationDate, modificationDate, name, naturalName, description, "
+
...
...
@@ -85,7 +85,7 @@ public class MUCPersistenceManager {
"WHERE ofMucMember.roomID = ofMucRoom.roomID AND ofMucRoom.serviceID=?"
;
private
static
final
String
LOAD_ALL_HISTORY
=
"SELECT ofMucConversationLog.roomID, ofMucConversationLog.sender, ofMucConversationLog.nickname, "
+
"ofMucConversationLog.logTime, ofMucConversationLog.subject, ofMucConversationLog.body FROM "
+
"ofMucConversationLog.logTime, ofMucConversationLog.subject, ofMucConversationLog.body
, ofMucConversationLog.stanza
FROM "
+
"ofMucConversationLog, ofMucRoom WHERE ofMucConversationLog.roomID = ofMucRoom.roomID AND "
+
"ofMucRoom.serviceID=? AND ofMucConversationLog.logTime>? AND (ofMucConversationLog.nickname IS NOT NULL "
+
"OR ofMucConversationLog.subject IS NOT NULL) ORDER BY ofMucConversationLog.logTime"
;
...
...
@@ -129,8 +129,8 @@ public class MUCPersistenceManager {
private
static
final
String
DELETE_USER_MUCAFFILIATION
=
"DELETE FROM ofMucAffiliation WHERE jid=?"
;
private
static
final
String
ADD_CONVERSATION_LOG
=
"INSERT INTO ofMucConversationLog (roomID,sender,nickname,logTime,subject,body) "
+
"VALUES (?,?,?,?,?,?)"
;
"INSERT INTO ofMucConversationLog (roomID,sender,nickname,logTime,subject,body
,stanza
) "
+
"VALUES (?,?,?,?,?,?
,?
)"
;
/* Map of subdomains to their associated properties */
private
static
ConcurrentHashMap
<
String
,
MUCServiceProperties
>
propertyMaps
=
new
ConcurrentHashMap
<>();
...
...
@@ -249,8 +249,9 @@ public class MUCPersistenceManager {
Date
sentDate
=
new
Date
(
Long
.
parseLong
(
rs
.
getString
(
3
).
trim
()));
String
subject
=
rs
.
getString
(
4
);
String
body
=
rs
.
getString
(
5
);
String
stanza
=
rs
.
getString
(
6
);
room
.
getRoomHistory
().
addOldMessage
(
senderJID
,
nickname
,
sentDate
,
subject
,
body
);
body
,
stanza
);
}
}
DbConnectionManager
.
fastcloseStmt
(
rs
,
pstmt
);
...
...
@@ -260,7 +261,7 @@ public class MUCPersistenceManager {
if
(!
room
.
getRoomHistory
().
hasChangedSubject
()
&&
room
.
getSubject
()
!=
null
&&
room
.
getSubject
().
length
()
>
0
)
{
room
.
getRoomHistory
().
addOldMessage
(
room
.
getRole
().
getRoleAddress
().
toString
(),
null
,
room
.
getModificationDate
(),
room
.
getSubject
(),
null
);
null
,
room
.
getModificationDate
(),
room
.
getSubject
(),
null
,
null
);
}
pstmt
=
con
.
prepareStatement
(
LOAD_AFFILIATIONS
);
...
...
@@ -599,7 +600,8 @@ public class MUCPersistenceManager {
Date
sentDate
=
new
Date
(
Long
.
parseLong
(
resultSet
.
getString
(
4
).
trim
()));
String
subject
=
resultSet
.
getString
(
5
);
String
body
=
resultSet
.
getString
(
6
);
room
.
getRoomHistory
().
addOldMessage
(
senderJID
,
nickname
,
sentDate
,
subject
,
body
);
String
stanza
=
resultSet
.
getString
(
7
);
room
.
getRoomHistory
().
addOldMessage
(
senderJID
,
nickname
,
sentDate
,
subject
,
body
,
stanza
);
}
catch
(
SQLException
e
)
{
Log
.
warn
(
"A database exception prevented the history for one particular MUC room to be loaded from the database."
,
e
);
}
...
...
@@ -620,6 +622,7 @@ public class MUCPersistenceManager {
null
,
loadedRoom
.
getModificationDate
(),
loadedRoom
.
getSubject
(),
null
,
null
);
}
}
...
...
@@ -1063,6 +1066,7 @@ public class MUCPersistenceManager {
pstmt
.
setString
(
4
,
StringUtils
.
dateToMillis
(
entry
.
getDate
()));
pstmt
.
setString
(
5
,
entry
.
getSubject
());
pstmt
.
setString
(
6
,
entry
.
getBody
());
pstmt
.
setString
(
7
,
entry
.
getStanza
());
pstmt
.
executeUpdate
();
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment