private static OmemoBundleElement fetchBundle(XMPPConnection connection,
                                                  OmemoDevice contactsDevice)
            throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException,
            XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException,
            PubSubException.NotAPubSubNodeException {

        PubSubManager pm = PubSubManager.getInstanceFor(connection, contactsDevice.getJid());
        LeafNode node = pm.getLeafNode(contactsDevice.getBundleNodeName());

        if (node == null) {
            return null;
        }

        List<PayloadItem<OmemoBundleElement>> bundleItems = node.getItems();
        if (bundleItems.isEmpty()) {
            return null;
        }

        return bundleItems.get(bundleItems.size() - 1).getPayload();
    }
private static OmemoBundleElement fetchBundle ( XMPPConnection connection , OmemoDevice contactsDevice ) throws SmackException . NotConnectedException , InterruptedException , SmackException . NoResponseException , XMPPException . XMPPErrorException , PubSubException . NotALeafNodeException , PubSubException . NotAPubSubNodeException { PubSubManager pm = PubSubManager . getInstanceFor ( connection , contactsDevice . getJid ( ) ) ; LeafNode node = pm . getLeafNode ( contactsDevice . getBundleNodeName ( ) ) ; if ( node == null ) { return null ; } List < PayloadItem < OmemoBundleElement > > bundleItems = node . getItems ( ) ; if ( bundleItems . isEmpty ( ) ) { return null ; } return bundleItems . get ( bundleItems . size ( ) - 1 ) . getPayload ( ) ; }
Retrieve a users OMEMO bundle.

@param connection authenticated XMPP connection.
@param contactsDevice device of which we want to retrieve the bundle.
@return OmemoBundle of the device or null, if it doesn't exist.

@throws SmackException.NotConnectedException
@throws InterruptedException
@throws SmackException.NoResponseException
@throws XMPPException.XMPPErrorException
@throws PubSubException.NotALeafNodeException
@throws PubSubException.NotAPubSubNodeException