Class Node

    • Field Detail

      • parentIdentifier

        protected Node.UniqueIdentifier parentIdentifier
        The ID of the node that is containing this node (if any). This node can be expected to be a CollectionNode.
      • nodeID

        protected String nodeID
        The unique identifier for a node within the context of a pubsub service.
      • deliverPayloads

        protected boolean deliverPayloads
        Flag that indicates whether to deliver payloads with event notifications.
      • replyPolicy

        protected Node.ItemReplyPolicy replyPolicy
        Policy that defines whether owners or publisher should receive replies to items.
      • notifyConfigChanges

        protected boolean notifyConfigChanges
        Flag that indicates whether to notify subscribers when the node configuration changes.
      • notifyDelete

        protected boolean notifyDelete
        Flag that indicates whether to notify subscribers when the node is deleted.
      • notifyRetract

        protected boolean notifyRetract
        Flag that indicates whether to notify subscribers when items are removed from the node.
      • presenceBasedDelivery

        protected boolean presenceBasedDelivery
        Flag that indicates whether to deliver notifications to available users only.
      • publisherModel

        protected PublisherModel publisherModel
        Publisher model that specifies who is allowed to publish items to the node.
      • subscriptionEnabled

        protected boolean subscriptionEnabled
        Flag that indicates that subscribing and unsubscribing are enabled.
      • accessModel

        protected AccessModel accessModel
        Access model that specifies who is allowed to subscribe and retrieve items.
      • rosterGroupsAllowed

        protected Collection<String> rosterGroupsAllowed
        The roster group(s) allowed to subscribe and retrieve items.
      • replyRooms

        protected Collection<org.xmpp.packet.JID> replyRooms
        List of multi-user chat rooms to specify for replyroom.
      • replyTo

        protected Collection<org.xmpp.packet.JID> replyTo
        List of JID(s) to specify for replyto.
      • payloadType

        protected String payloadType
        The type of payload data to be provided at the node. Usually specified by the namespace of the payload (if any).
      • bodyXSLT

        protected String bodyXSLT
        The URL of an XSL transformation which can be applied to payloads in order to generate an appropriate message body element.
      • dataformXSLT

        protected String dataformXSLT
        The URL of an XSL transformation which can be applied to the payload format in order to generate a valid Data Forms result that the client could display using a generic Data Forms rendering engine.
      • creationDate

        protected Date creationDate
        The datetime when the node was created.
      • creator

        protected org.xmpp.packet.JID creator
        The JID of the node creator.
      • description

        protected String description
        A description of the node.
      • language

        protected String language
        The default language of the node.
      • contacts

        protected Collection<org.xmpp.packet.JID> contacts
        The JIDs of those to contact with questions.
      • name

        protected String name
        The name of the node.
      • subscriptionConfigurationRequired

        protected boolean subscriptionConfigurationRequired
        Flag that indicates whether new subscriptions should be configured to be active.
      • affiliates

        protected Collection<NodeAffiliate> affiliates
        The JIDs of those who have an affiliation with this node. When subscriptionModel is whitelist then this collection acts as the white list (unless user is an outcast)
      • subscriptionsByID

        protected Map<String,​NodeSubscription> subscriptionsByID
        Map that contains the current subscriptions to the node. A user may have more than one subscription. Each subscription is uniquely identified by its ID. Key: Subscription ID, Value: the subscription.
      • subscriptionsByJID

        protected Map<String,​NodeSubscription> subscriptionsByJID
        Map that contains the current subscriptions to the node. This map should be used only when node is not configured to allow multiple subscriptions. When multiple subscriptions is not allowed the subscriptions can be searched by the subscriber JID. Otherwise searches should be done using the subscription ID. Key: Subscriber full JID, Value: the subscription.
    • Method Detail

      • getUniqueIdentifier

        public Node.UniqueIdentifier getUniqueIdentifier()
        Returns an identifier for this node that is unique within the XMPP domain.
        Returns:
        A unique identifier for this node.
      • addOwner

        public NodeAffiliate addOwner​(org.xmpp.packet.JID jid)
        Adds a new affiliation or updates an existing affiliation of the specified entity JID to become a node owner.
        Parameters:
        jid - the JID of the user being added as a node owner.
        Returns:
        the newly created or modified affiliation to the node.
      • removeOwner

        public void removeOwner​(org.xmpp.packet.JID jid)
        Removes the owner affiliation of the specified entity JID. If the user that is no longer an owner was subscribed to the node then his affiliation will be of type NodeAffiliate.Affiliation.none.
        Parameters:
        jid - the JID of the user being removed as a node owner.
      • addPublisher

        public NodeAffiliate addPublisher​(org.xmpp.packet.JID jid)
        Adds a new affiliation or updates an existing affiliation of the specified entity JID to become a node publisher.
        Parameters:
        jid - the JID of the user being added as a node publisher.
        Returns:
        the newly created or modified affiliation to the node.
      • removePublisher

        public void removePublisher​(org.xmpp.packet.JID jid)
        Removes the publisher affiliation of the specified entity JID. If the user that is no longer a publisher was subscribed to the node then his affiliation will be of type NodeAffiliate.Affiliation.none.
        Parameters:
        jid - the JID of the user being removed as a node publisher.
      • addNoneAffiliation

        public NodeAffiliate addNoneAffiliation​(org.xmpp.packet.JID jid)
        Adds a new affiliation or updates an existing affiliation of the specified entity JID to become a none affiliate. Affiliates of type none are allowed to subscribe to the node.
        Parameters:
        jid - the JID of the user with affiliation "none".
        Returns:
        the newly created or modified affiliation to the node.
      • addOutcast

        public NodeAffiliate addOutcast​(org.xmpp.packet.JID jid)
        Sets that the specified entity is an outcast of the node. Outcast entities are not able to publish or subscribe to the node. Existing subscriptions will be deleted.
        Parameters:
        jid - the JID of the user that is no longer able to publish or subscribe to the node.
        Returns:
        the newly created or modified affiliation to the node.
      • removeOutcast

        public void removeOutcast​(org.xmpp.packet.JID jid)
        Removes the banning to subscribe to the node for the specified entity.
        Parameters:
        jid - the JID of the user that is no longer an outcast.
      • getSubscriptions

        public Collection<NodeSubscription> getSubscriptions​(org.xmpp.packet.JID owner)
        Returns the list of subscriptions owned by the specified user. The subscription owner may have more than one subscription based on isMultipleSubscriptionsEnabled(). Each subscription may have a different subscription JID if the owner wants to receive notifications in different resources (or even JIDs).
        Parameters:
        owner - the owner of the subscriptions.
        Returns:
        the list of subscriptions owned by the specified user.
      • getAllSubscriptions

        public Collection<NodeSubscription> getAllSubscriptions()
        Returns all subscriptions to the node. If multiple subscriptions are enabled, this method returns the subscriptions by subId, otherwise it returns the subscriptions by JID.
        Returns:
        All subscriptions to the node.
      • getAllAffiliates

        public Collection<NodeAffiliate> getAllAffiliates()
        Returns all affiliates of the node.
        Returns:
        All affiliates of the node.
      • getAffiliate

        public NodeAffiliate getAffiliate​(org.xmpp.packet.JID jid)
        Returns the NodeAffiliate of the specified JID or null if none was found. Users that have a subscription with the node will ALWAYS have an affiliation even if the affiliation is of type none.
        Parameters:
        jid - the JID of the user to look his affiliation with this node.
        Returns:
        the NodeAffiliate of the specified JID or null if none was found.
      • getOwners

        public Collection<org.xmpp.packet.JID> getOwners()
        Returns a collection with the JID of the node owners. Entities that are node owners have an affiliation of NodeAffiliate.Affiliation.owner. Owners are allowed to purge and delete the node. Moreover, owners may also get The collection can be modified since it represents a snapshot.
        Returns:
        a collection with the JID of the node owners.
      • getPublishers

        public Collection<org.xmpp.packet.JID> getPublishers()
        Returns a collection with the JID of the enitities with an affiliation of NodeAffiliate.Affiliation.publisher. When using the publisher model OpenPublisher anyone may publish to the node so this collection may be empty or may not contain the complete list of publishers. The returned collection can be modified since it represents a snapshot.
        Returns:
        a collection with the JID of the enitities with an affiliation of publishers.
      • configure

        public void configure​(org.xmpp.forms.DataForm completedForm)
                       throws NotAcceptableException
        Changes the node configuration based on the completed data form. Only owners or sysadmins are allowed to change the node configuration. The completed data form cannot remove all node owners. An exception is going to be thrown if the new form tries to leave the node without owners.
        Parameters:
        completedForm - the completed data form.
        Throws:
        NotAcceptableException - if completed data form tries to leave the node without owners.
      • configure

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

        public org.xmpp.forms.DataForm getConfigurationForm​(Locale preferredLocale)
        Returns a data form used by the owner to edit the node configuration.
        Parameters:
        preferredLocale - The preferred locale to localize the form.
        Returns:
        data form used by the owner to edit the node configuration.
      • addFormFields

        protected void addFormFields​(org.xmpp.forms.DataForm form,
                                     Locale preferredLocale,
                                     boolean isEditing)
        Adds the required form fields to the specified form. When editing is true the field type and a label is included in each field. The form being completed will contain the current node configuration. This information can be used for editing the node or for notifying that the node configuration has changed.
        Parameters:
        form - the form containing the node configuration.
        preferredLocale - the preferred locale to localize the form.
        isEditing - true when the form will be used to edit the node configuration.
      • getMetadataForm

        public org.xmpp.forms.DataForm getMetadataForm​(Locale preferredLocale)
        Returns a data form containing the node configuration that is going to be used for service discovery.
        Parameters:
        preferredLocale - The preferred locale to localize the form.
        Returns:
        a data form with the node configuration.
      • isRootCollectionNode

        public boolean isRootCollectionNode()
        Returns true if this node is the root node of the pubsub service.
        Returns:
        true if this node is the root node of the pubsub service.
      • isMultipleSubscriptionsEnabled

        public boolean isMultipleSubscriptionsEnabled()
        Returns true if a user may have more than one subscription with the node. When multiple subscriptions is enabled each subscription request, event notification and unsubscription request should include a subid attribute. By default multiple subscriptions is enabled.
        Returns:
        true if a user may have more than one subscription with the node.
      • isCollectionNode

        public boolean isCollectionNode()
        Returns true if this node is a node container. Node containers may only contain nodes but are not allowed to get items published.
        Returns:
        true if this node is a node container.
      • isChildNode

        public boolean isChildNode​(Node child)
        Returns true if the specified node is a first-level children of this node.
        Parameters:
        child - the node to check if it is a direct child of this node.
        Returns:
        true if the specified node is a first-level children of this collection node.
      • isDescendantNode

        public boolean isDescendantNode​(Node child)
        Returns true if the specified node is a direct child node of this node or a descendant of the children nodes.
        Parameters:
        child - the node to check if it is a descendant of this node.
        Returns:
        true if the specified node is a direct child node of this node or a descendant of the children nodes.
      • isAdmin

        public boolean isAdmin​(org.xmpp.packet.JID user)
        Returns true if the specified user is allowed to administer the node. Node administrator are allowed to retrieve the node configuration, change the node configuration, purge the node, delete the node and get the node affiliations and subscriptions.
        Parameters:
        user - the user to check if he is an admin.
        Returns:
        true if the specified user is allowed to administer the node.
      • getService

        public PubSubService getService()
        Returns the PubSubService to which this node belongs.
        Returns:
        the pubsub service.
      • getNodeID

        public String getNodeID()
        Returns the string representation of the unique identifier for a node within the context of a pubsub service. Preferably, use #getUniqueIdentifier() instead of this method, as that gives a more type-safe value than the String instance that's returned by this method.
        Returns:
        the unique identifier for a node within the context of a pubsub service.
        See Also:
        getUniqueIdentifier()
      • getName

        public String getName()
        Returns the name of the node. The node may not have a configured name. The node's name can be changed by submiting a completed data form.
        Returns:
        the name of the node.
      • isPayloadDelivered

        public boolean isPayloadDelivered()
        Returns true if event notifications will include payloads. Payloads are included when publishing new items. However, new items may not always include a payload depending on the node configuration. Nodes can be configured to not deliver payloads for performance reasons.
        Returns:
        true if event notifications will include payloads.
      • isNotifiedOfConfigChanges

        public boolean isNotifiedOfConfigChanges()
        Returns true if subscribers will be notified when the node configuration changes.
        Returns:
        true if subscribers will be notified when the node configuration changes.
      • isNotifiedOfDelete

        public boolean isNotifiedOfDelete()
        Returns true if subscribers will be notified when the node is deleted.
        Returns:
        true if subscribers will be notified when the node is deleted.
      • isNotifiedOfRetract

        public boolean isNotifiedOfRetract()
        Returns true if subscribers will be notified when items are removed from the node.
        Returns:
        true if subscribers will be notified when items are removed from the node.
      • isPresenceBasedDelivery

        public boolean isPresenceBasedDelivery()
        Returns true if notifications are going to be delivered to available users only.
        Returns:
        true if notifications are going to be delivered to available users only.
      • isPresenceBasedDelivery

        public boolean isPresenceBasedDelivery​(org.xmpp.packet.JID user)
        Returns true if notifications to the specified user will be delivered when the user is online.
        Parameters:
        user - the JID of the affiliate that has to be subscribed to the node.
        Returns:
        true if notifications are going to be delivered when the user is online.
      • isSendItemSubscribe

        public boolean isSendItemSubscribe()
        Returns true if the last published item is going to be sent to new subscribers.
        Returns:
        true if the last published item is going to be sent to new subscribers.
      • getPublisherModel

        public PublisherModel getPublisherModel()
        Returns the publisher model that specifies who is allowed to publish items to the node.
        Returns:
        the publisher model that specifies who is allowed to publish items to the node.
      • isSubscriptionEnabled

        public boolean isSubscriptionEnabled()
        Returns true if users are allowed to subscribe and unsubscribe.
        Returns:
        true if users are allowed to subscribe and unsubscribe.
      • isSubscriptionConfigurationRequired

        public boolean isSubscriptionConfigurationRequired()
        Returns true if new subscriptions should be configured to be active. Inactive subscriptions will not get event notifications. However, subscribers will be notified when a node is deleted no matter the subscription status.
        Returns:
        true if new subscriptions should be configured to be active.
      • getAccessModel

        public AccessModel getAccessModel()
        Returns the access model that specifies who is allowed to subscribe and retrieve items.
        Returns:
        the access model that specifies who is allowed to subscribe and retrieve items.
      • getRosterGroupsAllowed

        public Collection<String> getRosterGroupsAllowed()
        Returns the roster group(s) allowed to subscribe and retrieve items. This information is going to be used only when using the RosterAccess access model.
        Returns:
        the roster group(s) allowed to subscribe and retrieve items.
      • getReplyRooms

        public Collection<org.xmpp.packet.JID> getReplyRooms()
      • getReplyTo

        public Collection<org.xmpp.packet.JID> getReplyTo()
      • getPayloadType

        public String getPayloadType()
        Returns the type of payload data to be provided at the node. Usually specified by the namespace of the payload (if any).
        Returns:
        the type of payload data to be provided at the node.
      • getBodyXSLT

        public String getBodyXSLT()
        Returns the URL of an XSL transformation which can be applied to payloads in order to generate an appropriate message body element.
        Returns:
        the URL of an XSL transformation which can be applied to payloads.
      • getDataformXSLT

        public String getDataformXSLT()
        Returns the URL of an XSL transformation which can be applied to the payload format in order to generate a valid Data Forms result that the client could display using a generic Data Forms rendering engine.
        Returns:
        the URL of an XSL transformation which can be applied to the payload format.
      • getCreationDate

        public Date getCreationDate()
        Returns the datetime when the node was created.
        Returns:
        the datetime when the node was created.
      • getModificationDate

        public Date getModificationDate()
        Returns the last date when the ndoe's configuration was modified.
        Returns:
        the last date when the ndoe's configuration was modified.
      • getCreator

        public org.xmpp.packet.JID getCreator()
        Returns the JID of the node creator. This is usually the sender's full JID of the IQ packet used for creating the node.
        Returns:
        the JID of the node creator.
      • getDescription

        public String getDescription()
        Returns the description of the node. This information is really optional and can be modified by submiting a completed data form with the new node configuration.
        Returns:
        the description of the node.
      • getLanguage

        public String getLanguage()
        Returns the default language of the node. This information is really optional and can be modified by submiting a completed data form with the new node configuration.
        Returns:
        the default language of the node.
      • getContacts

        public Collection<org.xmpp.packet.JID> getContacts()
        Returns the JIDs of those to contact with questions. This information is not used by the pubsub service. It is meant to be "discovered" by users and redirect any question to the returned people to contact.
        Returns:
        the JIDs of those to contact with questions.
      • getNodes

        public Collection<Node> getNodes()
        Returns the list of nodes contained by this node. Only CollectionNode may contain other nodes.
        Returns:
        the list of nodes contained by this node.
      • getParent

        public CollectionNode getParent()
        Returns the collection node that is containing this node. The only node that does not have a parent node is the root collection node.
        Returns:
        the collection node that is containing this node.
      • getParents

        public Collection<CollectionNode> getParents()
        Returns the complete hierarchy of parents of this node.
        Returns:
        the complete hierarchy of parents of this node.
      • saveToDB

        public void saveToDB()
        Saves the node configuration to the backend store.
      • addAffiliate

        public void addAffiliate​(NodeAffiliate affiliate)
      • addSubscription

        public void addSubscription​(NodeSubscription subscription)
      • getSubscription

        public NodeSubscription getSubscription​(org.xmpp.packet.JID subscriberJID)
        Returns the subscription whose subscription JID matches the specified JID or null if none was found. Accessing subscriptions by subscription JID and not by subscription ID is only possible when the node does not allow multiple subscriptions from the same entity. If the node allows multiple subscriptions and this message is sent then an IllegalStateException exception is going to be thrown.
        Parameters:
        subscriberJID - the JID of the entity that receives event notifications.
        Returns:
        the subscription whose subscription JID matches the specified JID or null if none was found.
        Throws:
        IllegalStateException - If this message was used when the node supports multiple subscriptions.
      • getSubscription

        public NodeSubscription getSubscription​(String subscriptionID)
        Returns the subscription whose subscription ID matches the specified ID or null if none was found. Accessing subscriptions by subscription ID is always possible no matter if the node allows one or multiple subscriptions for the same entity. Even when users can only subscribe once to the node a subscription ID is going to be internally created though never returned to the user.
        Parameters:
        subscriptionID - the ID of the subscription.
        Returns:
        the subscription whose subscription ID matches the specified ID or null if none was found.
      • delete

        public void delete()
        Deletes this node from memory and the database. Subscribers are going to be notified that the node has been deleted after the node was successfully deleted.
      • deletingNode

        protected abstract void deletingNode()
        Notification message indicating that the node is being deleted. Subclasses should implement this method to delete any subclass specific information.
      • changeParent

        protected void changeParent​(CollectionNode newParent)
        Changes the parent node of this node. The node ID of the node will not be modified based on the new parent so pubsub implementations where node ID has a semantic meaning will end up affecting the meaning of the node hierarchy and possibly messing up the meaning of the hierarchy.

        No notifications are sent due to the new parent adoption process.

        Parameters:
        newParent - the new parent node of this node.
      • broadcastNodeEvent

        protected void broadcastNodeEvent​(org.xmpp.packet.Message message,
                                          boolean includeAll)
        Broadcasts a node event to subscribers of the node.
        Parameters:
        message - the message containing the node event.
        includeAll - true if all subscribers will be notified no matter their subscriptions status or configuration.
      • sendEventNotification

        protected void sendEventNotification​(org.xmpp.packet.JID subscriberJID,
                                             org.xmpp.packet.Message notification,
                                             Collection<String> subIDs)
        Sends an event notification to the specified subscriber. The event notification may include information about the affected subscriptions.
        Parameters:
        subscriberJID - the subscriber JID that will get the notification.
        notification - the message to send to the subscriber.
        subIDs - the list of affected subscription IDs or null when node does not allow multiple subscriptions.
      • createSubscription

        public void createSubscription​(org.xmpp.packet.IQ originalIQ,
                                       org.xmpp.packet.JID owner,
                                       org.xmpp.packet.JID subscriber,
                                       boolean authorizationRequired,
                                       org.xmpp.forms.DataForm options)
        Creates a new subscription and possibly a new affiliate if the owner of the subscription does not have any existing affiliation with the node. The new subscription might require to be authorized by a node owner to be active. If new subscriptions are required to be configured before being active then the subscription state would be "unconfigured".

        The originalIQ parameter may be null when using this API internally. When no IQ packet was sent then no IQ result will be sent to the sender. The rest of the functionality is the same.

        Parameters:
        originalIQ - the IQ packet sent by the entity to subscribe to the node or null when using this API internally.
        owner - the JID of the affiliate.
        subscriber - the JID where event notifications are going to be sent.
        authorizationRequired - true if the new subscriptions needs to be authorized by a node owner.
        options - the data form with the subscription configuration or null if subscriber didn't provide a configuration.
      • cancelSubscription

        public void cancelSubscription​(NodeSubscription subscription,
                                       boolean sendToCluster)
        Cancels an existing subscription to the node. If the subscriber does not have any other subscription to the node and his affiliation was of type none then remove the existing affiliation too.
        Parameters:
        subscription - the subscription to cancel.
        sendToCluster - True to forward cancel order to cluster peers
      • cancelSubscription

        public void cancelSubscription​(NodeSubscription subscription)
        Cancels an existing subscription to the node. If the subscriber does not have any other subscription to the node and his affiliation was of type none then remove the existing affiliation too.
        Parameters:
        subscription - the subscription to cancel.
      • getPublishedItem

        public PublishedItem getPublishedItem​(String itemID)
        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.
        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()
        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.
        Returns:
        the list of PublishedItem that were published to the node.
      • getPublishedItems

        public List<PublishedItem> getPublishedItems​(int recentItems)
        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.
        Parameters:
        recentItems - number of recent items to retrieve.
        Returns:
        a list of PublishedItem with the most recent N items published to the node.
      • getPendingSubscriptions

        public Collection<NodeSubscription> getPendingSubscriptions()
        Returns a list with the subscriptions to the node that are pending to be approved by a node owner. If the node is not using the access model AuthorizeAccess then the result will be an empty collection.
        Returns:
        a list with the subscriptions to the node that are pending to be approved by a node owner.
      • getLastPublishedItem

        public PublishedItem getLastPublishedItem()
        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.
        Returns:
        the PublishedItem that was published to the node or null if the node does not have published items.
      • approveSubscription

        public void approveSubscription​(NodeSubscription subscription,
                                        boolean approved)
        Approves or cancels a subscriptions that was pending to be approved by a node owner. Subscriptions that were not approved will be deleted. Approved subscriptions will be activated (i.e. will be able to receive event notifications) as long as the subscriber is not required to configure the subscription.
        Parameters:
        subscription - the subscriptions that was approved or rejected.
        approved - true when susbcription was approved. Otherwise the subscription was rejected.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • 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
        Returns:
        the size of the Object in bytes.
        Throws:
        CannotCalculateSizeException - if the size cannot be calculated
      • getLogger

        protected abstract org.slf4j.Logger getLogger()