Commit 06ddc00b authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Fixed to let owners and admins fields be optional. JM-92


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@758 b35dd754-fafc-0310-a699-88a17e54d16e
parent 230bca9e
...@@ -333,6 +333,7 @@ public class IQOwnerHandler { ...@@ -333,6 +333,7 @@ public class IQOwnerHandler {
// Get the new list of admins // Get the new list of admins
field = completedForm.getField("muc#roomconfig_roomadmins"); field = completedForm.getField("muc#roomconfig_roomadmins");
boolean adminsSent = field != null;
List<String> admins = new ArrayList<String>(); List<String> admins = new ArrayList<String>();
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
...@@ -343,6 +344,7 @@ public class IQOwnerHandler { ...@@ -343,6 +344,7 @@ public class IQOwnerHandler {
// Get the new list of owners // Get the new list of owners
field = completedForm.getField("muc#roomconfig_roomowners"); field = completedForm.getField("muc#roomconfig_roomowners");
boolean ownersSent = field != null;
List<String> owners = new ArrayList<String>(); List<String> owners = new ArrayList<String>();
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
...@@ -352,7 +354,7 @@ public class IQOwnerHandler { ...@@ -352,7 +354,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 (ownersSent && owners.isEmpty()) {
throw new ConflictException(); throw new ConflictException();
} }
...@@ -482,26 +484,27 @@ public class IQOwnerHandler { ...@@ -482,26 +484,27 @@ public class IQOwnerHandler {
presences.addAll(room.addOwners(owners, senderRole)); presences.addAll(room.addOwners(owners, senderRole));
presences.addAll(room.addAdmins(admins, senderRole)); presences.addAll(room.addAdmins(admins, senderRole));
if (ownersSent) {
// Change the affiliation to "member" for the current owners that won't be neither // Change the affiliation to "member" for the current owners that won't be neither
// owner nor admin // owner nor admin (if the form included the owners field)
List ownersToRemove = new ArrayList(room.owners); List<String> ownersToRemove = new ArrayList<String>(room.owners);
ownersToRemove.removeAll(admins); ownersToRemove.removeAll(admins);
ownersToRemove.removeAll(owners); ownersToRemove.removeAll(owners);
String jid; for (String jid : ownersToRemove) {
for (Iterator it = ownersToRemove.iterator(); it.hasNext();) {
jid = (String)it.next();
presences.addAll(room.addMember(jid, null, senderRole)); presences.addAll(room.addMember(jid, null, senderRole));
} }
}
if (adminsSent) {
// Change the affiliation to "member" for the current admins that won't be neither // Change the affiliation to "member" for the current admins that won't be neither
// owner nor admin // owner nor admin (if the form included the admins field)
List adminsToRemove = new ArrayList(room.admins); List<String> adminsToRemove = new ArrayList<String>(room.admins);
adminsToRemove.removeAll(admins); adminsToRemove.removeAll(admins);
adminsToRemove.removeAll(owners); adminsToRemove.removeAll(owners);
for (Iterator it = adminsToRemove.iterator(); it.hasNext();) { for (String jid : adminsToRemove) {
jid = (String)it.next();
presences.addAll(room.addMember(jid, null, senderRole)); presences.addAll(room.addMember(jid, null, senderRole));
} }
}
// 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
......
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