Commit 6793c5d1 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Refactoring changes


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@612 b35dd754-fafc-0310-a699-88a17e54d16e
parent d3e9efe8
...@@ -145,63 +145,50 @@ public class IQOwnerHandler { ...@@ -145,63 +145,50 @@ public class IQOwnerHandler {
item = (Element)items.next(); item = (Element)items.next();
affiliation = item.attributeValue("affiliation"); affiliation = item.attributeValue("affiliation");
// Create the result that will hold an item for each owner or admin // Create the result that will hold an item for each owner or admin
MetaDataFragment result = new MetaDataFragment(DocumentHelper.createElement(QName Element result = reply.setChildElement("query", "http://jabber.org/protocol/muc#owner");
.get("query", "http://jabber.org/protocol/muc#owner")));
if ("owner".equals(affiliation)) { if ("owner".equals(affiliation)) {
// The client is requesting the list of owners // The client is requesting the list of owners
MetaDataFragment ownerMetaData; Element ownerMetaData;
MUCRole role; MUCRole role;
for (String jid : room.getOwners()) { for (String jid : room.getOwners()) {
ownerMetaData = ownerMetaData = result.addElement("item", "http://jabber.org/protocol/muc#owner");
new MetaDataFragment("http://jabber.org/protocol/muc#owner", ownerMetaData.addAttribute("affiliation", "owner");
"item"); ownerMetaData.addAttribute("jid", jid);
ownerMetaData.setProperty("item:affiliation", "owner");
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<MUCRole> roles = room.getOccupantsByBareJID(jid); List<MUCRole> roles = room.getOccupantsByBareJID(jid);
role = roles.get(0); role = roles.get(0);
ownerMetaData.setProperty("item:role", role.getRoleAsString()); ownerMetaData.addAttribute("role", role.getRoleAsString());
ownerMetaData.setProperty("item:nick", role.getNickname()); ownerMetaData.addAttribute("nick", role.getNickname());
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
// Do nothing // Do nothing
} }
// Add the item with the owner's information to the result
result.addFragment(ownerMetaData);
} }
// Add the result items to the reply
reply.addFragment(result);
} }
else if ("admin".equals(affiliation)) { else if ("admin".equals(affiliation)) {
// The client is requesting the list of admins // The client is requesting the list of admins
MetaDataFragment adminMetaData; Element adminMetaData;
MUCRole role; MUCRole role;
for (String jid : room.getAdmins()) { for (String jid : room.getAdmins()) {
adminMetaData = adminMetaData = result.addElement("item", "http://jabber.org/protocol/muc#owner");
new MetaDataFragment("http://jabber.org/protocol/muc#owner", adminMetaData.addAttribute("affiliation", "admin");
"item"); adminMetaData.addAttribute("jid", jid);
adminMetaData.setProperty("item:affiliation", "admin");
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<MUCRole> roles = room.getOccupantsByBareJID(jid); List<MUCRole> roles = room.getOccupantsByBareJID(jid);
role = roles.get(0); role = roles.get(0);
adminMetaData.setProperty("item:role", role.getRoleAsString()); adminMetaData.addAttribute("role", role.getRoleAsString());
adminMetaData.setProperty("item:nick", role.getNickname()); adminMetaData.addAttribute("nick", role.getNickname());
} }
catch (UserNotFoundException e) { catch (UserNotFoundException e) {
// Do nothing // Do nothing
} }
// Add the item with the admin's information to the result
result.addFragment(adminMetaData);
} }
// Add the result items to the reply
reply.addFragment(result);
} }
else { else {
reply.setError(XMPPError.Code.BAD_REQUEST); reply.setError(PacketError.Condition.bad_request);
} }
} }
} }
...@@ -265,8 +252,7 @@ public class IQOwnerHandler { ...@@ -265,8 +252,7 @@ public class IQOwnerHandler {
// If the user had an affiliation don't send an invitation. Otherwise // If the user had an affiliation don't send an invitation. Otherwise
// send an invitation if the room is members-only // send an invitation if the room is members-only
if (!hadAffiliation && room.isInvitationRequiredToEnter()) { if (!hadAffiliation && room.isInvitationRequiredToEnter()) {
room.sendInvitation(bareJID, null, senderRole, reply room.sendInvitation(new JID(bareJID), null, senderRole);
.getOriginatingSession());
} }
} }
else if ("none".equals(targetAffiliation)) { else if ("none".equals(targetAffiliation)) {
...@@ -739,7 +725,7 @@ public class IQOwnerHandler { ...@@ -739,7 +725,7 @@ public class IQOwnerHandler {
configurationForm.addField(field); configurationForm.addField(field);
// Create the probeResult and add the basic info together with the configuration form // Create the probeResult and add the basic info together with the configuration form
probeResult = new MetaDataFragment(element); probeResult = element;
probeResult.addFragment(configurationForm); probeResult.add(configurationForm.asXMLElement());
} }
} }
\ No newline at end of file
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