Package org.jivesoftware.smackx.pubsub
Class LeafNode
- java.lang.Object
-
- org.jivesoftware.smackx.pubsub.Node
-
- org.jivesoftware.smackx.pubsub.LeafNode
-
public class LeafNode extends Node
The main class for the majority of PubSub functionality. In general almost all PubSub capabilities are related to the concept of a node. All items are published to a node, and typically subscribed to by other users. These users then retrieve events based on this subscription.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jivesoftware.smackx.pubsub.Node
Node.ItemDeleteTranslator, Node.ItemEventTranslator, Node.NodeConfigTranslator
-
-
Field Summary
-
Fields inherited from class org.jivesoftware.smackx.pubsub.Node
configEventToListenerMap, id, itemDeleteToListenerMap, itemEventToListenerMap, pubSubManager
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
deleteAllItems()
Purges the node of all items.void
deleteItem(String itemId)
Delete the item with the specified id from the node.void
deleteItem(Collection<String> itemIds)
Delete the items with the specified id's from the node.DiscoverItems
discoverItems()
Get information on the items in the node in standardDiscoverItems
format.<T extends Item>
List<T>getItems()
Get the current items stored in the node.<T extends Item>
List<T>getItems(int maxItems)
Get items persisted on the node, limited to the specified number.<T extends Item>
List<T>getItems(int maxItems, String subscriptionId)
Get items persisted on the node, limited to the specified number based on the subscription associated with the provided subscriptionId.<T extends Item>
List<T>getItems(String subscriptionId)
Get the current items stored in the node based on the subscription associated with the provided subscription id.<T extends Item>
List<T>getItems(Collection<String> ids)
Get the items specified from the node.<T extends Item>
List<T>getItems(List<ExtensionElement> additionalExtensions, List<ExtensionElement> returnedExtensions)
Get items persisted on the node.void
publish()
Publishes an event to the node.<T extends Item>
voidpublish(Collection<T> items)
Publishes multiple events to the node.<T extends Item>
voidpublish(T item)
Publishes an event to the node.void
send()
Deprecated.usepublish()
instead.<T extends Item>
voidsend(Collection<T> items)
Deprecated.usepublish(Collection)
instead.<T extends Item>
voidsend(T item)
Deprecated.usepublish(Item)
instead.-
Methods inherited from class org.jivesoftware.smackx.pubsub.Node
addConfigurationListener, addItemDeleteListener, addItemEventListener, createPubsubPacket, discoverInfo, getAffiliations, getAffiliations, getAffiliationsAsOwner, getAffiliationsAsOwner, getId, getNodeConfiguration, getSubscriptionOptions, getSubscriptionOptions, getSubscriptions, getSubscriptions, getSubscriptionsAsOwner, getSubscriptionsAsOwner, modifyAffiliationAsOwner, modifySubscriptionsAsOwner, removeConfigurationListener, removeItemDeleteListener, removeItemEventListener, sendConfigurationForm, sendPubsubPacket, subscribe, subscribe, subscribe, subscribe, toString, unsubscribe, unsubscribe
-
-
-
-
Method Detail
-
discoverItems
public DiscoverItems discoverItems() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Get information on the items in the node in standardDiscoverItems
format.- Returns:
- The item details in
DiscoverItems
format - Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getItems
public <T extends Item> List<T> getItems() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Get the current items stored in the node.- Type Parameters:
T
- type of the items.- Returns:
- List of
Item
in the node - Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getItems
public <T extends Item> List<T> getItems(String subscriptionId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Get the current items stored in the node based on the subscription associated with the provided subscription id.- Type Parameters:
T
- type of the items.- Parameters:
subscriptionId
- - The subscription id for the associated subscription.- Returns:
- List of
Item
in the node - Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getItems
public <T extends Item> List<T> getItems(Collection<String> ids) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Get the items specified from the node. This would typically be used when the server does not return the payload due to size constraints. The user would be required to retrieve the payload after the items have been retrieved viagetItems()
or an event, that did not include the payload.- Type Parameters:
T
- type of the items.- Parameters:
ids
- Item ids of the items to retrieve- Returns:
- The list of
Item
with payload - Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getItems
public <T extends Item> List<T> getItems(int maxItems) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Get items persisted on the node, limited to the specified number.- Type Parameters:
T
- type of the items.- Parameters:
maxItems
- Maximum number of items to return- Returns:
- List of
Item
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getItems
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Get items persisted on the node, limited to the specified number based on the subscription associated with the provided subscriptionId.- Type Parameters:
T
- type of the items.- Parameters:
maxItems
- Maximum number of items to returnsubscriptionId
- The subscription which the retrieval is based on.- Returns:
- List of
Item
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getItems
public <T extends Item> List<T> getItems(List<ExtensionElement> additionalExtensions, List<ExtensionElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Get items persisted on the node.additionalExtensions
can be used e.g. to add a "Result Set Management" extension.returnedExtensions
will be filled with the stanza extensions found in the answer.- Type Parameters:
T
- type of the items.- Parameters:
additionalExtensions
- additionalPacketExtensions
to be added to the request. This is an optional argument, if provided as null no extensions will be added.returnedExtensions
- a collection that will be filled with the returned packet extensions. This is an optional argument, if provided as null it won't be populated.- Returns:
- List of
Item
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
send
@Deprecated public void send() throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, XMPPException.XMPPErrorException
Deprecated.usepublish()
instead.Publishes an event to the node. This is an empty event with no item. This is only acceptable for nodes withConfigureFormReader.isPersistItems()
=false andConfigureFormReader.isDeliverPayloads()
=false.- Throws:
SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.
-
send
@Deprecated public <T extends Item> void send(T item) throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, XMPPException.XMPPErrorException
Deprecated.usepublish(Item)
instead.Publishes an event to the node. This is a simple item with no payload. If the id is null, an empty item (one without an id) will be sent. Please note that this is not the same assend()
, which publishes an event with NO item.- Type Parameters:
T
- type of the items.- Parameters:
item
- - The item being sent- Throws:
SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.
-
send
@Deprecated public <T extends Item> void send(Collection<T> items) throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, XMPPException.XMPPErrorException
Deprecated.usepublish(Collection)
instead.Publishes multiple events to the node. Same rules apply as inpublish(Item)
. In addition, ifConfigureFormReader.isPersistItems()
=false, only the last item in the input list will get stored on the node, assuming it stores the last sent item.- Type Parameters:
T
- type of the items.- Parameters:
items
- - The collection of items being sent- Throws:
SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.
-
publish
public void publish() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Publishes an event to the node. This is an empty event with no item. This is only acceptable for nodes withConfigureFormReader.isPersistItems()
=false andConfigureFormReader.isDeliverPayloads()
=false.- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
publish
public <T extends Item> void publish(T item) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Publishes an event to the node. This can be either a simple item with no payload, or one with it. This is determined by the Node configuration. If the node has deliver_payload=false, the Item must not have a payload. If the id is null, an empty item (one without an id) will be sent. Please note that this is not the same assend()
, which publishes an event with NO item.- Type Parameters:
T
- type of the items.- Parameters:
item
- - The item being sent- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
publish
public <T extends Item> void publish(Collection<T> items) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Publishes multiple events to the node. Same rules apply as insend(Item)
. In addition, ifConfigureFormReader.isPersistItems()
=false, only the last item in the input list will get stored on the node, assuming it stores the last sent item.- Type Parameters:
T
- type of the items.- Parameters:
items
- - The collection ofItem
objects being sent- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
deleteAllItems
public void deleteAllItems() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Purges the node of all items.Note: Some implementations may keep the last item sent.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
deleteItem
public void deleteItem(String itemId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Delete the item with the specified id from the node.- Parameters:
itemId
- The id of the item- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
deleteItem
public void deleteItem(Collection<String> itemIds) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Delete the items with the specified id's from the node.- Parameters:
itemIds
- The list of id's of items to delete- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
-