use of org.jivesoftware.smackx.pubsub.packet.PubSub in project Smack by igniterealtime.
the class ConfigureFormTest method getConfigFormWithInsufficientPriviliges.
@Test
public void getConfigFormWithInsufficientPriviliges() throws XMPPException, SmackException, IOException, InterruptedException {
ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
DiscoverInfo info = new DiscoverInfo();
Identity ident = new Identity("pubsub", null, "leaf");
info.addIdentity(ident);
con.addIQReply(info);
Node node = mgr.getNode("princely_musings");
PubSub errorIq = new PubSub();
XMPPError.Builder error = XMPPError.getBuilder(Condition.forbidden);
errorIq.setError(error);
con.addIQReply(errorIq);
try {
node.getNodeConfiguration();
} catch (XMPPErrorException e) {
Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType());
}
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project ecf by eclipse.
the class LeafNode method send.
/**
* Publishes multiple events to the node. Same rules apply as in {@link #send(Item)}.
*
* In addition, if {@link ConfigureForm#isPersistItems()}=false, only the last item in the input
* list will get stored on the node, assuming it stores the last sent item.
*
* This is a synchronous call which will throw an exception
* on failure.
*
* For asynchronous calls, use {@link #publish(Collection) publish(Collection))}.
*
* @param items - The collection of {@link Item} objects being sent
*
* @throws XMPPException
*/
public <T extends Item> void send(Collection<T> items) throws XMPPException {
PubSub packet = createPubsubPacket(Type.SET, new PublishItem<T>(getId(), items));
SyncPacketSend.getReply(con, packet);
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project ecf by eclipse.
the class LeafNode method getItems.
/**
* Get items persisted on the node, limited to the specified number
* based on the subscription associated with the provided subscriptionId.
*
* @param maxItems Maximum number of items to return
* @param subscriptionId The subscription which the retrieval is based
* on.
*
* @return List of {@link Item}
*
* @throws XMPPException
*/
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws XMPPException {
PubSub request = createPubsubPacket(Type.GET, new GetItemsRequest(getId(), subscriptionId, maxItems));
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 LeafNode method send.
/**
* Publishes an event to the node. This is an empty event
* with no item.
*
* This is only acceptable for nodes with {@link ConfigureForm#isPersistItems()}=false
* and {@link ConfigureForm#isDeliverPayloads()}=false.
*
* This is a synchronous call which will throw an exception
* on failure.
*
* For asynchronous calls, use {@link #publish() publish()}.
*
* @throws XMPPException
*/
public void send() throws XMPPException {
PubSub packet = createPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.PUBLISH, getId()));
SyncPacketSend.getReply(con, packet);
}
use of org.jivesoftware.smackx.pubsub.packet.PubSub in project ecf by eclipse.
the class LeafNode method getItems.
/**
* Get the items specified from the node. This would typically be
* used when the server does not return the payload due to size
* constraints. The user would be required to retrieve the payload
* after the items have been retrieved via {@link #getItems()} or an
* event, that did not include the payload.
*
* @param ids Item ids of the items to retrieve
*
* @return The list of {@link Item} with payload
*
* @throws XMPPException
*/
public <T extends Item> List<T> getItems(Collection<String> ids) throws XMPPException {
List<Item> itemList = new ArrayList<Item>(ids.size());
for (String id : ids) {
itemList.add(new Item(id));
}
PubSub request = createPubsubPacket(Type.GET, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
PubSub result = (PubSub) SyncPacketSend.getReply(con, request);
ItemsExtension itemsElem = (ItemsExtension) result.getExtension(PubSubElementType.ITEMS);
return (List<T>) itemsElem.getItems();
}
Aggregations