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);
}
}
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);
}
}
Aggregations