Class LeafNode
- java.lang.Object
-
- org.jivesoftware.openfire.pubsub.Node
-
- org.jivesoftware.openfire.pubsub.LeafNode
-
- All Implemented Interfaces:
Externalizable
,Serializable
,Cacheable
public class LeafNode extends Node
A type of node that contains published items only. It is NOT a container for other nodes.- Author:
- Matt Tucker
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jivesoftware.openfire.pubsub.Node
Node.ItemReplyPolicy, Node.UniqueIdentifier
-
-
Field Summary
-
Fields inherited from class org.jivesoftware.openfire.pubsub.Node
accessModel, affiliates, bodyXSLT, contacts, creationDate, creator, dataformXSLT, deliverPayloads, description, language, name, nodeID, notifyConfigChanges, notifyDelete, notifyRetract, parentIdentifier, payloadType, presenceBasedDelivery, publisherModel, replyPolicy, replyRooms, replyTo, rosterGroupsAllowed, serviceIdentifier, subscriptionConfigurationRequired, subscriptionEnabled, subscriptionsByID, subscriptionsByJID
-
-
Constructor Summary
Constructors Constructor Description LeafNode()
LeafNode(PubSubService.UniqueIdentifier serviceId, CollectionNode parentNode, String nodeID, org.xmpp.packet.JID creator, boolean subscriptionEnabled, boolean deliverPayloads, boolean notifyConfigChanges, boolean notifyDelete, boolean notifyRetract, boolean presenceBasedDelivery, AccessModel accessModel, PublisherModel publisherModel, String language, Node.ItemReplyPolicy replyPolicy, boolean persistPublishedItems, int maxPublishedItems, int maxPayloadSize, boolean sendItemSubscribe)
LeafNode(PubSubService.UniqueIdentifier serviceId, CollectionNode parentNode, String nodeID, org.xmpp.packet.JID creator, DefaultNodeConfiguration defaultConfiguration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addFormFields(org.xmpp.forms.DataForm form, boolean isEditing)
Adds the required form fields to the specified form.protected void
configure(org.xmpp.forms.FormField field)
Configures the node with the completed form field.void
deleteItems(List<PublishedItem> toDelete)
Deletes the list of published items from the node.protected void
deletingNode()
Notification message indicating that the node is being deleted.int
getCachedSize()
Returns the approximate size of the Object in bytes.PublishedItem
getLastPublishedItem()
Returns the lastPublishedItem
that was published to the node ornull
if the node does not have published items.int
getMaxPayloadSize()
int
getMaxPublishedItems()
PublishedItem
getPublishedItem(String itemID)
Returns thePublishedItem
whose ID matches the specified item ID ornull
if none was found.List<PublishedItem>
getPublishedItems()
Returns the list ofPublishedItem
that were published to the node.List<PublishedItem>
getPublishedItems(int recentItems)
Returns a list ofPublishedItem
with the most recent N items published to the node.boolean
isItemRequired()
Returns true if an item element is required to be included when publishing an item to this node.boolean
isPersistPublishedItems()
boolean
isSendItemSubscribe()
Returns true if the last published item is going to be sent to new subscribers.void
publishItems(org.xmpp.packet.JID publisher, List<org.dom4j.Element> itemElements)
Publishes the list of items to the node.void
purge()
Purges items that were published to the node.void
readExternal(ObjectInput in)
void
setLastPublishedItem(PublishedItem item)
void
writeExternal(ObjectOutput out)
-
Methods inherited from class org.jivesoftware.openfire.pubsub.Node
addAffiliate, addNoneAffiliation, addOutcast, addOwner, addPublisher, addSubscription, approveSubscription, broadcastNodeEvent, cancelSubscription, cancelSubscription, changeParent, configure, createSubscription, delete, equals, getAccessModel, getAffiliate, getAllAffiliates, getAllSubscriptions, getBodyXSLT, getConfigurationForm, getContacts, getCreationDate, getCreator, getDataformXSLT, getDescription, getLanguage, getMetadataForm, getModificationDate, getName, getNodeID, getNodes, getOwners, getParent, getParents, getPayloadType, getPendingSubscriptions, getPublisherModel, getPublishers, getReplyPolicy, getReplyRooms, getReplyTo, getRosterGroupsAllowed, getService, getSubscription, getSubscription, getSubscriptions, getUniqueIdentifier, hashCode, isAdmin, isChildNode, isCollectionNode, isDescendantNode, isMultipleSubscriptionsEnabled, isNotifiedOfConfigChanges, isNotifiedOfDelete, isNotifiedOfRetract, isPayloadDelivered, isPresenceBasedDelivery, isPresenceBasedDelivery, isRootCollectionNode, isSubscriptionConfigurationRequired, isSubscriptionEnabled, removeOutcast, removeOwner, removePublisher, saveToDB, sendEventNotification, toString
-
-
-
-
Constructor Detail
-
LeafNode
public LeafNode(PubSubService.UniqueIdentifier serviceId, CollectionNode parentNode, String nodeID, org.xmpp.packet.JID creator, boolean subscriptionEnabled, boolean deliverPayloads, boolean notifyConfigChanges, boolean notifyDelete, boolean notifyRetract, boolean presenceBasedDelivery, AccessModel accessModel, PublisherModel publisherModel, String language, Node.ItemReplyPolicy replyPolicy, boolean persistPublishedItems, int maxPublishedItems, int maxPayloadSize, boolean sendItemSubscribe)
-
LeafNode
public LeafNode(PubSubService.UniqueIdentifier serviceId, CollectionNode parentNode, String nodeID, org.xmpp.packet.JID creator, DefaultNodeConfiguration defaultConfiguration)
-
LeafNode
public 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 inNode.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 classNode
- 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 classNode
- 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 classNode
-
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 thePublishedItem
whose ID matches the specified item ID ornull
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 anull
value will always be returned.- Overrides:
getPublishedItem
in classNode
- 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 ofPublishedItem
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 classNode
- 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 ofPublishedItem
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 classNode
- 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 lastPublishedItem
that was published to the node ornull
if the node does not have published items. Collection nodes does not support publishing of items so anull
will be returned in that case.- Overrides:
getLastPublishedItem
in classNode
- 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 classNode
- 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 interfaceCacheable
- Overrides:
getCachedSize
in classNode
- Returns:
- the size of the Object in bytes.
- Throws:
CannotCalculateSizeException
- if the size cannot be calculated
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classNode
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classNode
- Throws:
IOException
ClassNotFoundException
-
-