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

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

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

origin: igniterealtime/Smack

/**
 * Send geolocation through the PubSub node.
 *
 * @param geoLocation
 * @throws InterruptedException
 * @throws NotConnectedException
 * @throws XMPPErrorException
 * @throws NoResponseException
 * @throws NotALeafNodeException
 */
public void sendGeolocation(GeoLocation geoLocation)
    throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotALeafNodeException {
  getNode().publish(new PayloadItem<GeoLocation>(geoLocation));
}
origin: igniterealtime/Smack

@Test
public void verifyPayloadItem() throws Exception {
  SimplePayload payload = new SimplePayload("<data xmlns='https://example.org'>This is the payload</data>");
  PayloadItem<SimplePayload> simpleItem = new PayloadItem<>(payload);
  String simpleCtrl = "<item xmlns='http://jabber.org/protocol/pubsub'>" + payload.toXML(null) + "</item>";
  assertXMLEqual(simpleCtrl, simpleItem.toXML(null).toString());
  PayloadItem<SimplePayload> idItem = new PayloadItem<>("uniqueid", payload);
  String idCtrl = "<item xmlns='http://jabber.org/protocol/pubsub' id='uniqueid'>" + payload.toXML(null) + "</item>";
  assertXMLEqual(idCtrl, idItem.toXML(null).toString());
  PayloadItem<SimplePayload> itemWithNodeId = new PayloadItem<>("testId", "testNode", payload);
  String nodeIdCtrl = "<item xmlns='http://jabber.org/protocol/pubsub' id='testId' node='testNode'>" + payload.toXML(null) + "</item>";
  assertXMLEqual(nodeIdCtrl, itemWithNodeId.toXML(null).toString());
}
origin: igniterealtime/Smack

