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
687f633c
Commit
687f633c
authored
Apr 19, 2016
by
Florian Sailer
Committed by
daryl herzmann
Apr 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Occupants endpoint for restAPI (#580)
* Added occupants endpoint to restAPI plugin
parent
a4462425
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
167 additions
and
0 deletions
+167
-0
.gitignore
.gitignore
+1
-0
readme.html
src/plugins/restAPI/readme.html
+55
-0
MUCRoomController.java
...re/openfire/plugin/rest/controller/MUCRoomController.java
+32
-0
OccupantEntities.java
...oftware/openfire/plugin/rest/entity/OccupantEntities.java
+27
-0
OccupantEntity.java
...esoftware/openfire/plugin/rest/entity/OccupantEntity.java
+43
-0
MUCRoomService.java
...software/openfire/plugin/rest/service/MUCRoomService.java
+9
-0
No files found.
.gitignore
View file @
687f633c
...
...
@@ -20,3 +20,4 @@ out/
# Ignore Netbeans project files
nbproject/
nbbuild/
/bin/
src/plugins/restAPI/readme.html
View file @
687f633c
...
...
@@ -1360,6 +1360,11 @@ body.pdf{font-family:"DejaVu Sans"}body.pdf code,body.pdf pre{font-family:"DejaV
<li><a
href=
"#examples-17"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#retrieve-chat-room-occupants"
>
Retrieve chat room occupants
</a><ul>
<li><a
href=
"#possible-parameters-get-occupants"
>
Possible parameters
</a></li>
<li><a
href=
"#examples-get-occupants"
>
Examples
</a></li>
</ul>
</li>
<li><a
href=
"#create-a-chat-room"
>
Create a chat room
</a><ul>
<li><a
href=
"#possible-parameters-17"
>
Possible parameters
</a></li>
<li><a
href=
"#xml-examples-1"
>
XML Examples
</a></li>
...
...
@@ -3023,6 +3028,56 @@ Payload Example 1 (required parameters):</p>
<h2
id=
"retrieve-chat-room-occupants"
>
Retrieve chat room occupants
</h2>
<p>
Endpoint to get all occupants (all roles / affiliations) of a specified room.
</p>
<blockquote>
<p><strong>
GET
</strong>
/chatrooms/{roomName}/occupants
</p>
</blockquote>
<p><strong>
Payload:
</strong>
none
<br>
<strong>
Return value:
</strong>
Occupants
</p>
<h3
id=
"possible-parameters-get-occupants"
>
Possible parameters
</h3>
<table>
<thead>
<tr>
<th>
Parameter
</th>
<th>
Parameter Type
</th>
<th>
Description
</th>
<th>
Default value
</th>
</tr>
</thead>
<tbody><tr>
<td>
roomname
</td>
<td>
@Path
</td>
<td>
Exact room name
</td>
<td></td>
</tr>
<tr>
<td>
servicename
</td>
<td>
@QueryParam
</td>
<td>
The name of the Group Chat Service
</td>
<td>
conference
</td>
</tr>
</tbody></table>
<h3
id=
"examples-get-occupants"
>
Examples
</h3>
<blockquote>
<p><strong>
Header:
</strong>
Authorization: Basic YWRtaW46MTIzNDU=
</p>
<p><strong>
GET
</strong>
<a
href=
"http://example.org:9090/plugins/restapi/v1/chatrooms/room1/participants"
>
http://example.org:9090/plugins/restapi/v1/chatrooms/room1/occupants
</a></p>
</blockquote>
<h2
id=
"create-a-chat-room"
>
Create a chat room
</h2>
<p>
Endpoint to create a new chat room.
</p>
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java
View file @
687f633c
...
...
@@ -12,6 +12,8 @@ import org.jivesoftware.openfire.cluster.ClusterManager;
import
org.jivesoftware.openfire.plugin.rest.entity.MUCChannelType
;
import
org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntities
;
import
org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntity
;
import
org.jivesoftware.openfire.plugin.rest.entity.OccupantEntities
;
import
org.jivesoftware.openfire.plugin.rest.entity.OccupantEntity
;
import
org.jivesoftware.openfire.plugin.rest.entity.ParticipantEntities
;
import
org.jivesoftware.openfire.plugin.rest.entity.ParticipantEntity
;
import
org.jivesoftware.openfire.plugin.rest.exceptions.ExceptionType
;
...
...
@@ -308,6 +310,36 @@ public class MUCRoomController {
participantEntities
.
setParticipants
(
participants
);
return
participantEntities
;
}
/**
* Gets the room occupants.
*
* @param roomName
* the room name
* @param serviceName
* the service name
* @return the room occupants
*/
public
OccupantEntities
getRoomOccupants
(
String
roomName
,
String
serviceName
)
{
OccupantEntities
occupantEntities
=
new
OccupantEntities
();
List
<
OccupantEntity
>
occupants
=
new
ArrayList
<
OccupantEntity
>();
Collection
<
MUCRole
>
serverOccupants
=
XMPPServer
.
getInstance
().
getMultiUserChatManager
()
.
getMultiUserChatService
(
serviceName
).
getChatRoom
(
roomName
).
getOccupants
();
for
(
MUCRole
role
:
serverOccupants
)
{
OccupantEntity
occupantEntity
=
new
OccupantEntity
();
occupantEntity
.
setJid
(
role
.
getRoleAddress
().
toFullJID
());
occupantEntity
.
setRole
(
role
.
getRole
().
name
());
occupantEntity
.
setAffiliation
(
role
.
getAffiliation
().
name
());
occupants
.
add
(
occupantEntity
);
}
occupantEntities
.
setOccupants
(
occupants
);
return
occupantEntities
;
}
/**
* Convert to MUC room entity.
...
...
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/entity/OccupantEntities.java
0 → 100644
View file @
687f633c
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
entity
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
(
name
=
"occupants"
)
public
class
OccupantEntities
{
List
<
OccupantEntity
>
occupants
;
public
OccupantEntities
()
{
}
public
OccupantEntities
(
List
<
OccupantEntity
>
occupants
)
{
this
.
occupants
=
occupants
;
}
@XmlElement
(
name
=
"occupant"
)
public
List
<
OccupantEntity
>
getOccupants
()
{
return
occupants
;
}
public
void
setOccupants
(
List
<
OccupantEntity
>
occupants
)
{
this
.
occupants
=
occupants
;
}
}
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/entity/OccupantEntity.java
0 → 100644
View file @
687f633c
package
org
.
jivesoftware
.
openfire
.
plugin
.
rest
.
entity
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
(
name
=
"occupant"
)
public
class
OccupantEntity
{
private
String
jid
;
private
String
role
;
private
String
affiliation
;
public
OccupantEntity
()
{
}
@XmlElement
public
String
getJid
()
{
return
jid
;
}
public
void
setJid
(
String
jid
)
{
this
.
jid
=
jid
;
}
@XmlElement
public
String
getRole
()
{
return
role
;
}
public
void
setRole
(
String
role
)
{
this
.
role
=
role
;
}
@XmlElement
public
String
getAffiliation
()
{
return
affiliation
;
}
public
void
setAffiliation
(
String
affiliation
)
{
this
.
affiliation
=
affiliation
;
}
}
\ No newline at end of file
src/plugins/restAPI/src/java/org/jivesoftware/openfire/plugin/rest/service/MUCRoomService.java
View file @
687f633c
...
...
@@ -16,6 +16,7 @@ import javax.ws.rs.core.Response.Status;
import
org.jivesoftware.openfire.plugin.rest.entity.MUCChannelType
;
import
org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntities
;
import
org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntity
;
import
org.jivesoftware.openfire.plugin.rest.entity.OccupantEntities
;
import
org.jivesoftware.openfire.plugin.rest.entity.ParticipantEntities
;
import
org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException
;
import
org.jivesoftware.openfire.plugin.rest.controller.MUCRoomController
;
...
...
@@ -73,4 +74,12 @@ public class MUCRoomService {
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
)
{
return
MUCRoomController
.
getInstance
().
getRoomParticipants
(
roomName
,
serviceName
);
}
@GET
@Path
(
"/{roomName}/occupants"
)
@Produces
({
MediaType
.
APPLICATION_XML
,
MediaType
.
APPLICATION_JSON
})
public
OccupantEntities
getMUCRoomOccupants
(
@PathParam
(
"roomName"
)
String
roomName
,
@DefaultValue
(
"conference"
)
@QueryParam
(
"servicename"
)
String
serviceName
)
{
return
MUCRoomController
.
getInstance
().
getRoomOccupants
(
roomName
,
serviceName
);
}
}
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