Commit a98343cc authored by Redor's avatar Redor

MUC Service Plugin 0.2.0

- Extended the service with /participants endpoint to get all room
participants
- Extended the muc service to manage chat room roles (owners, admins,
members, outcasts)
parent e0562d9f
......@@ -44,6 +44,12 @@
MUC Service Plugin Changelog
</h1>
<p><b>0.2.0</b> -- 07.07.2014</p>
<ul>
<li>Extended the service with /participants endpoint to get all room participants</li>
<li>Extended the muc service to manage chat room roles (owners, admins, members, outcasts)</li>
</ul>
<p><b>0.1.0</b> -- 23.06.2014</p>
<ul>
<li>Initial setup of MUC Service Plugin</li>
......
......@@ -5,7 +5,7 @@
<name>MUC Service</name>
<description>MUC administration over REST Interface</description>
<author>Roman Soldatow</author>
<version>0.1.0</version>
<date>23.06.2014</date>
<version>0.2.0</version>
<date>07.07.2014</date>
<minServerVersion>3.9.1</minServerVersion>
</plugin>
This diff is collapsed.
......@@ -35,6 +35,14 @@ public class MUCRoomEntity {
private List<String> broadcastPresenceRoles;
private List<String> owners;
private List<String> admins;
private List<String> members;
private List<String> outcasts;
public MUCRoomEntity() {
}
......@@ -170,12 +178,6 @@ public class MUCRoomEntity {
this.canOccupantsInvite = canOccupantsInvite;
}
@XmlElement(name = "broadcastPresenceRole")
@XmlElementWrapper(name = "broadcastPresenceRoles")
public List<String> getBroadcastPresenceRoles() {
return broadcastPresenceRoles;
}
public void setBroadcastPresenceRoles(List<String> broadcastPresenceRoles) {
this.broadcastPresenceRoles = broadcastPresenceRoles;
}
......@@ -224,4 +226,51 @@ public class MUCRoomEntity {
public void setModerated(boolean moderated) {
this.moderated = moderated;
}
@XmlElement(name = "broadcastPresenceRole")
@XmlElementWrapper(name = "broadcastPresenceRoles")
public List<String> getBroadcastPresenceRoles() {
return broadcastPresenceRoles;
}
@XmlElementWrapper(name = "owners")
@XmlElement(name = "owner")
public List<String> getOwners() {
return owners;
}
public void setOwners(List<String> owners) {
this.owners = owners;
}
@XmlElementWrapper(name = "members")
@XmlElement(name = "member")
public List<String> getMembers() {
return members;
}
public void setMembers(List<String> members) {
this.members = members;
}
@XmlElementWrapper(name = "outcasts")
@XmlElement(name = "outcast")
public List<String> getOutcasts() {
return outcasts;
}
public void setOutcasts(List<String> outcasts) {
this.outcasts = outcasts;
}
@XmlElementWrapper(name = "admins")
@XmlElement(name = "admin")
public List<String> getAdmins() {
return admins;
}
public void setAdmins(List<String> admins) {
this.admins = admins;
}
}
\ No newline at end of file
package org.jivesoftware.openfire.entity;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "participants")
public class ParticipantEntities {
List<ParticipantEntity> participants;
public ParticipantEntities() {
}
public ParticipantEntities(List<ParticipantEntity> participants) {
this.participants = participants;
}
@XmlElement(name = "participant")
public List<ParticipantEntity> getParticipants() {
return participants;
}
public void setParticipants(List<ParticipantEntity> participants) {
this.participants = participants;
}
}
package org.jivesoftware.openfire.entity;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "participant")
public class ParticipantEntity {
private String jid;
private String role;
private String affiliation;
public ParticipantEntity() {
}
@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
......@@ -14,14 +14,14 @@ import javax.ws.rs.core.MediaType;
import org.jivesoftware.openfire.entity.MUCChannelType;
import org.jivesoftware.openfire.entity.MUCRoomEntities;
import org.jivesoftware.openfire.entity.MUCRoomEntity;
import org.jivesoftware.openfire.entity.ParticipantEntities;
import org.jivesoftware.openfire.exception.MUCServiceException;
import org.jivesoftware.openfire.plugin.MUCRoomController;
@Path("mucservice")
@Path("mucservice/chatrooms")
public class MUCRoomService {
@GET
@Path("/chatrooms")
@Produces(MediaType.APPLICATION_XML)
public MUCRoomEntities getMUCRooms(@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@DefaultValue(MUCChannelType.PUBLIC) @QueryParam("type") String channelType,
......@@ -30,7 +30,7 @@ public class MUCRoomService {
}
@GET
@Path("/chatrooms/{roomName}")
@Path("/{roomName}")
@Produces(MediaType.APPLICATION_XML)
public MUCRoomEntity getMUCRoom(@PathParam("roomName") String roomName,
@DefaultValue("conference") @QueryParam("servicename") String serviceName) throws MUCServiceException {
......@@ -38,27 +38,31 @@ public class MUCRoomService {
}
@DELETE
@Path("/chatrooms/{roomName}")
@Path("/{roomName}")
public void deleteMUCRoom(@PathParam("roomName") String roomName,
@DefaultValue("conference") @QueryParam("servicename") String serviceName) throws MUCServiceException {
MUCRoomController.getInstance().deleteChatRoom(roomName, serviceName);
}
@POST
@Path("/chatrooms")
public void createMUCRoom(@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@DefaultValue("admin") @QueryParam("owner") String owner, MUCRoomEntity mucRoomEntity)
throws MUCServiceException {
MUCRoomController.getInstance().createChatRoom(serviceName, owner, mucRoomEntity);
MUCRoomEntity mucRoomEntity) throws MUCServiceException {
MUCRoomController.getInstance().createChatRoom(serviceName, mucRoomEntity);
}
@PUT
@Path("/chatrooms/{roomName}")
@Path("/{roomName}")
public void udpateMUCRoom(@PathParam("roomName") String roomName,
@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@DefaultValue("admin") @QueryParam("owner") String owner, MUCRoomEntity mucRoomEntity)
@DefaultValue("conference") @QueryParam("servicename") String serviceName, MUCRoomEntity mucRoomEntity)
throws MUCServiceException {
MUCRoomController.getInstance().updateChatRoom(roomName, serviceName, owner, mucRoomEntity);
MUCRoomController.getInstance().updateChatRoom(roomName, serviceName, mucRoomEntity);
}
@GET
@Path("/{roomName}/participants")
@Produces(MediaType.APPLICATION_XML)
public ParticipantEntities getMUCRoomParticipants(@PathParam("roomName") String roomName,
@DefaultValue("conference") @QueryParam("servicename") String serviceName) throws MUCServiceException {
return MUCRoomController.getInstance().getRoomParticipants(roomName, serviceName);
}
}
package org.jivesoftware.openfire.utils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.xmpp.packet.JID;
/**
* The Class MUCRoomUtils.
*/
public class MUCRoomUtils {
/**
* Instantiates a new MUC room utils.
*/
private MUCRoomUtils() {
throw new AssertionError();
}
/**
* Convert jids to string list.
*
* @param jids
* the jids
* @return the array list< string>
*/
public static ArrayList<String> convertJIDsToStringList(Collection<JID> jids) {
ArrayList<String> result = new ArrayList<String>();
for (JID jid : jids) {
result.add(jid.toBareJID());
}
return result;
}
/**
* Convert strings to jids.
*
* @param jids
* the jids
* @return the list<jid>
*/
public static List<JID> convertStringsToJIDs(List<String> jids) {
List<JID> result = new ArrayList<JID>();
for (String jidString : jids) {
result.add(new JID(jidString));
}
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment