public final class PubSubManager
extends org.jivesoftware.smack.Manager
Modifier and Type | Field and Description |
---|---|
static java.lang.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(java.lang.String nodeId)
Creates a node with default configuration.
|
Node |
createNode(java.lang.String nodeId,
Form config)
Creates a node with specified configuration.
|
boolean |
deleteNode(java.lang.String nodeId)
Delete the specified node.
|
DiscoverItems |
discoverNodes(java.lang.String nodeId)
Get all the nodes that currently exist as a child of the specified
collection node.
|
java.util.List<Affiliation> |
getAffiliations()
Gets the affiliations on the root node.
|
ConfigureForm |
getDefaultConfiguration()
Returns the default settings for Node configuration.
|
static PubSubManager |
getInstance(org.jivesoftware.smack.XMPPConnection connection)
Deprecated.
use
getInstanceFor(XMPPConnection) instead. |
static PubSubManager |
getInstance(org.jivesoftware.smack.XMPPConnection connection,
org.jxmpp.jid.BareJid pubSubService)
Deprecated.
use
getInstanceFor(XMPPConnection, BareJid) instead. |
static PubSubManager |
getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
Get a PubSub manager for the default PubSub service of the connection.
|
static PubSubManager |
getInstanceFor(org.jivesoftware.smack.XMPPConnection connection,
org.jxmpp.jid.BareJid pubSubService)
Get the PubSub manager for the given connection and PubSub service.
|
LeafNode |
getLeafNode(java.lang.String id)
Try to get a leaf node with the given node ID.
|
Node |
getNode(java.lang.String id)
Retrieves the requested node, if it exists.
|
LeafNode |
getOrCreateLeafNode(java.lang.String id)
Try to get a leaf node and create one if it does not already exist.
|
static org.jxmpp.jid.DomainBareJid |
getPubSubService(org.jivesoftware.smack.XMPPConnection connection)
Get the "default" PubSub service for a given XMPP connection.
|
org.jxmpp.jid.BareJid |
getServiceJid()
Get the JID of the PubSub service managed by this manager.
|
java.util.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(java.lang.String id,
I item)
Try to publish an item and, if the node with the given ID does not exists, auto-create the node.
|
public static final java.lang.String AUTO_CREATE_FEATURE
public static PubSubManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection)
connection
- TODO javadoc me pleasepublic static PubSubManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection, org.jxmpp.jid.BareJid pubSubService)
null
as argument for
pubSubService to retrieve a PubSubManager for the users PEP service.connection
- the XMPP connection.pubSubService
- the PubSub service, may be null
.@Deprecated public static PubSubManager getInstance(org.jivesoftware.smack.XMPPConnection connection)
getInstanceFor(XMPPConnection)
instead.connection
- the connection.@Deprecated public static PubSubManager getInstance(org.jivesoftware.smack.XMPPConnection connection, org.jxmpp.jid.BareJid pubSubService)
getInstanceFor(XMPPConnection, BareJid)
instead.connection
- the connection.pubSubService
- the XMPP address of the PubSub service.public LeafNode createNode() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public LeafNode createNode(java.lang.String nodeId) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
nodeId
- The id of the node, which must be unique within the
pubsub serviceorg.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public Node createNode(java.lang.String nodeId, Form config) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
nodeId
- The name of the node, which must be unique within the
pubsub serviceconfig
- The configuration for the nodeorg.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public Node getNode(java.lang.String id) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, PubSubException.NotAPubSubNodeException
id
- - The unique id of the nodeorg.jivesoftware.smack.XMPPException.XMPPErrorException
- The node does not existorg.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the server.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.PubSubException.NotAPubSubNodeException
- if a involved node is not a PubSub node.public LeafNode getOrCreateLeafNode(java.lang.String id) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException
id
- The unique ID of the node.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.PubSubException.NotALeafNodeException
- in case the node already exists as collection node.public LeafNode getLeafNode(java.lang.String id) throws PubSubException.NotALeafNodeException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException
id
- the node ID.PubSubException.NotALeafNodeException
- in case the node exists but is a collection node.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.PubSubException.NotAPubSubNodeException
- if a involved node is not a PubSub node.public <I extends Item> LeafNode tryToPublishAndPossibleAutoCreate(java.lang.String id, I item) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, PubSubException.NotALeafNodeException
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.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.PubSubException.NotALeafNodeException
- if a PubSub leaf node operation was attempted on a non-leaf node.public DiscoverItems discoverNodes(java.lang.String nodeId) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
nodeId
- - The id of the collection node for which the child
nodes will be returned.DiscoverItems
representing the existing nodesorg.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the server.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public java.util.List<Subscription> getSubscriptions() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public java.util.List<Affiliation> getAffiliations() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public boolean deleteNode(java.lang.String nodeId) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
nodeId
- TODO javadoc me pleasetrue
if this node existed and was deleted and false
if this node did not exist.org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public ConfigureForm getDefaultConfiguration() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public org.jxmpp.jid.BareJid getServiceJid()
public DiscoverInfo getSupportedFeatures() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
DiscoverInfo
instance.org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public boolean supportsAutomaticNodeCreation() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.public boolean canCreateNodesAndPublishItems() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException, org.jivesoftware.smack.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.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.public static org.jxmpp.jid.DomainBareJid getPubSubService(org.jivesoftware.smack.XMPPConnection connection) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, java.lang.InterruptedException
connection
- TODO javadoc me pleasenull
.org.jivesoftware.smack.SmackException.NoResponseException
- if there was no response from the remote entity.org.jivesoftware.smack.XMPPException.XMPPErrorException
- if there was an XMPP error returned.org.jivesoftware.smack.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.