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
ed012548
Commit
ed012548
authored
Sep 01, 2015
by
Redor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the REST API plugin to 1.1.5
- Added: Send broadcast message to all online users
parent
68abcf32
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
204 additions
and
26 deletions
+204
-26
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
+77
-19
JustMarriedController.java
...penfire/plugin/rest/controller/JustMarriedController.java
+2
-0
MessageController.java
...re/openfire/plugin/rest/controller/MessageController.java
+44
-0
MessageEntity.java
...vesoftware/openfire/plugin/rest/entity/MessageEntity.java
+40
-0
JerseyWrapper.java
...esoftware/openfire/plugin/rest/service/JerseyWrapper.java
+6
-5
MessageService.java
...software/openfire/plugin/rest/service/MessageService.java
+28
-0
No files found.
src/plugins/restAPI/changelog.html
View file @
ed012548
...
...
@@ -44,6 +44,11 @@
REST API Plugin Changelog
</h1>
<p><b>
1.1.5
</b>
-- September 1st, 2015
</p>
<ul>
<li>
Added: Send broadcast message to all online users
</li>
</ul>
<p><b>
1.1.4
</b>
-- August 19th, 2015
</p>
<ul>
<li>
Added: get concurrent sessions (local or cluster wide)
</li>
...
...
src/plugins/restAPI/plugin.xml
View file @
ed012548
...
...
@@ -5,8 +5,8 @@
<name>
REST API
</name>
<description>
Allows administration over a RESTful API.
</description>
<author>
Roman Soldatow
</author>
<version>
1.1.
4
</version>
<date>
0
8/19
/2015
</date>
<version>
1.1.
5
</version>
<date>
0
9/01
/2015
</date>
<minServerVersion>
3.9.0
</minServerVersion>
<adminconsole>
...
...
src/plugins/restAPI/readme.html
View file @
ed012548
...
...
@@ -1410,43 +1410,50 @@ body.pdf{font-family:"DejaVu Sans"}body.pdf code,body.pdf pre{font-family:"DejaV
</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-2
6-1
"
>
Examples
</a></li>
<li><a
href=
"#examples-2
7
"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#retrieve-a-group"
>
Retrieve a group
</a><ul>
<li><a
href=
"#possible-parameters-24
-1
"
>
Possible parameters
</a></li>
<li><a
href=
"#examples-2
7
"
>
Examples
</a></li>
<li><a
href=
"#possible-parameters-24"
>
Possible parameters
</a></li>
<li><a
href=
"#examples-2
8
"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#create-a-group"
>
Create a group
</a><ul>
<li><a
href=
"#examples-2
8
"
>
Examples
</a></li>
<li><a
href=
"#examples-2
9
"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#delete-a-group"
>
Delete a group
</a><ul>
<li><a
href=
"#possible-parameters-25"
>
Possible parameters
</a></li>
<li><a
href=
"#examples-
29
"
>
Examples
</a></li>
<li><a
href=
"#examples-
30
"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#update-a-group"
>
Update a group
</a><ul>
<li><a
href=
"#possible-parameters-26"
>
Possible parameters
</a></li>
<li><a
href=
"#examples-3
0
"
>
Examples
</a></li>
<li><a
href=
"#examples-3
1
"
>
Examples
</a></li>
</ul>
</li>
</ul>
</li>
<li><a
href=
"#session-related-rest-endpoints"
>
Session related REST Endpoints
</a><ul>
<li><a
href=
"#retrieve-all-user-session"
>
Retrieve all user session
</a><ul>
<li><a
href=
"#examples-3
1
"
>
Examples
</a></li>
<li><a
href=
"#examples-3
2
"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#retrieve-the-user-sessions"
>
Retrieve the user sessions
</a><ul>
<li><a
href=
"#possible-parameters-27"
>
Possible parameters
</a></li>
<li><a
href=
"#examples-3
2
"
>
Examples
</a></li>
<li><a
href=
"#examples-3
3
"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#close-all-user-sessions"
>
Close all user sessions
</a><ul>
<li><a
href=
"#possible-parameters-28"
>
Possible parameters
</a></li>
<li><a
href=
"#examples-33"
>
Examples
</a></li>
<li><a
href=
"#examples-34"
>
Examples
</a></li>
</ul>
</li>
</ul>
</li>
<li><a
href=
"#message-related-rest-endpoints"
>
Message related REST Endpoints
</a><ul>
<li><a
href=
"#send-a-broadcast-message"
>
Send a broadcast message
</a><ul>
<li><a
href=
"#examples-35"
>
Examples
</a></li>
</ul>
</li>
</ul>
...
...
@@ -1475,10 +1482,9 @@ body.pdf{font-family:"DejaVu Sans"}body.pdf code,body.pdf pre{font-family:"DejaV
<li>
Get overview over all or specific system properties and to create, update or delete system property
</li>
<li>
Get overview over all or specific chat room and to create, update or delete a chat room
</li>
<li>
Get overview over all or specific user sessions
</li>
<li>
Send broadcast message to all online users
</li>
</ul>
<h2
id=
"available-rest-api-clients"
>
Available REST API clients
</h2>
<p>
REST API clients are implementations of the REST API in a specific programming language.
</p>
...
...
@@ -1878,6 +1884,8 @@ 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>
...
...
@@ -1901,6 +1909,8 @@ If you want to create a resource with JSON data format, please add “<strong>Co
</tbody></table>
<h1
id=
"user-related-rest-endpoints"
>
User related REST Endpoints
</h1>
...
...
@@ -3576,12 +3586,16 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<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>
...
...
@@ -3599,7 +3613,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3
id=
"examples-2
6
"
>
Examples
</h3>
<h3
id=
"examples-2
7
"
>
Examples
</h3>
<blockquote>
<p><strong>
Header
</strong>
: Authorization: Basic YWRtaW46MTIzNDU=
</p>
...
...
@@ -3644,7 +3658,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3
id=
"examples-2
7
"
>
Examples
</h3>
<h3
id=
"examples-2
8
"
>
Examples
</h3>
<p><strong>
Header:
</strong>
Authorization: Basic YWRtaW46MTIzNDU=
</p>
...
...
@@ -3665,7 +3679,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3
id=
"examples-2
8
"
>
Examples
</h3>
<h3
id=
"examples-2
9
"
>
Examples
</h3>
<blockquote>
<p><strong>
Header:
</strong>
Authorization: Basic YWRtaW46MTIzNDU=
<br>
...
...
@@ -3721,7 +3735,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3
id=
"examples-
29
"
>
Examples
</h3>
<h3
id=
"examples-
30
"
>
Examples
</h3>
<blockquote>
<p><strong>
Header:
</strong>
Authorization: Basic YWRtaW46MTIzNDU=
</p>
...
...
@@ -3766,7 +3780,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3
id=
"examples-3
0
"
>
Examples
</h3>
<h3
id=
"examples-3
1
"
>
Examples
</h3>
<blockquote>
<p><strong>
Header:
</strong>
Authorization: Basic YWRtaW46MTIzNDU=
<br>
...
...
@@ -3804,7 +3818,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3
id=
"examples-3
1
"
>
Examples
</h3>
<h3
id=
"examples-3
2
"
>
Examples
</h3>
<blockquote>
<p><strong>
Header
</strong>
: Authorization: Basic YWRtaW46MTIzNDU=
</p>
...
...
@@ -3849,7 +3863,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3
id=
"examples-3
2
"
>
Examples
</h3>
<h3
id=
"examples-3
3
"
>
Examples
</h3>
<p><strong>
Header:
</strong>
Authorization: Basic YWRtaW46MTIzNDU=
</p>
...
...
@@ -3892,7 +3906,7 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h3
id=
"examples-3
3
"
>
Examples
</h3>
<h3
id=
"examples-3
4
"
>
Examples
</h3>
<p><strong>
Header:
</strong>
Authorization: Basic YWRtaW46MTIzNDU=
</p>
...
...
@@ -3900,6 +3914,36 @@ DELETE /chatrooms/{roomName}/{roles}/{name}</p>
<h1
id=
"message-related-rest-endpoints"
>
Message related REST Endpoints
</h1>
<h2
id=
"send-a-broadcast-message"
>
Send a broadcast message
</h2>
<p>
Endpoint to send a broadcast/server message to all online users
</p>
<blockquote>
<p><strong>
POST
</strong>
/messages/users
</p>
</blockquote>
<p><strong>
Payload:
</strong>
Message
<br>
<strong>
Return value:
</strong>
HTTP status 201 (Created)
</p>
<h3
id=
"examples-35"
>
Examples
</h3>
<blockquote>
<p><strong>
Header
</strong>
: Authorization: Basic YWRtaW46MTIzNDU=
</p>
<p><strong>
POST
</strong>
<a
href=
"http://example.org:9090/plugins/restapi/v1/messages/users"
>
http://example.org:9090/plugins/restapi/v1/messages/users
</a></p>
</blockquote>
<p><strong>
Payload:
</strong></p>
<pre
class=
"prettyprint"
><code
class=
" hljs xml"
><span
class=
"hljs-pi"
>
<
?xml version="1.0" encoding="UTF-8" standalone="yes"?
>
</span>
<span
class=
"hljs-tag"
>
<
<span
class=
"hljs-title"
>
message
</span>
>
</span>
<span
class=
"hljs-tag"
>
<
<span
class=
"hljs-title"
>
body
</span>
>
</span>
Your message
<span
class=
"hljs-tag"
>
<
/
<span
class=
"hljs-title"
>
body
</span>
>
</span>
<span
class=
"hljs-tag"
>
<
/
<span
class=
"hljs-title"
>
message
</span>
>
</span></code></pre>
<h1
id=
"deprecated-user-service-plugin-readme"
>
(Deprecated) User Service Plugin Readme
</h1>
...
...
@@ -4427,6 +4471,20 @@ If the strings are encoded incorrectly, double byte characters will look garbele
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/controller/JustMarriedController.java
View file @
ed012548
...
...
@@ -11,6 +11,7 @@ import org.jivesoftware.openfire.XMPPServer;
import
org.jivesoftware.openfire.auth.AuthFactory
;
import
org.jivesoftware.openfire.group.Group
;
import
org.jivesoftware.openfire.group.GroupManager
;
import
org.jivesoftware.openfire.lockout.LockOutManager
;
import
org.jivesoftware.openfire.plugin.rest.exceptions.ExceptionType
;
import
org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException
;
import
org.jivesoftware.openfire.roster.Roster
;
...
...
@@ -130,6 +131,7 @@ public class JustMarriedController {
*/
private
static
void
deleteUser
(
User
oldUser
)
{
UserManager
.
getInstance
().
deleteUser
(
oldUser
);
LockOutManager
.
getInstance
().
enableAccount
(
oldUser
.
getUsername
());
final
StreamError
error
=
new
StreamError
(
StreamError
.
Condition
.
not_authorized
);
for
(
ClientSession
sess
:
SessionManager
.
getInstance
().
getSessions
(
oldUser
.
getUsername
()))
{
sess
.
deliverRawText
(
error
.
toXML
());
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/controller/MessageController.java
0 → 100644
View file @
ed012548
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
controller
;
import
javax.ws.rs.core.Response
;
import
org.jivesoftware.openfire.SessionManager
;
import
org.jivesoftware.openfire.plugin.rest.entity.MessageEntity
;
import
org.jivesoftware.openfire.plugin.rest.exceptions.ExceptionType
;
import
org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException
;
/**
* The Class MessageController.
*/
public
class
MessageController
{
/** The Constant INSTANCE. */
public
static
final
MessageController
INSTANCE
=
new
MessageController
();
/**
* Gets the single instance of MessageController.
*
* @return single instance of MessageController
*/
public
static
MessageController
getInstance
()
{
return
INSTANCE
;
}
/**
* Send broadcast message.
*
* @param messageEntity
* the message entity
* @throws ServiceException
* the service exception
*/
public
void
sendBroadcastMessage
(
MessageEntity
messageEntity
)
throws
ServiceException
{
if
(
messageEntity
.
getBody
()
!=
null
&&
!
messageEntity
.
getBody
().
isEmpty
())
{
SessionManager
.
getInstance
().
sendServerMessage
(
null
,
messageEntity
.
getBody
());
}
else
{
throw
new
ServiceException
(
"Message content/body is null or empty"
,
""
,
ExceptionType
.
ILLEGAL_ARGUMENT_EXCEPTION
,
Response
.
Status
.
BAD_REQUEST
);
}
}
}
\ No newline at end of file
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/entity/MessageEntity.java
0 → 100644
View file @
ed012548
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
entity
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
/**
* The Class MessageEntity.
*/
@XmlRootElement
(
name
=
"message"
)
public
class
MessageEntity
{
/** The body. */
private
String
body
;
/**
* Instantiates a new message entity.
*/
public
MessageEntity
()
{
}
/**
* Gets the body.
*
* @return the body
*/
@XmlElement
public
String
getBody
()
{
return
body
;
}
/**
* Sets the body.
*
* @param body
* the new body
*/
public
void
setBody
(
String
body
)
{
this
.
body
=
body
;
}
}
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/service/JerseyWrapper.java
View file @
ed012548
...
...
@@ -21,7 +21,7 @@ public class JerseyWrapper extends ServletContainer {
/** The Constant AUTHFILTER. */
private
static
final
String
AUTHFILTER
=
"org.jivesoftware.openfire.plugin.rest.AuthFilter"
;
/** The Constant CORSFILTER. */
private
static
final
String
CORSFILTER
=
"org.jivesoftware.openfire.plugin.rest.CORSFilter"
;
...
...
@@ -51,12 +51,12 @@ public class JerseyWrapper extends ServletContainer {
/** The prc. */
private
static
PackagesResourceConfig
prc
;
/** The Constant JERSEY_LOGGER. */
private
final
static
Logger
JERSEY_LOGGER
=
Logger
.
getLogger
(
"com.sun.jersey"
);
static
{
JERSEY_LOGGER
.
setLevel
(
Level
.
SEVERE
);
JERSEY_LOGGER
.
setLevel
(
Level
.
SEVERE
);
config
=
new
HashMap
<
String
,
Object
>();
config
.
put
(
RESOURCE_CONFIG_CLASS_KEY
,
RESOURCE_CONFIG_CLASS
);
prc
=
new
PackagesResourceConfig
(
SCAN_PACKAGE_DEFAULT
);
...
...
@@ -65,13 +65,13 @@ public class JerseyWrapper extends ServletContainer {
prc
.
getProperties
().
put
(
CONTAINER_RESPONSE_FILTERS
,
CORSFILTER
);
prc
.
getClasses
().
add
(
RestAPIService
.
class
);
prc
.
getClasses
().
add
(
MUCRoomService
.
class
);
prc
.
getClasses
().
add
(
MUCRoomOwnersService
.
class
);
prc
.
getClasses
().
add
(
MUCRoomAdminsService
.
class
);
prc
.
getClasses
().
add
(
MUCRoomMembersService
.
class
);
prc
.
getClasses
().
add
(
MUCRoomOutcastsService
.
class
);
prc
.
getClasses
().
add
(
UserServiceLegacy
.
class
);
prc
.
getClasses
().
add
(
UserService
.
class
);
prc
.
getClasses
().
add
(
UserRosterService
.
class
);
...
...
@@ -82,6 +82,7 @@ public class JerseyWrapper extends ServletContainer {
prc
.
getClasses
().
add
(
SessionService
.
class
);
prc
.
getClasses
().
add
(
MsgArchiveService
.
class
);
prc
.
getClasses
().
add
(
StatisticsService
.
class
);
prc
.
getClasses
().
add
(
MessageService
.
class
);
prc
.
getClasses
().
add
(
RESTExceptionMapper
.
class
);
}
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/service/MessageService.java
0 → 100644
View file @
ed012548
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
service
;
import
javax.annotation.PostConstruct
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.core.Response
;
import
org.jivesoftware.openfire.plugin.rest.controller.MessageController
;
import
org.jivesoftware.openfire.plugin.rest.entity.MessageEntity
;
import
org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException
;
@Path
(
"restapi/v1/messages"
)
public
class
MessageService
{
private
MessageController
messageController
;
@PostConstruct
public
void
init
()
{
messageController
=
MessageController
.
getInstance
();
}
@POST
@Path
(
"/users"
)
public
Response
sendBroadcastMessage
(
MessageEntity
messageEntity
)
throws
ServiceException
{
messageController
.
sendBroadcastMessage
(
messageEntity
);
return
Response
.
status
(
Response
.
Status
.
CREATED
).
build
();
}
}
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