public final class MamManager extends Manager
MamManager you need to obtain an instance for a particular archive.
To get the instance for the default archive on the user's server, use the getInstanceFor(XMPPConnection) method.
XMPPConnection connection = ...
MamManager mamManager = MamManager.getInstanceFor(connection);
If you want to retrieve a manager for a different archive use getInstanceFor(XMPPConnection, Jid), which takes the archive's XMPP address as second argument.
isSupported() to check if there is a MAM archive available.
boolean isSupported = mamManager.isSupported();
enableMamForAllMessages().
retrieveArchivingPreferences().
MamManager.MamPrefsResult.asMamPrefs() to get a modifiable MamManager.MamPrefs instance.
After performing the desired changes, use updateArchivingPreferences(MamPrefs) to update the preferences.
MamManager.MamQueryArgs instance, which can be build using MamManager.MamQueryArgs.Builder.
After you have build such an instance, use queryArchive(MamQueryArgs) to issue the query.
MamQueryArgs mamQueryArgs = MamQueryArgs.builder()
.withJid(jid)
.setResultPageSize(10)
.queryLastPage()
.build();
MamQuery mamQuery = mamManager.queryArchive(mamQueryArgs);
On success queryArchive(MamQueryArgs) returns a MamManager.MamQuery instance.
The instance will hold one page of the queries result set.
Use MamManager.MamQuery.getMessages() to retrieve the messages of the archive belonging to the page.
You can get the whole page including all metadata using MamManager.MamQuery.getPage().
MamManager.MamQuery.isComplete().
If this method returns false, then you may want to page through the archive.
MamManager.MamQuery provides convince methods to do so: MamManager.MamQuery.pageNext(int) and MamManager.MamQuery.pagePrevious(int).
MamQuery nextPageMamQuery = mamQuery.pageNext(10);
retrieveFormFields() to retrieve a list of the supported additional form fields by this archive.
Those fields can be used for further restrict a query.| Modifier and Type | Class and Description |
|---|---|
static class |
MamManager.MamPrefs |
static class |
MamManager.MamPrefsResult
MAM preferences result class.
|
class |
MamManager.MamQuery |
static class |
MamManager.MamQueryArgs |
static class |
MamManager.MamQueryPage |
static class |
MamManager.MamQueryResult
Deprecated.
|
connection, getAuthenticatedConnectionOrThrow, schedulepublic static MamManager getInstanceFor(XMPPConnection connection)
connection - the XMPP connection to get the archive for.public static MamManager getInstanceFor(MultiUserChat multiUserChat)
MultiUserChat. Note that not all MUCs support MAM,
hence it is recommended to use isSupported() to check if MAM is supported by the MUC.multiUserChat - the MultiUserChat to retrieve the MamManager for.public static MamManager getInstanceFor(XMPPConnection connection, Jid archiveAddress)
public Jid getArchiveAddress()
null if this MamManager
handles the local entity's archive and if the connection has never been authenticated at least once.null.@Deprecated public MamManager.MamQueryResult queryArchive(Integer max) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.max - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult queryArchive(Jid withJid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.withJid - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult queryArchive(Date start, Date end) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.start - end - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult queryArchive(List<FormField> additionalFields) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.additionalFields - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult queryArchiveWithStartDate(Date start) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.start - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult queryArchiveWithEndDate(Date end) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.end - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult queryArchive(Integer max, Date start, Date end, Jid withJid, List<FormField> additionalFields) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.max - start - end - withJid - additionalFields - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult queryArchive(String node, Integer max, Date start, Date end, Jid withJid, List<FormField> additionalFields) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.node - The PubSub node name, can be nullmax - start - end - withJid - additionalFields - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInExceptionpublic MamManager.MamQuery queryArchive(MamManager.MamQueryArgs mamQueryArgs) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NotLoggedInException, InterruptedException
@Deprecated public MamManager.MamQueryResult page(DataForm dataForm, RSMSet rsmSet) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.dataForm - rsmSet - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult page(String node, DataForm dataForm, RSMSet rsmSet) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
queryArchive(MamQueryArgs) instead.node - The PubSub node name, can be nulldataForm - rsmSet - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult pageNext(MamManager.MamQueryResult mamQueryResult, int count) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
MamManager.MamQuery.pageNext(int) instead.mamQueryResult - is the previous query resultcount - is the amount of messages that a page containsSmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult pagePrevious(MamManager.MamQueryResult mamQueryResult, int count) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
MamManager.MamQuery.pagePrevious(int) instead.mamQueryResult - is the previous query resultcount - is the amount of messages that a page containsSmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamQueryResult pageBefore(Jid chatJid, String messageUid, int max) throws XMPPException.XMPPErrorException, SmackException.NotLoggedInException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
queryArchive(MamQueryArgs) instead.Note that the messageUid is the XEP-0313 UID and not the stanza ID of the message.
chatJid - messageUid - the UID of the message of which messages before should be received.max - XMPPException.XMPPErrorExceptionSmackException.NotLoggedInExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NoResponseException@Deprecated public MamManager.MamQueryResult pageAfter(Jid chatJid, String messageUid, int max) throws XMPPException.XMPPErrorException, SmackException.NotLoggedInException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
queryArchive(MamQueryArgs) instead.Note that the messageUid is the XEP-0313 UID and not the stanza ID of the message.
chatJid - messageUid - the UID of the message of which messages after should be received.max - XMPPException.XMPPErrorExceptionSmackException.NotLoggedInExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NoResponseException@Deprecated public MamManager.MamQueryResult mostRecentPage(Jid chatJid, int max) throws XMPPException.XMPPErrorException, SmackException.NotLoggedInException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException
queryMostRecentPage(Jid, int) instead.chatJid - max - XMPPException.XMPPErrorExceptionSmackException.NotLoggedInExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NoResponseExceptionpublic MamManager.MamQuery queryMostRecentPage(Jid jid, int max) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NotLoggedInException, InterruptedException
public List<FormField> retrieveFormFields() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInExceptionpublic List<FormField> retrieveFormFields(String node) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
node - The PubSub node name, can be nullSmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInExceptionpublic boolean isSupported() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
falseotherwise.SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionpublic String getMessageUidOfLatestMessage() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NotLoggedInException, InterruptedException
null if the archive is
empty.null.SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionSmackException.NotLoggedInExceptionInterruptedExceptionpublic MamManager.MamPrefsResult retrieveArchivingPreferences() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInException@Deprecated public MamManager.MamPrefsResult updateArchivingPreferences(List<Jid> alwaysJids, List<Jid> neverJids, MamPrefsIQ.DefaultBehavior defaultBehavior) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
updateArchivingPreferences(MamPrefs) instead.alwaysJids - is the list of JIDs that should always have messages to/from
archived in the user's storeneverJids - is the list of JIDs that should never have messages to/from
archived in the user's storedefaultBehavior - can be "roster", "always", "never" (see XEP-0313)SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInExceptionpublic MamManager.MamPrefsResult updateArchivingPreferences(MamManager.MamPrefs mamPrefs) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NotLoggedInException
mamPrefs - SmackException.NoResponseExceptionXMPPException.XMPPErrorExceptionSmackException.NotConnectedExceptionInterruptedExceptionSmackException.NotLoggedInExceptionpublic MamManager.MamPrefsResult enableMamForAllMessages() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NotLoggedInException, InterruptedException
public MamManager.MamPrefsResult enableMamForRosterMessages() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NotLoggedInException, InterruptedException
public MamManager.MamPrefsResult setDefaultBehavior(MamPrefsIQ.DefaultBehavior desiredDefaultBehavior) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NotLoggedInException, InterruptedException