public final class PubSubManager extends Manager
| Modifier and Type | Field and Description |
|---|---|
static String |
AUTO_CREATE_FEATURE |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canCreateNodesAndPublishItems()
Check if it is possible to create PubSub nodes on this service.
|
LeafNode |
createNode()
Creates an instant node, if supported.
|
LeafNode |
createNode(String nodeId)
Creates a node with default configuration.
|
Node |
createNode(String nodeId,
Form config)
Creates a node with specified configuration.
|
void |
deleteNode(String nodeId)
Delete the specified node.
|
DiscoverItems |
discoverNodes(String nodeId)
Get all the nodes that currently exist as a child of the specified
collection node.
|
List<Affiliation> |
getAffiliations()
Gets the affiliations on the root node.
|
ConfigureForm |
getDefaultConfiguration()
Returns the default settings for Node configuration.
|
static PubSubManager |
getInstance(XMPPConnection connection)
Get a PubSub manager for the default PubSub service of the connection.
|
static PubSubManager |
getInstance(XMPPConnection connection,
BareJid pubSubService)
Get the PubSub manager for the given connection and PubSub service.
|
LeafNode |
getLeafNode(String id)
Try to get a leaf node with the given node ID.
|
<T extends Node> |
getNode(String id)
Retrieves the requested node, if it exists.
|
LeafNode |
getOrCreateLeafNode(String id)
Try to get a leaf node and create one if it does not already exist.
|
static DomainBareJid |
getPubSubService(XMPPConnection connection)
Get the "default" PubSub service for a given XMPP connection.
|
BareJid |
getServiceJid()
Get the JID of the PubSub service managed by this manager.
|
List<Subscription> |
getSubscriptions()
Gets the subscriptions on the root node.
|
DiscoverInfo |
getSupportedFeatures()
Gets the supported features of the servers pubsub implementation
as a standard
DiscoverInfo instance. |
boolean |
supportsAutomaticNodeCreation()
Check if the PubSub service supports automatic node creation.
|
<I extends Item> |
tryToPublishAndPossibleAutoCreate(String id,
I item)
Try to publish an item and, if the node with the given ID does not exists, auto-create the node.
|
connection, getAuthenticatedConnectionOrThrow, schedulepublic static final String AUTO_CREATE_FEATURE
public static PubSubManager getInstance(XMPPConnection connection)
connection - public static PubSubManager getInstance(XMPPConnection connection, BareJid pubSubService)
connection - the XMPP connection.pubSubService - the PubSub service.public LeafNode createNode() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
XMPPException.XMPPErrorExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic LeafNode createNode(String nodeId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
nodeId - The id of the node, which must be unique within the
pubsub serviceXMPPException.XMPPErrorExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic Node createNode(String nodeId, Form config) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
nodeId - The name of the node, which must be unique within the
pubsub serviceconfig - The configuration for the nodeXMPPException.XMPPErrorExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic <T extends Node> T getNode(String id) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException
T - type of the node.id - - The unique id of the nodeXMPPException.XMPPErrorException - The node does not existSmackException.NoResponseException - if there was no response from the server.SmackException.NotConnectedExceptionInterruptedExceptionPubSubException.NotAPubSubNodeExceptionpublic LeafNode getOrCreateLeafNode(String id) throws SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException
id - The unique ID of the node.SmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionXMPPException.XMPPErrorExceptionPubSubException.NotALeafNodeException - in case the node already exists as collection node.public LeafNode getLeafNode(String id) throws PubSubException.NotALeafNodeException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException
id - the node ID.PubSubException.NotALeafNodeException - in case the node exists but is a collection node.SmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionXMPPException.XMPPErrorExceptionPubSubException.NotAPubSubNodeExceptionpublic <I extends Item> LeafNode tryToPublishAndPossibleAutoCreate(String id, I item) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Not every PubSub service supports automatic node creation. You can discover if this service supports it by using
supportsAutomaticNodeCreation().
I - type of the item.id - The unique id of the node.item - The item to publish.SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic DiscoverItems discoverNodes(String nodeId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
nodeId - - The id of the collection node for which the child
nodes will be returned.DiscoverItems representing the existing nodesXMPPException.XMPPErrorExceptionSmackException.NoResponseException - if there was no response from the server.SmackException.NotConnectedExceptionInterruptedExceptionpublic List<Subscription> getSubscriptions() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
XMPPException.XMPPErrorExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic List<Affiliation> getAffiliations() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
XMPPException.XMPPErrorExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic void deleteNode(String nodeId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
nodeId - XMPPException.XMPPErrorExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic ConfigureForm getDefaultConfiguration() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
XMPPException.XMPPErrorExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic BareJid getServiceJid()
public DiscoverInfo getSupportedFeatures() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
DiscoverInfo instance.XMPPException.XMPPErrorExceptionSmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic boolean supportsAutomaticNodeCreation() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic boolean canCreateNodesAndPublishItems() throws SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException
Note that since XEP-60 does not provide an API to determine if an XMPP entity is allowed to
create nodes, therefore this method creates an instant node calling createNode() to
determine if it is possible to create nodes.
true if it is possible to create nodes, false otherwise.SmackException.NoResponseExceptionSmackException.NotConnectedExceptionInterruptedExceptionXMPPException.XMPPErrorExceptionpublic static DomainBareJid getPubSubService(XMPPConnection connection) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
connection - null.SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedException