/** * The the XMPP address of this MAM archive. Note that this method may return {@code null} if this MamManager * handles the local entity's archive and if the connection has never been authenticated at least once. * * @return the XMPP address of this MAM archive or {@code null}. * @since 4.3.0 */ public Jid getArchiveAddress() { if (archiveAddress == null) { EntityFullJid localJid = connection().getUser(); if (localJid == null) { return null; } return localJid.asBareJid(); } return archiveAddress; }
/** * Get the form fields supported by the server. * * @param node The PubSub node name, can be null * @return the list of form fields. * @throws NoResponseException * @throws XMPPErrorException * @throws NotConnectedException * @throws InterruptedException * @throws NotLoggedInException */ public List<FormField> retrieveFormFields(String node) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { String queryId = UUID.randomUUID().toString(); MamQueryIQ mamQueryIq = new MamQueryIQ(queryId, node, null); mamQueryIq.setTo(archiveAddress); MamQueryIQ mamResponseQueryIq = connection().createStanzaCollectorAndSend(mamQueryIq).nextResultOrThrow(); return mamResponseQueryIq.getDataForm().getFields(); }
private void ensureMamQueryResultMatchesThisManager(MamQueryResult mamQueryResult) { EntityFullJid localAddress = connection().getUser(); EntityBareJid localBareAddress = null; if (localAddress != null) { localBareAddress = localAddress.asEntityBareJid(); } boolean isLocalUserArchive = archiveAddress == null || archiveAddress.equals(localBareAddress); Jid finIqFrom = mamQueryResult.mamFin.getFrom(); if (finIqFrom != null) { if (finIqFrom.equals(archiveAddress) || (isLocalUserArchive && finIqFrom.equals(localBareAddress))) { return; } throw new IllegalArgumentException("The given MamQueryResult is from the MAM archive '" + finIqFrom + "' whereas this MamManager is responsible for '" + archiveAddress + '\''); } else if (!isLocalUserArchive) { throw new IllegalArgumentException( "The given MamQueryResult is from the local entity (user) MAM archive, whereas this MamManager is responsible for '" + archiveAddress + '\''); } }
/** * The the XMPP address of this MAM archive. Note that this method may return {@code null} if this MamManager * handles the local entity's archive and if the connection has never been authenticated at least once. * * @return the XMPP address of this MAM archive or {@code null}. * @since 4.3.0 */ public Jid getArchiveAddress() { if (archiveAddress == null) { EntityFullJid localJid = connection().getUser(); if (localJid == null) { return null; } return localJid.asBareJid(); } return archiveAddress; }
private void ensureMamQueryResultMatchesThisManager(MamQueryResult mamQueryResult) { EntityFullJid localAddress = connection().getUser(); EntityBareJid localBareAddress = null; if (localAddress != null) { localBareAddress = localAddress.asEntityBareJid(); } boolean isLocalUserArchive = archiveAddress == null || archiveAddress.equals(localBareAddress); Jid finIqFrom = mamQueryResult.mamFin.getFrom(); if (finIqFrom != null) { if (finIqFrom.equals(archiveAddress) || (isLocalUserArchive && finIqFrom.equals(localBareAddress))) { return; } throw new IllegalArgumentException("The given MamQueryResult is from the MAM archive '" + finIqFrom + "' whereas this MamManager is responsible for '" + archiveAddress + '\''); } else if (!isLocalUserArchive) { throw new IllegalArgumentException( "The given MamQueryResult is from the local entity (user) MAM archive, whereas this MamManager is responsible for '" + archiveAddress + '\''); } }
/** * Get the form fields supported by the server. * * @param node The PubSub node name, can be null * @return the list of form fields. * @throws NoResponseException * @throws XMPPErrorException * @throws NotConnectedException * @throws InterruptedException * @throws NotLoggedInException */ public List<FormField> retrieveFormFields(String node) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { String queryId = UUID.randomUUID().toString(); MamQueryIQ mamQueryIq = new MamQueryIQ(queryId, node, null); mamQueryIq.setTo(archiveAddress); MamQueryIQ mamResponseQueryIq = connection().createStanzaCollectorAndSend(mamQueryIq).nextResultOrThrow(); return mamResponseQueryIq.getDataForm().getFields(); }