1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-08 14:11:07 +01:00

Add Node.getSubscriptionsAsOwner() in PubSub API

To retrieve the subscriptions of a PubSub node as owner. Fixes
SMACK-623.
This commit is contained in:
Florian Schmaus 2015-01-01 14:56:12 +01:00
parent f029b576a5
commit 5c086eeefa
3 changed files with 125 additions and 2 deletions

View file

@ -166,8 +166,56 @@ abstract public class Node
*/
public List<Subscription> getSubscriptions(List<PacketExtension> additionalExtensions, Collection<PacketExtension> returnedExtensions)
throws NoResponseException, XMPPErrorException, NotConnectedException {
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(
PubSubElementType.SUBSCRIPTIONS, getId()));
return getSubscriptions(additionalExtensions, returnedExtensions, null);
}
/**
* Get the subscriptions currently associated with this node as owner.
*
* @return List of {@link Subscription}
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @see #getSubscriptionsAsOwner(List, Collection)
* @since 4.1
*/
public List<Subscription> getSubscriptionsAsOwner() throws NoResponseException, XMPPErrorException,
NotConnectedException {
return getSubscriptionsAsOwner(null, null);
}
/**
* Get the subscriptions currently associated with this node as owner.
* <p>
* Unlike {@link #getSubscriptions(List, Collection)}, which only retrieves the subscriptions of the current entity
* ("user"), this method returns a list of <b>all</b> subscriptions. This requires the entity to have the sufficient
* privileges to manage subscriptions.
* </p>
* <p>
* {@code additionalExtensions} can be used e.g. to add a "Result Set Management" extension.
* {@code returnedExtensions} will be filled with the packet extensions found in the answer.
* </p>
*
* @param additionalExtensions
* @param returnedExtensions a collection that will be filled with the returned packet extensions
* @return List of {@link Subscription}
* @throws NoResponseException
* @throws XMPPErrorException
* @throws NotConnectedException
* @see <a href="http://www.xmpp.org/extensions/xep-0060.html#owner-subscriptions-retrieve">XEP-60 § 8.8.1 -
* Retrieve Subscriptions List</a>
* @since 4.1
*/
public List<Subscription> getSubscriptionsAsOwner(List<PacketExtension> additionalExtensions,
Collection<PacketExtension> returnedExtensions) throws NoResponseException, XMPPErrorException,
NotConnectedException {
return getSubscriptions(additionalExtensions, returnedExtensions, PubSubNamespace.OWNER);
}
private List<Subscription> getSubscriptions(List<PacketExtension> additionalExtensions,
Collection<PacketExtension> returnedExtensions, PubSubNamespace pubSubNamespace)
throws NoResponseException, XMPPErrorException, NotConnectedException {
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()), pubSubNamespace);
if (additionalExtensions != null) {
for (PacketExtension pe : additionalExtensions) {
pubSub.addExtension(pe);

View file

@ -339,6 +339,18 @@
<className>org.jivesoftware.smackx.pubsub.provider.FormNodeProvider</className>
</extensionProvider>
<extensionProvider>
<elementName>subscriptions</elementName>
<namespace>http://jabber.org/protocol/pubsub#owner</namespace>
<className>org.jivesoftware.smackx.pubsub.provider.SubscriptionsProvider</className>
</extensionProvider>
<extensionProvider>
<elementName>subscription</elementName>
<namespace>http://jabber.org/protocol/pubsub#owner</namespace>
<className>org.jivesoftware.smackx.pubsub.provider.SubscriptionProvider</className>
</extensionProvider>
<!-- XEP-0060 pubsub#event -->
<extensionProvider>
<elementName>event</elementName>