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
f25447b3
Commit
f25447b3
authored
Jul 25, 2016
by
Dave Cridland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-817 Persist entire MUC stanza
parent
45fb7ff9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
62 additions
and
14 deletions
+62
-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
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 @
f25447b3
...
...
@@ -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 @
f25447b3
...
...
@@ -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 @
f25447b3
...
...
@@ -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 @
f25447b3
...
...
@@ -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 @
f25447b3
...
...
@@ -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 @
f25447b3
...
...
@@ -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 @
f25447b3
...
...
@@ -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/java/org/jivesoftware/openfire/muc/MUCRoomHistory.java
View file @
f25447b3
...
...
@@ -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 @
f25447b3
...
...
@@ -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 @
f25447b3
...
...
@@ -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