Class LeafNode

    • Method Detail

      • configure

        protected void configure​(org.xmpp.forms.FormField field)
                          throws NotAcceptableException
        Description copied from class: Node
        Configures the node with the completed form field. Fields that are common to leaf and collection nodes are handled in Node.configure(org.xmpp.forms.DataForm). Subclasses should implement this method in order to configure the node with form fields specific to the node type.
        Specified by:
        configure in class Node
        Parameters:
        field - the form field specific to the node type.
        Throws:
        NotAcceptableException - if field cannot be configured because of invalid data.
      • addFormFields

        protected void addFormFields​(org.xmpp.forms.DataForm form,
                                     boolean isEditing)
        Description copied from class: Node
        Adds the required form fields to the specified form. When editing is true the field type and a label is included in each fields. The form being completed will contain the current node configuration. This information can be used for editing the node or for notifing that the node configuration has changed.
        Overrides:
        addFormFields in class Node
        Parameters:
        form - the form containing the node configuration.
        isEditing - true when the form will be used to edit the node configuration.
      • deletingNode

        protected void deletingNode()
        Description copied from class: Node
        Notification message indicating that the node is being deleted. Subclasses should implement this method to delete any subclass specific information.
        Specified by:
        deletingNode in class Node
      • setLastPublishedItem

        public void setLastPublishedItem​(PublishedItem item)
      • getMaxPayloadSize

        public int getMaxPayloadSize()
      • isPersistPublishedItems

        public boolean isPersistPublishedItems()
      • getMaxPublishedItems

        public int getMaxPublishedItems()
      • isItemRequired

        public boolean isItemRequired()
        Returns true if an item element is required to be included when publishing an item to this node. When an item is included then the item will have an item ID that will be included when sending items to node subscribers.

        Leaf nodes that are transient and do not deliver payloads with event notifications do not require an item element. If a user tries to publish an item to a node that does not require items then an error will be returned.

        Returns:
        true if an item element is required to be included when publishing an item to this node.
      • publishItems

        public void publishItems​(org.xmpp.packet.JID publisher,
                                 List<org.dom4j.Element> itemElements)
        Publishes the list of items to the node. Event notifications will be sent to subscribers for the new published event, as well as all connected resources of the owner, in case the node is a node in a PEP service.

        The published event may or may not include an item. When the node is not persistent and does not require payloads then an item is not going to be created or included in the event notification.

        When an affiliate has many subscriptions to the node, the affiliate will get a notification for each set of items that affected the same list of subscriptions.

        When an item is included in the published event then a new PublishedItem is going to be created and added to the list of published item. Each published item will have a unique ID in the node scope. The new published item will be added to the end of the published list to keep the chronological order. When the max number of published items is exceeded then the oldest published items will be removed.

        For performance reasons the newly added published items and the deleted items (if any) are saved to the database using a background thread. Sending event notifications to node subscribers may also use another thread to ensure good performance.

        Parameters:
        publisher - the full JID of the user that sent the new published event.
        itemElements - list of dom4j elements that contain info about the published items.
      • deleteItems

        public void deleteItems​(List<PublishedItem> toDelete)
        Deletes the list of published items from the node. Event notifications may be sent to subscribers for the deleted items, as well as all connected resources of the service owner, if the service is a PEP service.

        When an affiliate has many subscriptions to the node, the affiliate will get a notification for each set of items that affected the same list of subscriptions.

        Parameters:
        toDelete - list of items that were deleted from the node.
      • getPublishedItem

        public PublishedItem getPublishedItem​(String itemID)
        Description copied from class: Node
        Returns the PublishedItem whose ID matches the specified item ID or null if none was found. Item ID may or may not exist and it depends on the node's configuration. When the node is configured to not include payloads in event notifications and published items are not persistent then item ID is not used. In this case a null value will always be returned.
        Overrides:
        getPublishedItem in class Node
        Parameters:
        itemID - the ID of the item to retrieve.
        Returns:
        the PublishedItem whose ID matches the specified item ID or null if none was found.
      • getPublishedItems

        public List<PublishedItem> getPublishedItems()
        Description copied from class: Node
        Returns the list of PublishedItem that were published to the node. The returned collection cannot be modified. Collection nodes does not support publishing of items so an empty list will be returned in that case.
        Overrides:
        getPublishedItems in class Node
        Returns:
        the list of PublishedItem that were published to the node.
      • getPublishedItems

        public List<PublishedItem> getPublishedItems​(int recentItems)
        Description copied from class: Node
        Returns a list of PublishedItem with the most recent N items published to the node. The returned collection cannot be modified. Collection nodes does not support publishing of items so an empty list will be returned in that case.
        Overrides:
        getPublishedItems in class Node
        Parameters:
        recentItems - number of recent items to retrieve.
        Returns:
        a list of PublishedItem with the most recent N items published to the node.
      • getLastPublishedItem

        public PublishedItem getLastPublishedItem()
        Description copied from class: Node
        Returns the last PublishedItem that was published to the node or null if the node does not have published items. Collection nodes does not support publishing of items so a null will be returned in that case.
        Overrides:
        getLastPublishedItem in class Node
        Returns:
        the PublishedItem that was published to the node or null if the node does not have published items.
      • isSendItemSubscribe

        public boolean isSendItemSubscribe()
        Returns true if the last published item is going to be sent to new subscribers.
        Overrides:
        isSendItemSubscribe in class Node
        Returns:
        true if the last published item is going to be sent to new subscribers.
      • purge

        public void purge()
        Purges items that were published to the node. Only owners can request this operation. This operation is only available for nodes configured to store items in the database. All published items will be deleted with the exception of the last published item.
      • getCachedSize

        public int getCachedSize()
                          throws CannotCalculateSizeException
        Description copied from interface: Cacheable
        Returns the approximate size of the Object in bytes. The size should be considered to be a best estimate of how much memory the Object occupies and may be based on empirical trials or dynamic calculations.

        Specified by:
        getCachedSize in interface Cacheable
        Overrides:
        getCachedSize in class Node
        Returns:
        the size of the Object in bytes.
        Throws:
        CannotCalculateSizeException - if the size cannot be calculated