congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SubscriptionsExtension
Code IndexAdd Tabnine to your IDE (free)

How to use
SubscriptionsExtension
in
org.jivesoftware.smackx.pubsub

Best Java code snippets using org.jivesoftware.smackx.pubsub.SubscriptionsExtension (Showing top 19 results out of 315)

origin: igniterealtime/Smack

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();
}
origin: igniterealtime/Smack

@SuppressWarnings("unchecked")
@Override
protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) {
  SubscriptionsNamespace subscriptionsNamespace = SubscriptionsNamespace.fromXmlns(currentNamespace);
  String nodeId = attributeMap.get("node");
  return new SubscriptionsExtension(subscriptionsNamespace, nodeId, (List<Subscription>) content);
}
origin: igniterealtime/Smack

  @Override
  public CharSequence toXML(String enclosingNamespace) {
    if ((items == null) || (items.size() == 0)) {
      return super.toXML(enclosingNamespace);
    }
    else {
      StringBuilder builder = new StringBuilder("<");
      builder.append(getElementName());

      if (getNode() != null) {
        builder.append(" node='");
        builder.append(getNode());
        builder.append('\'');
      }
      builder.append('>');

      for (Subscription item : items) {
        builder.append(item.toXML(null));
      }

      builder.append("</");
      builder.append(getElementName());
      builder.append('>');
      return builder.toString();
    }
  }
}
origin: org.igniterealtime.smack/smackx

builder.append(getElementName());
if (getNode() != null)
  builder.append(getNode());
  builder.append("'");
builder.append(getElementName());
builder.append(">");
return builder.toString();
origin: igniterealtime/Smack

/**
 * Gets the subscriptions on the root node.
 *
 * @return List of exceptions
 * @throws XMPPErrorException
 * @throws NoResponseException
 * @throws NotConnectedException
 * @throws InterruptedException
 */
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
  Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
  SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
  return subElem.getSubscriptions();
}
origin: igniterealtime/Smack

/**
 * 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
 * @throws XMPPErrorException
 * @throws NotConnectedException
 * @throws InterruptedException
 * @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);
}
origin: org.littleshoot/smack-xmpp-3-2-2

builder.append(getElementName());
if (getNode() != null)
  builder.append(getNode());
  builder.append("'");
builder.append(getElementName());
builder.append(">");
return builder.toString();
origin: igniterealtime/Smack

  @Test
  public void subscriptionsOwnerResultTest() throws Exception {
    // @formatter:off
    final String resultStanza =
     "<iq from='pubsub.example.org' to='julia@example.org/Smack' id='HaT4m-13' type='result'>" +
      "<pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>" +
       "<subscriptions node='test'>" +
        "<subscription jid='foo@example.org/Smack' subscription='subscribed' subid='58C1A6F99F2A7'/>" +
        "<subscription jid='julia@example.org/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("foo@example.org/Smack", equalsCharSequence(sub1.getJid()));
    assertEquals(Subscription.State.subscribed, sub1.getState());
    assertEquals("58C1A6F99F2A7", sub1.getId());

    Subscription sub2 = subscriptions.get(1);
    assertThat("julia@example.org/Smack", equalsCharSequence(sub2.getJid()));
    assertEquals(Subscription.State.subscribed, sub2.getState());
    assertEquals("58C18F8917321", sub2.getId());
  }
}
origin: org.littleshoot/smack-xmpp-3-2-2

@Override
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
{
  return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>)content);
}
origin: tiandawu/IotXmpp

builder.append(getElementName());
if (getNode() != null)
  builder.append(getNode());
  builder.append("'");
builder.append(getElementName());
builder.append(">");
return builder.toString();
origin: igniterealtime/Smack

@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("romeo@montague.org"), Subscription.State.subscribed),
    new Subscription(JidCreate.from("juliet@capulet.org"), 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(null).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("romeo@montague.org", sub1.getJid().toString());
  assertEquals(Subscription.State.subscribed, sub1.getState());
  Subscription sub2 = subscriptions.get(1);
  assertEquals("juliet@capulet.org", sub2.getJid().toString());
  assertEquals(Subscription.State.none, sub2.getState());
}
origin: org.igniterealtime.smack/smackx

@Override
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
{
  return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>)content);
}
origin: tiandawu/IotXmpp

/**
 * 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();
}
origin: tiandawu/IotXmpp

@Override
protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content)
{
  return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>)content);
}
origin: org.igniterealtime.smack/smackx

/**
 * 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();
}
origin: org.littleshoot/smack-xmpp-3-2-2

/**
 * 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();
}
origin: org.igniterealtime.smack/smackx

/**
 * Gets the subscriptions on the root node.
 * 
 * @return List of exceptions
 * 
 * @throws XMPPException
 */
public List<Subscription> getSubscriptions()
  throws XMPPException
{
  Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS));
  SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
  return subElem.getSubscriptions();
}
 
origin: tiandawu/IotXmpp

/**
 * Gets the subscriptions on the root node.
 * 
 * @return List of exceptions
 * 
 * @throws XMPPException
 */
public List<Subscription> getSubscriptions()
  throws XMPPException
{
  Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS));
  SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
  return subElem.getSubscriptions();
}

origin: org.littleshoot/smack-xmpp-3-2-2

/**
 * Gets the subscriptions on the root node.
 * 
 * @return List of exceptions
 * 
 * @throws XMPPException
 */
public List<Subscription> getSubscriptions()
  throws XMPPException
{
  Packet reply = sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS));
  SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
  return subElem.getSubscriptions();
}
 
org.jivesoftware.smackx.pubsubSubscriptionsExtension

Javadoc

Represents the element holding the list of subscription elements.

Most used methods

  • getSubscriptions
    Gets the list of subscriptions.
  • <init>
    Subscriptions to the root node
  • getElementName
  • getNode

Popular in Java

  • Finding current android device location
  • putExtra (Intent)
  • findViewById (Activity)
  • getExternalFilesDir (Context)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • JFileChooser (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now