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
9374ba71
Commit
9374ba71
authored
Aug 19, 2015
by
daryl herzmann
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #282 from Redor/master
Update the REST API plugin to 1.1.4
parents
4235cb26
68abcf32
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
252 additions
and
20 deletions
+252
-20
changelog.html
src/plugins/restAPI/changelog.html
+5
-0
plugin.xml
src/plugins/restAPI/plugin.xml
+2
-2
readme.html
src/plugins/restAPI/readme.html
+96
-2
MsgArchiveController.java
...openfire/plugin/rest/controller/MsgArchiveController.java
+11
-14
StatisticsController.java
...openfire/plugin/rest/controller/StatisticsController.java
+34
-0
SessionsCount.java
...vesoftware/openfire/plugin/rest/entity/SessionsCount.java
+73
-0
JerseyWrapper.java
...esoftware/openfire/plugin/rest/service/JerseyWrapper.java
+2
-2
StatisticsService.java
...tware/openfire/plugin/rest/service/StatisticsService.java
+29
-0
No files found.
src/plugins/restAPI/changelog.html
View file @
9374ba71
...
...
@@ -44,6 +44,11 @@
REST API Plugin Changelog
</h1>
<p><b>
1.1.4
</b>
-- August 19th, 2015
</p>
<ul>
<li>
Added: get concurrent sessions (local or cluster wide)
</li>
</ul>
<p><b>
1.1.3
</b>
-- August 15th, 2015
</p>
<ul>
<li>
Added: get count of users unread messages
</li>
...
...
src/plugins/restAPI/plugin.xml
View file @
9374ba71
...
...
@@ -5,8 +5,8 @@
<name>
REST API
</name>
<description>
Allows administration over a RESTful API.
</description>
<author>
Roman Soldatow
</author>
<version>
1.1.
3
</version>
<date>
08/1
5
/2015
</date>
<version>
1.1.
4
</version>
<date>
08/1
9
/2015
</date>
<minServerVersion>
3.9.0
</minServerVersion>
<adminconsole>
...
...
src/plugins/restAPI/readme.html
View file @
9374ba71
...
...
@@ -1248,6 +1248,7 @@ body.pdf{font-family:"DejaVu Sans"}body.pdf code,body.pdf pre{font-family:"DejaV
<li><a
href=
"#chatroom"
>
Chatroom
</a></li>
<li><a
href=
"#system-property"
>
System Property
</a></li>
<li><a
href=
"#session"
>
Session
</a></li>
<li><a
href=
"#sessions-count"
>
Sessions count
</a></li>
</ul>
</li>
</ul>
...
...
@@ -1401,15 +1402,19 @@ body.pdf{font-family:"DejaVu Sans"}body.pdf code,body.pdf pre{font-family:"DejaV
<li><a
href=
"#examples-25"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#retrieve-concurrent-sessions"
>
Retrieve concurrent sessions
</a><ul>
<li><a
href=
"#examples-26"
>
Examples
</a></li>
</ul>
</li>
</ul>
</li>
<li><a
href=
"#group-related-rest-endpoints"
>
Group related REST Endpoints
</a><ul>
<li><a
href=
"#retrieve-all-groups"
>
Retrieve all groups
</a><ul>
<li><a
href=
"#examples-26"
>
Examples
</a></li>
<li><a
href=
"#examples-26
-1
"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#retrieve-a-group"
>
Retrieve a group
</a><ul>
<li><a
href=
"#possible-parameters-24"
>
Possible parameters
</a></li>
<li><a
href=
"#possible-parameters-24
-1
"
>
Possible parameters
</a></li>
<li><a
href=
"#examples-27"
>
Examples
</a></li>
</ul>
</li>
...
...
@@ -1873,6 +1878,27 @@ If you want to create a resource with JSON data format, please add “<strong>Co
</tbody></table>
<h3
id=
"sessions-count"
>
Sessions count
</h3>
<table>
<thead>
<tr>
<th>
Parameter
</th>
<th>
Optional
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody><tr>
<td>
clusterSessions
</td>
<td>
No
</td>
<td>
Number of client sessions that are authenticated with the server. This includes anonymous and non-anoymous users from the whole cluster.
</td>
</tr>
<tr>
<td>
localSessions
</td>
<td>
No
</td>
<td>
Number of client sessions that are authenticated with the server. This includes anonymous and non-anoymous users.
</td>
</tr>
</tbody></table>
<h1
id=
"user-related-rest-endpoints"
>
User related REST Endpoints
</h1>
...
...
@@ -3539,6 +3565,23 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h2
id=
"retrieve-concurrent-sessions"
>
Retrieve concurrent sessions
</h2>
<p>
Endpoint to get count of concurrent sessions
</p>
<blockquote>
<p><strong>
GET
</strong>
/system/statistics/sessions
</p>
</blockquote>
<p><strong>
Payload:
</strong>
none
<br>
<strong>
Return value:
</strong>
Sessions count
</p>
<h3
id=
"examples-26"
>
Examples
</h3>
<p><strong>
Header:
</strong>
Authorization: Basic YWRtaW46MTIzNDU=
</p>
<p><strong>
GET
</strong>
<a
href=
"http://example.org:9090/plugins/restapi/v1/system/statistics/sessions"
>
http://example.org:9090/plugins/restapi/v1/system/statistics/sessions
</a></p>
<h1
id=
"group-related-rest-endpoints"
>
Group related REST Endpoints
</h1>
...
...
@@ -4327,6 +4370,57 @@ If the strings are encoded incorrectly, double byte characters will look garbele
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/controller/MsgArchiveController.java
View file @
9374ba71
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
controller
;
import
org.jivesoftware.database.DbConnectionManager
;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.xmpp.packet.JID
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
org.jivesoftware.database.DbConnectionManager
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.xmpp.packet.JID
;
/**
* The Class MsgArchiveController.
*/
public
class
MsgArchiveController
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
MsgArchiveController
.
class
);
/** The Constant LOG. */
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MsgArchiveController
.
class
);
/** The Constant INSTANCE. */
public
static
final
MsgArchiveController
INSTANCE
=
new
MsgArchiveController
();
/** The server. */
private
XMPPServer
server
;
/** The Constant USER_MESSAGE_COUNT. */
private
static
final
String
USER_MESSAGE_COUNT
=
"select COUNT(1) from ofMessageArchive a "
+
"join ofPresence p on (a.sentDate > p.offlineDate) "
+
"WHERE a.toJID = ? AND p.username = ?"
;
...
...
@@ -39,15 +36,15 @@ public class MsgArchiveController {
}
/**
*
Instantiates a new user service controlle
r.
*
The Constructo
r.
*/
private
MsgArchiveController
()
{
server
=
XMPPServer
.
getInstance
();
}
/**
* Returns the total number of messages that haven't been delivered to the user.
*
* @param jid the jid
* @return the total number of user unread messages.
*/
public
int
getUnReadMessagesCount
(
JID
jid
)
{
...
...
@@ -65,7 +62,7 @@ public class MsgArchiveController {
messageCount
=
rs
.
getInt
(
1
);
}
}
catch
(
SQLException
sqle
)
{
L
og
.
error
(
sqle
.
getMessage
(),
sqle
);
L
OG
.
error
(
sqle
.
getMessage
(),
sqle
);
}
finally
{
DbConnectionManager
.
closeConnection
(
rs
,
pstmt
,
con
);
}
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/controller/StatisticsController.java
0 → 100644
View file @
9374ba71
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
controller
;
import
org.jivesoftware.openfire.SessionManager
;
import
org.jivesoftware.openfire.plugin.rest.entity.SessionsCount
;
/**
* The Class StatisticsController.
*/
public
class
StatisticsController
{
/** The Constant INSTANCE. */
public
static
final
StatisticsController
INSTANCE
=
new
StatisticsController
();
/**
* Gets the instance.
*
* @return the instance
*/
public
static
StatisticsController
getInstance
()
{
return
INSTANCE
;
}
/**
* Gets the concurent sessions.
*
* @return the concurent sessions
*/
public
SessionsCount
getConcurentSessions
()
{
int
userSessionsCountLocal
=
SessionManager
.
getInstance
().
getUserSessionsCount
(
true
);
int
userSessionsCountCluster
=
SessionManager
.
getInstance
().
getUserSessionsCount
(
false
);
return
new
SessionsCount
(
userSessionsCountLocal
,
userSessionsCountCluster
);
}
}
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/entity/SessionsCount.java
0 → 100644
View file @
9374ba71
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
entity
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
/**
* The Class SessionsCount.
*/
@XmlRootElement
(
name
=
"sessions"
)
public
class
SessionsCount
{
/** The local sessions. */
private
int
localSessions
;
/** The cluster sessions. */
private
int
clusterSessions
;
/**
* The Constructor.
*/
public
SessionsCount
()
{
}
/**
* The Constructor.
*
* @param localSessions the local sessions
* @param clusterSessions the cluster sessions
*/
public
SessionsCount
(
int
localSessions
,
int
clusterSessions
)
{
this
.
localSessions
=
localSessions
;
this
.
clusterSessions
=
clusterSessions
;
}
/**
* Gets the local sessions.
*
* @return the local sessions
*/
@XmlElement
()
public
int
getLocalSessions
()
{
return
localSessions
;
}
/**
* Sets the local sessions.
*
* @param localSessions the local sessions
*/
public
void
setLocalSessions
(
int
localSessions
)
{
this
.
localSessions
=
localSessions
;
}
/**
* Gets the cluster sessions.
*
* @return the cluster sessions
*/
@XmlElement
()
public
int
getClusterSessions
()
{
return
clusterSessions
;
}
/**
* Sets the cluster sessions.
*
* @param clusterSessions the cluster sessions
*/
public
void
setClusterSessions
(
int
clusterSessions
)
{
this
.
clusterSessions
=
clusterSessions
;
}
}
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/service/JerseyWrapper.java
View file @
9374ba71
...
...
@@ -80,10 +80,10 @@ public class JerseyWrapper extends ServletContainer {
prc
.
getClasses
().
add
(
GroupService
.
class
);
prc
.
getClasses
().
add
(
SessionService
.
class
);
prc
.
getClasses
().
add
(
MsgArchiveService
.
class
);
prc
.
getClasses
().
add
(
StatisticsService
.
class
);
prc
.
getClasses
().
add
(
RESTExceptionMapper
.
class
);
prc
.
getClasses
().
add
(
MsgArchiveService
.
class
);
}
/**
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/service/StatisticsService.java
0 → 100644
View file @
9374ba71
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
service
;
import
javax.annotation.PostConstruct
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.MediaType
;
import
org.jivesoftware.openfire.plugin.rest.controller.StatisticsController
;
import
org.jivesoftware.openfire.plugin.rest.entity.SessionsCount
;
import
org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException
;
@Path
(
"restapi/v1/system/statistics"
)
public
class
StatisticsService
{
private
StatisticsController
controller
;
@PostConstruct
public
void
init
()
{
controller
=
StatisticsController
.
getInstance
();
}
@GET
@Path
(
"/sessions"
)
@Produces
({
MediaType
.
APPLICATION_XML
,
MediaType
.
APPLICATION_JSON
})
public
SessionsCount
getCCS
()
throws
ServiceException
{
return
controller
.
getConcurentSessions
();
}
}
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