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

Code modified to take advantage of Generics and new "for" format.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@223 b35dd754-fafc-0310-a699-88a17e54d16e
parent 97aea9cc
...@@ -125,7 +125,7 @@ public interface FormField { ...@@ -125,7 +125,7 @@ public interface FormField {
* *
* @return an Iterator for the default values or answered values of the question. * @return an Iterator for the default values or answered values of the question.
*/ */
public abstract Iterator getValues(); public abstract Iterator<String> getValues();
/** /**
* Returns an indicative of the format for the data to answer. Valid formats are: * Returns an indicative of the format for the data to answer. Valid formats are:
......
...@@ -36,8 +36,8 @@ public class XFormFieldImpl implements XMPPFragment, FormField { ...@@ -36,8 +36,8 @@ public class XFormFieldImpl implements XMPPFragment, FormField {
private String label; private String label;
private String variable; private String variable;
private String type; private String type;
private List options = new ArrayList(); private List<Option> options = new ArrayList<Option>();
private List values = new ArrayList(); private List<String> values = new ArrayList<String>();
private ConcurrentHashSet fragments = new ConcurrentHashSet(); private ConcurrentHashSet fragments = new ConcurrentHashSet();
public XFormFieldImpl() { public XFormFieldImpl() {
...@@ -90,18 +90,18 @@ public class XFormFieldImpl implements XMPPFragment, FormField { ...@@ -90,18 +90,18 @@ public class XFormFieldImpl implements XMPPFragment, FormField {
} }
// Loop through all the values and append them to the stream writer // Loop through all the values and append them to the stream writer
if (values.size() > 0) { if (values.size() > 0) {
Iterator valuesItr = getValues(); Iterator<String> valuesItr = getValues();
while (valuesItr.hasNext()) { while (valuesItr.hasNext()) {
xmlSerializer.writeStartElement("jabber:x:data", "value"); xmlSerializer.writeStartElement("jabber:x:data", "value");
xmlSerializer.writeCharacters((String)valuesItr.next()); xmlSerializer.writeCharacters(valuesItr.next());
xmlSerializer.writeEndElement(); xmlSerializer.writeEndElement();
} }
} }
// Loop through all the options and append them to the stream writer // Loop through all the options and append them to the stream writer
if (options.size() > 0) { if (options.size() > 0) {
Iterator optionsItr = getOptions(); Iterator<Option> optionsItr = getOptions();
while (optionsItr.hasNext()) { while (optionsItr.hasNext()) {
((Option)optionsItr.next()).send(xmlSerializer, version); (optionsItr.next()).send(xmlSerializer, version);
} }
} }
Iterator frags = fragments.iterator(); Iterator frags = fragments.iterator();
...@@ -132,16 +132,16 @@ public class XFormFieldImpl implements XMPPFragment, FormField { ...@@ -132,16 +132,16 @@ public class XFormFieldImpl implements XMPPFragment, FormField {
} }
// Loop through all the values and append them to the stream writer // Loop through all the values and append them to the stream writer
if (values.size() > 0) { if (values.size() > 0) {
Iterator valuesItr = getValues(); Iterator<String> valuesItr = getValues();
while (valuesItr.hasNext()) { while (valuesItr.hasNext()) {
field.addElement("value").addText((String)valuesItr.next()); field.addElement("value").addText(valuesItr.next());
} }
} }
// Loop through all the options and append them to the stream writer // Loop through all the options and append them to the stream writer
if (options.size() > 0) { if (options.size() > 0) {
Iterator optionsItr = getOptions(); Iterator<Option> optionsItr = getOptions();
while (optionsItr.hasNext()) { while (optionsItr.hasNext()) {
field.add(((Option)optionsItr.next()).asXMLElement()); field.add((optionsItr.next()).asXMLElement());
} }
} }
...@@ -161,8 +161,8 @@ public class XFormFieldImpl implements XMPPFragment, FormField { ...@@ -161,8 +161,8 @@ public class XFormFieldImpl implements XMPPFragment, FormField {
copy.required = this.required; copy.required = this.required;
copy.label = this.label; copy.label = this.label;
copy.type = this.type; copy.type = this.type;
copy.options = (List)((ArrayList)this.options).clone(); copy.options = (List<Option>)((ArrayList)this.options).clone();
copy.values = (List)((ArrayList)this.values).clone(); copy.values = (List<String>)((ArrayList)this.values).clone();
Iterator fragmentIter = getFragments(); Iterator fragmentIter = getFragments();
while (fragmentIter.hasNext()) { while (fragmentIter.hasNext()) {
...@@ -247,9 +247,9 @@ public class XFormFieldImpl implements XMPPFragment, FormField { ...@@ -247,9 +247,9 @@ public class XFormFieldImpl implements XMPPFragment, FormField {
return variable; return variable;
} }
public Iterator getValues() { public Iterator<String> getValues() {
synchronized (values) { synchronized (values) {
return Collections.unmodifiableList(new ArrayList(values)).iterator(); return Collections.unmodifiableList(new ArrayList<String>(values)).iterator();
} }
} }
...@@ -263,9 +263,9 @@ public class XFormFieldImpl implements XMPPFragment, FormField { ...@@ -263,9 +263,9 @@ public class XFormFieldImpl implements XMPPFragment, FormField {
* *
* @return Iterator for the available options. * @return Iterator for the available options.
*/ */
private Iterator getOptions() { private Iterator<Option> getOptions() {
synchronized (options) { synchronized (options) {
return Collections.unmodifiableList(new ArrayList(options)).iterator(); return Collections.unmodifiableList(new ArrayList<Option>(options)).iterator();
} }
} }
......
...@@ -256,19 +256,19 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -256,19 +256,19 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
registrationForm = new XDataFormImpl(); registrationForm = new XDataFormImpl();
registrationForm.parse(formElement); registrationForm.parse(formElement);
// Get the username sent in the form // Get the username sent in the form
Iterator values = registrationForm.getField("username").getValues(); Iterator<String> values = registrationForm.getField("username").getValues();
username = (values.hasNext() ? (String)values.next() : " "); username = (values.hasNext() ? values.next() : " ");
// Get the password sent in the form // Get the password sent in the form
field = registrationForm.getField("password"); field = registrationForm.getField("password");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
password = (values.hasNext() ? (String)values.next() : " "); password = (values.hasNext() ? values.next() : " ");
} }
// Get the email sent in the form // Get the email sent in the form
field = registrationForm.getField("email"); field = registrationForm.getField("email");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
email = (values.hasNext() ? (String)values.next() : " "); email = (values.hasNext() ? values.next() : " ");
} }
} }
else { else {
...@@ -316,21 +316,21 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -316,21 +316,21 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
} }
// Set and save the extra user info (e.g. Full name, name visible, etc.) // Set and save the extra user info (e.g. Full name, name visible, etc.)
if (newUser != null && registrationForm != null) { if (newUser != null && registrationForm != null) {
Iterator values; Iterator<String> values;
// Get the full name sent in the form // Get the full name sent in the form
field = registrationForm.getField("name"); field = registrationForm.getField("name");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
String name = (values.hasNext() ? (String)values.next() : " "); String name = (values.hasNext() ? values.next() : " ");
newUser.getInfo().setName(name); newUser.getInfo().setName(name);
} }
// Get the name visible flag sent in the form // Get the name visible flag sent in the form
values = registrationForm.getField("x-nameVisible").getValues(); values = registrationForm.getField("x-nameVisible").getValues();
String visible = (values.hasNext() ? (String)values.next() : "1"); String visible = (values.hasNext() ? values.next() : "1");
boolean nameVisible = ("1".equals(visible) ? true : false); boolean nameVisible = ("1".equals(visible) ? true : false);
// Get the email visible flag sent in the form // Get the email visible flag sent in the form
values = registrationForm.getField("x-emailVisible").getValues(); values = registrationForm.getField("x-emailVisible").getValues();
visible = (values.hasNext() ? (String)values.next() : "0"); visible = (values.hasNext() ? values.next() : "0");
boolean emailVisible = ("1".equals(visible) ? true : false); boolean emailVisible = ("1".equals(visible) ? true : false);
// Save the extra user info // Save the extra user info
newUser.getInfo().setNameVisible(nameVisible); newUser.getInfo().setNameVisible(nameVisible);
......
...@@ -222,7 +222,7 @@ public interface MUCRoom extends ChatDeliverer { ...@@ -222,7 +222,7 @@ public interface MUCRoom extends ChatDeliverer {
* join the room. * join the room.
* @throws ForbiddenException If the user is not allowed to modify the owner list. * @throws ForbiddenException If the user is not allowed to modify the owner list.
*/ */
public List addOwner(String bareJID, MUCRole senderRole) throws ForbiddenException; public List<Presence> addOwner(String bareJID, MUCRole senderRole) throws ForbiddenException;
/** /**
* Adds a list of users to the list of owners. * Adds a list of users to the list of owners.
...@@ -233,7 +233,8 @@ public interface MUCRoom extends ChatDeliverer { ...@@ -233,7 +233,8 @@ public interface MUCRoom extends ChatDeliverer {
* join the room. * join the room.
* @throws ForbiddenException If the user is not allowed to modify the owner list. * @throws ForbiddenException If the user is not allowed to modify the owner list.
*/ */
public List addOwners(List newOwners, MUCRole senderRole) throws ForbiddenException; public List<Presence> addOwners(List<String> newOwners, MUCRole senderRole)
throws ForbiddenException;
/** /**
* Adds a list of users to the list of admins. * Adds a list of users to the list of admins.
...@@ -245,8 +246,8 @@ public interface MUCRoom extends ChatDeliverer { ...@@ -245,8 +246,8 @@ public interface MUCRoom extends ChatDeliverer {
* @throws ForbiddenException If the user is not allowed to modify the admin list. * @throws ForbiddenException If the user is not allowed to modify the admin list.
* @throws ConflictException If the room was going to lose all its owners. * @throws ConflictException If the room was going to lose all its owners.
*/ */
public List addAdmins(List newAdmins, MUCRole senderRole) throws ForbiddenException, public List<Presence> addAdmins(List<String> newAdmins, MUCRole senderRole)
ConflictException; throws ForbiddenException, ConflictException;
/** /**
* Adds a new user to the list of admins. * Adds a new user to the list of admins.
...@@ -258,7 +259,7 @@ public interface MUCRoom extends ChatDeliverer { ...@@ -258,7 +259,7 @@ public interface MUCRoom extends ChatDeliverer {
* @throws ForbiddenException If the user is not allowed to modify the admin list. * @throws ForbiddenException If the user is not allowed to modify the admin list.
* @throws ConflictException If the room was going to lose all its owners. * @throws ConflictException If the room was going to lose all its owners.
*/ */
public List addAdmin(String bareJID, MUCRole senderRole) throws ForbiddenException, public List<Presence> addAdmin(String bareJID, MUCRole senderRole) throws ForbiddenException,
ConflictException; ConflictException;
/** /**
...@@ -273,7 +274,7 @@ public interface MUCRoom extends ChatDeliverer { ...@@ -273,7 +274,7 @@ public interface MUCRoom extends ChatDeliverer {
* @throws ConflictException If the desired room nickname is already reserved for the room or if * @throws ConflictException If the desired room nickname is already reserved for the room or if
* the room was going to lose all its owners. * the room was going to lose all its owners.
*/ */
public List addMember(String bareJID, String nickname, MUCRole senderRole) public List<Presence> addMember(String bareJID, String nickname, MUCRole senderRole)
throws ForbiddenException, ConflictException; throws ForbiddenException, ConflictException;
/** /**
...@@ -288,7 +289,7 @@ public interface MUCRoom extends ChatDeliverer { ...@@ -288,7 +289,7 @@ public interface MUCRoom extends ChatDeliverer {
* @throws ForbiddenException If the user is not allowed to modify the outcast list. * @throws ForbiddenException If the user is not allowed to modify the outcast list.
* @throws ConflictException If the room was going to lose all its owners. * @throws ConflictException If the room was going to lose all its owners.
*/ */
public List addOutcast(String bareJID, String reason, MUCRole senderRole) public List<Presence> addOutcast(String bareJID, String reason, MUCRole senderRole)
throws NotAllowedException, ForbiddenException, ConflictException; throws NotAllowedException, ForbiddenException, ConflictException;
/** /**
...@@ -301,7 +302,7 @@ public interface MUCRoom extends ChatDeliverer { ...@@ -301,7 +302,7 @@ public interface MUCRoom extends ChatDeliverer {
* @throws ForbiddenException If the user is not allowed to modify the none list. * @throws ForbiddenException If the user is not allowed to modify the none list.
* @throws ConflictException If the room was going to lose all its owners. * @throws ConflictException If the room was going to lose all its owners.
*/ */
public List addNone(String bareJID, MUCRole senderRole) throws ForbiddenException, public List<Presence> addNone(String bareJID, MUCRole senderRole) throws ForbiddenException,
ConflictException; ConflictException;
/** /**
......
...@@ -102,8 +102,8 @@ public class IQAdminHandler { ...@@ -102,8 +102,8 @@ public class IQAdminHandler {
throw new ForbiddenException(); throw new ForbiddenException();
} }
String jid; String jid;
for (Iterator it = room.getOutcasts(); it.hasNext();) { for (Iterator<String> it = room.getOutcasts(); it.hasNext();) {
jid = (String)it.next(); jid = it.next();
metaData = new MetaDataFragment("http://jabber.org/protocol/muc#admin", metaData = new MetaDataFragment("http://jabber.org/protocol/muc#admin",
"item"); "item");
metaData.setProperty("item:affiliation", "outcast"); metaData.setProperty("item:affiliation", "outcast");
...@@ -123,15 +123,15 @@ public class IQAdminHandler { ...@@ -123,15 +123,15 @@ public class IQAdminHandler {
throw new ForbiddenException(); throw new ForbiddenException();
} }
String jid; String jid;
for (Iterator it = room.getMembers(); it.hasNext();) { for (Iterator<String> it = room.getMembers(); it.hasNext();) {
jid = (String)it.next(); jid = it.next();
metaData = new MetaDataFragment("http://jabber.org/protocol/muc#admin", metaData = new MetaDataFragment("http://jabber.org/protocol/muc#admin",
"item"); "item");
metaData.setProperty("item:affiliation", "member"); metaData.setProperty("item:affiliation", "member");
metaData.setProperty("item:jid", jid); metaData.setProperty("item:jid", jid);
try { try {
List roles = room.getOccupantsByBareJID(jid); List<MUCRole> roles = room.getOccupantsByBareJID(jid);
role = (MUCRole)roles.get(0); role = roles.get(0);
metaData.setProperty("item:role", role.getRoleAsString()); metaData.setProperty("item:role", role.getRoleAsString());
metaData.setProperty("item:nick", role.getNickname()); metaData.setProperty("item:nick", role.getNickname());
} }
...@@ -150,8 +150,8 @@ public class IQAdminHandler { ...@@ -150,8 +150,8 @@ public class IQAdminHandler {
&& MUCRole.OWNER != senderRole.getAffiliation()) { && MUCRole.OWNER != senderRole.getAffiliation()) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
for (Iterator roles = room.getModerators(); roles.hasNext();) { for (Iterator<MUCRole> roles = room.getModerators(); roles.hasNext();) {
role = (MUCRole)roles.next(); role = roles.next();
metaData = new MetaDataFragment("http://jabber.org/protocol/muc#admin", metaData = new MetaDataFragment("http://jabber.org/protocol/muc#admin",
"item"); "item");
metaData.setProperty("item:role", "moderator"); metaData.setProperty("item:role", "moderator");
...@@ -170,8 +170,8 @@ public class IQAdminHandler { ...@@ -170,8 +170,8 @@ public class IQAdminHandler {
if (MUCRole.MODERATOR != senderRole.getRole()) { if (MUCRole.MODERATOR != senderRole.getRole()) {
throw new ForbiddenException(); throw new ForbiddenException();
} }
for (Iterator roles = room.getParticipants(); roles.hasNext();) { for (Iterator<MUCRole> roles = room.getParticipants(); roles.hasNext();) {
role = (MUCRole)roles.next(); role = roles.next();
metaData = new MetaDataFragment("http://jabber.org/protocol/muc#admin", metaData = new MetaDataFragment("http://jabber.org/protocol/muc#admin",
"item"); "item");
metaData.setProperty("item:role", "participant"); metaData.setProperty("item:role", "participant");
...@@ -195,10 +195,11 @@ public class IQAdminHandler { ...@@ -195,10 +195,11 @@ public class IQAdminHandler {
String jid = null; String jid = null;
String nick; String nick;
String target = null; String target = null;
boolean hasAffiliation = ((Element) itemsList.get(0)).attributeValue("affiliation") != null; boolean hasAffiliation = ((Element) itemsList.get(0)).attributeValue("affiliation") !=
null;
// Keep a registry of the updated presences // Keep a registry of the updated presences
List presences = new ArrayList(itemsList.size()); List<Presence> presences = new ArrayList<Presence>(itemsList.size());
// Collect the new affiliations or roles for the specified jids // Collect the new affiliations or roles for the specified jids
for (Iterator items = itemsList.iterator(); items.hasNext();) { for (Iterator items = itemsList.iterator(); items.hasNext();) {
...@@ -288,8 +289,8 @@ public class IQAdminHandler { ...@@ -288,8 +289,8 @@ public class IQAdminHandler {
// Send the updated presences to the room occupants // Send the updated presences to the room occupants
try { try {
for (Iterator it = presences.iterator(); it.hasNext();) { for (Presence presence : presences) {
room.send((Presence)it.next()); room.send(presence);
} }
} }
catch (UnauthorizedException e) { catch (UnauthorizedException e) {
......
...@@ -151,7 +151,7 @@ public class IQMUCRegisterHandler extends IQHandler { ...@@ -151,7 +151,7 @@ public class IQMUCRegisterHandler extends IQHandler {
else if (IQ.SET.equals(packet.getType())) { else if (IQ.SET.equals(packet.getType())) {
try { try {
// Keep a registry of the updated presences // Keep a registry of the updated presences
List presences = new ArrayList(); List<Presence> presences = new ArrayList<Presence>();
reply = packet.createResult(); reply = packet.createResult();
XMPPFragment iq = packet.getChildFragment(); XMPPFragment iq = packet.getChildFragment();
...@@ -171,9 +171,9 @@ public class IQMUCRegisterHandler extends IQHandler { ...@@ -171,9 +171,9 @@ public class IQMUCRegisterHandler extends IQHandler {
XDataFormImpl registrationForm = new XDataFormImpl(); XDataFormImpl registrationForm = new XDataFormImpl();
registrationForm.parse(formElement); registrationForm.parse(formElement);
// Get the desired nickname sent in the form // Get the desired nickname sent in the form
Iterator values = registrationForm.getField("muc#register_roomnick") Iterator<String> values = registrationForm.getField("muc#register_roomnick")
.getValues(); .getValues();
String nickname = (values.hasNext() ? (String)values.next() : null); String nickname = (values.hasNext() ? values.next() : null);
// TODO The rest of the fields of the form are ignored. If we have a // TODO The rest of the fields of the form are ignored. If we have a
// requirement in the future where we need those fields we'll have to change // requirement in the future where we need those fields we'll have to change
...@@ -190,8 +190,8 @@ public class IQMUCRegisterHandler extends IQHandler { ...@@ -190,8 +190,8 @@ public class IQMUCRegisterHandler extends IQHandler {
} }
// Send the updated presences to the room occupants // Send the updated presences to the room occupants
try { try {
for (Iterator it = presences.iterator(); it.hasNext();) { for (Presence presence : presences) {
room.send((Presence)it.next()); room.send(presence);
} }
} }
catch (UnauthorizedException e) { catch (UnauthorizedException e) {
......
...@@ -127,8 +127,8 @@ public class IQOwnerHandler { ...@@ -127,8 +127,8 @@ public class IQOwnerHandler {
MetaDataFragment ownerMetaData; MetaDataFragment ownerMetaData;
String jid; String jid;
MUCRole role; MUCRole role;
for (Iterator owners = room.getOwners(); owners.hasNext();) { for (Iterator<String> owners = room.getOwners(); owners.hasNext();) {
jid = (String)owners.next(); jid = owners.next();
ownerMetaData = ownerMetaData =
new MetaDataFragment("http://jabber.org/protocol/muc#owner", new MetaDataFragment("http://jabber.org/protocol/muc#owner",
"item"); "item");
...@@ -136,8 +136,8 @@ public class IQOwnerHandler { ...@@ -136,8 +136,8 @@ public class IQOwnerHandler {
ownerMetaData.setProperty("item:jid", jid); ownerMetaData.setProperty("item:jid", jid);
// Add role and nick to the metadata if the user is in the room // Add role and nick to the metadata if the user is in the room
try { try {
List roles = room.getOccupantsByBareJID(jid); List<MUCRole> roles = room.getOccupantsByBareJID(jid);
role = (MUCRole)roles.get(0); role = roles.get(0);
ownerMetaData.setProperty("item:role", role.getRoleAsString()); ownerMetaData.setProperty("item:role", role.getRoleAsString());
ownerMetaData.setProperty("item:nick", role.getNickname()); ownerMetaData.setProperty("item:nick", role.getNickname());
} }
...@@ -155,8 +155,8 @@ public class IQOwnerHandler { ...@@ -155,8 +155,8 @@ public class IQOwnerHandler {
MetaDataFragment adminMetaData; MetaDataFragment adminMetaData;
String jid; String jid;
MUCRole role; MUCRole role;
for (Iterator admins = room.getAdmins(); admins.hasNext();) { for (Iterator<String> admins = room.getAdmins(); admins.hasNext();) {
jid = (String)admins.next(); jid = admins.next();
adminMetaData = adminMetaData =
new MetaDataFragment("http://jabber.org/protocol/muc#owner", new MetaDataFragment("http://jabber.org/protocol/muc#owner",
"item"); "item");
...@@ -164,8 +164,8 @@ public class IQOwnerHandler { ...@@ -164,8 +164,8 @@ public class IQOwnerHandler {
adminMetaData.setProperty("item:jid", jid); adminMetaData.setProperty("item:jid", jid);
// Add role and nick to the metadata if the user is in the room // Add role and nick to the metadata if the user is in the room
try { try {
List roles = room.getOccupantsByBareJID(jid); List<MUCRole> roles = room.getOccupantsByBareJID(jid);
role = (MUCRole)roles.get(0); role = roles.get(0);
adminMetaData.setProperty("item:role", role.getRoleAsString()); adminMetaData.setProperty("item:role", role.getRoleAsString());
adminMetaData.setProperty("item:nick", role.getNickname()); adminMetaData.setProperty("item:nick", role.getNickname());
} }
...@@ -185,7 +185,7 @@ public class IQOwnerHandler { ...@@ -185,7 +185,7 @@ public class IQOwnerHandler {
} }
else { else {
// The client is modifying the list of owners or admins // The client is modifying the list of owners or admins
Map jids = new HashMap(); Map<String,String> jids = new HashMap<String,String>();
String bareJID = null; String bareJID = null;
String nick; String nick;
// Collect the new affiliations for the specified jids // Collect the new affiliations for the specified jids
...@@ -210,7 +210,7 @@ public class IQOwnerHandler { ...@@ -210,7 +210,7 @@ public class IQOwnerHandler {
} }
// Keep a registry of the updated presences // Keep a registry of the updated presences
List presences = new ArrayList(jids.size()); List<Presence> presences = new ArrayList<Presence>(jids.size());
room.lock.readLock().lock(); room.lock.readLock().lock();
try { try {
...@@ -227,9 +227,9 @@ public class IQOwnerHandler { ...@@ -227,9 +227,9 @@ public class IQOwnerHandler {
room.lock.writeLock().lock(); room.lock.writeLock().lock();
try { try {
String targetAffiliation = null; String targetAffiliation = null;
for (Iterator it = jids.keySet().iterator(); it.hasNext();) { for (Iterator<String> it = jids.keySet().iterator(); it.hasNext();) {
bareJID = (String)it.next(); bareJID = it.next();
targetAffiliation = (String)jids.get(bareJID); targetAffiliation = jids.get(bareJID);
if ("owner".equals(targetAffiliation)) { if ("owner".equals(targetAffiliation)) {
// Add the new user as an owner of the room // Add the new user as an owner of the room
presences.addAll(room.addOwner(bareJID, senderRole)); presences.addAll(room.addOwner(bareJID, senderRole));
...@@ -259,8 +259,8 @@ public class IQOwnerHandler { ...@@ -259,8 +259,8 @@ public class IQOwnerHandler {
// Send the updated presences to the room occupants // Send the updated presences to the room occupants
try { try {
for (Iterator it = presences.iterator(); it.hasNext();) { for (Presence presence : presences) {
room.send((Presence)it.next()); room.send(presence);
} }
} }
catch (UnauthorizedException e) { catch (UnauthorizedException e) {
...@@ -311,14 +311,14 @@ public class IQOwnerHandler { ...@@ -311,14 +311,14 @@ public class IQOwnerHandler {
private void processConfigurationForm(XDataFormImpl completedForm, MUCRole senderRole, IQ reply) private void processConfigurationForm(XDataFormImpl completedForm, MUCRole senderRole, IQ reply)
throws ForbiddenException, ConflictException { throws ForbiddenException, ConflictException {
Iterator values; Iterator<String> values;
String booleanValue; String booleanValue;
List list; List list;
FormField field; FormField field;
// Get the new list of admins // Get the new list of admins
field = completedForm.getField("muc#roomconfig_roomadmins"); field = completedForm.getField("muc#roomconfig_roomadmins");
List admins = new ArrayList(); List<String> admins = new ArrayList<String>();
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
while (values.hasNext()) { while (values.hasNext()) {
...@@ -328,7 +328,7 @@ public class IQOwnerHandler { ...@@ -328,7 +328,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");
List owners = new ArrayList(); List<String> owners = new ArrayList<String>();
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
while (values.hasNext()) { while (values.hasNext()) {
...@@ -350,28 +350,26 @@ public class IQOwnerHandler { ...@@ -350,28 +350,26 @@ public class IQOwnerHandler {
field = completedForm.getField("muc#roomconfig_roomname"); field = completedForm.getField("muc#roomconfig_roomname");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
room.setNaturalLanguageName((values.hasNext() ? (String)values.next() : " ")); room.setNaturalLanguageName((values.hasNext() ? values.next() : " "));
} }
field = completedForm.getField("muc#roomconfig_roomdesc"); field = completedForm.getField("muc#roomconfig_roomdesc");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
room.setDescription((values.hasNext() ? (String)values.next() : " ")); room.setDescription((values.hasNext() ? values.next() : " "));
} }
field = completedForm.getField("muc#roomconfig_changesubject"); field = completedForm.getField("muc#roomconfig_changesubject");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? (String)values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
room.setCanOccupantsChangeSubject(("1".equals(booleanValue) ? true : false)); room.setCanOccupantsChangeSubject(("1".equals(booleanValue) ? true : false));
} }
field = completedForm.getField("muc#roomconfig_maxusers"); field = completedForm.getField("muc#roomconfig_maxusers");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
room room.setMaxUsers((values.hasNext() ? Integer.parseInt(values.next()) : 30));
.setMaxUsers((values.hasNext() ? Integer.parseInt((String) values.next())
: 30));
} }
field = completedForm.getField("muc#roomconfig_presencebroadcast"); field = completedForm.getField("muc#roomconfig_presencebroadcast");
...@@ -387,14 +385,14 @@ public class IQOwnerHandler { ...@@ -387,14 +385,14 @@ public class IQOwnerHandler {
field = completedForm.getField("muc#roomconfig_publicroom"); field = completedForm.getField("muc#roomconfig_publicroom");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? (String)values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
room.setPublicRoom(("1".equals(booleanValue) ? true : false)); room.setPublicRoom(("1".equals(booleanValue) ? true : false));
} }
field = completedForm.getField("muc#roomconfig_persistentroom"); field = completedForm.getField("muc#roomconfig_persistentroom");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? (String)values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
boolean isPersistent = ("1".equals(booleanValue) ? true : false); boolean isPersistent = ("1".equals(booleanValue) ? true : false);
// Delete the room from the DB if it's no longer persistent // Delete the room from the DB if it's no longer persistent
if (room.isPersistent() && !isPersistent) { if (room.isPersistent() && !isPersistent) {
...@@ -406,35 +404,35 @@ public class IQOwnerHandler { ...@@ -406,35 +404,35 @@ public class IQOwnerHandler {
field = completedForm.getField("muc#roomconfig_moderatedroom"); field = completedForm.getField("muc#roomconfig_moderatedroom");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? (String)values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
room.setModerated(("1".equals(booleanValue) ? true : false)); room.setModerated(("1".equals(booleanValue) ? true : false));
} }
field = completedForm.getField("muc#roomconfig_inviteonly"); field = completedForm.getField("muc#roomconfig_inviteonly");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? (String)values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
room.setInvitationRequiredToEnter(("1".equals(booleanValue) ? true : false)); room.setInvitationRequiredToEnter(("1".equals(booleanValue) ? true : false));
} }
field = completedForm.getField("muc#roomconfig_allowinvites"); field = completedForm.getField("muc#roomconfig_allowinvites");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? (String)values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
room.setCanOccupantsInvite(("1".equals(booleanValue) ? true : false)); room.setCanOccupantsInvite(("1".equals(booleanValue) ? true : false));
} }
field = completedForm.getField("muc#roomconfig_passwordprotectedroom"); field = completedForm.getField("muc#roomconfig_passwordprotectedroom");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? (String)values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
boolean isPasswordProtected = "1".equals(booleanValue); boolean isPasswordProtected = "1".equals(booleanValue);
if (isPasswordProtected) { if (isPasswordProtected) {
// The room is password protected so set the new password // The room is password protected so set the new password
field = completedForm.getField("muc#roomconfig_roomsecret"); field = completedForm.getField("muc#roomconfig_roomsecret");
if (field != null) { if (field != null) {
values = completedForm.getField("muc#roomconfig_roomsecret").getValues(); values = completedForm.getField("muc#roomconfig_roomsecret").getValues();
room.setPassword((values.hasNext() ? (String)values.next() : null)); room.setPassword((values.hasNext() ? values.next() : null));
} }
} }
else { else {
...@@ -446,14 +444,14 @@ public class IQOwnerHandler { ...@@ -446,14 +444,14 @@ public class IQOwnerHandler {
field = completedForm.getField("muc#roomconfig_whois"); field = completedForm.getField("muc#roomconfig_whois");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? (String)values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
room.setCanAnyoneDiscoverJID(("anyone".equals(booleanValue) ? true : false)); room.setCanAnyoneDiscoverJID(("anyone".equals(booleanValue) ? true : false));
} }
field = completedForm.getField("muc#roomconfig_enablelogging"); field = completedForm.getField("muc#roomconfig_enablelogging");
if (field != null) { if (field != null) {
values = field.getValues(); values = field.getValues();
booleanValue = (values.hasNext() ? (String)values.next() : "1"); booleanValue = (values.hasNext() ? values.next() : "1");
room.setLogEnabled(("1".equals(booleanValue) ? true : false)); room.setLogEnabled(("1".equals(booleanValue) ? true : false));
} }
...@@ -565,14 +563,14 @@ public class IQOwnerHandler { ...@@ -565,14 +563,14 @@ public class IQOwnerHandler {
field = configurationForm.getField("muc#roomconfig_roomadmins"); field = configurationForm.getField("muc#roomconfig_roomadmins");
field.clearValues(); field.clearValues();
for (Iterator it = room.getAdmins(); it.hasNext();) { for (Iterator<String> it = room.getAdmins(); it.hasNext();) {
field.addValue((String)it.next()); field.addValue(it.next());
} }
field = configurationForm.getField("muc#roomconfig_roomowners"); field = configurationForm.getField("muc#roomconfig_roomowners");
field.clearValues(); field.clearValues();
for (Iterator it = room.getOwners(); it.hasNext();) { for (Iterator<String> it = room.getOwners(); it.hasNext();) {
field.addValue((String)it.next()); field.addValue(it.next());
} }
} }
finally { finally {
......
...@@ -237,26 +237,26 @@ class MUCPersistentRoomSurrogate implements MUCRoom, Cacheable { ...@@ -237,26 +237,26 @@ class MUCPersistentRoomSurrogate implements MUCRoom, Cacheable {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public List addOwner(String bareJID, MUCRole sendRole) throws ForbiddenException { public List<Presence> addOwner(String bareJID, MUCRole sendRole) throws ForbiddenException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public List addAdmin(String bareJID, MUCRole sendRole) throws ForbiddenException, public List<Presence> addAdmin(String bareJID, MUCRole sendRole) throws ForbiddenException,
ConflictException { ConflictException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public List addMember(String bareJID, String nickname, MUCRole sendRole) public List<Presence> addMember(String bareJID, String nickname, MUCRole sendRole)
throws ForbiddenException, ConflictException { throws ForbiddenException, ConflictException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public List addOutcast(String bareJID, String reason, MUCRole sendRole) public List<Presence> addOutcast(String bareJID, String reason, MUCRole sendRole)
throws NotAllowedException, ForbiddenException, ConflictException { throws NotAllowedException, ForbiddenException, ConflictException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public List addNone(String bareJID, MUCRole sendRole) throws ForbiddenException, public List<Presence> addNone(String bareJID, MUCRole sendRole) throws ForbiddenException,
ConflictException { ConflictException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
...@@ -470,12 +470,13 @@ class MUCPersistentRoomSurrogate implements MUCRoom, Cacheable { ...@@ -470,12 +470,13 @@ class MUCPersistentRoomSurrogate implements MUCRoom, Cacheable {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public List addAdmins(List newAdmins, MUCRole sendRole) throws ForbiddenException, public List<Presence> addAdmins(List<String> newAdmins, MUCRole sendRole)
ConflictException { throws ForbiddenException, ConflictException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public List addOwners(List newOwners, MUCRole sendRole) throws ForbiddenException { public List<Presence> addOwners(List<String> newOwners, MUCRole sendRole)
throws ForbiddenException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
......
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