Ejemplo n.º 1
0
 public Map<String, Object> convertToRoomSpec(MUCRoom room) {
   Map<String, Object> roomSpec = new HashMap();
   roomSpec.put("naturalLanguageName", room.getNaturalLanguageName());
   roomSpec.put("name", room.getName());
   roomSpec.put("description", room.getDescription());
   roomSpec.put("canAnyoneDiscoverJID", room.canAnyoneDiscoverJID());
   roomSpec.put("canChangeNickname", room.canChangeNickname());
   roomSpec.put("canOccupantsChangeSubject", room.canOccupantsChangeSubject());
   roomSpec.put("canOccupantsInvite", room.canOccupantsInvite());
   roomSpec.put("publicRoom", room.isPublicRoom());
   roomSpec.put("password", room.getPassword());
   roomSpec.put("ID", room.getID());
   roomSpec.put("persistent", room.isPersistent());
   roomSpec.put("registrationEnabled", room.isRegistrationEnabled());
   roomSpec.put("logEnabled", room.isLogEnabled());
   roomSpec.put("loginRestrictedToNickname", room.isLoginRestrictedToNickname());
   roomSpec.put("maxUsers", room.getMaxUsers());
   roomSpec.put("membersOnly", room.isMembersOnly());
   roomSpec.put("moderated", room.isModerated());
   roomSpec.put("owners", convertJIDsToStringList(room.getOwners()));
   roomSpec.put("admins", convertJIDsToStringList(room.getAdmins()));
   roomSpec.put("members", convertJIDsToStringList(room.getMembers()));
   roomSpec.put("outcasts", convertJIDsToStringList(room.getOutcasts()));
   roomSpec.put("broadcastPresenceRoles", room.getRolesToBroadcastPresence());
   roomSpec.put("creationDate", room.getCreationDate());
   roomSpec.put("modificationDate", room.getModificationDate());
   return roomSpec;
 }
Ejemplo n.º 2
0
 private void setRoles(MUCRoom room, Map<String, Object> roomSpec) throws Exception {
   List<JID> roles = new ArrayList<JID>();
   Collection<JID> owners = new ArrayList<JID>();
   Collection<JID> existingOwners = new ArrayList<JID>();
   List<String> specOwners = (List) roomSpec.get("owners");
   List<String> specAdmins = (List) roomSpec.get("admins");
   List<String> specMembers = (List) roomSpec.get("members");
   List<String> specOutcasts = (List) roomSpec.get("outcasts");
   List<JID> mucRoomEntityOwners = convertStringsToJIDs(specOwners);
   owners.addAll(room.getOwners());
   // Find same owners
   for (JID jid : owners) {
     if (mucRoomEntityOwners.contains(jid)) {
       existingOwners.add(jid);
     }
   }
   // Don't delete the same owners
   owners.removeAll(existingOwners);
   room.addOwners(convertStringsToJIDs(specOwners), room.getRole());
   // Collect all roles to reset
   roles.addAll(owners);
   roles.addAll(room.getAdmins());
   roles.addAll(room.getMembers());
   roles.addAll(room.getOutcasts());
   for (JID jid : roles) {
     room.addNone(jid, room.getRole());
   }
   room.addOwners(convertStringsToJIDs(specOwners), room.getRole());
   if (specAdmins != null) {
     room.addAdmins(convertStringsToJIDs(specAdmins), room.getRole());
   }
   if (specMembers != null) {
     for (String memberJid : specMembers) {
       room.addMember(new JID(memberJid), null, room.getRole());
     }
   }
   if (specOutcasts != null) {
     for (String outcastJid : specOutcasts) {
       room.addOutcast(new JID(outcastJid), null, room.getRole());
     }
   }
 }