Package org.jivesoftware.openfire.pep
Class PEPService
- java.lang.Object
-
- org.jivesoftware.openfire.pep.PEPService
-
- All Implemented Interfaces:
Serializable
,EntityCapabilitiesListener
,PubSubService
,Cacheable
public class PEPService extends Object implements PubSubService, Cacheable
A PEPService is aPubSubService
for use with XEP-0163: "Personal Eventing via Pubsub" Version 1.0 Note: Although this class implementsCacheable
, instances should only be cached in caches that have time-based (as opposed to size-based) eviction policies.- Author:
- Armando Jagucki
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jivesoftware.openfire.pubsub.PubSubService
PubSubService.UniqueIdentifier
-
-
Constructor Summary
Constructors Constructor Description PEPService(XMPPServer server, String bareJID)
Deprecated.Replaced byPEPService(XMPPServer, JID)
PEPService(XMPPServer server, org.xmpp.packet.JID bareJID)
Constructs a PEPService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNode(Node node)
Adds an already persistent node to the service.void
broadcast(Node node, org.xmpp.packet.Message message, Collection<org.xmpp.packet.JID> jids)
Broadcasts the specified Message containing an event notification to a list of subscribers to the specified node.boolean
canCreateNode(org.xmpp.packet.JID creator)
Returns true if the pubsub service allows the specified user to create nodes.void
entityCapabilitiesChanged(org.xmpp.packet.JID entity, EntityCapabilities updatedEntityCapabilities, Set<String> featuresAdded, Set<String> featuresRemoved, Set<String> identitiesAdded, Set<String> identitiesRemoved)
Invoked when a change was detected in the capabilities of a particular entity.org.xmpp.packet.JID
getAddress()
Returns the XMPP address of the service.int
getCachedSize()
Returns the approximate size of the Object in bytes.DefaultNodeConfiguration
getDefaultNodeConfiguration(boolean leafType)
Returns the default node configuration for the specified node type ornull
if the specified node type is not supported by the service.AdHocCommandManager
getManager()
Returns the ad-hoc commands manager used for this service.Node
getNode(Node.UniqueIdentifier nodeID)
Returns theNode
that matches the specified node ID ornull
if none was found.Collection<Node>
getNodes()
Returns the collection of nodes hosted by the pubsub service.CollectionNode
getRootCollectionNode()
Returns theCollectionNode
that acts as the root node of the entire node hierarchy.String
getServiceID()
Returns a String that uniquely identifies this pubsub service.Collection<String>
getShowPresences(org.xmpp.packet.JID subscriber)
Returns the show values of the last know presence of all connected resources of the specified subscriber.Map<org.xmpp.packet.JID,Map<org.xmpp.packet.JID,String>>
getSubscriberPresences()
Returns a registry of the presence's show value of users that subscribed to a node of the pubsub service and for which the node only delivers notifications for online users or node subscriptions deliver events based on the user presence show value.void
initialize()
boolean
isCollectionNodesSupported()
Returns true if the pubsub service supports collection nodes.boolean
isInstantNodeSupported()
Returns true if the pubsub service allows users to create nodes without specifying the node ID.boolean
isMultipleSubscriptionsEnabled()
Returns true if a user may have more than one subscription with the node.boolean
isNodeCreationRestricted()
Returns the permission policy for creating nodes.boolean
isServiceAdmin(org.xmpp.packet.JID user)
Returns true if the specified user is a sysadmin of the pubsub service or has admin privileges.void
presenceSubscriptionNotRequired(Node node, org.xmpp.packet.JID user)
Requests the pubsub service to unsubscribe from the presence of the user.void
presenceSubscriptionRequired(Node node, org.xmpp.packet.JID user)
Requests the pubsub service to subscribe to the presence of the user.void
removeNode(Node.UniqueIdentifier nodeID)
Removes the specified node from the service.void
send(org.xmpp.packet.Packet packet)
Sends the specified packet.void
sendLastPublishedItems(org.xmpp.packet.JID recipientJID)
Sends an event notification for the last published item of each leaf node under the root collection node to the recipient JID.void
sendLastPublishedItems(org.xmpp.packet.JID recipientJID, Set<String> nodeIdFilter)
Sends an event notification for the last published item of each leaf node under the root collection node to the recipient JID.void
sendNotification(Node node, org.xmpp.packet.Message message, org.xmpp.packet.JID recipientJID)
Sends the specified Message containing an event notification to a specific subscriber of the specified node.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jivesoftware.openfire.pubsub.PubSubService
getBarePresences, getNode, getUniqueIdentifier, removeNode
-
-
-
-
Constructor Detail
-
PEPService
@Deprecated public PEPService(XMPPServer server, String bareJID)
Deprecated.Replaced byPEPService(XMPPServer, JID)
Constructs a PEPService.- Parameters:
server
- the XMPP server.bareJID
- the bare JID (service ID) of the user owning the service.
-
PEPService
public PEPService(XMPPServer server, org.xmpp.packet.JID bareJID)
Constructs a PEPService.- Parameters:
server
- the XMPP server.bareJID
- the bare JID (service ID) of the user owning the service.
-
-
Method Detail
-
initialize
public void initialize()
-
addNode
public void addNode(Node node)
Description copied from interface:PubSubService
Adds an already persistent node to the service.- Specified by:
addNode
in interfacePubSubService
- Parameters:
node
- the persistent node to add to the service.
-
removeNode
public void removeNode(Node.UniqueIdentifier nodeID)
Description copied from interface:PubSubService
Removes the specified node from the service. Most probably the node was deleted from the database as well.A future version may support unloading of inactive nodes even though they may still exist in the database.
- Specified by:
removeNode
in interfacePubSubService
- Parameters:
nodeID
- the ID that uniquely identifies the node.
-
getNode
public Node getNode(Node.UniqueIdentifier nodeID)
Description copied from interface:PubSubService
Returns theNode
that matches the specified node ID ornull
if none was found.- Specified by:
getNode
in interfacePubSubService
- Parameters:
nodeID
- the ID that uniquely identifies the node.- Returns:
- the Node that matches the specified node ID or
null
if none was found.
-
getNodes
public Collection<Node> getNodes()
Description copied from interface:PubSubService
Returns the collection of nodes hosted by the pubsub service. The collection does not support modifications.- Specified by:
getNodes
in interfacePubSubService
- Returns:
- the collection of nodes hosted by the pubsub service.
-
getRootCollectionNode
public CollectionNode getRootCollectionNode()
Description copied from interface:PubSubService
Returns theCollectionNode
that acts as the root node of the entire node hierarchy. The returned node does not have a node identifier. If collection nodes is not supported then returnnull
.- Specified by:
getRootCollectionNode
in interfacePubSubService
- Returns:
- the CollectionNode that acts as the root node of the entire node hierarchy
or
null
if collection nodes is not supported.
-
getAddress
public org.xmpp.packet.JID getAddress()
Description copied from interface:PubSubService
Returns the XMPP address of the service.- Specified by:
getAddress
in interfacePubSubService
- Returns:
- the XMPP address of the service.
-
getServiceID
public String getServiceID()
Description copied from interface:PubSubService
Returns a String that uniquely identifies this pubsub service. This information is being used when storing node information in the database so it's possible to have nodes with the same ID but under different pubsub services.- Specified by:
getServiceID
in interfacePubSubService
- Returns:
- a String that uniquely identifies this pubsub service.
-
getDefaultNodeConfiguration
public DefaultNodeConfiguration getDefaultNodeConfiguration(boolean leafType)
Description copied from interface:PubSubService
Returns the default node configuration for the specified node type ornull
if the specified node type is not supported by the service.- Specified by:
getDefaultNodeConfiguration
in interfacePubSubService
- Parameters:
leafType
- true when requesting default configuration of leaf nodes- Returns:
- the default node configuration for the specified node type or
null
if the specified node type is not supported by the service.
-
getShowPresences
public Collection<String> getShowPresences(org.xmpp.packet.JID subscriber)
Description copied from interface:PubSubService
Returns the show values of the last know presence of all connected resources of the specified subscriber. When the subscriber JID is a bare JID then the answered collection will have many entries one for each connected resource. Moreover, if the user is offline then an empty collectin is returned. Available show status is represented by aonline
value. The rest of the possible show values as defined in RFC 3921.- Specified by:
getShowPresences
in interfacePubSubService
- Parameters:
subscriber
- the JID of the subscriber. This is not the JID of the affiliate.- Returns:
- an empty collection when offline. Otherwise, a collection with the show value of each connected resource.
-
canCreateNode
public boolean canCreateNode(org.xmpp.packet.JID creator)
Description copied from interface:PubSubService
Returns true if the pubsub service allows the specified user to create nodes.- Specified by:
canCreateNode
in interfacePubSubService
- Parameters:
creator
- the JID of the entity trying to create a new node.- Returns:
- true if the pubsub service allows the specified user to create nodes.
-
isCollectionNodesSupported
public boolean isCollectionNodesSupported()
Description copied from interface:PubSubService
Returns true if the pubsub service supports collection nodes. When collection nodes is supported it is possible to create hierarchy of nodes where aCollectionNode
may only hold children nodes of typeCollectionNode
orLeafNode
. On the other hand,LeafNode
can only holdPublishedItem
.- Specified by:
isCollectionNodesSupported
in interfacePubSubService
- Returns:
- true if the pubsub service supports collection nodes.
-
isInstantNodeSupported
public boolean isInstantNodeSupported()
Description copied from interface:PubSubService
Returns true if the pubsub service allows users to create nodes without specifying the node ID. The service will create a random node ID and assigne it to the node.- Specified by:
isInstantNodeSupported
in interfacePubSubService
- Returns:
- true if the pubsub service allows users to create nodes without specifying the node ID.
-
isMultipleSubscriptionsEnabled
public boolean isMultipleSubscriptionsEnabled()
Description copied from interface:PubSubService
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 asubid
attribute.- Specified by:
isMultipleSubscriptionsEnabled
in interfacePubSubService
- Returns:
- true if a user may have more than one subscription with the node.
-
isServiceAdmin
public boolean isServiceAdmin(org.xmpp.packet.JID user)
Description copied from interface:PubSubService
Returns true if the specified user is a sysadmin of the pubsub service or has admin privileges.- Specified by:
isServiceAdmin
in interfacePubSubService
- Parameters:
user
- the user to check if he has admin privileges.- Returns:
- true if the specified user is a sysadmin of the pubsub service or has admin privileges.
-
isNodeCreationRestricted
public boolean isNodeCreationRestricted()
Returns the permission policy for creating nodes. A true value means that not anyone can create a node, only the service admin. Note that PEP services will always return 'true'.- Returns:
- true
-
presenceSubscriptionNotRequired
public void presenceSubscriptionNotRequired(Node node, org.xmpp.packet.JID user)
Description copied from interface:PubSubService
Requests the pubsub service to unsubscribe from the presence of the user. If the service was not subscribed to the user's presence or any node still requires to be subscribed to the user presence then do nothing.- Specified by:
presenceSubscriptionNotRequired
in interfacePubSubService
- Parameters:
node
- the node that originated the unsubscription request.user
- the JID of the affiliate to unsubscribe from his presence.
-
presenceSubscriptionRequired
public void presenceSubscriptionRequired(Node node, org.xmpp.packet.JID user)
Description copied from interface:PubSubService
Requests the pubsub service to subscribe to the presence of the user. If the service has already subscribed to the user's presence then do nothing.- Specified by:
presenceSubscriptionRequired
in interfacePubSubService
- Parameters:
node
- the node that originated the subscription request.user
- the JID of the affiliate to subscribe to his presence.
-
send
public void send(org.xmpp.packet.Packet packet)
Description copied from interface:PubSubService
Sends the specified packet.- Specified by:
send
in interfacePubSubService
- Parameters:
packet
- the packet to send.
-
broadcast
public void broadcast(Node node, org.xmpp.packet.Message message, Collection<org.xmpp.packet.JID> jids)
Description copied from interface:PubSubService
Broadcasts the specified Message containing an event notification to a list of subscribers to the specified node. Each message being sent has to have a unique ID value so that the service can properly track any notification-related errors that may occur.- Specified by:
broadcast
in interfacePubSubService
- Parameters:
node
- the node that triggered the event notification.message
- the message containing the event notification.jids
- the list of entities to get the event notification.
-
sendNotification
public void sendNotification(Node node, org.xmpp.packet.Message message, org.xmpp.packet.JID recipientJID)
Description copied from interface:PubSubService
Sends the specified Message containing an event notification to a specific subscriber of the specified node. The message being sent has to have a unique ID value so that the service can properly track any notification-related errors that may occur.- Specified by:
sendNotification
in interfacePubSubService
- Parameters:
node
- the node that triggered the event notification.message
- the message containing the event notification.recipientJID
- the entity to get the event notification.
-
sendLastPublishedItems
public void sendLastPublishedItems(org.xmpp.packet.JID recipientJID)
Sends an event notification for the last published item of each leaf node under the root collection node to the recipient JID. If the recipient is not the owner of this service, has no subscription to the root collection node, has not yet been authorized, or is pending to be configured -- then no notifications are going to be sent.Depending on the subscription configuration the event notifications may or may not have a payload, may not be sent if a keyword (i.e. filter) was defined and it was not matched.
- Parameters:
recipientJID
- the recipient that is to receive the last published item notifications.
-
sendLastPublishedItems
public void sendLastPublishedItems(org.xmpp.packet.JID recipientJID, Set<String> nodeIdFilter)
Sends an event notification for the last published item of each leaf node under the root collection node to the recipient JID. If the recipient is not the owner of this service, has no subscription to the root collection node, has not yet been authorized, or is pending to be configured -- then no notifications are going to be sent.Depending on the subscription configuration the event notifications may or may not have a payload, may not be sent if a keyword (i.e. filter) was defined and it was not matched. An optional filter for nodes to be processed can be provided in the second argument to this method. When non-null only the nodes that match an ID in the argument will be processed.
- Parameters:
recipientJID
- the recipient that is to receive the last published item notifications.nodeIdFilter
- An optional filter of nodes to process (only IDs that are included in the filter are processed).
-
getSubscriberPresences
public Map<org.xmpp.packet.JID,Map<org.xmpp.packet.JID,String>> getSubscriberPresences()
Description copied from interface:PubSubService
Returns a registry of the presence's show value of users that subscribed to a node of the pubsub service and for which the node only delivers notifications for online users or node subscriptions deliver events based on the user presence show value. Offline users will not have an entry in the map. Note: Key-> bare JID and Value-> Map whose key is full JID of connected resource and value is show value of the last received presence.- Specified by:
getSubscriberPresences
in interfacePubSubService
- Returns:
- a registry of the presence's show value of users that subscribed to a node of the pubsub service.
-
getManager
public AdHocCommandManager getManager()
Description copied from interface:PubSubService
Returns the ad-hoc commands manager used for this service.- Specified by:
getManager
in interfacePubSubService
- Returns:
- the ad-hoc commands manager used for this service.
-
getCachedSize
public int getCachedSize()
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
- Returns:
- the size of the Object in bytes.
-
entityCapabilitiesChanged
public void entityCapabilitiesChanged(@Nonnull org.xmpp.packet.JID entity, @Nonnull EntityCapabilities updatedEntityCapabilities, @Nonnull Set<String> featuresAdded, @Nonnull Set<String> featuresRemoved, @Nonnull Set<String> identitiesAdded, @Nonnull Set<String> identitiesRemoved)
Description copied from interface:EntityCapabilitiesListener
Invoked when a change was detected in the capabilities of a particular entity. Apart from supplying the full entity capabilities object, each invocation will also include a the 'delta' of each capability characteristic: the features and identities that are new, or are removed, in the new capabilities, as compared to the previous capabilities for the entity. When no previous capabilities were registered for this entity, all characteristics will be new.- Specified by:
entityCapabilitiesChanged
in interfaceEntityCapabilitiesListener
- Parameters:
entity
- The entity for which CAPS changed.updatedEntityCapabilities
- The updated capabilities.featuresAdded
- The features that are now part of the capabilities, but were not in the previous capabilities of this entity.featuresRemoved
- The features that are now no longer part of the capabilities, but were in the previous capabilities of this entity.identitiesAdded
- The identities that are now present in the capabilities, but were not in the previous capabilities of this entity.identitiesRemoved
- The identities that are no longer part of the capabilities, but were in the previous capabilities of this entity.
-
-