if (items.isEmpty()) {
  LOGGER.log(Level.FINE, "Node " + keyNodeName + " is empty. Publish.");
  keyNode.publish(new PayloadItem<>(pubkeyElement));
} else {
  LOGGER.log(Level.FINE, "Node " + keyNodeName + " already contains key. Skip.");
if (!metadataItems.isEmpty() && metadataItems.get(0).getPayload() != null) {
  PublicKeysListElement publishedList = metadataItems.get(0).getPayload();
  for (PublicKeysListElement.PubkeyMetadataElement meta : publishedList.getMetadata().values()) {
    builder.addMetadata(meta);
metadataNode.publish(new PayloadItem<>(builder.build()));
origin: igniterealtime/Smack

@Test
public void parseSimplePayloadItem() throws Exception {
  String itemContent = "<foo xmlns='smack:test'>Some text</foo>";
  XmlPullParser parser = PacketParserUtils.getParserFor(
    "<message from='pubsub.myserver.com' to='francisco@denmark.lit' id='foo'>" +
      "<event xmlns='http://jabber.org/protocol/pubsub#event'>" +
        "<items node='testNode'>" +
          "<item id='testid1' >" +
            itemContent +
          "</item>" +
        "</items>" +
       "</event>" +
    "</message>");
  Stanza message = PacketParserUtils.parseMessage(parser);
  ExtensionElement eventExt = message.getExtension(PubSubNamespace.event.getXmlns());
  EventElement event = (EventElement) eventExt;
  NamedElement itemExt = ((ItemsExtension) event.getExtensions().get(0)).items.get(0);
  assertTrue(itemExt instanceof PayloadItem<?>);
  PayloadItem<?> item = (PayloadItem<?>) itemExt;
  assertEquals("testid1", item.getId());
  assertTrue(item.getPayload() instanceof SimplePayload);
  SimplePayload payload = (SimplePayload) item.getPayload();
  assertEquals("foo", payload.getElementName());
  assertEquals("smack:test", payload.getNamespace());
  assertXMLEqual(itemContent, payload.toXML(null).toString());
}
origin: org.littleshoot/smack-xmpp-3-2-2

@Override
public String toXML()
{
  StringBuilder builder = new StringBuilder("<item");
  
  if (getId() != null)
  {
    builder.append(" id='");
    builder.append(getId());
    builder.append("'");
  }
  
  if (getNode() != null) {
    builder.append(" node='");
    builder.append(getNode());
    builder.append("'");
  }
  builder.append(">");
  builder.append(payload.toXML());
  builder.append("</item>");
  
  return builder.toString();
}
origin: igniterealtime/Smack

  @Override
  public String toString() {
    return getClass().getName() + " | Content [" + toXML(null) + "]";
  }
}
origin: igniterealtime/Smack

/**
 * Retrieve the OMEMO device list of a contact.
 *
 * @param connection authenticated XMPP connection.
 * @param contact BareJid of the contact of which we want to retrieve the device list from.
 * @return
 * @throws InterruptedException
 * @throws PubSubException.NotALeafNodeException
 * @throws SmackException.NoResponseException
 * @throws SmackException.NotConnectedException
 * @throws XMPPException.XMPPErrorException
 * @throws PubSubException.NotAPubSubNodeException
 */
private static OmemoDeviceListElement fetchDeviceList(XMPPConnection connection, BareJid contact)
    throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException,
    SmackException.NotConnectedException, XMPPException.XMPPErrorException,
    PubSubException.NotAPubSubNodeException {
  PubSubManager pm = PubSubManager.getInstance(connection, contact);
  String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST;
  LeafNode node = pm.getLeafNode(nodeName);
  if (node == null) {
    return null;
  }
  List<PayloadItem<OmemoDeviceListElement>> items = node.getItems();
  if (items.isEmpty()) {
    return null;
  }
  return items.get(items.size() - 1).getPayload();
}
origin: jitsi/jicofo

Jid bridgeId = JidCreate.from(item.getId());
verifyJvbJid(bridgeId);
origin: igniterealtime/Smack

PayloadItem<?> item = (PayloadItem<?>) itemExt;
assertEquals("testid1", item.getId());
assertTrue(item.getPayload() instanceof SimplePayload);
assertXMLEqual(itemContent, item.getPayload().toXML(null).toString());
origin: org.igniterealtime.smack/smackx

@Override
public String toXML()
{
  StringBuilder builder = new StringBuilder("<item");
  
  if (getId() != null)
  {
    builder.append(" id='");
    builder.append(getId());
    builder.append("'");
  }
  
  if (getNode() != null) {
    builder.append(" node='");
    builder.append(getNode());
    builder.append("'");
  }
  builder.append(">");
  builder.append(payload.toXML());
  builder.append("</item>");
  
  return builder.toString();
}
origin: org.igniterealtime.smack/smackx

  @Override
  public String toString()
  {
    return getClass().getName() + " | Content [" + toXML() + "]";
  }
}
origin: igniterealtime/Smack

/**
 * Fetch the latest {@link SecretkeyElement} from the private backup node.
 *
 * @see <a href="https://xmpp.org/extensions/xep-0373.html#synchro-pep">
 *      XEP-0373 §5. Synchronizing the Secret Key with a Private PEP Node</a>
 *
 * @param pepManager the PEP manager.
 * @return the secret key node or null, if it doesn't exist.
 *
 * @throws InterruptedException if the thread gets interrupted
 * @throws PubSubException.NotALeafNodeException if there is an issue with the PubSub node
 * @throws XMPPException.XMPPErrorException if there is an XMPP protocol related issue
 * @throws SmackException.NotConnectedException if we are not connected
 * @throws SmackException.NoResponseException /watch?v=7U0FzQzJzyI
 */
public static SecretkeyElement fetchSecretKey(PepManager pepManager)
    throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
    SmackException.NotConnectedException, SmackException.NoResponseException {
  PubSubManager pm = pepManager.getPepPubSubManager();
  LeafNode secretKeyNode = pm.getOrCreateLeafNode(PEP_NODE_SECRET_KEY);
  List<PayloadItem<SecretkeyElement>> list = secretKeyNode.getItems(1);
  if (list.size() == 0) {
    LOGGER.log(Level.INFO, "No secret key published!");
    return null;
  }
  SecretkeyElement secretkeyElement = list.get(0).getPayload();
  return secretkeyElement;
}
origin: igniterealtime/Smack

@Override
public Item parse(XmlPullParser parser, int initialDepth)
        throws Exception {
  String id = parser.getAttributeValue(null, "id");
  String node = parser.getAttributeValue(null, "node");
  String xmlns = parser.getNamespace();
  ItemNamespace itemNamespace = ItemNamespace.fromXmlns(xmlns);
  int tag = parser.next();
  if (tag == XmlPullParser.END_TAG)  {
    return new Item(itemNamespace, id, node);
  }
  else {
    String payloadElemName = parser.getName();
    String payloadNS = parser.getNamespace();
    final ExtensionElementProvider<ExtensionElement> extensionProvider = ProviderManager.getExtensionProvider(payloadElemName, payloadNS);
    if (extensionProvider == null) {
      // TODO: Should we use StandardExtensionElement in this case? And probably remove SimplePayload all together.
      CharSequence payloadText = PacketParserUtils.parseElement(parser, true);
      return new PayloadItem<>(itemNamespace, id, node, new SimplePayload(payloadText.toString()));
    }
    else {
      return new PayloadItem<>(itemNamespace, id, node, extensionProvider.parse(parser));
    }
  }
}
origin: igniterealtime/Smack

PayloadItem<?> item = (PayloadItem<?>) itemExt;
assertEquals("testid1", item.getId());
assertTrue(item.getPayload() instanceof SimplePayload);
SimplePayload payload = (SimplePayload) item.getPayload();
assertEquals("entry", payload.getElementName());
assertEquals("http://www.w3.org/2005/Atom", payload.getNamespace());
origin: tiandawu/IotXmpp

@Override
public String toXML()
{
  StringBuilder builder = new StringBuilder("<item");
  
  if (getId() != null)
  {
    builder.append(" id='");
    builder.append(getId());
    builder.append("'");
  }
  
  if (getNode() != null) {
    builder.append(" node='");
    builder.append(getNode());
    builder.append("'");
  }
  builder.append(">");
  builder.append(payload.toXML());
  builder.append("</item>");
  
  return builder.toString();
}
origin: org.littleshoot/smack-xmpp-3-2-2

  @Override
  public String toString()
  {
    return getClass().getName() + " | Content [" + toXML() + "]";
  }
}
origin: igniterealtime/Smack

