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,25 +484,26 @@ public class IQOwnerHandler { ...@@ -482,25 +484,26 @@ 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));
// Change the affiliation to "member" for the current owners that won't be neither if (ownersSent) {
// owner nor admin // Change the affiliation to "member" for the current owners that won't be neither
List ownersToRemove = new ArrayList(room.owners); // owner nor admin (if the form included the owners field)
ownersToRemove.removeAll(admins); List<String> ownersToRemove = new ArrayList<String>(room.owners);
ownersToRemove.removeAll(owners); ownersToRemove.removeAll(admins);
String jid; ownersToRemove.removeAll(owners);
for (Iterator it = ownersToRemove.iterator(); it.hasNext();) { for (String jid : ownersToRemove) {
jid = (String)it.next(); presences.addAll(room.addMember(jid, null, senderRole));
presences.addAll(room.addMember(jid, null, senderRole)); }
} }
// Change the affiliation to "member" for the current admins that won't be neither if (adminsSent) {
// owner nor admin // Change the affiliation to "member" for the current admins that won't be neither
List adminsToRemove = new ArrayList(room.admins); // owner nor admin (if the form included the admins field)
adminsToRemove.removeAll(admins); List<String> adminsToRemove = new ArrayList<String>(room.admins);
adminsToRemove.removeAll(owners); adminsToRemove.removeAll(admins);
for (Iterator it = adminsToRemove.iterator(); it.hasNext();) { adminsToRemove.removeAll(owners);
jid = (String)it.next(); for (String jid : adminsToRemove) {
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
......
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