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.
  • Method Details

    • discoverItems

      public DiscoverItems discoverItems() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Get information on the items in the node in standard DiscoverItems format.
      Returns:
      The item details in DiscoverItems format
      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.
    • getItems

      public <T extends Item> List<T> getItems() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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:
      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.
    • getItems

      public <T extends Item> List<T> getItems(String subscriptionId) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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:
      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.
    • getItems

      public <T extends Item> List<T> getItems(Collection<String> ids) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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 via getItems() 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:
      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.
    • getItems

      public <T extends Item> List<T> getItems(int maxItems) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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:
      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.
    • getItems

      public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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 return
      subscriptionId - The subscription which the retrieval is based on.
      Returns:
      List of Item
      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.
    • getItems

      public <T extends Item> List<T> getItems(List<org.jivesoftware.smack.packet.XmlElement> additionalExtensions, List<org.jivesoftware.smack.packet.XmlElement> returnedExtensions) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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 - additional PacketExtensions 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:
      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.
    • send

      @Deprecated public void send() throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException
      Deprecated.
      use publish() instead.
      Publishes an event to the node. This is an empty event with no item. This is only acceptable for nodes with ConfigureFormReader.isPersistItems()=false and ConfigureFormReader.isDeliverPayloads()=false.
      Throws:
      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.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
    • send

      @Deprecated public <T extends Item> void send(T item) throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException
      Deprecated.
      use publish(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 as send(), which publishes an event with NO item.
      Type Parameters:
      T - type of the items.
      Parameters:
      item - - The item being sent
      Throws:
      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.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
    • send

      @Deprecated public <T extends Item> void send(Collection<T> items) throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException
      Deprecated.
      use publish(Collection) instead.
      Publishes multiple events to the node. Same rules apply as in publish(Item). In addition, if ConfigureFormReader.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:
      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.
      org.jivesoftware.smack.SmackException.NoResponseException - if there was no response from the remote entity.
    • publish

      public void publish() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Publishes an event to the node. This is an empty event with no item. This is only acceptable for nodes with ConfigureFormReader.isPersistItems()=false and ConfigureFormReader.isDeliverPayloads()=false.
      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.
    • publish

      public <T extends Item> void publish(T item) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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 as send(), which publishes an event with NO item.
      Type Parameters:
      T - type of the items.
      Parameters:
      item - - The item being sent
      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.
    • publish

      public <T extends Item> void publish(Collection<T> items) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Publishes multiple events to the node. Same rules apply as in send(Item). In addition, if ConfigureFormReader.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 Item objects being sent
      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.
    • deleteAllItems

      public void deleteAllItems() throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Purges the node of all items.

      Note: Some implementations may keep the last item sent.

      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.
    • deleteItem

      public void deleteItem(String itemId) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Delete the item with the specified id from the node.
      Parameters:
      itemId - The id of the item
      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.
    • deleteItem

      public void deleteItem(Collection<String> itemIds) throws org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smack.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:
      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.