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
757bb674
Commit
757bb674
authored
Sep 24, 2015
by
daryl herzmann
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #292 from Redor/master
Updated the REST API plugin to 1.1.6
parents
6f732813
c6435b62
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
276 additions
and
52 deletions
+276
-52
changelog.html
src/plugins/restAPI/changelog.html
+6
-0
plugin.xml
src/plugins/restAPI/plugin.xml
+2
-2
readme.html
src/plugins/restAPI/readme.html
+193
-48
UserServiceController.java
...penfire/plugin/rest/controller/UserServiceController.java
+37
-0
RESTExceptionMapper.java
.../openfire/plugin/rest/exceptions/RESTExceptionMapper.java
+21
-1
GroupService.java
...vesoftware/openfire/plugin/rest/service/GroupService.java
+1
-1
UserGroupService.java
...ftware/openfire/plugin/rest/service/UserGroupService.java
+16
-0
No files found.
src/plugins/restAPI/changelog.html
View file @
757bb674
...
@@ -44,6 +44,12 @@
...
@@ -44,6 +44,12 @@
REST API Plugin Changelog
REST API Plugin Changelog
</h1>
</h1>
<p><b>
1.1.6
</b>
-- September 24th, 2015
</p>
<ul>
<li>
Added: Endpoints to add / remove a user from a user group
</li>
<li>
Fixed: Error response in JSON format
</li>
</ul>
<p><b>
1.1.5
</b>
-- September 1st, 2015
</p>
<p><b>
1.1.5
</b>
-- September 1st, 2015
</p>
<ul>
<ul>
<li>
Added: Send broadcast message to all online users
</li>
<li>
Added: Send broadcast message to all online users
</li>
...
...
src/plugins/restAPI/plugin.xml
View file @
757bb674
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
<name>
REST API
</name>
<name>
REST API
</name>
<description>
Allows administration over a RESTful API.
</description>
<description>
Allows administration over a RESTful API.
</description>
<author>
Roman Soldatow
</author>
<author>
Roman Soldatow
</author>
<version>
1.1.
5
</version>
<version>
1.1.
6
</version>
<date>
09/
01
/2015
</date>
<date>
09/
24
/2015
</date>
<minServerVersion>
3.9.0
</minServerVersion>
<minServerVersion>
3.9.0
</minServerVersion>
<adminconsole>
<adminconsole>
...
...
src/plugins/restAPI/readme.html
View file @
757bb674
This diff is collapsed.
Click to expand it.
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/controller/UserServiceController.java
View file @
757bb674
...
@@ -395,6 +395,25 @@ public class UserServiceController {
...
@@ -395,6 +395,25 @@ public class UserServiceController {
}
}
}
}
/**
* Adds the user to group.
*
* @param username the username
* @param groupName the group name
* @throws ServiceException the service exception
*/
public
void
addUserToGroup
(
String
username
,
String
groupName
)
throws
ServiceException
{
Group
group
=
null
;
try
{
group
=
GroupManager
.
getInstance
().
getGroup
(
groupName
);
}
catch
(
GroupNotFoundException
e
)
{
// Create this group
group
=
GroupController
.
getInstance
().
createGroup
(
new
GroupEntity
(
groupName
,
""
));
}
group
.
getMembers
().
add
(
server
.
createJID
(
username
,
null
));
}
/**
/**
* Delete user from groups.
* Delete user from groups.
*
*
...
@@ -420,6 +439,24 @@ public class UserServiceController {
...
@@ -420,6 +439,24 @@ public class UserServiceController {
}
}
}
}
/**
* Delete user from group.
*
* @param username the username
* @param groupName the group name
* @throws ServiceException the service exception
*/
public
void
deleteUserFromGroup
(
String
username
,
String
groupName
)
throws
ServiceException
{
Group
group
=
null
;
try
{
group
=
GroupManager
.
getInstance
().
getGroup
(
groupName
);
}
catch
(
GroupNotFoundException
e
)
{
throw
new
ServiceException
(
"Could not find group"
,
groupName
,
ExceptionType
.
GROUP_NOT_FOUND
,
Response
.
Status
.
NOT_FOUND
,
e
);
}
group
.
getMembers
().
remove
(
server
.
createJID
(
username
,
null
));
}
/**
/**
* Gets the user entities by property key and or value.
* Gets the user entities by property key and or value.
*
*
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/exceptions/RESTExceptionMapper.java
View file @
757bb674
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
exceptions
;
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
exceptions
;
import
java.util.List
;
import
javax.ws.rs.core.Context
;
import
javax.ws.rs.core.HttpHeaders
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response.ResponseBuilder
;
import
javax.ws.rs.ext.ExceptionMapper
;
import
javax.ws.rs.ext.ExceptionMapper
;
import
javax.ws.rs.ext.Provider
;
import
javax.ws.rs.ext.Provider
;
...
@@ -17,6 +22,11 @@ public class RESTExceptionMapper implements ExceptionMapper<ServiceException> {
...
@@ -17,6 +22,11 @@ public class RESTExceptionMapper implements ExceptionMapper<ServiceException> {
/** The log. */
/** The log. */
private
static
Logger
LOG
=
LoggerFactory
.
getLogger
(
RESTExceptionMapper
.
class
);
private
static
Logger
LOG
=
LoggerFactory
.
getLogger
(
RESTExceptionMapper
.
class
);
/** The headers. */
@Context
private
HttpHeaders
headers
;
/**
/**
* Instantiates a new REST exception mapper.
* Instantiates a new REST exception mapper.
*/
*/
...
@@ -36,7 +46,17 @@ public class RESTExceptionMapper implements ExceptionMapper<ServiceException> {
...
@@ -36,7 +46,17 @@ public class RESTExceptionMapper implements ExceptionMapper<ServiceException> {
LOG
.
error
(
LOG
.
error
(
exception
.
getException
()
+
": "
+
exception
.
getMessage
()
+
" with ressource "
exception
.
getException
()
+
": "
+
exception
.
getMessage
()
+
" with ressource "
+
exception
.
getRessource
(),
exception
.
getException
());
+
exception
.
getRessource
(),
exception
.
getException
());
return
Response
.
status
(
exception
.
getStatus
()).
entity
(
errorResponse
).
type
(
MediaType
.
APPLICATION_XML
).
build
();
ResponseBuilder
responseBuilder
=
Response
.
status
(
exception
.
getStatus
()).
entity
(
errorResponse
);
List
<
MediaType
>
accepts
=
headers
.
getAcceptableMediaTypes
();
if
(
accepts
!=
null
&&
accepts
.
size
()
>
0
)
{
MediaType
mediaType
=
accepts
.
get
(
0
);
responseBuilder
=
responseBuilder
.
type
(
mediaType
);
}
else
{
responseBuilder
=
responseBuilder
.
type
(
headers
.
getMediaType
());
}
return
responseBuilder
.
build
();
}
}
}
}
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/service/GroupService.java
View file @
757bb674
...
@@ -54,7 +54,7 @@ public class GroupService {
...
@@ -54,7 +54,7 @@ public class GroupService {
@DELETE
@DELETE
@Path
(
"/{groupName}"
)
@Path
(
"/{groupName}"
)
public
Response
delete
UserFromGroups
(
@PathParam
(
"groupName"
)
String
groupName
)
throws
ServiceException
{
public
Response
delete
Group
(
@PathParam
(
"groupName"
)
String
groupName
)
throws
ServiceException
{
groupController
.
deleteGroup
(
groupName
);
groupController
.
deleteGroup
(
groupName
);
return
Response
.
status
(
Response
.
Status
.
OK
).
build
();
return
Response
.
status
(
Response
.
Status
.
OK
).
build
();
}
}
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/service/UserGroupService.java
View file @
757bb674
...
@@ -37,6 +37,22 @@ public class UserGroupService {
...
@@ -37,6 +37,22 @@ public class UserGroupService {
return
Response
.
status
(
Response
.
Status
.
CREATED
).
build
();
return
Response
.
status
(
Response
.
Status
.
CREATED
).
build
();
}
}
@POST
@Path
(
"/{groupName}"
)
public
Response
addUserToGroup
(
@PathParam
(
"username"
)
String
username
,
@PathParam
(
"groupName"
)
String
groupName
)
throws
ServiceException
{
plugin
.
addUserToGroup
(
username
,
groupName
);
return
Response
.
status
(
Response
.
Status
.
CREATED
).
build
();
}
@DELETE
@Path
(
"/{groupName}"
)
public
Response
deleteUserFromGroup
(
@PathParam
(
"username"
)
String
username
,
@PathParam
(
"groupName"
)
String
groupName
)
throws
ServiceException
{
plugin
.
deleteUserFromGroup
(
username
,
groupName
);
return
Response
.
status
(
Response
.
Status
.
OK
).
build
();
}
@DELETE
@DELETE
public
Response
deleteUserFromGroups
(
@PathParam
(
"username"
)
String
username
,
UserGroupsEntity
userGroupsEntity
)
public
Response
deleteUserFromGroups
(
@PathParam
(
"username"
)
String
username
,
UserGroupsEntity
userGroupsEntity
)
throws
ServiceException
{
throws
ServiceException
{
...
...
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