Commit de4835a7 authored by Roman S's avatar Roman S

Merge pull request #310 from sengels/group_management

Added: Handle group addition/removal per MUCRoom in REST API
parents a25b3993 04554eef
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<author>Roman Soldatow</author> <author>Roman Soldatow</author>
<version>1.1.6</version> <version>1.1.6</version>
<date>09/24/2015</date> <date>09/24/2015</date>
<minServerVersion>3.9.0</minServerVersion> <minServerVersion>3.10.0</minServerVersion>
<adminconsole> <adminconsole>
<tab id="tab-server"> <tab id="tab-server">
......
...@@ -23,6 +23,14 @@ public class MUCRoomAdminsService { ...@@ -23,6 +23,14 @@ public class MUCRoomAdminsService {
return Response.status(Status.CREATED).build(); return Response.status(Status.CREATED).build();
} }
@POST
@Path("/group/{groupname}")
public Response addMUCRoomAdminGroup(@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("groupname") String groupname, @PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().addAdmin(serviceName, roomName, groupname);
return Response.status(Status.CREATED).build();
}
@DELETE @DELETE
@Path("/{jid}") @Path("/{jid}")
public Response deleteMUCRoomAdmin(@PathParam("jid") String jid, public Response deleteMUCRoomAdmin(@PathParam("jid") String jid,
...@@ -31,4 +39,13 @@ public class MUCRoomAdminsService { ...@@ -31,4 +39,13 @@ public class MUCRoomAdminsService {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid); MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid);
return Response.status(Status.OK).build(); return Response.status(Status.OK).build();
} }
@DELETE
@Path("/group/{groupname}")
public Response deleteMUCRoomAdminGroup(@PathParam("groupname") String groupname,
@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, groupname);
return Response.status(Status.OK).build();
}
} }
...@@ -23,6 +23,14 @@ public class MUCRoomMembersService { ...@@ -23,6 +23,14 @@ public class MUCRoomMembersService {
return Response.status(Status.CREATED).build(); return Response.status(Status.CREATED).build();
} }
@POST
@Path("/group/{groupname}")
public Response addMUCRoomMemberGroup(@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("groupname") String groupname, @PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().addMember(serviceName, roomName, groupname);
return Response.status(Status.CREATED).build();
}
@DELETE @DELETE
@Path("/{jid}") @Path("/{jid}")
public Response deleteMUCRoomMember(@PathParam("jid") String jid, public Response deleteMUCRoomMember(@PathParam("jid") String jid,
...@@ -31,4 +39,13 @@ public class MUCRoomMembersService { ...@@ -31,4 +39,13 @@ public class MUCRoomMembersService {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid); MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid);
return Response.status(Status.OK).build(); return Response.status(Status.OK).build();
} }
@DELETE
@Path("/group/{groupname}")
public Response deleteMUCRoomMemberGroup(@PathParam("groupname") String groupname,
@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, groupname);
return Response.status(Status.OK).build();
}
} }
...@@ -23,6 +23,14 @@ public class MUCRoomOutcastsService { ...@@ -23,6 +23,14 @@ public class MUCRoomOutcastsService {
return Response.status(Status.CREATED).build(); return Response.status(Status.CREATED).build();
} }
@POST
@Path("/group/{groupname}")
public Response addMUCRoomOutcastGroup(@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("groupname") String groupname, @PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().addOutcast(serviceName, roomName, groupname);
return Response.status(Status.CREATED).build();
}
@DELETE @DELETE
@Path("/{jid}") @Path("/{jid}")
public Response deleteMUCRoomOutcast(@PathParam("jid") String jid, public Response deleteMUCRoomOutcast(@PathParam("jid") String jid,
...@@ -31,4 +39,13 @@ public class MUCRoomOutcastsService { ...@@ -31,4 +39,13 @@ public class MUCRoomOutcastsService {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid); MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid);
return Response.status(Status.OK).build(); return Response.status(Status.OK).build();
} }
@DELETE
@Path("/group/{groupname}")
public Response deleteMUCRoomOutcastGroup(@PathParam("groupname") String groupname,
@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, groupname);
return Response.status(Status.OK).build();
}
} }
...@@ -23,6 +23,14 @@ public class MUCRoomOwnersService { ...@@ -23,6 +23,14 @@ public class MUCRoomOwnersService {
return Response.status(Status.CREATED).build(); return Response.status(Status.CREATED).build();
} }
@POST
@Path("/group/{groupname}")
public Response addMUCRoomOwnerGroup(@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("groupname") String groupname, @PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().addOwner(serviceName, roomName, groupname);
return Response.status(Status.CREATED).build();
}
@DELETE @DELETE
@Path("/{jid}") @Path("/{jid}")
public Response deleteMUCRoomOwner(@PathParam("jid") String jid, public Response deleteMUCRoomOwner(@PathParam("jid") String jid,
...@@ -31,4 +39,13 @@ public class MUCRoomOwnersService { ...@@ -31,4 +39,13 @@ public class MUCRoomOwnersService {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid); MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, jid);
return Response.status(Status.OK).build(); return Response.status(Status.OK).build();
} }
@DELETE
@Path("/group/{groupname}")
public Response deleteMUCRoomOwnerGroup(@PathParam("groupname") String groupname,
@DefaultValue("conference") @QueryParam("servicename") String serviceName,
@PathParam("roomName") String roomName) throws ServiceException {
MUCRoomController.getInstance().deleteAffiliation(serviceName, roomName, groupname);
return Response.status(Status.OK).build();
}
} }
...@@ -10,6 +10,10 @@ import org.jivesoftware.openfire.plugin.rest.entity.UserEntity; ...@@ -10,6 +10,10 @@ import org.jivesoftware.openfire.plugin.rest.entity.UserEntity;
import org.jivesoftware.openfire.plugin.rest.entity.UserProperty; import org.jivesoftware.openfire.plugin.rest.entity.UserProperty;
import org.jivesoftware.openfire.user.User; import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserAlreadyExistsException; import org.jivesoftware.openfire.user.UserAlreadyExistsException;
import org.jivesoftware.openfire.group.Group;
import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.group.GroupJID;
import org.jivesoftware.openfire.group.GroupNotFoundException;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
// TODO: Auto-generated Javadoc // TODO: Auto-generated Javadoc
...@@ -89,6 +93,9 @@ public class UserUtils { ...@@ -89,6 +93,9 @@ public class UserUtils {
public static JID checkAndGetJID(String jid) { public static JID checkAndGetJID(String jid) {
if(isValidBareJid(jid)) { if(isValidBareJid(jid)) {
return new JID(jid); return new JID(jid);
} else if (isValidGroupName(jid)) {
GroupJID gjid = new GroupJID(jid);
return gjid.asBareJID();
} else { } else {
return XMPPServer.getInstance().createJID(jid, null); return XMPPServer.getInstance().createJID(jid, null);
} }
...@@ -109,4 +116,18 @@ public class UserUtils { ...@@ -109,4 +116,18 @@ public class UserUtils {
} }
return true; return true;
} }
/**
* Checks if this group exists.
*
* @param groupname The groupname as a string
* @return true, if the groupname exists
*/
public static boolean isValidGroupName(String groupname) {
try {
Group g = GroupManager.getInstance().getGroup(groupname);
} catch(GroupNotFoundException e) {
return false;
}
return true;
}
} }
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