Element result = reply.setChildElement("query", "http://jabber.org/protocol/muc#owner");
if ("owner".equals(affiliation)) {
// The client is requesting the list of owners
Element ownerMetaData;
MUCRole role;
for (String jid : room.getOwners()) {
ownerMetaData = result.addElement("item", "http://jabber.org/protocol/muc#owner");
ownerMetaData.addAttribute("affiliation", "owner");
ownerMetaData.addAttribute("jid", jid);
// Add role and nick to the metadata if the user is in the room
try {
List<MUCRole> roles = room.getOccupantsByBareJID(jid);
role = roles.get(0);
ownerMetaData.addAttribute("role", role.getRole().toString());
ownerMetaData.addAttribute("nick", role.getNickname());
}
catch (UserNotFoundException e) {
// Do nothing
}
}
} else if ("admin".equals(affiliation)) {
// The client is requesting the list of admins
Element adminMetaData;
MUCRole role;
for (String jid : room.getAdmins()) {
adminMetaData = result.addElement("item", "http://jabber.org/protocol/muc#owner");
adminMetaData.addAttribute("affiliation", "admin");
adminMetaData.addAttribute("jid", jid);
// Add role and nick to the metadata if the user is in the room
try {
List<MUCRole> roles = room.getOccupantsByBareJID(jid);
role = roles.get(0);
adminMetaData.addAttribute("role", role.getRole().toString());
adminMetaData.addAttribute("nick", role.getNickname());
}
catch (UserNotFoundException e) {
// Do nothing
}
}