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
e586132d
Commit
e586132d
authored
Jul 25, 2016
by
Dave Cridland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update MAM support to cover :0 and :1
parent
57e24df5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
158 additions
and
16 deletions
+158
-16
IQQueryHandler.java
...eucon/openfire/plugin/archive/xep0313/IQQueryHandler.java
+31
-14
IQQueryHandler0.java
...ucon/openfire/plugin/archive/xep0313/IQQueryHandler0.java
+59
-0
IQQueryHandler1.java
...ucon/openfire/plugin/archive/xep0313/IQQueryHandler1.java
+37
-0
Xep0313Support.java
...eucon/openfire/plugin/archive/xep0313/Xep0313Support.java
+2
-2
Xep0313Support1.java
...ucon/openfire/plugin/archive/xep0313/Xep0313Support1.java
+24
-0
MonitoringPlugin.java
...va/org/jivesoftware/openfire/plugin/MonitoringPlugin.java
+5
-0
No files found.
src/plugins/monitoring/src/java/com/reucon/openfire/plugin/archive/xep0313/IQQueryHandler.java
View file @
e586132d
package
com
.
reucon
.
openfire
.
plugin
.
archive
.
xep0313
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.TimeZone
;
import
org.dom4j.*
;
import
org.jivesoftware.openfire.auth.UnauthorizedException
;
...
...
@@ -31,17 +28,17 @@ import com.reucon.openfire.plugin.archive.xep0059.XmppResultSet;
/**
* XEP-0313 IQ Query Handler
*/
public
class
IQQueryHandler
extends
AbstractIQHandler
implements
abstract
class
IQQueryHandler
extends
AbstractIQHandler
implements
ServerFeaturesProvider
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
IQHandler
.
class
);
private
static
final
String
NAMESPACE
=
"urn:xmpp:mam:0"
;
private
static
final
String
MODULE_NAME
=
"Message Archive Management Query Handler"
;
protected
final
String
NAMESPACE
;
XMPPDateTimeFormat
xmppDateTimeFormat
=
new
XMPPDateTimeFormat
();
private
final
XMPPDateTimeFormat
xmppDateTimeFormat
=
new
XMPPDateTimeFormat
();
protected
IQQueryHandler
()
{
super
(
MODULE_NAME
,
"query"
,
NAMESPACE
);
IQQueryHandler
(
final
String
moduleName
,
final
String
namespace
)
{
super
(
moduleName
,
"query"
,
namespace
);
NAMESPACE
=
namespace
;
}
public
IQ
handleIQ
(
IQ
packet
)
throws
UnauthorizedException
{
...
...
@@ -73,6 +70,8 @@ public class IQQueryHandler extends AbstractIQHandler implements
}
}
sendMidQuery
(
packet
,
session
);
final
QueryRequest
queryRequest
=
new
QueryRequest
(
packet
.
getChildElement
(),
archiveJid
);
Collection
<
ArchivedMessage
>
archivedMessages
=
retrieveMessages
(
queryRequest
);
...
...
@@ -80,17 +79,21 @@ public class IQQueryHandler extends AbstractIQHandler implements
sendMessageResult
(
session
,
queryRequest
,
archivedMessage
);
}
sendFinalMessage
(
session
,
queryRequest
);
sendAcknowledgementResult
(
packet
,
session
);
sendEndQuery
(
packet
,
session
,
queryRequest
);
return
null
;
}
protected
void
sendMidQuery
(
IQ
packet
,
LocalClientSession
session
)
{
// Default: Do nothing.
}
protected
abstract
void
sendEndQuery
(
IQ
packet
,
LocalClientSession
session
,
QueryRequest
queryRequest
);
/**
* Create error response to send to client
* @param packet
* @return
* @param packet
IQ stanza received
* @return
IQ stanza to be sent.
*/
private
IQ
buildErrorResponse
(
IQ
packet
)
{
IQ
reply
=
IQ
.
createResultIQ
(
packet
);
...
...
@@ -268,4 +271,18 @@ public class IQQueryHandler extends AbstractIQHandler implements
return
Collections
.
singleton
(
NAMESPACE
).
iterator
();
}
void
completeFinElement
(
QueryRequest
queryRequest
,
Element
fin
)
{
if
(
queryRequest
.
getQueryid
()
!=
null
)
{
fin
.
addAttribute
(
"queryid"
,
queryRequest
.
getQueryid
());
}
XmppResultSet
resultSet
=
queryRequest
.
getResultSet
();
if
(
resultSet
!=
null
)
{
fin
.
add
(
resultSet
.
createResultElement
());
if
(
resultSet
.
isComplete
())
{
fin
.
addAttribute
(
"complete"
,
"true"
);
}
}
}
}
src/plugins/monitoring/src/java/com/reucon/openfire/plugin/archive/xep0313/IQQueryHandler0.java
0 → 100644
View file @
e586132d
package
com
.
reucon
.
openfire
.
plugin
.
archive
.
xep0313
;
import
org.dom4j.*
;
import
org.jivesoftware.openfire.handler.IQHandler
;
import
org.jivesoftware.openfire.session.LocalClientSession
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.xmpp.packet.IQ
;
import
org.xmpp.packet.Message
;
/**
* XEP-0313 IQ Query Handler
*/
class
IQQueryHandler0
extends
IQQueryHandler
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
IQHandler
.
class
);
private
static
final
String
MODULE_NAME
=
"Message Archive Management Query Handler v0"
;
IQQueryHandler0
()
{
super
(
MODULE_NAME
,
"urn:xmpp:mam:0"
);
}
@Override
protected
void
sendMidQuery
(
IQ
packet
,
LocalClientSession
session
)
{
sendAcknowledgementResult
(
packet
,
session
);
}
@Override
protected
void
sendEndQuery
(
IQ
packet
,
LocalClientSession
session
,
QueryRequest
queryRequest
)
{
sendFinalMessage
(
session
,
queryRequest
);
}
/**
* Send result packet to client acknowledging query.
* @param packet Received query packet
* @param session Client session to respond to
*/
private
void
sendAcknowledgementResult
(
IQ
packet
,
LocalClientSession
session
)
{
IQ
result
=
IQ
.
createResultIQ
(
packet
);
session
.
process
(
result
);
}
/**
* Send final message back to client following query.
* @param session Client session to respond to
* @param queryRequest Received query request
*/
private
void
sendFinalMessage
(
LocalClientSession
session
,
final
QueryRequest
queryRequest
)
{
Message
finalMessage
=
new
Message
();
finalMessage
.
setTo
(
session
.
getAddress
());
Element
fin
=
finalMessage
.
addChildElement
(
"fin"
,
NAMESPACE
);
completeFinElement
(
queryRequest
,
fin
);
session
.
process
(
finalMessage
);
}
}
src/plugins/monitoring/src/java/com/reucon/openfire/plugin/archive/xep0313/IQQueryHandler1.java
0 → 100644
View file @
e586132d
package
com
.
reucon
.
openfire
.
plugin
.
archive
.
xep0313
;
import
org.dom4j.*
;
import
org.jivesoftware.openfire.session.LocalClientSession
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.xmpp.packet.IQ
;
/**
* XEP-0313 IQ Query Handler
*/
class
IQQueryHandler1
extends
IQQueryHandler
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
IQQueryHandler1
.
class
);
private
static
final
String
MODULE_NAME
=
"Message Archive Management Query Handler v1"
;
IQQueryHandler1
()
{
super
(
MODULE_NAME
,
"urn:xmpp:mam:1"
);
}
@Override
protected
void
sendEndQuery
(
IQ
packet
,
LocalClientSession
session
,
QueryRequest
queryRequest
)
{
sendAcknowledgementResult
(
packet
,
session
,
queryRequest
);
}
/**
* Send result packet to client acknowledging query.
* @param packet Received query packet
* @param session Client session to respond to
*/
private
void
sendAcknowledgementResult
(
IQ
packet
,
LocalClientSession
session
,
QueryRequest
queryRequest
)
{
IQ
result
=
IQ
.
createResultIQ
(
packet
);
Element
fin
=
result
.
setChildElement
(
"fin"
,
NAMESPACE
);
completeFinElement
(
queryRequest
,
fin
);
session
.
process
(
result
);
}
}
src/plugins/monitoring/src/java/com/reucon/openfire/plugin/archive/xep0313/Xep0313Support.java
View file @
e586132d
...
...
@@ -18,8 +18,8 @@ public class Xep0313Support extends AbstractXepSupport {
public
Xep0313Support
(
XMPPServer
server
)
{
super
(
server
,
NAMESPACE
,
NAMESPACE
,
"XEP-0313 IQ Dispatcher"
);
this
.
iqHandlers
=
new
ArrayList
<
IQHandler
>();
iqHandlers
.
add
(
new
IQQueryHandler
());
this
.
iqHandlers
=
new
ArrayList
<>();
iqHandlers
.
add
(
new
IQQueryHandler
0
());
}
}
src/plugins/monitoring/src/java/com/reucon/openfire/plugin/archive/xep0313/Xep0313Support1.java
0 → 100644
View file @
e586132d
package
com
.
reucon
.
openfire
.
plugin
.
archive
.
xep0313
;
import
com.reucon.openfire.plugin.archive.xep.AbstractXepSupport
;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.jivesoftware.openfire.handler.IQHandler
;
import
java.util.ArrayList
;
/**
* Encapsulates support for <a
* href="http://www.xmpp.org/extensions/xep-0313.html">XEP-0313</a>.
*/
public
class
Xep0313Support1
extends
AbstractXepSupport
{
private
static
final
String
NAMESPACE
=
"urn:xmpp:mam:1"
;
public
Xep0313Support1
(
XMPPServer
server
)
{
super
(
server
,
NAMESPACE
,
NAMESPACE
,
"XEP-0313 IQ Dispatcher"
);
this
.
iqHandlers
=
new
ArrayList
<>();
iqHandlers
.
add
(
new
IQQueryHandler1
());
}
}
src/plugins/monitoring/src/java/org/jivesoftware/openfire/plugin/MonitoringPlugin.java
View file @
e586132d
...
...
@@ -22,6 +22,7 @@ package org.jivesoftware.openfire.plugin;
import
java.io.File
;
import
java.io.FileFilter
;
import
com.reucon.openfire.plugin.archive.xep0313.Xep0313Support1
;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.jivesoftware.openfire.archive.ArchiveIndexer
;
import
org.jivesoftware.openfire.archive.ArchiveInterceptor
;
...
...
@@ -73,6 +74,7 @@ public class MonitoringPlugin implements Plugin {
private
IndexManager
indexManager
;
private
Xep0136Support
xep0136Support
;
private
Xep0313Support
xep0313Support
;
private
Xep0313Support1
xep0313Support1
;
public
MonitoringPlugin
()
{
instance
=
this
;
...
...
@@ -162,6 +164,9 @@ public class MonitoringPlugin implements Plugin {
xep0313Support
=
new
Xep0313Support
(
XMPPServer
.
getInstance
());
xep0313Support
.
start
();
xep0313Support1
=
new
Xep0313Support1
(
XMPPServer
.
getInstance
());
xep0313Support1
.
start
();
// Check if we Enterprise is installed and stop loading this plugin if
// found
File
pluginDir
=
new
File
(
JiveGlobals
.
getHomeDirectory
(),
"plugins"
);
...
...
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