org.jivesoftware.smackx.pubsub.packet.PubSub Java Examples
The following examples show how to use
org.jivesoftware.smackx.pubsub.packet.PubSub.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlogPostDetailsActivity.java From mangosta-android with Apache License 2.0 | 6 votes |
public BlogPostComment sendBlogPostComment(String content, BlogPost blogPost) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException { Jid jid = XMPPSession.getInstance().getUser().asEntityBareJid(); String userName = XMPPUtils.fromJIDToUserName(jid.toString()); Jid pubSubServiceJid = XMPPSession.getInstance().getPubSubService(); // create stanza PublishCommentExtension publishCommentExtension = new PublishCommentExtension(blogPost.getId(), userName, jid, content, new Date()); PubSub publishCommentPubSub = PubSub.createPubsubPacket(pubSubServiceJid, IQ.Type.set, publishCommentExtension, null); // send stanza XMPPSession.getInstance().sendStanza(publishCommentPubSub); return new BlogPostComment(publishCommentExtension.getId(), blogPost.getId(), content, userName, jid.toString(), publishCommentExtension.getPublished()); }
Example #2
Source File: Node.java From Smack with Apache License 2.0 | 6 votes |
private List<Subscription> getSubscriptions(SubscriptionsNamespace subscriptionsNamespace, List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSubElementType pubSubElementType = subscriptionsNamespace.type; PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(pubSubElementType, getId())); if (additionalExtensions != null) { for (ExtensionElement pe : additionalExtensions) { pubSub.addExtension(pe); } } PubSub reply = sendPubsubPacket(pubSub); if (returnedExtensions != null) { returnedExtensions.addAll(reply.getExtensions()); } SubscriptionsExtension subElem = reply.getExtension(pubSubElementType); return subElem.getSubscriptions(); }
Example #3
Source File: Node.java From Smack with Apache License 2.0 | 6 votes |
private List<Affiliation> getAffiliations(AffiliationNamespace affiliationsNamespace, List<ExtensionElement> additionalExtensions, Collection<ExtensionElement> returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSubElementType pubSubElementType = affiliationsNamespace.type; PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(pubSubElementType, getId())); if (additionalExtensions != null) { for (ExtensionElement pe : additionalExtensions) { pubSub.addExtension(pe); } } PubSub reply = sendPubsubPacket(pubSub); if (returnedExtensions != null) { returnedExtensions.addAll(reply.getExtensions()); } AffiliationsExtension affilElem = reply.getExtension(pubSubElementType); return affilElem.getAffiliations(); }
Example #4
Source File: PubSubProvider.java From Smack with Apache License 2.0 | 6 votes |
@Override public PubSub parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException { String namespace = parser.getNamespace(); PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace); PubSub pubsub = new PubSub(pubSubNamespace); outerloop: while (true) { XmlPullParser.Event eventType = parser.next(); switch (eventType) { case START_ELEMENT: PacketParserUtils.addExtensionElement(pubsub, parser, xmlEnvironment); break; case END_ELEMENT: if (parser.getDepth() == initialDepth) { break outerloop; } break; default: // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement. break; } } return pubsub; }
Example #5
Source File: PubSubManager.java From Smack with Apache License 2.0 | 6 votes |
/** * Creates a node with specified configuration. * * Note: This is the only way to create a collection node. * * @param nodeId 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 * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public Node createNode(String nodeId, FillableConfigureForm config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = PubSub.createPubsubPacket(pubSubService, Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId)); boolean isLeafNode = true; if (config != null) { DataForm submitForm = config.getDataFormToSubmit(); request.addExtension(new FormNode(FormNodeType.CONFIGURE, submitForm)); NodeType nodeType = config.getNodeType(); // Note that some implementations do to have the pubsub#node_type field in their defauilt configuration, // which I believe to be a bug. However, since PubSub specifies the default node type to be 'leaf' we assume // leaf if the field does not exist. isLeafNode = nodeType == null || nodeType == NodeType.leaf; } // Errors will cause exceptions in getReply, so it only returns // on success. sendPubsubPacket(request); Node newNode = isLeafNode ? new LeafNode(this, nodeId) : new CollectionNode(this, nodeId); nodeMap.put(newNode.getId(), newNode); return newNode; }
Example #6
Source File: PubSubManager.java From Smack with Apache License 2.0 | 5 votes |
/** * Creates an instant node, if supported. * * @return The node that was created * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null); QName qname = new QName(PubSubNamespace.basic.getXmlns(), "create"); NodeExtension elem = (NodeExtension) reply.getExtension(qname); LeafNode newNode = new LeafNode(this, elem.getNode()); nodeMap.put(newNode.getId(), newNode); return newNode; }
Example #7
Source File: PubSubManager.java From Smack with Apache License 2.0 | 5 votes |
/** * Retrieves the requested node, if it exists. It will throw an * exception if it does not. * * @param id - The unique id of the node * * @return the node * @throws XMPPErrorException The node does not exist * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. * @throws NotAPubSubNodeException if a involved node is not a PubSub node. */ public Node getNode(String id) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAPubSubNodeException { StringUtils.requireNotNullNorEmpty(id, "The node ID can not be null or the empty string"); Node node = nodeMap.get(id); if (node == null) { XMPPConnection connection = connection(); DiscoverInfo info = DiscoverInfo.builder(connection) .to(pubSubService) .setNode(id) .build(); DiscoverInfo infoReply = connection.createStanzaCollectorAndSend(info).nextResultOrThrow(); if (infoReply.hasIdentity(PubSub.ELEMENT, "leaf")) { node = new LeafNode(this, id); } else if (infoReply.hasIdentity(PubSub.ELEMENT, "collection")) { node = new CollectionNode(this, id); } else { throw new PubSubException.NotAPubSubNodeException(id, infoReply); } nodeMap.put(id, node); } return node; }
Example #8
Source File: AffiliationsExtensionTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void testAffiliationsExtensionToXml() throws SAXException, IOException { BareJid affiliatedJid = JidTestUtil.BARE_JID_1; Affiliation affiliation = new Affiliation(affiliatedJid, Type.member); List<Affiliation> affiliationsList = new ArrayList<>(); affiliationsList.add(affiliation); AffiliationsExtension affiliationsExtension = new AffiliationsExtension(affiliationsList, "testNode"); CharSequence xml = affiliationsExtension.toXML(PubSub.NAMESPACE); assertXmlSimilar("<affiliations node='testNode'><affiliation xmlns='http://jabber.org/protocol/pubsub#owner' jid='[email protected]' affiliation='member'/></affiliations>", xml); }
Example #9
Source File: PubSubProviderTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void subscriptionsOwnerResultTest() throws Exception { // @formatter:off final String resultStanza = "<iq from='pubsub.example.org' to='[email protected]/Smack' id='HaT4m-13' type='result'>" + "<pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>" + "<subscriptions node='test'>" + "<subscription jid='[email protected]/Smack' subscription='subscribed' subid='58C1A6F99F2A7'/>" + "<subscription jid='[email protected]/Smack' subscription='subscribed' subid='58C18F8917321'/>" + "</subscriptions>" + "</pubsub>" + "</iq>"; // @formatter:on XmlPullParser parser = TestUtils.getIQParser(resultStanza); PubSub pubsubResult = (PubSub) PacketParserUtils.parseIQ(parser); SubscriptionsExtension subElem = pubsubResult.getExtension(PubSubElementType.SUBSCRIPTIONS_OWNER); List<Subscription> subscriptions = subElem.getSubscriptions(); assertEquals(2, subscriptions.size()); Subscription sub1 = subscriptions.get(0); assertThat("[email protected]/Smack", equalsCharSequence(sub1.getJid())); assertEquals(Subscription.State.subscribed, sub1.getState()); assertEquals("58C1A6F99F2A7", sub1.getId()); Subscription sub2 = subscriptions.get(1); assertThat("[email protected]/Smack", equalsCharSequence(sub2.getJid())); assertEquals(Subscription.State.subscribed, sub2.getState()); assertEquals("58C18F8917321", sub2.getId()); }
Example #10
Source File: LeafNode.java From Smack with Apache License 2.0 | 5 votes |
/** * Delete the items with the specified id's from the node. * * @param itemIds The list of id's of items to delete * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { List<Item> items = new ArrayList<>(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(); }
Example #11
Source File: PubSubManager.java From Smack with Apache License 2.0 | 5 votes |
PubSub sendPubsubPacket(Jid to, Type type, List<ExtensionElement> extList, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // CHECKSTYLE:OFF PubSub pubSub = new PubSub(to, type, ns); for (ExtensionElement pe : extList) { pubSub.addExtension(pe); } // CHECKSTYLE:ON return sendPubsubPacket(pubSub); }
Example #12
Source File: PubSubManager.java From Smack with Apache License 2.0 | 5 votes |
PubSub sendPubsubPacket(PubSub packet) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { IQ resultIQ = connection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); if (resultIQ instanceof EmptyResultIQ) { return null; } return (PubSub) resultIQ; }
Example #13
Source File: PubSubManagerTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void deleteNodeTest() throws InterruptedException, SmackException, IOException, XMPPException { ThreadedDummyConnection con = ThreadedDummyConnection.newInstance(); PubSubManager mgr = new PubSubManager(con, DUMMY_PUBSUB_SERVICE); mgr.deleteNode("[email protected]"); PubSub pubSubDeleteRequest = con.getSentPacket(); assertEquals("http://jabber.org/protocol/pubsub#owner", pubSubDeleteRequest.getChildElementNamespace()); assertEquals("pubsub", pubSubDeleteRequest.getChildElementName()); }
Example #14
Source File: PubSubNodeTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void getAffiliationsAsOwnerTest() throws InterruptedException, SmackException, IOException, XMPPException, Exception { Protocol protocol = new Protocol(); XMPPConnection connection = ConnectionUtils.createMockedConnection(protocol, JidTestUtil.FULL_JID_1_RESOURCE_1); PubSubManager mgr = new PubSubManager(connection, JidTestUtil.PUBSUB_EXAMPLE_ORG); Node testNode = new LeafNode(mgr, "princely_musings"); List<Affiliation> affiliations = Arrays.asList( new Affiliation(JidTestUtil.BARE_JID_1, Affiliation.Type.member), new Affiliation(JidTestUtil.BARE_JID_2, Affiliation.Type.publisher) ); AffiliationsExtension affiliationsExtension = new AffiliationsExtension(AffiliationNamespace.owner, affiliations); PubSub response = new PubSub(JidTestUtil.PUBSUB_EXAMPLE_ORG, Type.result, PubSubNamespace.owner); response.addExtension(affiliationsExtension); protocol.addResponse(response); List<Affiliation> returnedAffiliations = testNode.getAffiliationsAsOwner(); PubSub request = (PubSub) protocol.getRequests().get(0); assertEquals("http://jabber.org/protocol/pubsub#owner", request.getChildElementNamespace()); assertEquals("pubsub", request.getChildElementName()); Affiliation affiliationOne = returnedAffiliations.get(0); assertEquals(affiliationOne.getJid(), JidTestUtil.BARE_JID_1); assertEquals(affiliationOne.getAffiliation(), Affiliation.Type.member); Affiliation affiliationTwo = returnedAffiliations.get(1); assertEquals(affiliationTwo.getJid(), JidTestUtil.BARE_JID_2); assertEquals(affiliationTwo.getAffiliation(), Affiliation.Type.publisher); }
Example #15
Source File: PubSubNodeTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void modifySubscriptionsAsOwnerTest() throws InterruptedException, SmackException, IOException, XMPPException, Exception { ThreadedDummyConnection con = ThreadedDummyConnection.newInstance(); PubSubManager mgr = new PubSubManager(con, JidTestUtil.PUBSUB_EXAMPLE_ORG); Node testNode = new LeafNode(mgr, "princely_musings"); List<Subscription> ChangeSubs = Arrays.asList( new Subscription(JidCreate.from("[email protected]"), Subscription.State.subscribed), new Subscription(JidCreate.from("[email protected]"), Subscription.State.none) ); testNode.modifySubscriptionsAsOwner(ChangeSubs); PubSub request = con.getSentPacket(); assertEquals("http://jabber.org/protocol/pubsub#owner", request.getChildElementNamespace()); assertEquals("pubsub", request.getChildElementName()); XmlPullParser parser = TestUtils.getIQParser(request.toXML().toString()); PubSub pubsubResult = (PubSub) PacketParserUtils.parseIQ(parser); SubscriptionsExtension subElem = pubsubResult.getExtension(PubSubElementType.SUBSCRIPTIONS_OWNER); List<Subscription> subscriptions = subElem.getSubscriptions(); assertEquals(2, subscriptions.size()); Subscription sub1 = subscriptions.get(0); assertEquals("[email protected]", sub1.getJid().toString()); assertEquals(Subscription.State.subscribed, sub1.getState()); Subscription sub2 = subscriptions.get(1); assertEquals("[email protected]", sub2.getJid().toString()); assertEquals(Subscription.State.none, sub2.getState()); }
Example #16
Source File: EnablePushNotificationsIQ.java From Smack with Apache License 2.0 | 5 votes |
@Override protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) { xml.attribute("jid", jid); xml.attribute("node", node); xml.rightAngleBracket(); if (publishOptions != null) { DataForm.Builder dataForm = DataForm.builder(); // TODO: Shouldn't this use some potentially existing PubSub API? Also FORM_TYPE fields are usually of type // 'hidden', but the examples in XEP-0357 do also not set the value to hidden and FORM_TYPE itself appears // to be more convention than specification. FormField formTypeField = FormField.buildHiddenFormType(PubSub.NAMESPACE + "#publish-options"); dataForm.addField(formTypeField); Iterator<Map.Entry<String, String>> publishOptionsIterator = publishOptions.entrySet().iterator(); while (publishOptionsIterator.hasNext()) { Map.Entry<String, String> pairVariableValue = publishOptionsIterator.next(); TextSingleFormField.Builder field = FormField.builder(pairVariableValue.getKey()); field.setValue(pairVariableValue.getValue()); dataForm.addField(field.build()); } xml.append(dataForm.build()); } return xml; }
Example #17
Source File: LeafNode.java From Smack with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <T extends Item> List<T> getItems(PubSub request, List<ExtensionElement> returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub result = pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow(); ItemsExtension itemsElem = result.getExtension(PubSubElementType.ITEMS); if (returnedExtensions != null) { returnedExtensions.addAll(result.getExtensions()); } return (List<T>) itemsElem.getItems(); }
Example #18
Source File: PushNotificationsElements.java From Smack with Apache License 2.0 | 4 votes |
@Override public String getNamespace() { return PubSub.NAMESPACE; }
Example #19
Source File: LeafNode.java From Smack with Apache License 2.0 | 4 votes |
private <T extends Item> List<T> getItems(PubSub request) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return getItems(request, null); }
Example #20
Source File: Node.java From Smack with Apache License 2.0 | 4 votes |
protected PubSub createPubsubPacket(Type type, NodeExtension ext) { return PubSub.createPubsubPacket(pubSubManager.getServiceJid(), type, ext); }
Example #21
Source File: Node.java From Smack with Apache License 2.0 | 4 votes |
protected PubSub sendPubsubPacket(PubSub packet) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return pubSubManager.sendPubsubPacket(packet); }
Example #22
Source File: PushNotificationsElements.java From Smack with Apache License 2.0 | 4 votes |
@Override public String getElementName() { return PubSub.ELEMENT; }
Example #23
Source File: PubSubManager.java From Smack with Apache License 2.0 | 4 votes |
private PubSub sendPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return sendPubsubPacket(pubSubService, type, Collections.singletonList(ext), ns); }
Example #24
Source File: Node.java From Smack with Apache License 2.0 | 3 votes |
/** * 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. * @param subForm TODO javadoc me please * * @return The subscription * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public Subscription subscribe(Jid jid, FillableSubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DataForm submitForm = subForm.getDataFormToSubmit(); PubSub request = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId())); request.addExtension(new FormNode(FormNodeType.OPTIONS, submitForm)); PubSub reply = sendPubsubPacket(request); return reply.getExtension(PubSubElementType.SUBSCRIPTION); }
Example #25
Source File: Node.java From Smack with Apache License 2.0 | 3 votes |
/** * Modify the affiliations for this PubSub node as owner. The {@link Affiliation}s given must be created with the * {@link Affiliation#Affiliation(org.jxmpp.jid.BareJid, Affiliation.Type)} constructor. * <p> * Note that this is an <b>optional</b> PubSub feature ('pubsub#modify-affiliations'). * </p> * * @param affiliations TODO javadoc me please * @return <code>null</code> or a PubSub stanza with additional information on success. * @throws NoResponseException if there was no response from the remote entity. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. * @see <a href="http://www.xmpp.org/extensions/xep-0060.html#owner-affiliations-modify">XEP-60 § 8.9.2 Modify Affiliation</a> * @since 4.2 */ public PubSub modifyAffiliationAsOwner(List<Affiliation> affiliations) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { for (Affiliation affiliation : affiliations) { if (affiliation.getPubSubNamespace() != PubSubNamespace.owner) { throw new IllegalArgumentException("Must use Affiliation(BareJid, Type) affiliations"); } } PubSub pubSub = createPubsubPacket(Type.set, new AffiliationsExtension(AffiliationNamespace.owner, affiliations, getId())); return sendPubsubPacket(pubSub); }
Example #26
Source File: Node.java From Smack with Apache License 2.0 | 3 votes |
/** * Modify the subscriptions for this PubSub node as owner. * <p> * Note that the subscriptions are _not_ checked against the existing subscriptions * since these are not cached (and indeed could change asynchronously) * </p> * * @param changedSubs subscriptions that have changed * @return <code>null</code> or a PubSub stanza with additional information on success. * @throws NoResponseException if there was no response from the remote entity. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. * @see <a href="https://xmpp.org/extensions/xep-0060.html#owner-subscriptions-modify">XEP-60 § 8.8.2 Modify Subscriptions</a> * @since 4.3 */ public PubSub modifySubscriptionsAsOwner(List<Subscription> changedSubs) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub pubSub = createPubsubPacket(Type.set, new SubscriptionsExtension(SubscriptionsNamespace.owner, getId(), changedSubs)); return sendPubsubPacket(pubSub); }
Example #27
Source File: OmemoManager.java From Smack with Apache License 2.0 | 3 votes |
/** * Returns true, if the Server supports PEP. * * @param connection XMPPConnection * @param server domainBareJid of the server to test * @return true if server supports pep * * @throws XMPPException.XMPPErrorException if there was an XMPP error returned. * @throws SmackException.NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. * @throws SmackException.NoResponseException if there was no response from the remote entity. */ public static boolean serverSupportsOmemo(XMPPConnection connection, DomainBareJid server) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { return ServiceDiscoveryManager.getInstanceFor(connection) .discoverInfo(server).containsFeature(PubSub.NAMESPACE); }
Example #28
Source File: Node.java From Smack with Apache License 2.0 | 3 votes |
/** * Returns a configuration form, from which you can create an answer form to be submitted * via the {@link #sendConfigurationForm(FillableConfigureForm)}. * * @return the configuration form * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension( PubSubElementType.CONFIGURE_OWNER, getId())); Stanza reply = sendPubsubPacket(pubSub); return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER); }
Example #29
Source File: LeafNode.java From Smack with Apache License 2.0 | 3 votes |
/** * Get items persisted on the node. * <p> * {@code additionalExtensions} can be used e.g. to add a "Result Set Management" extension. * {@code returnedExtensions} will be filled with the stanza extensions found in the answer. * </p> * * @param additionalExtensions additional {@code PacketExtensions} to be added to the request. * This is an optional argument, if provided as null no extensions will be added. * @param returnedExtensions a collection that will be filled with the returned packet * extensions. This is an optional argument, if provided as null it won't be populated. * @param <T> type of the items. * * @return List of {@link Item} * @throws NoResponseException if there was no response from the remote entity. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public <T extends Item> List<T> getItems(List<ExtensionElement> additionalExtensions, List<ExtensionElement> returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId())); request.addExtensions(additionalExtensions); return getItems(request, returnedExtensions); }
Example #30
Source File: LeafNode.java From Smack with Apache License 2.0 | 3 votes |
/** * 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 * @param <T> type of the items. * * @return The list of {@link Item} with payload * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { List<Item> itemList = new ArrayList<>(ids.size()); for (String id : ids) { itemList.add(new Item(id)); } PubSub request = createPubsubPacket(Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList)); return getItems(request); }