Commit 4b2ba31f authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

1) Modified to ensure that if a conflict occurs an exception is thrown.

2) Removed UnauthorizedException as a thrown exception in methods that was being used for ACL.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@488 b35dd754-fafc-0310-a699-88a17e54d16e
parent 9c882c20
...@@ -63,7 +63,7 @@ public class IQOwnerHandler { ...@@ -63,7 +63,7 @@ public class IQOwnerHandler {
// Analyze the action to perform based on the included element // Analyze the action to perform based on the included element
Element formElement = element.element(QName.get("x", "jabber:x:data")); Element formElement = element.element(QName.get("x", "jabber:x:data"));
if (formElement != null) { if (formElement != null) {
handleDataFormElement(role, formElement, reply); handleDataFormElement(role, formElement);
} }
else { else {
Element destroyElement = element.element("destroy"); Element destroyElement = element.element("destroy");
...@@ -222,8 +222,7 @@ public class IQOwnerHandler { ...@@ -222,8 +222,7 @@ public class IQOwnerHandler {
if (jids.keySet().containsAll(room.owners)) { if (jids.keySet().containsAll(room.owners)) {
// Answer a conflict error if we are only removing ALL the owners // Answer a conflict error if we are only removing ALL the owners
if (!jids.containsValue("owner")) { if (!jids.containsValue("owner")) {
reply.setError(XMPPError.Code.CONFLICT); throw new ConflictException();
return;
} }
} }
...@@ -269,13 +268,8 @@ public class IQOwnerHandler { ...@@ -269,13 +268,8 @@ public class IQOwnerHandler {
} }
// Send the updated presences to the room occupants // Send the updated presences to the room occupants
try { for (Presence presence : presences) {
for (Presence presence : presences) { room.send(presence);
room.send(presence);
}
}
catch (UnauthorizedException e) {
// Do nothing
} }
} }
} }
...@@ -286,13 +280,10 @@ public class IQOwnerHandler { ...@@ -286,13 +280,10 @@ public class IQOwnerHandler {
* *
* @param senderRole the role of the user that sent the data form. * @param senderRole the role of the user that sent the data form.
* @param formElement the element that contains the data form specification. * @param formElement the element that contains the data form specification.
* @param reply the iq packet that will be sent back as a reply to the client's request.
* @throws UnauthorizedException If the user doesn't have permission to destroy/configure the
* room.
* @throws ForbiddenException if the user does not have enough privileges. * @throws ForbiddenException if the user does not have enough privileges.
*/ */
private void handleDataFormElement(MUCRole senderRole, Element formElement, IQ reply) private void handleDataFormElement(MUCRole senderRole, Element formElement)
throws UnauthorizedException, ForbiddenException, ConflictException { throws ForbiddenException, ConflictException {
XDataFormImpl completedForm = new XDataFormImpl(); XDataFormImpl completedForm = new XDataFormImpl();
completedForm.parse(formElement); completedForm.parse(formElement);
...@@ -310,7 +301,7 @@ public class IQOwnerHandler { ...@@ -310,7 +301,7 @@ public class IQOwnerHandler {
} }
// The owner is requesting a reserved room or is changing the current configuration // The owner is requesting a reserved room or is changing the current configuration
else { else {
processConfigurationForm(completedForm, senderRole, reply); processConfigurationForm(completedForm, senderRole);
} }
// If the room was locked, unlock it and send to the owner the "room is now unlocked" // If the room was locked, unlock it and send to the owner the "room is now unlocked"
// message // message
...@@ -320,7 +311,7 @@ public class IQOwnerHandler { ...@@ -320,7 +311,7 @@ public class IQOwnerHandler {
} }
} }
private void processConfigurationForm(XDataFormImpl completedForm, MUCRole senderRole, IQ reply) private void processConfigurationForm(XDataFormImpl completedForm, MUCRole senderRole)
throws ForbiddenException, ConflictException { throws ForbiddenException, ConflictException {
Iterator<String> values; Iterator<String> values;
String booleanValue; String booleanValue;
...@@ -349,8 +340,7 @@ public class IQOwnerHandler { ...@@ -349,8 +340,7 @@ public class IQOwnerHandler {
// Answer a conflic error if all the current owners will be removed // Answer a conflic error if all the current owners will be removed
if (owners.isEmpty()) { if (owners.isEmpty()) {
reply.setError(XMPPError.Code.CONFLICT); throw new ConflictException();
return;
} }
// Keep a registry of the updated presences // Keep a registry of the updated presences
...@@ -503,12 +493,7 @@ public class IQOwnerHandler { ...@@ -503,12 +493,7 @@ public class IQOwnerHandler {
// Destroy the room if the room is no longer persistent and there are no occupants in // Destroy the room if the room is no longer persistent and there are no occupants in
// the room // the room
if (!room.isPersistent() && room.getOccupantsCount() == 0) { if (!room.isPersistent() && room.getOccupantsCount() == 0) {
try { room.destroyRoom(null, null);
room.destroyRoom(null, null);
}
catch (UnauthorizedException e) {
// Do nothing.
}
} }
} }
...@@ -517,13 +502,8 @@ public class IQOwnerHandler { ...@@ -517,13 +502,8 @@ public class IQOwnerHandler {
} }
// Send the updated presences to the room occupants // Send the updated presences to the room occupants
try { for (Iterator it = presences.iterator(); it.hasNext();) {
for (Iterator it = presences.iterator(); it.hasNext();) { room.send((Presence)it.next());
room.send((Presence)it.next());
}
}
catch (UnauthorizedException e) {
// Do nothing
} }
} }
......
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