Package org.jivesoftware.smackx.pubsub
Class PubSubManager
java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.pubsub.PubSubManager
public final class PubSubManager
extends org.jivesoftware.smack.Manager
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck if it is possible to create PubSub nodes on this service.Creates an instant node, if supported.createNode(String nodeId) Creates a node with default configuration.createNode(String nodeId, FillableConfigureForm config) Creates a node with specified configuration.booleandeleteNode(String nodeId) Delete the specified node.discoverNodes(String nodeId) Get all the nodes that currently exist as a child of the specified collection node.Gets the affiliations on the root node.Returns the default settings for Node configuration.static PubSubManagergetInstanceFor(org.jivesoftware.smack.XMPPConnection connection) Get a PubSub manager for the default PubSub service of the connection.static PubSubManagergetInstanceFor(org.jivesoftware.smack.XMPPConnection connection, org.jxmpp.jid.BareJid pubSubService) Get the PubSub manager for the given connection and PubSub service.getLeafNode(String id) Try to get a leaf node with the given node ID.Retrieves the requested node, if it exists.Try to get a leaf node and create one if it does not already exist.static org.jxmpp.jid.DomainBareJidgetPubSubService(org.jivesoftware.smack.XMPPConnection connection) Get the "default" PubSub service for a given XMPP connection.org.jxmpp.jid.BareJidGet the JID of the PubSub service managed by this manager.Gets the subscriptions on the root node.Gets the supported features of the servers pubsub implementation as a standardDiscoverInfoinstance.booleanCheck if the PubSub service supports automatic node creation.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.Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
Field Details
-
PLUS_NOTIFY
- See Also:
-
AUTO_CREATE_FEATURE
- See Also:
-
-
Method Details
-
getInstanceFor
Get a PubSub manager for the default PubSub service of the connection.- Parameters:
connection- TODO javadoc me please- Returns:
- the default PubSub manager.
-
getInstanceFor
public static PubSubManager getInstanceFor(org.jivesoftware.smack.XMPPConnection connection, org.jxmpp.jid.BareJid pubSubService) Get the PubSub manager for the given connection and PubSub service. Usenullas argument for pubSubService to retrieve a PubSubManager for the users PEP service.- Parameters:
connection- the XMPP connection.pubSubService- the PubSub service, may benull.- Returns:
- a PubSub manager for the connection and service.
-
createNode
public LeafNode createNode() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedExceptionCreates an instant node, if supported.- Returns:
- The node that was created
- Throws:
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.InterruptedException- if the calling thread was interrupted.
-
createNode
public LeafNode createNode(String nodeId) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException Creates a node with default configuration.- Parameters:
nodeId- The id of the node, which must be unique within the pubsub service- Returns:
- The node that was created
- Throws:
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.InterruptedException- if the calling thread was interrupted.
-
createNode
public Node createNode(String nodeId, FillableConfigureForm config) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException Creates a node with specified configuration. Note: This is the only way to create a collection node.- Parameters:
nodeId- The name of the node, which must be unique within the pubsub serviceconfig- The configuration for the node- Returns:
- The node that was created
- Throws:
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.InterruptedException- if the calling thread was interrupted.
-
getNode
public Node getNode(String id) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException Retrieves the requested node, if it exists. It will throw an exception if it does not.- Parameters:
id- - The unique id of the node- Returns:
- the node
- Throws:
org.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.InterruptedException- if the calling thread was interrupted.PubSubException.NotAPubSubNodeException- if a involved node is not a PubSub node.
-
getOrCreateLeafNode
public LeafNode getOrCreateLeafNode(String id) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException Try to get a leaf node and create one if it does not already exist.- Parameters:
id- The unique ID of the node.- Returns:
- the leaf node.
- Throws:
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.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.- Since:
- 4.2.1
-
getLeafNode
public LeafNode getLeafNode(String id) throws PubSubException.NotALeafNodeException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException Try to get a leaf node with the given node ID.- Parameters:
id- the node ID.- Returns:
- the requested leaf node.
- Throws:
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.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.- Since:
- 4.2.1
-
tryToPublishAndPossibleAutoCreate
public <I extends Item> LeafNode tryToPublishAndPossibleAutoCreate(String id, I item) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, PubSubException.NotALeafNodeException Try to publish an item and, if the node with the given ID does not exists, auto-create the node.Not every PubSub service supports automatic node creation. You can discover if this service supports it by using
supportsAutomaticNodeCreation().- Type Parameters:
I- type of the item.- Parameters:
id- The unique id of the node.item- The item to publish.- Returns:
- the LeafNode on which the item was published.
- Throws:
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.InterruptedException- if the calling thread was interrupted.PubSubException.NotALeafNodeException- if a PubSub leaf node operation was attempted on a non-leaf node.- Since:
- 4.2.1
-
discoverNodes
public DiscoverItems discoverNodes(String nodeId) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException Get all the nodes that currently exist as a child of the specified collection node. If the service does not support collection nodes then all nodes will be returned. To retrieve contents of the root collection node (if it exists), or there is no root collection node, pass null as the nodeId.- Parameters:
nodeId- - The id of the collection node for which the child nodes will be returned.- Returns:
DiscoverItemsrepresenting the existing nodes- Throws:
org.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.InterruptedException- if the calling thread was interrupted.
-
getSubscriptions
public List<Subscription> getSubscriptions() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedExceptionGets the subscriptions on the root node.- Returns:
- List of exceptions
- Throws:
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.InterruptedException- if the calling thread was interrupted.
-
getAffiliations
public List<Affiliation> getAffiliations() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedExceptionGets the affiliations on the root node.- Returns:
- List of affiliations
- Throws:
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.InterruptedException- if the calling thread was interrupted.
-
deleteNode
public boolean deleteNode(String nodeId) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException Delete the specified node.- Parameters:
nodeId- TODO javadoc me please- Returns:
trueif this node existed and was deleted andfalseif this node did not exist.- Throws:
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.InterruptedException- if the calling thread was interrupted.
-
getDefaultConfiguration
public ConfigureForm getDefaultConfiguration() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedExceptionReturns the default settings for Node configuration.- Returns:
- configuration form containing the default settings.
- Throws:
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.InterruptedException- if the calling thread was interrupted.
-
getServiceJid
public org.jxmpp.jid.BareJid getServiceJid()Get the JID of the PubSub service managed by this manager.- Returns:
- the JID of the PubSub service.
-
getSupportedFeatures
public DiscoverInfo getSupportedFeatures() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedExceptionGets the supported features of the servers pubsub implementation as a standardDiscoverInfoinstance.- Returns:
- The supported features
- Throws:
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.InterruptedException- if the calling thread was interrupted.
-
supportsAutomaticNodeCreation
public boolean supportsAutomaticNodeCreation() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedExceptionCheck if the PubSub service supports automatic node creation.- Returns:
- true if the PubSub service supports automatic node creation.
- Throws:
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.InterruptedException- if the calling thread was interrupted.- Since:
- 4.2.1
- See Also:
-
canCreateNodesAndPublishItems
public boolean canCreateNodesAndPublishItems() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorExceptionCheck if it is possible to create PubSub nodes on this service. It could be possible that the PubSub service allows only certain XMPP entities (clients) to create nodes and publish items to them.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.- Returns:
trueif it is possible to create nodes,falseotherwise.- Throws:
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.InterruptedException- if the calling thread was interrupted.org.jivesoftware.smack.XMPPException.XMPPErrorException- if there was an XMPP error returned.
-
getPubSubService
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, InterruptedException Get the "default" PubSub service for a given XMPP connection. The default PubSub service is simply an arbitrary XMPP service with the PubSub feature and an identity of category "pubsub" and type "service".- Parameters:
connection- TODO javadoc me please- Returns:
- the default PubSub service or
null. - Throws:
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.InterruptedException- if the calling thread was interrupted.- See Also:
-