use of org.jivesoftware.smackx.pubsub.packet.PubSub in project Smack by igniterealtime.
the class LeafNode method deleteItem.
/**
* Delete the items with the specified id's from the node.
*
* @param itemIds The list of id's of items to delete
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
* @throws InterruptedException
*/
public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
List<Item> items = new ArrayList<Item>(itemIds.size());
for (String id : itemIds) {
items.add(new Item(id));
}
PubSub request = createPubsubPacket(Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items));
pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project Smack by igniterealtime.
the class Node method subscribe.
/**
* 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 the {@link Subscription.State} should be checked
* on return since more actions may be required by the caller.
* {@link Subscription.State#pending} - The owner must approve the subscription
* request before messages will be received.
* {@link Subscription.State#unconfigured} - If the {@link 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.
* @param jid The jid to subscribe as.
* @return The subscription
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*/
public Subscription subscribe(String jid, SubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId()));
request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm));
PubSub reply = sendPubsubPacket(request);
return reply.getExtension(PubSubElementType.SUBSCRIPTION);
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project Smack by igniterealtime.
the class Node method getAffiliations.
private List<Affiliation> getAffiliations(PubSubNamespace namespace, List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS, getId()), namespace);
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe);
}
}
PubSub reply = sendPubsubPacket(pubSub);
if (returnedExtensions != null) {
returnedExtensions.addAll(reply.getExtensions());
}
AffiliationsExtension affilElem = (AffiliationsExtension) reply.getExtension(PubSubElementType.AFFILIATIONS);
return affilElem.getAffiliations();
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project Smack by igniterealtime.
the class Node method getSubscriptionOptions.
/**
* Get the options for configuring the specified subscription.
*
* @param jid JID the subscription is registered under
* @param subscriptionId The subscription id
*
* @return The subscription option form
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
*
*/
public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub packet = sendPubsubPacket(createPubsubPacket(Type.get, new OptionsExtension(jid, getId(), subscriptionId)));
FormNode ext = packet.getExtension(PubSubElementType.OPTIONS);
return new SubscribeForm(ext.getForm());
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project camel by apache.
the class XmppBinding method extractHeadersFromXmpp.
public Map<String, Object> extractHeadersFromXmpp(Packet xmppPacket, Exchange exchange) {
Map<String, Object> answer = new HashMap<String, Object>();
PacketExtension jpe = xmppPacket.getExtension(JivePropertiesExtension.NAMESPACE);
if (jpe != null && jpe instanceof JivePropertiesExtension) {
extractHeadersFrom((JivePropertiesExtension) jpe, exchange, answer);
}
if (jpe != null && jpe instanceof DefaultPacketExtension) {
extractHeadersFrom((DefaultPacketExtension) jpe, exchange, answer);
}
if (xmppPacket instanceof Message) {
Message xmppMessage = (Message) xmppPacket;
answer.put(XmppConstants.MESSAGE_TYPE, xmppMessage.getType());
answer.put(XmppConstants.SUBJECT, xmppMessage.getSubject());
answer.put(XmppConstants.THREAD_ID, xmppMessage.getThread());
} else if (xmppPacket instanceof PubSub) {
PubSub pubsubPacket = (PubSub) xmppPacket;
answer.put(XmppConstants.MESSAGE_TYPE, pubsubPacket.getType());
}
answer.put(XmppConstants.FROM, xmppPacket.getFrom());
answer.put(XmppConstants.PACKET_ID, xmppPacket.getPacketID());
answer.put(XmppConstants.TO, xmppPacket.getTo());
return answer;
}
Aggregations