/**
 * Consult the public key metadata node of {@code contact} to fetch the list of their published OpenPGP public keys.
 *
 * @see <a href="https://xmpp.org/extensions/xep-0373.html#discover-pubkey-list">
 *     XEP-0373 §4.3: Discovering Public Keys of a User</a>
 *
 * @param connection XMPP connection
 * @param contact {@link BareJid} of the user we want to fetch the list from.
 * @return content of {@code contact}'s metadata node.
 *
 * @throws InterruptedException if the thread gets interrupted.
 * @throws XMPPException.XMPPErrorException in case of an XMPP protocol exception.
 * @throws SmackException.NoResponseException in case the server doesn't respond
 * @throws PubSubException.NotALeafNodeException in case the queried node is not a {@link LeafNode}
 * @throws SmackException.NotConnectedException in case we are not connected
 * @throws PubSubException.NotAPubSubNodeException in case the queried entity is not a PubSub node
 */
public static PublicKeysListElement fetchPubkeysList(XMPPConnection connection, BareJid contact)
    throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException,
    PubSubException.NotALeafNodeException, SmackException.NotConnectedException, PubSubException.NotAPubSubNodeException {
  PubSubManager pm = PubSubManager.getInstance(connection, contact);
  LeafNode node = getLeafNode(pm, PEP_NODE_PUBLIC_KEYS);
  List<PayloadItem<PublicKeysListElement>> list = node.getItems(1);
  if (list.isEmpty()) {
    return null;
  }
  return list.get(0).getPayload();
}
origin: igniterealtime/Smack

/**
 * Send empty geolocation through the PubSub node.
 *
 * @throws InterruptedException
 * @throws NotConnectedException
 * @throws XMPPErrorException
 * @throws NoResponseException
 * @throws NotALeafNodeException
 */
public void stopPublishingGeolocation()
    throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotALeafNodeException {
  GeoLocation emptyGeolocation = new GeoLocation.Builder().build();
  getNode().publish(new PayloadItem<GeoLocation>(emptyGeolocation));
}
origin: jitsi/jicofo

/**
 * Notifies all <tt>SubscriptionListener</tt>s about published
 * <tt>PayloadItem</tt>.
 * @param payloadItem new <tt>PayloadItem</tt> published to the PubSub
 *                    node observed by this subscription.
 */
void notifyListeners(PayloadItem payloadItem)
{
  for (SubscriptionListener l : listeners)
  {
    l.onSubscriptionUpdate(
      node, payloadItem.getId(), payloadItem.getPayload());
  }
}
origin: tiandawu/IotXmpp

  @Override
  public String toString()
  {
    return getClass().getName() + " | Content [" + toXML() + "]";
  }
}
org.jivesoftware.smackx.pubsubPayloadItem

Javadoc

This class represents an item that has been, or will be published to a pubsub node. An Item has several properties that are dependent on the configuration of the node to which it has been or will be published. An Item received from a node (via LeafNode#getItems() or LeafNode#addItemEventListener(org.jivesoftware.smackx.pubsub.listener.ItemEventListener)
  • Will always have an id (either user or server generated) unless node configuration has both ConfigureForm#isPersistItems() and ConfigureForm#isDeliverPayloads()set to false.
  • Will have a payload if the node configuration has ConfigureForm#isDeliverPayloads() set to true, otherwise it will be null. An Item created to send to a node (via LeafNode#send() or LeafNode#publish()
  • The id is optional, since the server will generate one if necessary, but should be used if it is meaningful in the context of the node. This value must be unique within the node that it is sent to, since resending an item with the same id will overwrite the one that already exists if the items are persisted.
  • Will require payload if the node configuration has ConfigureForm#isDeliverPayloads() set to true.

    To customise the payload object being returned from the #getPayload() method, you can add a custom parser as explained in ItemProvider.

  • Most used methods

    • <init>
      Create an Item with no id and a payload The id will be set by the server.
    • getId
    • toXML
    • getPayload
      Get the payload associated with this Item. Customising the payload parsing from the server can be ac
    • getNode
    • getCommonXml

    Popular in Java

    • Creating JSON documents from java classes using gson
    • onCreateOptionsMenu (Activity)
    • scheduleAtFixedRate (Timer)
    • addToBackStack (FragmentTransaction)
    • GridBagLayout (java.awt)
      The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
    • FileOutputStream (java.io)
      An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
    • Path (java.nio.file)
    • Executors (java.util.concurrent)
      Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
    • JButton (javax.swing)
    • Response (javax.ws.rs.core)
      Defines the contract between a returned instance and the runtime when an application needs to provid
    • Github Copilot alternatives
    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