Search in sources :

Example 6 with Node

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

the class PEPServiceManager method remove.

/**
	 * Deletes the {@link PEPService} belonging to the specified owner.
	 * 
	 * @param owner
	 *            The JID of the owner of the service to be deleted.
	 */
public void remove(JID owner) {
    PEPService service = null;
    final Lock lock = CacheFactory.getLock(owner, pepServices);
    try {
        lock.lock();
        service = pepServices.remove(owner.toBareJID());
    } finally {
        lock.unlock();
    }
    if (service == null) {
        return;
    }
    // Delete the user's PEP nodes from memory and the database.
    CollectionNode rootNode = service.getRootCollectionNode();
    for (final Node node : service.getNodes()) {
        if (rootNode.isChildNode(node)) {
            node.delete();
        }
    }
    rootNode.delete();
}
Also used : Node(org.jivesoftware.openfire.pubsub.Node) CollectionNode(org.jivesoftware.openfire.pubsub.CollectionNode) CollectionNode(org.jivesoftware.openfire.pubsub.CollectionNode) Lock(java.util.concurrent.locks.Lock)

Example 7 with Node

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

the class CancelSubscriptionTask method run.

@Override
public void run() {
    log.debug("[TASK] Cancel Subscription : {}", toString());
    Node node = getNode();
    // case since any changes will get loaded from the db when it is loaded.
    if (node == null)
        return;
    // This method will make a db call, but it will simply do nothing since
    // the record will already be deleted.
    node.cancelSubscription(getSubscription(), false);
}
Also used : Node(org.jivesoftware.openfire.pubsub.Node)

Example 8 with Node

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

the class NewSubscriptionTask method run.

@Override
public void run() {
    log.debug("[TASK] New subscription : {}", toString());
    Node node = getNode();
    // case since any changes will get loaded from the db when it is loaded.
    if (node == null)
        return;
    if (node.getAffiliate(getOwner()) == null) {
        // add the missing 'none' affiliation
        NodeAffiliate affiliate = new NodeAffiliate(node, getOwner());
        affiliate.setAffiliation(NodeAffiliate.Affiliation.none);
        node.addAffiliate(affiliate);
    }
    node.addSubscription(getSubscription());
    if (node.isPresenceBasedDelivery() && node.getSubscriptions(getSubscription().getOwner()).size() == 1) {
        if (getSubscription().getPresenceStates().isEmpty()) {
            // Subscribe to the owner's presence since the node is only
            // sending events to online subscribers and this is the first
            // subscription of the user and the subscription is not
            // filtering notifications based on presence show values.
            getService().presenceSubscriptionRequired(getNode(), getOwner());
        }
    }
}
Also used : Node(org.jivesoftware.openfire.pubsub.Node) NodeAffiliate(org.jivesoftware.openfire.pubsub.NodeAffiliate)

Aggregations

Node (org.jivesoftware.openfire.pubsub.Node)8 CollectionNode (org.jivesoftware.openfire.pubsub.CollectionNode)5 Element (org.dom4j.Element)3 JID (org.xmpp.packet.JID)3 LeafNode (org.jivesoftware.openfire.pubsub.LeafNode)2 NodeAffiliate (org.jivesoftware.openfire.pubsub.NodeAffiliate)2 NodeSubscription (org.jivesoftware.openfire.pubsub.NodeSubscription)2 AccessModel (org.jivesoftware.openfire.pubsub.models.AccessModel)2 Message (org.xmpp.packet.Message)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Lock (java.util.concurrent.locks.Lock)1 EntityCapabilities (org.jivesoftware.openfire.entitycaps.EntityCapabilities)1 PublishedItem (org.jivesoftware.openfire.pubsub.PublishedItem)1 ClientSession (org.jivesoftware.openfire.session.ClientSession)1 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)1 PacketExtension (org.xmpp.packet.PacketExtension)1