Search in sources :

Example 1 with MUCRoomEntity

use of org.jivesoftware.openfire.entity.MUCRoomEntity in project Openfire by igniterealtime.

the class MUCRoomController method getChatRoom.

/**
	 * Gets the chat room.
	 * 
	 * @param roomName
	 *            the room name
	 * @param serviceName
	 *            the service name
	 * @return the chat room
	 * @throws MUCServiceException
	 *             the MUC service exception
	 */
public MUCRoomEntity getChatRoom(String roomName, String serviceName) throws MUCServiceException {
    MUCRoom chatRoom = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceName).getChatRoom(roomName);
    if (chatRoom == null) {
        throw new MUCServiceException("Could not fetch the channel", roomName, "Chat room could be not found");
    }
    MUCRoomEntity mucRoomEntity = convertToMUCRoomEntity(chatRoom);
    return mucRoomEntity;
}
Also used : MUCRoom(org.jivesoftware.openfire.muc.MUCRoom) MUCServiceException(org.jivesoftware.openfire.exception.MUCServiceException) MUCRoomEntity(org.jivesoftware.openfire.entity.MUCRoomEntity)

Example 2 with MUCRoomEntity

use of org.jivesoftware.openfire.entity.MUCRoomEntity in project Openfire by igniterealtime.

the class MUCRoomController method convertToMUCRoomEntity.

/**
	 * Convert to MUC room entity.
	 * 
	 * @param room
	 *            the room
	 * @return the MUC room entity
	 */
public MUCRoomEntity convertToMUCRoomEntity(MUCRoom room) {
    MUCRoomEntity mucRoomEntity = new MUCRoomEntity(room.getNaturalLanguageName(), room.getName(), room.getDescription());
    mucRoomEntity.setCanAnyoneDiscoverJID(room.canAnyoneDiscoverJID());
    mucRoomEntity.setCanChangeNickname(room.canChangeNickname());
    mucRoomEntity.setCanOccupantsChangeSubject(room.canOccupantsChangeSubject());
    mucRoomEntity.setCanOccupantsInvite(room.canOccupantsInvite());
    mucRoomEntity.setPublicRoom(room.isPublicRoom());
    mucRoomEntity.setPassword(room.getPassword());
    mucRoomEntity.setPersistent(room.isPersistent());
    mucRoomEntity.setRegistrationEnabled(room.isRegistrationEnabled());
    mucRoomEntity.setLogEnabled(room.isLogEnabled());
    mucRoomEntity.setLoginRestrictedToNickname(room.isLoginRestrictedToNickname());
    mucRoomEntity.setMaxUsers(room.getMaxUsers());
    mucRoomEntity.setMembersOnly(room.isMembersOnly());
    mucRoomEntity.setModerated(room.isModerated());
    mucRoomEntity.setOwners(MUCRoomUtils.convertJIDsToStringList(room.getOwners()));
    mucRoomEntity.setAdmins(MUCRoomUtils.convertJIDsToStringList(room.getAdmins()));
    mucRoomEntity.setMembers(MUCRoomUtils.convertJIDsToStringList(room.getMembers()));
    mucRoomEntity.setOutcasts(MUCRoomUtils.convertJIDsToStringList(room.getOutcasts()));
    mucRoomEntity.setBroadcastPresenceRoles(room.getRolesToBroadcastPresence());
    mucRoomEntity.setCreationDate(room.getCreationDate());
    mucRoomEntity.setModificationDate(room.getModificationDate());
    return mucRoomEntity;
}
Also used : MUCRoomEntity(org.jivesoftware.openfire.entity.MUCRoomEntity)

Example 3 with MUCRoomEntity

use of org.jivesoftware.openfire.entity.MUCRoomEntity in project Openfire by igniterealtime.

the class MUCRoomController method getChatRooms.

/**
	 * Gets the chat rooms.
	 * 
	 * @param serviceName
	 *            the service name
	 * @param channelType
	 *            the channel type
	 * @param roomSearch
	 *            the room search
	 * @return the chat rooms
	 */
public MUCRoomEntities getChatRooms(String serviceName, String channelType, String roomSearch) {
    List<MUCRoom> rooms = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceName).getChatRooms();
    List<MUCRoomEntity> mucRoomEntities = new ArrayList<MUCRoomEntity>();
    for (MUCRoom chatRoom : rooms) {
        if (roomSearch != null) {
            if (!chatRoom.getName().contains(roomSearch)) {
                continue;
            }
        }
        if (channelType.equals(MUCChannelType.ALL)) {
            mucRoomEntities.add(convertToMUCRoomEntity(chatRoom));
        } else if (channelType.equals(MUCChannelType.PUBLIC) && chatRoom.isPublicRoom()) {
            mucRoomEntities.add(convertToMUCRoomEntity(chatRoom));
        }
    }
    return new MUCRoomEntities(mucRoomEntities);
}
Also used : MUCRoom(org.jivesoftware.openfire.muc.MUCRoom) MUCRoomEntity(org.jivesoftware.openfire.entity.MUCRoomEntity) ArrayList(java.util.ArrayList) MUCRoomEntities(org.jivesoftware.openfire.entity.MUCRoomEntities)

Aggregations

MUCRoomEntity (org.jivesoftware.openfire.entity.MUCRoomEntity)3 MUCRoom (org.jivesoftware.openfire.muc.MUCRoom)2 ArrayList (java.util.ArrayList)1 MUCRoomEntities (org.jivesoftware.openfire.entity.MUCRoomEntities)1 MUCServiceException (org.jivesoftware.openfire.exception.MUCServiceException)1