Class Node
- Direct Known Subclasses:
CollectionNode,LeafNode
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class translates low level item deletion events into api level objects for user consumption.static classThis class translates low level item publication events into api level objects for user consumption.static classThis class translates low level node configuration events into api level objects for user consumption. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConcurrentHashMap<NodeConfigListener,StanzaListener> protected final Stringprotected ConcurrentHashMap<ItemDeleteListener,StanzaListener> protected ConcurrentHashMap<ItemEventListener<Item>,StanzaListener> protected final PubSubManager -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConfigurationListener(NodeConfigListener listener) Register a listener for configuration events.voidaddItemDeleteListener(ItemDeleteListener listener) Register an listener for item delete events.voidaddItemEventListener(ItemEventListener listener) Register a listener for item publication events.protected PubSubcreatePubsubPacket(IQ.Type type, NodeExtension ext) Discover node information in standardDiscoverInfoformat.Get the affiliations of this node.getAffiliations(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions) Get the affiliations of this node.Retrieve the affiliation list for this node as owner.getAffiliationsAsOwner(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions) Retrieve the affiliation list for this node as owner.getId()Get the NodeId.Returns a configuration form, from which you can create an answer form to be submitted via thesendConfigurationForm(FillableConfigureForm).Returns a SubscribeForm for subscriptions, from which you can create an answer form to be submitted via thesendConfigurationForm(FillableConfigureForm).getSubscriptionOptions(String jid, String subscriptionId) Get the options for configuring the specified subscription.Get the subscriptions currently associated with this node.getSubscriptions(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions) Get the subscriptions currently associated with this node.Get the subscriptions currently associated with this node as owner.getSubscriptionsAsOwner(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions) Get the subscriptions currently associated with this node as owner.modifyAffiliationAsOwner(List<Affiliation> affiliations) Modify the affiliations for this PubSub node as owner.modifySubscriptionsAsOwner(List<Subscription> changedSubs) Modify the subscriptions for this PubSub node as owner.voidUnregister a listener for configuration events.voidremoveItemDeleteListener(ItemDeleteListener listener) Unregister a listener for item delete events.voidremoveItemEventListener(ItemEventListener listener) Unregister a listener for publication events.voidsendConfigurationForm(FillableConfigureForm configureForm) Update the configuration with the contents of the newFillableConfigureForm.protected PubSubsendPubsubPacket(PubSub packet) The user subscribes to the node using the supplied jid.subscribe(Jid jid, FillableSubscribeForm subForm) The user subscribes to the node using the supplied jid and subscription options.toString()voidunsubscribe(String jid) Remove the subscription related to the specified JID.voidunsubscribe(String jid, String subscriptionId) Remove the specific subscription related to the specified JID.
-
Field Details
-
pubSubManager
-
id
-
itemEventToListenerMap
-
itemDeleteToListenerMap
-
configEventToListenerMap
-
-
Method Details
-
getId
Get the NodeId.- Returns:
- the node id
-
getNodeConfiguration
public ConfigureForm getNodeConfiguration() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionReturns 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.InterruptedException- if the calling thread was interrupted.
-
sendConfigurationForm
public void sendConfigurationForm(FillableConfigureForm configureForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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.InterruptedException- if the calling thread was interrupted.
-
discoverInfo
public DiscoverInfo discoverInfo() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionDiscover node information in standardDiscoverInfoformat.- 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.InterruptedException- if the calling thread was interrupted.
-
getSubscriptions
public List<Subscription> getSubscriptions() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionGet 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.InterruptedException- if the calling thread was interrupted.
-
getSubscriptions
public List<Subscription> getSubscriptions(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Get the subscriptions currently associated with this node.additionalExtensionscan be used e.g. to add a "Result Set Management" extension.returnedExtensionswill 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.InterruptedException- if the calling thread was interrupted.
-
getSubscriptionsAsOwner
public List<Subscription> getSubscriptionsAsOwner() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionGet 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.InterruptedException- if the calling thread was interrupted.- Since:
- 4.1
- See Also:
-
getSubscriptionsAsOwner
public List<Subscription> getSubscriptionsAsOwner(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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.additionalExtensionscan be used e.g. to add a "Result Set Management" extension.returnedExtensionswill 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.InterruptedException- if the calling thread was interrupted.- Since:
- 4.1
- See Also:
-
modifySubscriptionsAsOwner
public PubSub modifySubscriptionsAsOwner(List<Subscription> changedSubs) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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:
nullor 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.InterruptedException- if the calling thread was interrupted.- Since:
- 4.3
- See Also:
-
getAffiliations
public List<Affiliation> getAffiliations() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionGet 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.InterruptedException- if the calling thread was interrupted.
-
getAffiliations
public List<Affiliation> getAffiliations(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Get the affiliations of this node.additionalExtensionscan be used e.g. to add a "Result Set Management" extension.returnedExtensionswill be filled with the stanza extensions found in the answer.- Parameters:
additionalExtensions- additionalPacketExtensionsadd 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.InterruptedException- if the calling thread was interrupted.
-
getAffiliationsAsOwner
public List<Affiliation> getAffiliationsAsOwner() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionRetrieve 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.InterruptedException- if the calling thread was interrupted.- Since:
- 4.2
- See Also:
-
getAffiliationsAsOwner
public List<Affiliation> getAffiliationsAsOwner(List<XmlElement> additionalExtensions, Collection<XmlElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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.InterruptedException- if the calling thread was interrupted.- Since:
- 4.2
- See Also:
-
modifyAffiliationAsOwner
public PubSub modifyAffiliationAsOwner(List<Affiliation> affiliations) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Modify the affiliations for this PubSub node as owner. TheAffiliations 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:
nullor 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.InterruptedException- if the calling thread was interrupted.- Since:
- 4.2
- See Also:
-
subscribe
public Subscription subscribe(Jid jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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.Stateshould 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.InterruptedException- if the calling thread was interrupted.
-
subscribe
public Subscription subscribe(Jid jid, FillableSubscribeForm subForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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.Stateshould 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.InterruptedException- if the calling thread was interrupted.
-
unsubscribe
public void unsubscribe(String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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.InterruptedException- if the calling thread was interrupted.
-
unsubscribe
public void unsubscribe(String jid, String subscriptionId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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.InterruptedException- if the calling thread was interrupted.
-
getSubscriptionOptions
public SubscribeForm getSubscriptionOptions(String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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.InterruptedException- if the calling thread was interrupted.
-
getSubscriptionOptions
public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, 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.InterruptedException- if the calling thread was interrupted.
-
addItemEventListener
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
Unregister a listener for publication events.- Parameters:
listener- The handler to unregister
-
addConfigurationListener
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
Unregister a listener for configuration events.- Parameters:
listener- The handler to unregister
-
addItemDeleteListener
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
Unregister a listener for item delete events.- Parameters:
listener- The handler to unregister
-
toString
-
createPubsubPacket
-
sendPubsubPacket
-