use of org.jivesoftware.smackx.pubsub.packet.PubSub in project ecf by eclipse.
the class LeafNode method getItems.
/**
* Get the current items stored in the node.
*
* @return List of {@link Item} in the node
*
* @throws XMPPException
*/
public <T extends Item> List<T> getItems() throws XMPPException {
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId()));
PubSub result = (PubSub) SyncPacketSend.getReply(con, request);
ItemsExtension itemsElem = (ItemsExtension) result.getExtension(PubSubElementType.ITEMS);
return (List<T>) itemsElem.getItems();
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project ecf by eclipse.
the class Node method getSubscriptions.
/**
* Get the subscriptions currently associated with this node.
*
* @return List of {@link Subscription}
*
* @throws XMPPException
*/
public List<Subscription> getSubscriptions() throws XMPPException {
PubSub reply = (PubSub) sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()));
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
return subElem.getSubscriptions();
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project ecf by eclipse.
the class Node method sendConfigurationForm.
/**
* Update the configuration with the contents of the new {@link Form}
*
* @param submitForm
*/
public void sendConfigurationForm(Form submitForm) throws XMPPException {
PubSub packet = createPubsubPacket(Type.SET, new FormNode(FormNodeType.CONFIGURE_OWNER, getId(), submitForm), PubSubNamespace.OWNER);
SyncPacketSend.getReply(con, packet);
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project ecf by eclipse.
the class PubSubManager method createNode.
/**
* Creates an instant node, if supported.
*
* @return The node that was created
* @exception XMPPException
*/
public LeafNode createNode() throws XMPPException {
PubSub reply = (PubSub) sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.CREATE));
NodeExtension elem = (NodeExtension) reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
LeafNode newNode = new LeafNode(con, elem.getNode());
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project ecf by eclipse.
the class PubSubManager method createNode.
/**
* Creates a node with specified configuration.
*
* Note: This is the only way to create a collection node.
*
* @param name The name of the node, which must be unique within the
* pubsub service
* @param config The configuration for the node
* @return The node that was created
* @exception XMPPException
*/
public Node createNode(String name, Form config) throws XMPPException {
PubSub request = createPubsubPacket(to, Type.SET, new NodeExtension(PubSubElementType.CREATE, name));
boolean isLeafNode = true;
if (config != null) {
request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
if (nodeTypeField != null)
isLeafNode = nodeTypeField.getValues().next().equals(NodeType.leaf.toString());
}
// Errors will cause exceptions in getReply, so it only returns
// on success.
sendPubsubPacket(con, to, Type.SET, request);
Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
newNode.setTo(to);
nodeMap.put(newNode.getId(), newNode);
return newNode;
}
Aggregations