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

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

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

origin: igniterealtime/Smack

/**
 * Creates a node with default configuration.
 *
 * @param nodeId The id of the node, which must be unique within the
 * pubsub service
 * @return The node that was created
 * @throws XMPPErrorException
 * @throws NoResponseException
 * @throws NotConnectedException
 * @throws InterruptedException
 */
public LeafNode createNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
  return (LeafNode) createNode(nodeId, null);
}
origin: igniterealtime/Smack

public static void cleanUpPubSub(OmemoManager omemoManager) {
  PubSubManager pm = PubSubManager.getInstance(omemoManager.getConnection(),omemoManager.getOwnJid());
  try {
    omemoManager.requestDeviceListUpdateFor(omemoManager.getOwnJid());
      pm.getLeafNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id)).deleteAllItems();
    } catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException |
        PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException |
      pm.deleteNode(OmemoConstants.PEP_NODE_BUNDLE_FROM_DEVICE_ID(id));
    } catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException
        | XMPPException.XMPPErrorException e) {
    pm.getLeafNode(OmemoConstants.PEP_NODE_DEVICE_LIST).deleteAllItems();
  } catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException |
      PubSubException.NotALeafNodeException | XMPPException.XMPPErrorException |
    pm.deleteNode(OmemoConstants.PEP_NODE_DEVICE_LIST);
  } catch (SmackException.NoResponseException | InterruptedException | SmackException.NotConnectedException |
      XMPPException.XMPPErrorException e) {
origin: igniterealtime/Smack

Node node;
try {
  node = getNode(id);
    return getLeafNodeProsodyWorkaround(id);
origin: igniterealtime/Smack

private LeafNode getNode()
    throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotALeafNodeException {
  return PubSubManager.getInstance(connection()).getOrCreateLeafNode(GeoLocation.NAMESPACE);
}
origin: igniterealtime/Smack

public PubSubIntegrationTest(SmackIntegrationTestEnvironment environment)
        throws TestNotPossibleException, NoResponseException, XMPPErrorException,
        NotConnectedException, InterruptedException {
  super(environment);
  DomainBareJid pubSubService = PubSubManager.getPubSubService(conOne);
  if (pubSubService == null) {
    throw new TestNotPossibleException("No PubSub service found");
  }
  pubSubManagerOne = PubSubManager.getInstance(conOne, pubSubService);
  if (!pubSubManagerOne.canCreateNodesAndPublishItems()) {
    throw new TestNotPossibleException("PubSub service does not allow node creation");
  }
}
origin: igniterealtime/Smack

private LeafNode getOrCreateLeafNodeProsodyWorkaround(final String id)
        throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException, NotALeafNodeException {
  try {
    return createNode(id);
  }
  catch (XMPPErrorException e1) {
    if (e1.getStanzaError().getCondition() == Condition.conflict) {
      return getLeafNodeProsodyWorkaround(id);
    }
    throw e1;
  }
}
origin: igniterealtime/Smack

protected PubSub sendPubsubPacket(PubSub packet) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
  return pubSubManager.sendPubsubPacket(packet);
}
origin: igniterealtime/Smack

  @SmackIntegrationTest
  public void simplePubSubNodeTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    final String nodename = "sinttest-simple-nodename-" + testRunId;
    final String itemId = "sintest-simple-itemid-" + testRunId;
    ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
    ConfigureForm config = new ConfigureForm(defaultConfiguration.createAnswerForm());
    // Configure the node as "Notification-Only Node", which in turn means that
    // items do not need payload, to prevent payload-required error responses when
    // publishing the item.
    config.setDeliverPayloads(false);
    config.setPersistentItems(true);
    Node node = pubSubManagerOne.createNode(nodename, config);
    try {
      LeafNode leafNode = (LeafNode) node;
      leafNode.publish(new Item(itemId));
      List<Item> items = leafNode.getItems();
      assertEquals(1, items.size());
      Item item = items.get(0);
      assertEquals(itemId, item.getId());
    }
    finally {
      pubSubManagerOne.deleteNode(nodename);
    }
  }
}
origin: igniterealtime/Smack

      throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException, NotALeafNodeException {
try {
  return getLeafNode(id);
  return createNode(id);
      return createNode(id);
          return getLeafNode(id);
    return getOrCreateLeafNodeProsodyWorkaround(id);
origin: igniterealtime/Smack

LeafNode leafNode = null;
try {
  leafNode = createNode();
} finally {
  if (leafNode != null) {
    deleteNode(leafNode.getId());
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: org.igniterealtime.smack/smackx

throws XMPPException
PubSub request = createPubsubPacket(to, Type.SET, new NodeExtension(PubSubElementType.CREATE, name));
boolean isLeafNode = true;
sendPubsubPacket(con, to, Type.SET, request);
Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name);
newNode.setTo(to);
origin: org.renci/xmpp-pubsub

  DiscoverItems dItems = manager.discoverNodes(null);
  Iterator<DiscoverItems.Item> iItems = dItems.getItems();
  while(iItems.hasNext()) {
    if (it.getNode().equalsIgnoreCase(nodePath)) {
      return (LeafNode)manager.getNode(nodePath);
  form.setDeliverPayloads(true);
  form.setAccessModel(AccessModel.open);
  return (LeafNode)manager.createNode(nodePath, form);
} catch (XMPPException e) {
  logger.error("Error creating XMPP pubsub node: " + e);
origin: igniterealtime/Smack

/**
 * Creates a new PEP exchange manager.
 *
 * @param connection an XMPPConnection which is used to send and receive messages.
 */
private PepManager(XMPPConnection connection) {
  super(connection);
  StanzaListener packetListener = new StanzaListener() {
    @Override
    public void processStanza(Stanza stanza) {
      final Message message = (Message) stanza;
      final EventElement event = EventElement.from(stanza);
      assert (event != null);
      final EntityBareJid from = message.getFrom().asEntityBareJidIfPossible();
      assert (from != null);
      asyncButOrdered.performAsyncButOrdered(from, new Runnable() {
        @Override
        public void run() {
          for (PepListener listener : pepListeners) {
            listener.eventReceived(from, event, message);
          }
        }
      });
    }
  };
  // TODO Add filter to check if from supports PubSub as per xep163 2 2.4
  connection.addSyncStanzaListener(packetListener, FROM_BARE_JID_WITH_EVENT_EXTENSION_FILTER);
  pepPubSubManager = PubSubManager.getInstance(connection, null);
}
origin: org.renci/xmpp-pubsub

/**
 * Delete all nodes
 */
public synchronized void deleteAllNodes() {
  if ((xmppCon == null) || (!xmppCon.isConnected()))
    login();
  try {
    DiscoverItems dItems = manager.discoverNodes(null);
    Iterator<DiscoverItems.Item> iItems = dItems.getItems();
    while(iItems.hasNext()) {
      DiscoverItems.Item it = iItems.next();
      logger.debug("Deleting node " + it.getNode());
      try {
        Node n = manager.getNode(it.getNode());
        if ((n != null) && (n instanceof LeafNode)){
          LeafNode ln = (LeafNode)n;
          ln.deleteAllItems();
        } else
          logger.info("Unable to delete items of node " + it.getNode());
        manager.deleteNode(it.getNode());
      } catch (XMPPException e) {
        logger.error("Error deleting node: " + e);
      }
    }
  } catch (XMPPException e) {
    logger.error("Error deleting nodes: " + e);
  }
}
origin: igniterealtime/Smack

@Test(expected = SmackException.class)
public void getConfigFormWithTimeout() throws XMPPException, SmackException, InterruptedException {
  ThreadedDummyConnection con = new ThreadedDummyConnection();
  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");
  SmackConfiguration.setDefaultReplyTimeout(100);
  con.setTimeout();
  node.getNodeConfiguration();
}
origin: org.igniterealtime.smack/smackx

static PubSub createPubsubPacket(String to, Type type, PacketExtension ext)
{
  return createPubsubPacket(to, type, ext, null);
}
 
origin: org.renci/xmpp-pubsub

/**
 * Delete specified node
 * @param nodepath - path to node
 */
public synchronized void deleteNode(String nodepath) {
  if ((xmppCon == null) || (!xmppCon.isConnected()))
    login();
  logger.info("Deleting node " + nodepath);
  try {
    Node n = manager.getNode(nodepath);
    if ((n != null) && (n instanceof LeafNode)){
      LeafNode ln = (LeafNode)n;
      ln.deleteAllItems();
    } else 
      logger.info("Unable to delete items of node " + nodepath);
    manager.deleteNode(nodepath);
  } catch (XMPPException e) {
    logger.error("Error deleting node: " + e);
  }
}
origin: org.renci/xmpp-pubsub

/**
 * 
 * @param nodeName - node name
 * @param s - subscription
 */
public synchronized void unsubscribeFromNode(String nodeName, Subscription s) {
  try {
    LeafNode node = (LeafNode)manager.getNode(nodeName);
    node.unsubscribe(s.getJid(), s.getId());
  } catch (XMPPException e) {
    logger.error("XMPP Error unsubscribing from XMPP pubsub node: " + e);
  } catch (Exception e) {
    logger.error("Error unsubscribing from XMPP pubsub node: " + e);
  }
}
origin: igniterealtime/Smack

  @Test
  public void deleteNodeTest() throws InterruptedException, SmackException, IOException, XMPPException {
    ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
    PubSubManager mgr = new PubSubManager(con, DUMMY_PUBSUB_SERVICE);

    mgr.deleteNode("foo@bar.org");

    PubSub pubSubDeleteRequest = con.getSentPacket();
    assertEquals("http://jabber.org/protocol/pubsub#owner", pubSubDeleteRequest.getChildElementNamespace());
    assertEquals("pubsub", pubSubDeleteRequest.getChildElementName());
  }
}
org.jivesoftware.smackx.pubsubPubSubManager

Javadoc

This is the starting point for access to the pubsub service. It will provide access to general information about the service, as well as create or retrieve pubsub LeafNode instances. These instances provide the bulk of the functionality as defined in the pubsub specification XEP-0060.

Most used methods

  • createNode
    Creates a node with specified configuration. Note: This is the only way to create a collection node.
  • deleteNode
    Delete the specified node.
  • getInstance
    Get the PubSub manager for the given connection and PubSub service. Use null as argument for pubSubS
  • getLeafNode
    Try to get a leaf node with the given node ID.
  • getNode
    Retrieves the requested node, if it exists. It will throw an exception if it does not.
  • sendPubsubPacket
  • <init>
    Create a pubsub manager associated to the specified connection where the pubsub requests require a s
  • createPubsubPacket
  • getOrCreateLeafNode
    Try to get a leaf node and create one if it does not already exist.
  • getPubSubService
    Get the "default" PubSub service for a given XMPP connection. The default PubSub service is simply a
  • getServiceJid
    Get the JID of the PubSub service managed by this manager.
  • canCreateNodesAndPublishItems
    Check if it is possible to create PubSub nodes on this service. It could be possible that the PubSub
  • getServiceJid,
  • canCreateNodesAndPublishItems,
  • connection,
  • discoverNodes,
  • getConnection,
  • getDefaultConfiguration,
  • getLeafNodeProsodyWorkaround,
  • getOrCreateLeafNodeProsodyWorkaround,
  • tryToPublishAndPossibleAutoCreate

Popular in Java

  • Reading from database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • compareTo (BigDecimal)
  • requestLocationUpdates (LocationManager)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JList (javax.swing)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top PhpStorm plugins
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