*/
private void processConfigurationForm(DataForm completedForm, MUCRole senderRole)
throws ForbiddenException, ConflictException {
List<String> values;
String booleanValue;
FormField field;
// Get the new list of admins
field = completedForm.getField("muc#roomconfig_roomadmins");
boolean adminsSent = field != null;
List<String> admins = new ArrayList<String>();
if (field != null) {
admins.addAll(field.getValues());
}
// Get the new list of owners
field = completedForm.getField("muc#roomconfig_roomowners");
boolean ownersSent = field != null;
List<String> owners = new ArrayList<String>();
if (field != null) {
owners.addAll(field.getValues());
}
// Answer a conflic error if all the current owners will be removed
if (ownersSent && owners.isEmpty()) {
throw new ConflictException();
}
// Keep a registry of the updated presences
List<Presence> presences = new ArrayList<Presence>(admins.size() + owners.size());
field = completedForm.getField("muc#roomconfig_roomname");
if (field != null) {
final String value = field.getFirstValue();
room.setNaturalLanguageName((value != null ? value : " "));
}
field = completedForm.getField("muc#roomconfig_roomdesc");
if (field != null) {
final String value = field.getFirstValue();
room.setDescription((value != null ? value : " "));
}
field = completedForm.getField("muc#roomconfig_changesubject");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
room.setCanOccupantsChangeSubject(("1".equals(booleanValue)));
}
field = completedForm.getField("muc#roomconfig_maxusers");
if (field != null) {
final String value = field.getFirstValue();
room.setMaxUsers((value != null ? Integer.parseInt(value) : 30));
}
field = completedForm.getField("muc#roomconfig_presencebroadcast");
if (field != null) {
values = new ArrayList<String>(field.getValues());
room.setRolesToBroadcastPresence(values);
}
field = completedForm.getField("muc#roomconfig_publicroom");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
room.setPublicRoom(("1".equals(booleanValue)));
}
field = completedForm.getField("muc#roomconfig_persistentroom");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
boolean isPersistent = ("1".equals(booleanValue));
// Delete the room from the DB if it's no longer persistent
if (room.isPersistent() && !isPersistent) {
MUCPersistenceManager.deleteFromDB(room);
}
room.setPersistent(isPersistent);
}
field = completedForm.getField("muc#roomconfig_moderatedroom");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
room.setModerated(("1".equals(booleanValue)));
}
field = completedForm.getField("muc#roomconfig_membersonly");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
presences.addAll(room.setMembersOnly(("1".equals(booleanValue))));
}
field = completedForm.getField("muc#roomconfig_allowinvites");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
room.setCanOccupantsInvite(("1".equals(booleanValue)));
}
field = completedForm.getField("muc#roomconfig_passwordprotectedroom");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
boolean isPasswordProtected = "1".equals(booleanValue);
if (isPasswordProtected) {
// The room is password protected so set the new password
field = completedForm.getField("muc#roomconfig_roomsecret");
if (field != null) {
final String secret = completedForm.getField("muc#roomconfig_roomsecret").getFirstValue();
room.setPassword(secret);
}
}
else {
// The room is not password protected so remove any previous password
room.setPassword(null);
}
}
field = completedForm.getField("muc#roomconfig_whois");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
room.setCanAnyoneDiscoverJID(("anyone".equals(booleanValue)));
}
field = completedForm.getField("muc#roomconfig_enablelogging");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
room.setLogEnabled(("1".equals(booleanValue)));
}
field = completedForm.getField("x-muc#roomconfig_reservednick");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
room.setLoginRestrictedToNickname(("1".equals(booleanValue)));
}
field = completedForm.getField("x-muc#roomconfig_canchangenick");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
room.setChangeNickname(("1".equals(booleanValue)));
}
field = completedForm.getField("x-muc#roomconfig_registration");
if (field != null) {
final String value = field.getFirstValue();
booleanValue = ((value != null ? value : "1"));
room.setRegistrationEnabled(("1".equals(booleanValue)));
}
// Update the modification date to reflect the last time when the room's configuration