Search in sources :

Example 1 with MultiUserChatServiceImpl

use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.

the class MultiUserChatManager method joinedCluster.

// Cluster management tasks
@Override
public void joinedCluster() {
    if (!ClusterManager.isSeniorClusterMember()) {
        // Get transient rooms and persistent rooms with occupants from senior
        // cluster member and merge with local ones. If room configuration was
        // changed in both places then latest configuration will be kept
        @SuppressWarnings("unchecked") List<ServiceInfo> result = (List<ServiceInfo>) CacheFactory.doSynchronousClusterTask(new SeniorMemberServicesRequest(), ClusterManager.getSeniorClusterMember().toByteArray());
        if (result != null) {
            for (ServiceInfo serviceInfo : result) {
                MultiUserChatService service;
                service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceInfo.getSubdomain());
                if (service == null) {
                    // This is a service we don't know about yet, create it locally and register it;
                    service = new MultiUserChatServiceImpl(serviceInfo.getSubdomain(), serviceInfo.getDescription(), serviceInfo.isHidden());
                    XMPPServer.getInstance().getMultiUserChatManager().registerMultiUserChatService(service);
                }
                MultiUserChatServiceImpl serviceImpl = (MultiUserChatServiceImpl) service;
                for (RoomInfo roomInfo : serviceInfo.getRooms()) {
                    LocalMUCRoom remoteRoom = roomInfo.getRoom();
                    LocalMUCRoom localRoom = serviceImpl.getLocalChatRoom(remoteRoom.getName());
                    if (localRoom == null) {
                        // Create local room with remote information
                        localRoom = remoteRoom;
                        serviceImpl.chatRoomAdded(localRoom);
                    } else {
                        // Update local room with remote information
                        localRoom.updateConfiguration(remoteRoom);
                    }
                    // TODO Handle conflict of nicknames
                    for (OccupantAddedEvent event : roomInfo.getOccupants()) {
                        event.setSendPresence(true);
                        event.run();
                    }
                }
            }
        }
    }
}
Also used : ServiceInfo(org.jivesoftware.openfire.muc.cluster.ServiceInfo) SeniorMemberServicesRequest(org.jivesoftware.openfire.muc.cluster.SeniorMemberServicesRequest) LocalMUCRoom(org.jivesoftware.openfire.muc.spi.LocalMUCRoom) MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl) RoomInfo(org.jivesoftware.openfire.muc.cluster.RoomInfo) ArrayList(java.util.ArrayList) List(java.util.List) OccupantAddedEvent(org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent)

Example 2 with MultiUserChatServiceImpl

use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.

the class MultiUserChatManager method removeMultiUserChatService.

/**
     * Deletes a configured MultiUserChatService by ID, and shuts it down.
     *
     * @param serviceID The ID opf the service to be deleted.
     * @throws NotFoundException if the service was not found.
     */
public void removeMultiUserChatService(Long serviceID) throws NotFoundException {
    MultiUserChatServiceImpl muc = (MultiUserChatServiceImpl) getMultiUserChatService(serviceID);
    if (muc == null) {
        Log.error("MultiUserChatManager: Unable to find service to remove for service ID " + serviceID);
        throw new NotFoundException();
    }
    unregisterMultiUserChatService(muc.getServiceName());
    deleteService(serviceID);
}
Also used : MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl) NotFoundException(org.jivesoftware.util.NotFoundException)

Example 3 with MultiUserChatServiceImpl

use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.

the class MultiUserChatManager method updateMultiUserChatService.

/**
     * Updates the configuration of a MUC service.  This is more involved than it may seem.  If the
     * subdomain is changed, we need to shut down the old service and start up the new one, registering
     * the new subdomain and cleaning up the old one.  Properties are tied to the ID, which will not change.
     *
     * @param serviceID The ID of the service to be updated.
     * @param subdomain New subdomain to assign to the service.
     * @param description New description to assign to the service.
     * @throws NotFoundException if service was not found.
     */
public void updateMultiUserChatService(Long serviceID, String subdomain, String description) throws NotFoundException {
    MultiUserChatServiceImpl muc = (MultiUserChatServiceImpl) getMultiUserChatService(serviceID);
    if (muc == null)
        throw new NotFoundException();
    // A NotFoundException is thrown if the specified service was not found.
    String oldsubdomain = muc.getServiceName();
    if (!mucServices.containsKey(oldsubdomain)) {
        // This should never occur, but just in case...
        throw new NotFoundException();
    }
    if (oldsubdomain.equals(subdomain)) {
        // Alright, all we're changing is the description.  This is easy.
        updateService(serviceID, subdomain, description);
        // Update the existing service's description.
        muc.setDescription(description);
    } else {
        // Changing the subdomain, here's where it gets complex.
        // Unregister existing muc service
        unregisterMultiUserChatService(subdomain);
        // Update the information stored about the MUC service
        updateService(serviceID, subdomain, description);
        // Create new MUC service with new settings
        muc = new MultiUserChatServiceImpl(subdomain, description, muc.isHidden());
        // Register to new service
        registerMultiUserChatService(muc);
    }
}
Also used : MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl) NotFoundException(org.jivesoftware.util.NotFoundException)

Example 4 with MultiUserChatServiceImpl

use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.

the class UpdateHistoryStrategy method run.

@Override
public void run() {
    MultiUserChatServiceImpl mucServer = (MultiUserChatServiceImpl) XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceName);
    if (mucServer == null)
        throw new IllegalArgumentException("MUC service not found for subdomain: " + serviceName);
    HistoryStrategy strategy = mucServer.getHistoryStrategy();
    strategy.setType(HistoryStrategy.Type.values()[type]);
    strategy.setMaxNumber(maxNumber);
}
Also used : MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl) HistoryStrategy(org.jivesoftware.openfire.muc.HistoryStrategy)

Example 5 with MultiUserChatServiceImpl

use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.

the class SyncLocalOccupantsAndSendJoinPresenceTask method run.

@Override
public void run() {
    Log.debug("Going to execute sync occupants task for {} occupants from node {}", occupants.size(), originator);
    final MultiUserChatService multiUserChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(subdomain);
    ((MultiUserChatServiceImpl) multiUserChatService).process(this);
    Log.trace("Finished executing sync occupants task for occupants {} from node {}", occupants.size(), originator);
}
Also used : MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl) MultiUserChatService(org.jivesoftware.openfire.muc.MultiUserChatService)

Aggregations

MultiUserChatServiceImpl (org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl)14 NotFoundException (org.jivesoftware.util.NotFoundException)6 AlreadyExistsException (org.jivesoftware.util.AlreadyExistsException)4 MultiUserChatService (org.jivesoftware.openfire.muc.MultiUserChatService)3 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 OccupantAddedEvent (org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent)2 RoomInfo (org.jivesoftware.openfire.muc.cluster.RoomInfo)2 LocalMUCRoom (org.jivesoftware.openfire.muc.spi.LocalMUCRoom)2 ComponentException (org.xmpp.component.ComponentException)2 Nonnull (javax.annotation.Nonnull)1 HistoryStrategy (org.jivesoftware.openfire.muc.HistoryStrategy)1 GetNewMemberRoomsRequest (org.jivesoftware.openfire.muc.cluster.GetNewMemberRoomsRequest)1 SeniorMemberServicesRequest (org.jivesoftware.openfire.muc.cluster.SeniorMemberServicesRequest)1 ServiceAddedEvent (org.jivesoftware.openfire.muc.cluster.ServiceAddedEvent)1 ServiceInfo (org.jivesoftware.openfire.muc.cluster.ServiceInfo)1