Commit c9a5e6ab authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Modified error code to return when max number of occupants has been reached. JM-264


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1277 b35dd754-fafc-0310-a699-88a17e54d16e
parent 69f2cb7c
...@@ -187,26 +187,27 @@ public interface MUCRoom { ...@@ -187,26 +187,27 @@ public interface MUCRoom {
/** /**
* Joins the room using the given nickname. * Joins the room using the given nickname.
* *
* @param nickname The nickname the user wants to use in the chatroom. * @param nickname The nickname the user wants to use in the chatroom.
* @param password The password provided by the user to enter the chatroom or null if none. * @param password The password provided by the user to enter the chatroom or null if none.
* @param historyRequest The amount of history that the user request or null meaning default. * @param historyRequest The amount of history that the user request or null meaning default.
* @param user The user joining. * @param user The user joining.
* @param presence The presence sent by the user to join the room. * @param presence The presence sent by the user to join the room.
* @return The role created for the user. * @return The role created for the user.
* @throws UnauthorizedException If the user doesn't have permision to join the room. * @throws UnauthorizedException If the user doesn't have permision to join the room.
* @throws UserAlreadyExistsException If the nickname is already taken. * @throws UserAlreadyExistsException If the nickname is already taken.
* @throws RoomLockedException If the user is trying to join a locked room. * @throws RoomLockedException If the user is trying to join a locked room.
* @throws ForbiddenException If the user is an outcast. * @throws ForbiddenException If the user is an outcast.
* @throws RegistrationRequiredException If the user is not a member of a members-only room. * @throws RegistrationRequiredException If the user is not a member of a members-only room.
* @throws NotAllowedException If the user is has exceded the max number of occupants. * @throws ConflictException If another user attempts to join the room with a
* @throws ConflictException If another user attempts to join the room with a nickname reserved * nickname reserved by the first user.
* by the first user. * @throws ServiceUnavailableException If the user cannot join the room since the max number
* of users has been reached.
*/ */
MUCRole joinRoom(String nickname, String password, HistoryRequest historyRequest, MUCUser user, MUCRole joinRoom(String nickname, String password, HistoryRequest historyRequest, MUCUser user,
Presence presence) throws UnauthorizedException, UserAlreadyExistsException, Presence presence) throws UnauthorizedException, UserAlreadyExistsException,
RoomLockedException, ForbiddenException, RegistrationRequiredException, RoomLockedException, ForbiddenException, RegistrationRequiredException,
NotAllowedException, ConflictException; ConflictException, ServiceUnavailableException;
/** /**
* Remove a member from the chat room. * Remove a member from the chat room.
......
...@@ -390,13 +390,13 @@ public class MUCRoomImpl implements MUCRoom { ...@@ -390,13 +390,13 @@ public class MUCRoomImpl implements MUCRoom {
public MUCRole joinRoom(String nickname, String password, HistoryRequest historyRequest, public MUCRole joinRoom(String nickname, String password, HistoryRequest historyRequest,
MUCUser user, Presence presence) throws UnauthorizedException, MUCUser user, Presence presence) throws UnauthorizedException,
UserAlreadyExistsException, RoomLockedException, ForbiddenException, UserAlreadyExistsException, RoomLockedException, ForbiddenException,
RegistrationRequiredException, NotAllowedException, ConflictException { RegistrationRequiredException, ConflictException, ServiceUnavailableException {
MUCRoleImpl joinRole = null; MUCRoleImpl joinRole = null;
lock.writeLock().lock(); lock.writeLock().lock();
try { try {
// If the room has a limit of max user then check if the limit was reached // If the room has a limit of max user then check if the limit has been reached
if (isDestroyed || (getMaxUsers() > 0 && getOccupantsCount() >= getMaxUsers())) { if (isDestroyed || (getMaxUsers() > 0 && getOccupantsCount() >= getMaxUsers())) {
throw new NotAllowedException(); throw new ServiceUnavailableException();
} }
boolean isOwner = owners.contains(user.getAddress().toBareJID()); boolean isOwner = owners.contains(user.getAddress().toBareJID());
// If the room is locked and this user is not an owner raise a RoomLocked exception // If the room is locked and this user is not an owner raise a RoomLocked exception
......
...@@ -378,8 +378,8 @@ public class MUCUserImpl implements MUCUser { ...@@ -378,8 +378,8 @@ public class MUCUserImpl implements MUCUser {
catch (UnauthorizedException e) { catch (UnauthorizedException e) {
sendErrorPacket(packet, PacketError.Condition.not_authorized); sendErrorPacket(packet, PacketError.Condition.not_authorized);
} }
catch (NotAllowedException e) { catch (ServiceUnavailableException e) {
sendErrorPacket(packet, PacketError.Condition.not_allowed); sendErrorPacket(packet, PacketError.Condition.service_unavailable);
} }
catch (UserAlreadyExistsException e) { catch (UserAlreadyExistsException e) {
sendErrorPacket(packet, PacketError.Condition.conflict); sendErrorPacket(packet, PacketError.Condition.conflict);
......
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