Search in sources :

Example 1 with CollectionNode

use of org.jivesoftware.openfire.pubsub.CollectionNode in project Openfire by igniterealtime.

the class IQPEPHandler method cancelSubscriptionToPEPService.

/**
     * Cancels a subscription to a PEPService's root collection node.
     *
     * @param unsubscriber the JID of the subscriber whose subscription is being canceled.
     * @param serviceOwner the JID of the owner of the PEP service for which the subscription is being canceled.
     */
private void cancelSubscriptionToPEPService(JID unsubscriber, JID serviceOwner) {
    // Retrieve recipientJID's PEP service, if it exists.
    PEPService pepService = pepServiceManager.getPEPService(serviceOwner.toBareJID());
    if (pepService == null) {
        return;
    }
    // Cancel unsubscriberJID's subscription to recipientJID's PEP service, if it exists.
    CollectionNode rootNode = pepService.getRootCollectionNode();
    NodeSubscription nodeSubscription = rootNode.getSubscription(unsubscriber);
    if (nodeSubscription != null) {
        rootNode.cancelSubscription(nodeSubscription);
    }
}
Also used : NodeSubscription(org.jivesoftware.openfire.pubsub.NodeSubscription) CollectionNode(org.jivesoftware.openfire.pubsub.CollectionNode)

Example 2 with CollectionNode

use of org.jivesoftware.openfire.pubsub.CollectionNode in project Openfire by igniterealtime.

the class IQPEPHandler method subscribedToPresence.

@Override
public void subscribedToPresence(JID subscriberJID, JID authorizerJID) {
    final PEPService pepService = pepServiceManager.getPEPService(authorizerJID.toBareJID());
    if (pepService != null) {
        createSubscriptionToPEPService(pepService, subscriberJID, authorizerJID);
        // Delete any leaf node subscriptions the subscriber may have already
        // had (since a subscription to the PEP service, and thus its leaf PEP
        // nodes, would be duplicating publish notifications from previous leaf
        // node subscriptions).
        CollectionNode rootNode = pepService.getRootCollectionNode();
        for (Node node : pepService.getNodes()) {
            if (rootNode.isChildNode(node)) {
                for (NodeSubscription subscription : node.getSubscriptions(subscriberJID)) {
                    node.cancelSubscription(subscription);
                }
            }
        }
        pepService.sendLastPublishedItems(subscriberJID);
    }
}
Also used : NodeSubscription(org.jivesoftware.openfire.pubsub.NodeSubscription) CollectionNode(org.jivesoftware.openfire.pubsub.CollectionNode) Node(org.jivesoftware.openfire.pubsub.Node) LeafNode(org.jivesoftware.openfire.pubsub.LeafNode) CollectionNode(org.jivesoftware.openfire.pubsub.CollectionNode)

Aggregations

CollectionNode (org.jivesoftware.openfire.pubsub.CollectionNode)2 NodeSubscription (org.jivesoftware.openfire.pubsub.NodeSubscription)2 LeafNode (org.jivesoftware.openfire.pubsub.LeafNode)1 Node (org.jivesoftware.openfire.pubsub.Node)1