Search in sources :

Example 1 with MUCRoomEntity

use of org.jivesoftware.openfire.plugin.rest.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 ServiceException
	 *             the service exception
	 */
public MUCRoomEntity getChatRoom(String roomName, String serviceName, boolean expand) throws ServiceException {
    MUCRoom chatRoom = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceName).getChatRoom(roomName);
    if (chatRoom == null) {
        throw new ServiceException("Could not find the chat room", roomName, ExceptionType.ROOM_NOT_FOUND, Response.Status.NOT_FOUND);
    }
    MUCRoomEntity mucRoomEntity = convertToMUCRoomEntity(chatRoom, expand);
    return mucRoomEntity;
}
Also used : LocalMUCRoom(org.jivesoftware.openfire.muc.spi.LocalMUCRoom) MUCRoom(org.jivesoftware.openfire.muc.MUCRoom) ServiceException(org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException) MUCRoomEntity(org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntity)

Example 2 with MUCRoomEntity

use of org.jivesoftware.openfire.plugin.rest.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, boolean expand) {
    MUCRoomEntity mucRoomEntity = new MUCRoomEntity(room.getNaturalLanguageName(), room.getName(), room.getDescription());
    mucRoomEntity.setSubject(room.getSubject());
    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());
    ConcurrentGroupList<JID> owners = new ConcurrentGroupList<JID>(room.getOwners());
    ConcurrentGroupList<JID> admins = new ConcurrentGroupList<JID>(room.getAdmins());
    ConcurrentGroupList<JID> members = new ConcurrentGroupList<JID>(room.getMembers());
    ConcurrentGroupList<JID> outcasts = new ConcurrentGroupList<JID>(room.getOutcasts());
    if (expand) {
        for (Group ownerGroup : owners.getGroups()) {
            owners.addAllAbsent(ownerGroup.getAll());
        }
        for (Group adminGroup : admins.getGroups()) {
            admins.addAllAbsent(adminGroup.getAll());
        }
        for (Group memberGroup : members.getGroups()) {
            members.addAllAbsent(memberGroup.getAll());
        }
        for (Group outcastGroup : outcasts.getGroups()) {
            outcasts.addAllAbsent(outcastGroup.getAll());
        }
    }
    mucRoomEntity.setOwners(MUCRoomUtils.convertJIDsToStringList(owners));
    mucRoomEntity.setAdmins(MUCRoomUtils.convertJIDsToStringList(admins));
    mucRoomEntity.setMembers(MUCRoomUtils.convertJIDsToStringList(members));
    mucRoomEntity.setOutcasts(MUCRoomUtils.convertJIDsToStringList(outcasts));
    mucRoomEntity.setOwnerGroups(MUCRoomUtils.convertGroupsToStringList(owners.getGroups()));
    mucRoomEntity.setAdminGroups(MUCRoomUtils.convertGroupsToStringList(admins.getGroups()));
    mucRoomEntity.setMemberGroups(MUCRoomUtils.convertGroupsToStringList(members.getGroups()));
    mucRoomEntity.setOutcastGroups(MUCRoomUtils.convertGroupsToStringList(outcasts.getGroups()));
    mucRoomEntity.setBroadcastPresenceRoles(room.getRolesToBroadcastPresence());
    mucRoomEntity.setCreationDate(room.getCreationDate());
    mucRoomEntity.setModificationDate(room.getModificationDate());
    return mucRoomEntity;
}
Also used : Group(org.jivesoftware.openfire.group.Group) JID(org.xmpp.packet.JID) MUCRoomEntity(org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntity) ConcurrentGroupList(org.jivesoftware.openfire.group.ConcurrentGroupList)

Example 3 with MUCRoomEntity

use of org.jivesoftware.openfire.plugin.rest.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, boolean expand) {
    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, expand));
        } else if (channelType.equals(MUCChannelType.PUBLIC) && chatRoom.isPublicRoom()) {
            mucRoomEntities.add(convertToMUCRoomEntity(chatRoom, expand));
        }
    }
    return new MUCRoomEntities(mucRoomEntities);
}
Also used : LocalMUCRoom(org.jivesoftware.openfire.muc.spi.LocalMUCRoom) MUCRoom(org.jivesoftware.openfire.muc.MUCRoom) MUCRoomEntity(org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntity) ArrayList(java.util.ArrayList) MUCRoomEntities(org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntities)

Aggregations

MUCRoomEntity (org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntity)3 MUCRoom (org.jivesoftware.openfire.muc.MUCRoom)2 LocalMUCRoom (org.jivesoftware.openfire.muc.spi.LocalMUCRoom)2 ArrayList (java.util.ArrayList)1 ConcurrentGroupList (org.jivesoftware.openfire.group.ConcurrentGroupList)1 Group (org.jivesoftware.openfire.group.Group)1 MUCRoomEntities (org.jivesoftware.openfire.plugin.rest.entity.MUCRoomEntities)1 ServiceException (org.jivesoftware.openfire.plugin.rest.exceptions.ServiceException)1 JID (org.xmpp.packet.JID)1