protected void createRoom(Map<String, Object> roomSpec, String serviceName) throws Exception { List<String> owners = (List) roomSpec.get("owners"); JID owner = XMPPServer.getInstance().createJID("admin", null); if (owners != null && owners.size() > 0) { owner = new JID(owners.get(0)); } else { owners = new ArrayList<String>(); owners.add(owner.toBareJID()); roomSpec.put("owners", owners); } String roomName = (String) roomSpec.get("roomName"); Boolean isPersistent = (Boolean) roomSpec.get("persistent"); MUCRoom room = XMPPServer.getInstance() .getMultiUserChatManager() .getMultiUserChatService(serviceName) .getChatRoom(roomName.toLowerCase(), owner); IntrospectionSupport.setProperties(room, roomSpec); room.setRolesToBroadcastPresence(new ArrayList<String>()); setRoles(room, roomSpec); room.setCreationDate(new Date()); room.setModificationDate(new Date()); // Unlock the room, because the default configuration lock the room. room.unlock(room.getRole()); System.out.println("isPersistent:" + isPersistent); if (isPersistent == null) { room.setPersistent(true); } if (room.isPersistent()) { room.saveToDB(); } }
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; }