metaData = result.addElement("item", "http://jabber.org/protocol/muc#admin");
metaData.addAttribute("affiliation", "member");
metaData.addAttribute("jid", jid);
try {
List<MUCRole> roles = room.getOccupantsByBareJID(jid);
MUCRole role = roles.get(0);
metaData.addAttribute("role", role.getRole().toString());
metaData.addAttribute("nick", role.getNickname());
}
catch (UserNotFoundException e) {
// Do nothing
}
}
} else if ("moderator".equals(roleAttribute)) {
// The client is requesting the list of moderators
if (MUCRole.Affiliation.admin != senderRole.getAffiliation()
&& MUCRole.Affiliation.owner != senderRole.getAffiliation()) {
throw new ForbiddenException();
}
for (MUCRole role : room.getModerators()) {
metaData = result.addElement("item", "http://jabber.org/protocol/muc#admin");
metaData.addAttribute("role", "moderator");
metaData.addAttribute("jid", role.getUserAddress().toString());
metaData.addAttribute("nick", role.getNickname());
metaData.addAttribute("affiliation", role.getAffiliation().toString());
}
} else if ("participant".equals(roleAttribute)) {
// The client is requesting the list of participants
if (MUCRole.Role.moderator != senderRole.getRole()) {
throw new ForbiddenException();
}
for (MUCRole role : room.getParticipants()) {
metaData = result.addElement("item", "http://jabber.org/protocol/muc#admin");
metaData.addAttribute("role", "participant");
metaData.addAttribute("jid", role.getUserAddress().toString());
metaData.addAttribute("nick", role.getNickname());
metaData.addAttribute("affiliation", role.getAffiliation().toString());
}
} else {
reply.setError(PacketError.Condition.bad_request);
}
}