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
c6435b62
Commit
c6435b62
authored
Sep 16, 2015
by
Roman S
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the REST API plugin to 1.1.6
Fixed: the problem with wrong media type by error
parent
ed012548
Changes
7
Expand all
Hide 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 @
c6435b62
...
...
@@ -44,6 +44,12 @@
REST API Plugin Changelog
</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>
<ul>
<li>
Added: Send broadcast message to all online users
</li>
...
...
src/plugins/restAPI/plugin.xml
View file @
c6435b62
...
...
@@ -5,8 +5,8 @@
<name>
REST API
</name>
<description>
Allows administration over a RESTful API.
</description>
<author>
Roman Soldatow
</author>
<version>
1.1.
5
</version>
<date>
09/
01
/2015
</date>
<version>
1.1.
6
</version>
<date>
09/
24
/2015
</date>
<minServerVersion>
3.9.0
</minServerVersion>
<adminconsole>
...
...
src/plugins/restAPI/readme.html
View file @
c6435b62
This diff is collapsed.
Click to expand it.
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/controller/UserServiceController.java
View file @
c6435b62
...
...
@@ -394,6 +394,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.
...
...
@@ -419,6 +438,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.
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/exceptions/RESTExceptionMapper.java
View file @
c6435b62
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.Response
;
import
javax.ws.rs.core.Response.ResponseBuilder
;
import
javax.ws.rs.ext.ExceptionMapper
;
import
javax.ws.rs.ext.Provider
;
...
...
@@ -16,6 +21,11 @@ public class RESTExceptionMapper implements ExceptionMapper<ServiceException> {
/** The log. */
private
static
Logger
LOG
=
LoggerFactory
.
getLogger
(
RESTExceptionMapper
.
class
);
/** The headers. */
@Context
private
HttpHeaders
headers
;
/**
* Instantiates a new REST exception mapper.
...
...
@@ -36,7 +46,17 @@ public class RESTExceptionMapper implements ExceptionMapper<ServiceException> {
LOG
.
error
(
exception
.
getException
()
+
": "
+
exception
.
getMessage
()
+
" with ressource "
+
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 @
c6435b62
...
...
@@ -54,7 +54,7 @@ public class GroupService {
@DELETE
@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
);
return
Response
.
status
(
Response
.
Status
.
OK
).
build
();
}
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/service/UserGroupService.java
View file @
c6435b62
...
...
@@ -36,6 +36,22 @@ public class UserGroupService {
plugin
.
addUserToGroups
(
username
,
userGroupsEntity
);
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
public
Response
deleteUserFromGroups
(
@PathParam
(
"username"
)
String
username
,
UserGroupsEntity
userGroupsEntity
)
...
...
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