public abstract class Node extends Object
Modifier and Type | Class and 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.
|
Modifier and Type | Field and Description |
---|---|
protected ConcurrentHashMap<NodeConfigListener,StanzaListener> |
configEventToListenerMap |
protected String |
id |
protected ConcurrentHashMap<ItemDeleteListener,StanzaListener> |
itemDeleteToListenerMap |
protected ConcurrentHashMap<ItemEventListener<Item>,StanzaListener> |
itemEventToListenerMap |
protected PubSubManager |
pubSubManager |
Modifier and Type | Method and 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 standard
DiscoverInfo format. |
List<Affiliation> |
getAffiliations()
Get the affiliations of this node.
|
List<Affiliation> |
getAffiliations(List<ExtensionElement> additionalExtensions,
Collection<ExtensionElement> returnedExtensions)
Get the affiliations of this node.
|
List<Affiliation> |
getAffiliationsAsOwner()
Retrieve the affiliation list for this node as owner.
|
List<Affiliation> |
getAffiliationsAsOwner(List<ExtensionElement> additionalExtensions,
Collection<ExtensionElement> returnedExtensions)
Retrieve the affiliation list for this node as owner.
|
String |
getId()
Get the NodeId.
|
ConfigureForm |
getNodeConfiguration()
Returns a configuration form, from which you can create an answer form to be submitted
via the
sendConfigurationForm(Form) . |
SubscribeForm |
getSubscriptionOptions(String jid)
Returns a SubscribeForm for subscriptions, from which you can create an answer form to be submitted
via the
sendConfigurationForm(Form) . |
SubscribeForm |
getSubscriptionOptions(String jid,
String subscriptionId)
Get the options for configuring the specified subscription.
|
List<Subscription> |
getSubscriptions()
Get the subscriptions currently associated with this node.
|
List<Subscription> |
getSubscriptions(List<ExtensionElement> additionalExtensions,
Collection<ExtensionElement> returnedExtensions)
Get the subscriptions currently associated with this node.
|
List<Subscription> |
getSubscriptionsAsOwner()
Get the subscriptions currently associated with this node as owner.
|
List<Subscription> |
getSubscriptionsAsOwner(List<ExtensionElement> additionalExtensions,
Collection<ExtensionElement> returnedExtensions)
Get the subscriptions currently associated with this node as owner.
|
PubSub |
modifyAffiliationAsOwner(List<Affiliation> affiliations)
Modify the affiliations for this PubSub node as owner.
|
PubSub |
modifySubscriptionsAsOwner(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(Form submitForm)
Update the configuration with the contents of the new
Form . |
protected PubSub |
sendPubsubPacket(PubSub packet) |
Subscription |
subscribe(String jid)
The user subscribes to the node using the supplied jid.
|
Subscription |
subscribe(String jid,
SubscribeForm subForm)
The user subscribes to the node using the supplied jid and subscription
options.
|
String |
toString() |
void |
unsubscribe(String jid)
Remove the subscription related to the specified JID.
|
void |
unsubscribe(String jid,
String subscriptionId)
Remove the specific subscription related to the specified JID.
|
protected final PubSubManager pubSubManager
protected ConcurrentHashMap<ItemEventListener<Item>,StanzaListener> itemEventToListenerMap
protected ConcurrentHashMap<ItemDeleteListener,StanzaListener> itemDeleteToListenerMap
protected ConcurrentHashMap<NodeConfigListener,StanzaListener> configEventToListenerMap
public ConfigureForm getNodeConfiguration() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
sendConfigurationForm(Form)
.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public void sendConfigurationForm(Form submitForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Form
.submitForm
- XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public DiscoverInfo discoverInfo() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
DiscoverInfo
format.XMPPException.XMPPErrorException
SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public List<Subscription> getSubscriptions() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
public List<Subscription> getSubscriptions(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
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.
additionalExtensions
- returnedExtensions
- a collection that will be filled with the returned packet
extensionsSubscription
SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
InterruptedException
public List<Subscription> getSubscriptionsAsOwner() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Subscription
XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
getSubscriptionsAsOwner(List, Collection)
public List<Subscription> getSubscriptionsAsOwner(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
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.
additionalExtensions
- returnedExtensions
- a collection that will be filled with the returned stanza extensionsSubscription
SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
InterruptedException
public PubSub modifySubscriptionsAsOwner(List<Subscription> changedSubs) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Note that the subscriptions are _not_ checked against the existing subscriptions since these are not cached (and indeed could change asynchronously)
changedSubs
- subscriptions that have changednull
or a PubSub stanza with additional information on success.SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
InterruptedException
public List<Affiliation> getAffiliations() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
public List<Affiliation> getAffiliations(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
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.
additionalExtensions
- additional PacketExtensions
add to the requestreturnedExtensions
- a collection that will be filled with the returned packet
extensionsAffiliation
SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
InterruptedException
public List<Affiliation> getAffiliationsAsOwner() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
InterruptedException
getAffiliations(List, Collection)
public List<Affiliation> getAffiliationsAsOwner(List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Note that this is an optional PubSub feature ('pubsub#modify-affiliations').
additionalExtensions
- optional additional extension elements add to the request.returnedExtensions
- an optional collection that will be filled with the returned
extension elements.SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
InterruptedException
public PubSub modifyAffiliationAsOwner(List<Affiliation> affiliations) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Affiliation
s given must be created with the
Affiliation.Affiliation(org.jxmpp.jid.BareJid, Affiliation.Type)
constructor.
Note that this is an optional PubSub feature ('pubsub#modify-affiliations').
affiliations
- null
or a PubSub stanza with additional information on success.SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
InterruptedException
public Subscription subscribe(String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Subscription.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 the Subscription.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.jid
- The jid to subscribe as.XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public Subscription subscribe(String jid, SubscribeForm subForm) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Subscription.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 the Subscription.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.jid
- The jid to subscribe as.subForm
- XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public void unsubscribe(String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
unsubscribe(String, String)
.jid
- The JID used to subscribe to the nodeXMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public void unsubscribe(String jid, String subscriptionId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
jid
- The JID used to subscribe to the nodesubscriptionId
- The id of the subscription being removedXMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public SubscribeForm getSubscriptionOptions(String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
sendConfigurationForm(Form)
.jid
- XMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
jid
- JID the subscription is registered undersubscriptionId
- The subscription idXMPPException.XMPPErrorException
SmackException.NoResponseException
SmackException.NotConnectedException
InterruptedException
public void addItemEventListener(ItemEventListener listener)
listener
- The handler for the eventpublic void removeItemEventListener(ItemEventListener listener)
listener
- The handler to unregisterpublic void addConfigurationListener(NodeConfigListener listener)
listener
- The handler for the eventpublic void removeConfigurationListener(NodeConfigListener listener)
listener
- The handler to unregisterpublic void addItemDeleteListener(ItemDeleteListener listener)
listener
- The handler for the eventpublic void removeItemDeleteListener(ItemDeleteListener listener)
listener
- The handler to unregisterprotected PubSub createPubsubPacket(IQ.Type type, NodeExtension ext)
protected PubSub sendPubsubPacket(PubSub packet) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException