Commit 90501d8a authored by daryl herzmann's avatar daryl herzmann

Merge pull request #171 from Redor/openfire

REST API plugin version 1.0.0
parents 9c69db39 4c2804b6
......@@ -44,6 +44,12 @@
REST API Plugin Changelog
</h1>
<p><b>1.0.0</b> -- February 3rd, 2015</p>
<ul>
<li>UserService plugin and MUC Service plugin are merged to the REST API plugin.</li>
<li>Extended REST API with JSON data format.</li>
</ul>
<p><b>0.1.0</b> -- November 14th, 2014</p>
<ul>
<li>Initial release of REST API Plugin with possibility to manage system properties.</li>
......
......@@ -5,8 +5,8 @@
<name>REST API</name>
<description>Allows administration over a RESTful API.</description>
<author>Roman Soldatow</author>
<version>0.1.0</version>
<date>11/14/2014</date>
<version>1.0.0</version>
<date>02/03/2015</date>
<minServerVersion>3.9.0</minServerVersion>
<adminconsole>
......
This diff is collapsed.
......@@ -46,6 +46,11 @@ public class AuthFilter implements ContainerRequestFilter {
throw new WebApplicationException(Status.FORBIDDEN);
}
// To be backwards compatible to userservice 1.*
if ("restapi/v1/userservice".equals(containerRequest.getPath())) {
return containerRequest;
}
if (!plugin.getAllowedIPs().isEmpty()) {
// Get client's IP address
String ipAddress = httpRequest.getHeader("x-forwarded-for");
......
package org.jivesoftware.openfire.plugin.rest.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.Response;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.plugin.rest.exceptions.ExceptionType;
import org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException;
/**
* The Class PropertyDAO.
*/
public class PropertyDAO {
/** The Constant LOAD_PROPERTY. */
private final static String LOAD_PROPERTY = "SELECT username FROM ofUserProp WHERE name=? AND propValue=?";
/** The Constant LOAD_PROPERTY_BY_KEY. */
private final static String LOAD_PROPERTY_BY_KEY = "SELECT username FROM ofUserProp WHERE name=?";
/**
* Gets the username by property key and or value.
*
* @param propertyName
* the property name
* @param propertyValue
* the property value (can be null)
* @return the username by property
* @throws ServiceException
* the service exception
*/
public static List<String> getUsernameByProperty(String propertyName, String propertyValue) throws ServiceException {
List<String> usernames = new ArrayList<String>();
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
// Load property by key and value
if (propertyValue != null) {
pstmt = con.prepareStatement(LOAD_PROPERTY);
pstmt.setString(1, propertyName);
pstmt.setString(2, propertyValue);
} else {
// Load property by key
pstmt = con.prepareStatement(LOAD_PROPERTY_BY_KEY);
pstmt.setString(1, propertyName);
}
rs = pstmt.executeQuery();
while (rs.next()) {
usernames.add(rs.getString(1));
}
} catch (SQLException sqle) {
throw new ServiceException("Could not get username by property", propertyName,
ExceptionType.PROPERTY_NOT_FOUND, Response.Status.NOT_FOUND, sqle);
} finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
return usernames;
}
}
package org.jivesoftware.openfire.plugin.rest.entity;
public final class MUCChannelType {
public static final String PUBLIC = "public";
public static final String ALL = "all";
private MUCChannelType() {
}
}
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 = "chatRooms")
public class MUCRoomEntities {
List<MUCRoomEntity> mucRooms;
public MUCRoomEntities() {
}
public MUCRoomEntities(List<MUCRoomEntity> mucRooms) {
this.mucRooms = mucRooms;
}
@XmlElement(name = "chatRoom")
public List<MUCRoomEntity> getMucRooms() {
return mucRooms;
}
public void setMucRooms(List<MUCRoomEntity> mucRooms) {
this.mucRooms = mucRooms;
}
}
package org.jivesoftware.openfire.plugin.rest.entity;
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "chatRoom")
@XmlType(propOrder = { "roomName", "naturalName", "description", "password", "subject", "creationDate",
"modificationDate", "maxUsers", "persistent", "publicRoom", "registrationEnabled", "canAnyoneDiscoverJID",
"canOccupantsChangeSubject", "canOccupantsInvite", "canChangeNickname", "logEnabled",
"loginRestrictedToNickname", "membersOnly", "moderated", "broadcastPresenceRoles", "owners", "admins",
"members", "outcasts" })
public class MUCRoomEntity {
private String roomName;
private String description;
private String password;
private String subject;
private String naturalName;
private int maxUsers;
private Date creationDate;
private Date modificationDate;
private boolean persistent;
private boolean publicRoom;
private boolean registrationEnabled;
private boolean canAnyoneDiscoverJID;
private boolean canOccupantsChangeSubject;
private boolean canOccupantsInvite;
private boolean canChangeNickname;
private boolean logEnabled;
private boolean loginRestrictedToNickname;
private boolean membersOnly;
private boolean moderated;
private List<String> broadcastPresenceRoles;
private List<String> owners;
private List<String> admins;
private List<String> members;
private List<String> outcasts;
public MUCRoomEntity() {
}
public MUCRoomEntity(String naturalName, String roomName, String description) {
this.naturalName = naturalName;
this.roomName = roomName;
this.description = description;
}
@XmlElement
public String getNaturalName() {
return naturalName;
}
public void setNaturalName(String naturalName) {
this.naturalName = naturalName;
}
@XmlElement
public String getRoomName() {
return roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
@XmlElement
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@XmlElement
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@XmlElement
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
@XmlElement
public int getMaxUsers() {
return maxUsers;
}
public void setMaxUsers(int maxUsers) {
this.maxUsers = maxUsers;
}
@XmlElement
public Date getCreationDate() {
return creationDate;
}
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
@XmlElement
public Date getModificationDate() {
return modificationDate;
}
public void setModificationDate(Date modificationDate) {
this.modificationDate = modificationDate;
}
@XmlElement
public boolean isPersistent() {
return persistent;
}
public void setPersistent(boolean persistent) {
this.persistent = persistent;
}
@XmlElement
public boolean isPublicRoom() {
return publicRoom;
}
public void setPublicRoom(boolean publicRoom) {
this.publicRoom = publicRoom;
}
@XmlElement
public boolean isRegistrationEnabled() {
return registrationEnabled;
}
public void setRegistrationEnabled(boolean registrationEnabled) {
this.registrationEnabled = registrationEnabled;
}
@XmlElement
public boolean isCanAnyoneDiscoverJID() {
return canAnyoneDiscoverJID;
}
public void setCanAnyoneDiscoverJID(boolean canAnyoneDiscoverJID) {
this.canAnyoneDiscoverJID = canAnyoneDiscoverJID;
}
@XmlElement
public boolean isCanOccupantsChangeSubject() {
return canOccupantsChangeSubject;
}
public void setCanOccupantsChangeSubject(boolean canOccupantsChangeSubject) {
this.canOccupantsChangeSubject = canOccupantsChangeSubject;
}
@XmlElement
public boolean isCanOccupantsInvite() {
return canOccupantsInvite;
}
public void setCanOccupantsInvite(boolean canOccupantsInvite) {
this.canOccupantsInvite = canOccupantsInvite;
}
public void setBroadcastPresenceRoles(List<String> broadcastPresenceRoles) {
this.broadcastPresenceRoles = broadcastPresenceRoles;
}
@XmlElement
public boolean isCanChangeNickname() {
return canChangeNickname;
}
public void setCanChangeNickname(boolean canChangeNickname) {
this.canChangeNickname = canChangeNickname;
}
@XmlElement
public boolean isLogEnabled() {
return logEnabled;
}
public void setLogEnabled(boolean logEnabled) {
this.logEnabled = logEnabled;
}
@XmlElement
public boolean isLoginRestrictedToNickname() {
return loginRestrictedToNickname;
}
public void setLoginRestrictedToNickname(boolean loginRestrictedToNickname) {
this.loginRestrictedToNickname = loginRestrictedToNickname;
}
@XmlElement
public boolean isMembersOnly() {
return membersOnly;
}
public void setMembersOnly(boolean membersOnly) {
this.membersOnly = membersOnly;
}
@XmlElement
public boolean isModerated() {
return moderated;
}
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.plugin.rest.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.plugin.rest.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
package org.jivesoftware.openfire.plugin.rest.entity;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* The Class RosterEntities.
*/
@XmlRootElement(name = "roster")
public class RosterEntities {
/** The roster. */
List<RosterItemEntity> roster;
/**
* Instantiates a new roster entities.
*/
public RosterEntities() {
}
/**
* Instantiates a new roster entities.
*
* @param roster
* the roster
*/
public RosterEntities(List<RosterItemEntity> roster) {
this.roster = roster;
}
/**
* Gets the roster.
*
* @return the roster
*/
@XmlElement(name = "rosterItem")
public List<RosterItemEntity> getRoster() {
return roster;
}
/**
* Sets the roster.
*
* @param roster
* the new roster
*/
public void setRoster(List<RosterItemEntity> roster) {
this.roster = roster;
}
}
package org.jivesoftware.openfire.plugin.rest.entity;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* The Class RosterItemEntity.
*/
@XmlRootElement(name = "rosterItem")
@XmlType(propOrder = { "jid", "nickname", "subscriptionType", "groups" })
public class RosterItemEntity {
/** The jid. */
private String jid;
/** The nickname. */
private String nickname;
/** The subscription type. */
private int subscriptionType;
/** The groups. */
private List<String> groups;
/**
* Instantiates a new roster item entity.
*/
public RosterItemEntity() {
}
/**
* Instantiates a new roster item entity.
*
* @param jid
* the jid
* @param nickname
* the nickname
* @param subscriptionType
* the subscription type
*/
public RosterItemEntity(String jid, String nickname, int subscriptionType) {
this.jid = jid;
this.nickname = nickname;
this.subscriptionType = subscriptionType;
}
/**
* Gets the jid.
*
* @return the jid
*/
@XmlElement
public String getJid() {
return jid;
}
/**
* Sets the jid.
*
* @param jid
* the new jid
*/
public void setJid(String jid) {
this.jid = jid;
}
/**
* Gets the nickname.
*
* @return the nickname
*/
@XmlElement
public String getNickname() {
return nickname;
}
/**
* Sets the nickname.
*
* @param nickname
* the new nickname
*/
public void setNickname(String nickname) {
this.nickname = nickname;
}
/**
* Gets the subscription type.
*
* @return the subscription type
*/
@XmlElement
public int getSubscriptionType() {
return subscriptionType;
}
/**
* Sets the subscription type.
*
* @param subscriptionType
* the new subscription type
*/
public void setSubscriptionType(int subscriptionType) {
this.subscriptionType = subscriptionType;
}
/**
* Gets the groups.
*
* @return the groups
*/
@XmlElement(name = "group")
@XmlElementWrapper(name = "groups")
public List<String> getGroups() {
return groups;
}
/**
* Sets the groups.
*
* @param groups
* the new groups
*/
public void setGroups(List<String> groups) {
this.groups = groups;
}
}
package org.jivesoftware.openfire.plugin.rest.entity;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* The Class UserEntities.
*/
@XmlRootElement(name = "users")
public class UserEntities {
/** The users. */
List<UserEntity> users;
/**
* Instantiates a new user entities.
*/
public UserEntities() {
}
/**
* Instantiates a new user entities.
*
* @param users
* the users
*/
public UserEntities(List<UserEntity> users) {
this.users = users;
}
/**
* Gets the users.
*
* @return the users
*/
@XmlElement(name = "user")
public List<UserEntity> getUsers() {
return users;
}
/**
* Sets the users.
*
* @param users
* the new users
*/
public void setUsers(List<UserEntity> users) {
this.users = users;
}
}
package org.jivesoftware.openfire.plugin.rest.entity;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* The Class UserEntity.
*/
@XmlRootElement(name = "user")
@XmlType(propOrder = { "username", "name", "email", "password", "properties" })
public class UserEntity {
/** The username. */
private String username;
/** The name. */
private String name;
/** The email. */
private String email;
/** The password. */
private String password;
/** The properties. */
private List<UserProperty> properties;
/**
* Instantiates a new user entity.
*/
public UserEntity() {
}
/**
* Instantiates a new user entity.
*
* @param username
* the username
* @param name
* the name
* @param email
* the email
*/
public UserEntity(String username, String name, String email) {
this.username = username;
this.name = name;
this.email = email;
}
/**
* Gets the username.
*
* @return the username
*/
@XmlElement
public String getUsername() {
return username;
}
/**
* Sets the username.
*
* @param username
* the new username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* Gets the name.
*
* @return the name
*/
@XmlElement
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name
* the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the email.
*
* @return the email
*/
@XmlElement
public String getEmail() {
return email;
}
/**
* Sets the email.
*
* @param email
* the new email
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Gets the password.
*
* @return the password
*/
public String getPassword() {
return password;
}
/**
* Sets the password.
*
* @param password
* the new password
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Gets the properties.
*
* @return the properties
*/
@XmlElement(name = "property")
@XmlElementWrapper(name = "properties")
public List<UserProperty> getProperties() {
return properties;
}
/**
* Sets the properties.
*
* @param properties
* the new properties
*/
public void setProperties(List<UserProperty> properties) {
this.properties = properties;
}
}
package org.jivesoftware.openfire.plugin.rest.entity;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* The Class UserGroupsEntity.
*/
@XmlRootElement(name = "groups")
public class UserGroupsEntity {
/** The group names. */
private List<String> groupNames;
/**
* Instantiates a new user groups entity.
*/
public UserGroupsEntity() {
}
/**
* Instantiates a new user groups entity.
*
* @param groupNames
* the group names
*/
public UserGroupsEntity(List<String> groupNames) {
this.groupNames = groupNames;
}
/**
* Gets the group names.
*
* @return the group names
*/
@XmlElement(name = "groupname")
public List<String> getGroupNames() {
return groupNames;
}
/**
* Sets the group names.
*
* @param groupNames
* the new group names
*/
public void setGroupNames(List<String> groupNames) {
this.groupNames = groupNames;
}
}
package org.jivesoftware.openfire.plugin.rest.entity;
import javax.xml.bind.annotation.XmlAttribute;
/**
* The Class UserProperty.
*/
public class UserProperty {
/** The key. */
private String key;
/** The value. */
private String value;
/**
* Instantiates a new user property.
*/
public UserProperty() {
}
/**
* Instantiates a new user property.
*
* @param key
* the key
* @param value
* the value
*/
public UserProperty(String key, String value) {
this.key = key;
this.value = value;
}
/**
* Gets the key.
*
* @return the key
*/
@XmlAttribute
public String getKey() {
return key;
}
/**
* Sets the key.
*
* @param key
* the new key
*/
public void setKey(String key) {
this.key = key;
}
/**
* Gets the value.
*
* @return the value
*/
@XmlAttribute
public String getValue() {
return value;
}
/**
* Sets the value.
*
* @param value
* the new value
*/
public void setValue(String value) {
this.value = value;
}
}
......@@ -4,11 +4,32 @@ package org.jivesoftware.openfire.plugin.rest.exceptions;
* The Class ExceptionType.
*/
public final class ExceptionType {
/** The Constant ILLEGAL_ARGUMENT_EXCEPTION. */
public static final String ILLEGAL_ARGUMENT_EXCEPTION = "IllegalArgumentException";
/** The Constant SHARED_GROUP_EXCEPTION. */
public static final String SHARED_GROUP_EXCEPTION = "SharedGroupException";
/** The Constant PROPERTY_NOT_FOUND. */
public static final String PROPERTY_NOT_FOUND = "PropertyNotFoundException";
/** The Constant ILLEGAL_ARGUMENT_EXCEPTION. */
public static final String ILLEGAL_ARGUMENT_EXCEPTION = "IllegalArgumentException";
/** The Constant USER_ALREADY_EXISTS_EXCEPTION. */
public static final String USER_ALREADY_EXISTS_EXCEPTION = "UserAlreadyExistsException";
/** The Constant USER_NOT_FOUND_EXCEPTION. */
public static final String USER_NOT_FOUND_EXCEPTION = "UserNotFoundException";
/** The Constant GROUP_ALREADY_EXISTS. */
public static final String GROUP_ALREADY_EXISTS = "GroupAlreadyExistsException";
/** The Constant GROUP_NOT_FOUND. */
public static final String GROUP_NOT_FOUND = "GroupNotFoundException";
/** The Constant ROOM_NOT_FOUND. */
public static final String ROOM_NOT_FOUND = "RoomNotFoundException";
/** The Constant NOT_ALLOWED. */
public static final String NOT_ALLOWED = "NotAllowedException";
/**
* Instantiates a new exception type.
......
package org.jivesoftware.openfire.plugin.rest;
package org.jivesoftware.openfire.plugin.rest.exceptions;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.jivesoftware.openfire.plugin.rest.exceptions.ErrorResponse;
import org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
package org.jivesoftware.openfire.plugin.rest;
package org.jivesoftware.openfire.plugin.rest.service;
import java.util.HashMap;
import java.util.Map;
......@@ -7,7 +7,7 @@ import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import org.jivesoftware.admin.AuthCheckFilter;
import org.jivesoftware.openfire.plugin.rest.service.RestAPIService;
import org.jivesoftware.openfire.plugin.rest.exceptions.RESTExceptionMapper;
import com.sun.jersey.api.core.PackagesResourceConfig;
import com.sun.jersey.spi.container.servlet.ServletContainer;
......@@ -53,6 +53,18 @@ public class JerseyWrapper extends ServletContainer {
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);
prc.getClasses().add(UserGroupService.class);
prc.getClasses().add(UserLockoutService.class);
prc.getClasses().add(RESTExceptionMapper.class);
}
......
package org.jivesoftware.openfire.plugin.rest.service;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException;
import org.jivesoftware.openfire.plugin.rest.controller.MUCRoomController;
@Path("restapi/v1/chatrooms/{roomName}/admins")
public class MUCRoomAdminsService {
@POST
@Path("/{jid}")
public Response addMUCRoomAdmin(@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("jid") String jid, @PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().addAdmin(serviceName, roomName, jid);
return Response.status(Status.CREATED).build();
}
@DELETE
@Path("/{jid}")
public Response deleteMUCRoomAdmin(@PathParam("jid") String jid,
@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid);
return Response.status(Status.OK).build();
}
}
package org.jivesoftware.openfire.plugin.rest.service;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException;
import org.jivesoftware.openfire.plugin.rest.controller.MUCRoomController;
@Path("restapi/v1/chatrooms/{roomName}/members")
public class MUCRoomMembersService {
@POST
@Path("/{jid}")
public Response addMUCRoomMember(@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("jid") String jid, @PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().addMember(serviceName, roomName, jid);
return Response.status(Status.CREATED).build();
}
@DELETE
@Path("/{jid}")
public Response deleteMUCRoomMember(@PathParam("jid") String jid,
@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid);
return Response.status(Status.OK).build();
}
}
This diff is collapsed.
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