Commit 6c1db772 authored by Patrick R. Spendrin's avatar Patrick R. Spendrin

Handle group addition/removal per MUCRoom

Since 3.10.0 OF-179 (https://igniterealtime.org/issues/browse/OF-179) has
been implemented. This patch makes it possible to use the restAPI for
that.
parent a25b3993
...@@ -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,
......
...@@ -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