Class Node
- java.lang.Object
-
- org.jivesoftware.smackx.pubsub.Node
-
- Direct Known Subclasses:
CollectionNode
,LeafNode
public abstract class Node extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Node.ItemDeleteTranslator
This class translates low level item deletion events into api level objects for user consumption.static class
Node.ItemEventTranslator
This class translates low level item publication events into api level objects for user consumption.static class
Node.NodeConfigTranslator
This class translates low level node configuration events into api level objects for user consumption.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ConcurrentHashMap<NodeConfigListener,StanzaListener>
configEventToListenerMap
protected java.lang.String
id
protected java.util.concurrent.ConcurrentHashMap<ItemDeleteListener,StanzaListener>
itemDeleteToListenerMap
protected java.util.concurrent.ConcurrentHashMap<ItemEventListener<Item>,StanzaListener>
itemEventToListenerMap
protected PubSubManager
pubSubManager
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addConfigurationListener(NodeConfigListener listener)
Register a listener for configuration events.void
addItemDeleteListener(ItemDeleteListener listener)
Register an listener for item delete events.void
addItemEventListener(ItemEventListener listener)
Register a listener for item publication events.protected PubSub
createPubsubPacket(IQ.Type type, NodeExtension ext)
DiscoverInfo
discoverInfo()
Discover node information in standardDiscoverInfo
format.java.util.List<Affiliation>
getAffiliations()
Get the affiliations of this node.java.util.List<Affiliation>
getAffiliations(java.util.List<ExtensionElement> additionalExtensions, java.util.Collection<ExtensionElement> returnedExtensions)
Get the affiliations of this node.java.util.List<Affiliation>
getAffiliationsAsOwner()
Retrieve the affiliation list for this node as owner.java.util.List<Affiliation>
getAffiliationsAsOwner(java.util.List<ExtensionElement> additionalExtensions, java.util.Collection<ExtensionElement> returnedExtensions)
Retrieve the affiliation list for this node as owner.java.lang.String
getId()
Get the NodeId.ConfigureForm
getNodeConfiguration()
Returns a configuration form, from which you can create an answer form to be submitted via thesendConfigurationForm(FillableConfigureForm)
.SubscribeForm
getSubscriptionOptions(java.lang.String jid)
Returns a SubscribeForm for subscriptions, from which you can create an answer form to be submitted via thesendConfigurationForm(FillableConfigureForm)
.SubscribeForm
getSubscriptionOptions(java.lang.String jid, java.lang.String subscriptionId)
Get the options for configuring the specified subscription.java.util.List<Subscription>
getSubscriptions()
Get the subscriptions currently associated with this node.java.util.List<Subscription>
getSubscriptions(java.util.List<ExtensionElement> additionalExtensions, java.util.Collection<ExtensionElement> returnedExtensions)
Get the subscriptions currently associated with this node.java.util.List<Subscription>
getSubscriptionsAsOwner()
Get the subscriptions currently associated with this node as owner.java.util.List<Subscription>
getSubscriptionsAsOwner(java.util.List<ExtensionElement> additionalExtensions, java.util.Collection<ExtensionElement> returnedExtensions)
Get the subscriptions currently associated with this node as owner.PubSub
modifyAffiliationAsOwner(java.util.List<Affiliation> affiliations)
Modify the affiliations for this PubSub node as owner.PubSub
modifySubscriptionsAsOwner(java.util.List<Subscription> changedSubs)
Modify the subscriptions for this PubSub node as owner.void
removeConfigurationListener(NodeConfigListener listener)
Unregister a listener for configuration events.void
removeItemDeleteListener(ItemDeleteListener listener)
Unregister a listener for item delete events.void
removeItemEventListener(ItemEventListener listener)
Unregister a listener for publication events.void
sendConfigurationForm(FillableConfigureForm configureForm)
Update the configuration with the contents of the newFillableConfigureForm
.protected PubSub
sendPubsubPacket(PubSub packet)
Subscription
subscribe(java.lang.String jidString)
Deprecated.usesubscribe(Jid)
instead.Subscription
subscribe(java.lang.String jidString, FillableSubscribeForm subForm)
Deprecated.usesubscribe(Jid, FillableSubscribeForm)
instead.Subscription
subscribe(Jid jid)
The user subscribes to the node using the supplied jid.Subscription
subscribe(Jid jid, FillableSubscribeForm subForm)
The user subscribes to the node using the supplied jid and subscription options.java.lang.String
toString()
void
unsubscribe(java.lang.String jid)
Remove the subscription related to the specified JID.void
unsubscribe(java.lang.String jid, java.lang.String subscriptionId)
Remove the specific subscription related to the specified JID.
-
-
-
Field Detail
-
pubSubManager
protected final PubSubManager pubSubManager
-
id
protected final java.lang.String id
-
itemEventToListenerMap
protected java.util.concurrent.ConcurrentHashMap<ItemEventListener<Item>,StanzaListener> itemEventToListenerMap
-
itemDeleteToListenerMap
protected java.util.concurrent.ConcurrentHashMap<ItemDeleteListener,StanzaListener> itemDeleteToListenerMap
-
configEventToListenerMap
protected java.util.concurrent.ConcurrentHashMap<NodeConfigListener,StanzaListener> configEventToListenerMap
-
-
Method Detail
-
getId
public java.lang.String getId()
Get the NodeId.- Returns:
- the node id
-
getNodeConfiguration
public ConfigureForm getNodeConfiguration() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Returns a configuration form, from which you can create an answer form to be submitted via thesendConfigurationForm(FillableConfigureForm)
.- Returns:
- the configuration form
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
sendConfigurationForm
public void sendConfigurationForm(FillableConfigureForm configureForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Update the configuration with the contents of the newFillableConfigureForm
.- Parameters:
configureForm
- the filled node configuration form with the nodes new configuration.- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
discoverInfo
public DiscoverInfo discoverInfo() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Discover node information in standardDiscoverInfo
format.- Returns:
- The discovery information about the node.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
getSubscriptions
public java.util.List<Subscription> getSubscriptions() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Get the subscriptions currently associated with this node.- Returns:
- List of
Subscription
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
getSubscriptions
public java.util.List<Subscription> getSubscriptions(java.util.List<ExtensionElement> additionalExtensions, java.util.Collection<ExtensionElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Get the subscriptions currently associated with this 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.- Parameters:
additionalExtensions
- TODO javadoc me pleasereturnedExtensions
- a collection that will be filled with the returned packet extensions- Returns:
- List of
Subscription
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
getSubscriptionsAsOwner
public java.util.List<Subscription> getSubscriptionsAsOwner() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Get the subscriptions currently associated with this node as owner.- Returns:
- List of
Subscription
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.1
- See Also:
getSubscriptionsAsOwner(List, Collection)
-
getSubscriptionsAsOwner
public java.util.List<Subscription> getSubscriptionsAsOwner(java.util.List<ExtensionElement> additionalExtensions, java.util.Collection<ExtensionElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Get the subscriptions currently associated with this node as owner.Unlike
getSubscriptions(List, Collection)
, which only retrieves the subscriptions of the current entity ("user"), this method returns a list of all subscriptions. This requires the entity to have the sufficient privileges to manage subscriptions.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.- Parameters:
additionalExtensions
- TODO javadoc me pleasereturnedExtensions
- a collection that will be filled with the returned stanza extensions- Returns:
- List of
Subscription
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.1
- See Also:
- XEP-60 § 8.8.1 - Retrieve Subscriptions List
-
modifySubscriptionsAsOwner
public PubSub modifySubscriptionsAsOwner(java.util.List<Subscription> changedSubs) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Modify the subscriptions for this PubSub node as owner.Note that the subscriptions are _not_ checked against the existing subscriptions since these are not cached (and indeed could change asynchronously)
- Parameters:
changedSubs
- subscriptions that have changed- Returns:
null
or a PubSub stanza with additional information on success.- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.3
- See Also:
- XEP-60 § 8.8.2 Modify Subscriptions
-
getAffiliations
public java.util.List<Affiliation> getAffiliations() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Get the affiliations of this node.- Returns:
- List of
Affiliation
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
getAffiliations
public java.util.List<Affiliation> getAffiliations(java.util.List<ExtensionElement> additionalExtensions, java.util.Collection<ExtensionElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Get the affiliations of this 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.- Parameters:
additionalExtensions
- additionalPacketExtensions
add to the requestreturnedExtensions
- a collection that will be filled with the returned packet extensions- Returns:
- List of
Affiliation
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
getAffiliationsAsOwner
public java.util.List<Affiliation> getAffiliationsAsOwner() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Retrieve the affiliation list for this node as owner.- Returns:
- list of entities whose affiliation is not 'none'.
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.2
- See Also:
getAffiliations(List, Collection)
-
getAffiliationsAsOwner
public java.util.List<Affiliation> getAffiliationsAsOwner(java.util.List<ExtensionElement> additionalExtensions, java.util.Collection<ExtensionElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Retrieve the affiliation list for this node as owner.Note that this is an optional PubSub feature ('pubsub#modify-affiliations').
- Parameters:
additionalExtensions
- optional additional extension elements add to the request.returnedExtensions
- an optional collection that will be filled with the returned extension elements.- Returns:
- list of entities whose affiliation is not 'none'.
- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.2
- See Also:
- XEP-60 § 8.9.1 Retrieve Affiliations List
-
modifyAffiliationAsOwner
public PubSub modifyAffiliationAsOwner(java.util.List<Affiliation> affiliations) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Modify the affiliations for this PubSub node as owner. TheAffiliation
s given must be created with theAffiliation(org.jxmpp.jid.BareJid, Affiliation.Type)
constructor.Note that this is an optional PubSub feature ('pubsub#modify-affiliations').
- Parameters:
affiliations
- TODO javadoc me please- Returns:
null
or a PubSub stanza with additional information on success.- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.2
- See Also:
- XEP-60 § 8.9.2 Modify Affiliation
-
subscribe
public Subscription subscribe(Jid jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
The user subscribes to the node using the supplied jid. The bare jid portion of this one must match the jid for the connection. Please note that theSubscription.State
should be checked on return since more actions may be required by the caller.Subscription.State.pending
- The owner must approve the subscription request before messages will be received.Subscription.State.unconfigured
- If theSubscription.isConfigRequired()
is true, the caller must configure the subscription before messages will be received. If it is false the caller can configure it but is not required to do so.- Parameters:
jid
- The jid to subscribe as.- Returns:
- The subscription
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
subscribe
@Deprecated public Subscription subscribe(java.lang.String jidString) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Deprecated.usesubscribe(Jid)
instead.The user subscribes to the node using the supplied jid. The bare jid portion of this one must match the jid for the connection. Please note that theSubscription.State
should be checked on return since more actions may be required by the caller.Subscription.State.pending
- The owner must approve the subscription request before messages will be received.Subscription.State.unconfigured
- If theSubscription.isConfigRequired()
is true, the caller must configure the subscription before messages will be received. If it is false the caller can configure it but is not required to do so.- Parameters:
jidString
- The jid to subscribe as.- Returns:
- The subscription
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.java.lang.IllegalArgumentException
- if the provided string is not a valid JID.
-
subscribe
public Subscription subscribe(Jid jid, FillableSubscribeForm subForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
The user subscribes to the node using the supplied jid and subscription options. The bare jid portion of this one must match the jid for the connection. Please note that theSubscription.State
should be checked on return since more actions may be required by the caller.Subscription.State.pending
- The owner must approve the subscription request before messages will be received.Subscription.State.unconfigured
- If theSubscription.isConfigRequired()
is true, the caller must configure the subscription before messages will be received. If it is false the caller can configure it but is not required to do so.- Parameters:
jid
- The jid to subscribe as.subForm
- TODO javadoc me please- Returns:
- The subscription
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
subscribe
@Deprecated public Subscription subscribe(java.lang.String jidString, FillableSubscribeForm subForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Deprecated.usesubscribe(Jid, FillableSubscribeForm)
instead.The user subscribes to the node using the supplied jid and subscription options. The bare jid portion of this one must match the jid for the connection. Please note that theSubscription.State
should be checked on return since more actions may be required by the caller.Subscription.State.pending
- The owner must approve the subscription request before messages will be received.Subscription.State.unconfigured
- If theSubscription.isConfigRequired()
is true, the caller must configure the subscription before messages will be received. If it is false the caller can configure it but is not required to do so.- Parameters:
jidString
- The jid to subscribe as.subForm
- TODO javadoc me please- Returns:
- The subscription
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.java.lang.IllegalArgumentException
- if the provided string is not a valid JID.
-
unsubscribe
public void unsubscribe(java.lang.String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Remove the subscription related to the specified JID. This will only work if there is only 1 subscription. If there are multiple subscriptions, useunsubscribe(String, String)
.- Parameters:
jid
- The JID used to subscribe to the node- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
unsubscribe
public void unsubscribe(java.lang.String jid, java.lang.String subscriptionId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Remove the specific subscription related to the specified JID.- Parameters:
jid
- The JID used to subscribe to the nodesubscriptionId
- The id of the subscription being removed- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
getSubscriptionOptions
public SubscribeForm getSubscriptionOptions(java.lang.String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Returns a SubscribeForm for subscriptions, from which you can create an answer form to be submitted via thesendConfigurationForm(FillableConfigureForm)
.- Parameters:
jid
- TODO javadoc me please- Returns:
- A subscription options form
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
getSubscriptionOptions
public SubscribeForm getSubscriptionOptions(java.lang.String jid, java.lang.String subscriptionId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
Get the options for configuring the specified subscription.- Parameters:
jid
- JID the subscription is registered undersubscriptionId
- The subscription id- Returns:
- The subscription option form
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.java.lang.InterruptedException
- if the calling thread was interrupted.
-
addItemEventListener
public void addItemEventListener(ItemEventListener listener)
Register a listener for item publication events. This listener will get called whenever an item is published to this node.- Parameters:
listener
- The handler for the event
-
removeItemEventListener
public void removeItemEventListener(ItemEventListener listener)
Unregister a listener for publication events.- Parameters:
listener
- The handler to unregister
-
addConfigurationListener
public void addConfigurationListener(NodeConfigListener listener)
Register a listener for configuration events. This listener will get called whenever the node's configuration changes.- Parameters:
listener
- The handler for the event
-
removeConfigurationListener
public void removeConfigurationListener(NodeConfigListener listener)
Unregister a listener for configuration events.- Parameters:
listener
- The handler to unregister
-
addItemDeleteListener
public void addItemDeleteListener(ItemDeleteListener listener)
Register an listener for item delete events. This listener gets called whenever an item is deleted from the node.- Parameters:
listener
- The handler for the event
-
removeItemDeleteListener
public void removeItemDeleteListener(ItemDeleteListener listener)
Unregister a listener for item delete events.- Parameters:
listener
- The handler to unregister
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
createPubsubPacket
protected PubSub createPubsubPacket(IQ.Type type, NodeExtension ext)
-
sendPubsubPacket
protected PubSub sendPubsubPacket(PubSub packet) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, java.lang.InterruptedException
- Throws:
SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
java.lang.InterruptedException
-
-