Id - public class StoreMailboxManager<Id> extends Object implements MailboxManager
MailboxManager implementation provides a high-level api for writing your own
MailboxManager implementation. If you plan to write your own MailboxManager its most times so easiest
to extend just this class or use it directly.
If you need a more low-level api just implement MailboxManager directly| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_FETCH_BATCH_SIZE |
static char |
SQL_WILDCARD_CHAR |
| Constructor and Description |
|---|
StoreMailboxManager(MailboxSessionMapperFactory<Id> mailboxSessionMapperFactory,
Authenticator authenticator,
MailboxACLResolver aclResolver,
GroupMembershipResolver groupMembershipResolver) |
StoreMailboxManager(MailboxSessionMapperFactory<Id> mailboxSessionMapperFactory,
Authenticator authenticator,
MailboxPathLocker locker,
MailboxACLResolver aclResolver,
GroupMembershipResolver groupMembershipResolver) |
| Modifier and Type | Method and Description |
|---|---|
void |
addGlobalListener(MailboxListener listener,
MailboxSession session)
Add a
MailboxListener which get fired for ever
MailboxPath |
void |
addListener(MailboxPath path,
MailboxListener listener,
MailboxSession session)
Implementations of Mailbox may interpret the fact that someone is
listening and do some caching and even postpone persistence until
everyone has removed itself.
|
List<MessageRange> |
copyMessages(MessageRange set,
MailboxPath from,
MailboxPath to,
MailboxSession session)
Copy the given
MessageRange from one Mailbox to the other. |
void |
createMailbox(MailboxPath mailboxPath,
MailboxSession mailboxSession)
Creates a new mailbox.
|
protected StoreMessageManager<Id> |
createMessageManager(Mailbox<Id> mailbox,
MailboxSession session)
Create a
MailboxManager for the given Mailbox. |
protected MailboxSession |
createSession(String userName,
String password,
org.slf4j.Logger log,
MailboxSession.SessionType type)
Create Session
|
MailboxSession |
createSystemSession(String userName,
org.slf4j.Logger log)
Creates a new system session.
A system session is intended to be used for programmatic access. Use MailboxManager.login(String, String, Logger) when accessing this API from a
protocol. |
void |
deleteMailbox(MailboxPath mailboxPath,
MailboxSession session)
Delete the mailbox with the name
|
protected Mailbox<Id> |
doCreateMailbox(MailboxPath mailboxPath,
MailboxSession session)
Create a Mailbox for the given mailbox path.
|
void |
endProcessingRequest(MailboxSession session)
End processing of Request for session
|
MailboxACLResolver |
getAclResolver() |
AbstractDelegatingMailboxListener |
getDelegationListener()
Return the
AbstractDelegatingMailboxListener which is used by this MailboxManager |
char |
getDelimiter()
Return the delimiter to use for folders
|
MailboxEventDispatcher<Id> |
getEventDispatcher()
Return the
MailboxEventDispatcher used by thei MailboxManager |
GroupMembershipResolver |
getGroupMembershipResolver() |
MailboxPathLocker |
getLocker() |
MessageManager |
getMailbox(MailboxPath mailboxPath,
MailboxSession session)
Gets an session suitable for IMAP.
|
MailboxSessionMapperFactory<Id> |
getMapperFactory()
Return the
MailboxSessionMapperFactory used by this MailboxManager |
MessageSearchIndex<Id> |
getMessageSearchIndex()
Return the
MessageSearchIndex used by this MailboxManager |
void |
init()
Init the
MailboxManager |
List<MailboxPath> |
list(MailboxSession session)
Return a unmodifiable
List of MailboxPath objects |
MailboxSession |
login(String userid,
String passwd,
org.slf4j.Logger log)
Autenticates the given user against the given password.
When authentic and authorized, a session will be supplied |
void |
logout(MailboxSession session,
boolean force)
Close the
MailboxSession if not null |
boolean |
mailboxExists(MailboxPath mailboxPath,
MailboxSession session)
Does the given mailbox exist?
|
protected long |
randomId()
Generate and return the next id to use
|
protected int |
randomUidValidity()
Generate an return the next uid validity
|
void |
removeGlobalListener(MailboxListener listener,
MailboxSession session)
Remove the
MailboxListener |
void |
removeListener(MailboxPath mailboxPath,
MailboxListener listener,
MailboxSession session)
Remove the
MailboxListener |
void |
renameMailbox(MailboxPath from,
MailboxPath to,
MailboxSession session)
Renames a mailbox.
|
List<MailboxMetaData> |
search(MailboxQuery mailboxExpression,
MailboxSession session)
Searches for mailboxes matching the given query.
|
void |
setCopyBatchSize(int copyBatchSize) |
void |
setDelegatingMailboxListener(AbstractDelegatingMailboxListener delegatingListener)
Set the
AbstractDelegatingMailboxListener to use with this MailboxManager instance. |
void |
setFetchBatchSize(int fetchBatchSize) |
void |
setMailboxSessionIdGenerator(MailboxSessionIdGenerator idGenerator) |
void |
setMessageSearchIndex(MessageSearchIndex<Id> index)
Set the
MessageSearchIndex which should be used by this MailboxManager. |
void |
startProcessingRequest(MailboxSession session)
Do nothing.
|
public static final char SQL_WILDCARD_CHAR
public static final int DEFAULT_FETCH_BATCH_SIZE
public StoreMailboxManager(MailboxSessionMapperFactory<Id> mailboxSessionMapperFactory, Authenticator authenticator, MailboxPathLocker locker, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver)
public StoreMailboxManager(MailboxSessionMapperFactory<Id> mailboxSessionMapperFactory, Authenticator authenticator, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver)
public void setMailboxSessionIdGenerator(MailboxSessionIdGenerator idGenerator)
public void setCopyBatchSize(int copyBatchSize)
public void setFetchBatchSize(int fetchBatchSize)
public void init()
throws MailboxException
MailboxManagerMailboxExceptionpublic AbstractDelegatingMailboxListener getDelegationListener()
AbstractDelegatingMailboxListener which is used by this MailboxManagerpublic MessageSearchIndex<Id> getMessageSearchIndex()
MessageSearchIndex used by this MailboxManagerpublic MailboxEventDispatcher<Id> getEventDispatcher()
MailboxEventDispatcher used by thei MailboxManagerpublic MailboxSessionMapperFactory<Id> getMapperFactory()
MailboxSessionMapperFactory used by this MailboxManagerpublic MailboxPathLocker getLocker()
public MailboxACLResolver getAclResolver()
public GroupMembershipResolver getGroupMembershipResolver()
public void setDelegatingMailboxListener(AbstractDelegatingMailboxListener delegatingListener)
AbstractDelegatingMailboxListener to use with this MailboxManager instance. If none is set here a HashMapDelegatingMailboxListener instance will
be created lazydelegatingListener - public void setMessageSearchIndex(MessageSearchIndex<Id> index)
MessageSearchIndex which should be used by this MailboxManager. If none is given this implementation will use a SimpleMessageSearchIndex
by defaultindex - protected int randomUidValidity()
public MailboxSession createSystemSession(String userName, org.slf4j.Logger log)
MailboxManagerMailboxManager.login(String, String, Logger) when accessing this API from a
protocol.createSystemSession in interface MailboxManageruserName - the name of the user whose session is being createdlog - context sensitive logMailboxSession, not nullMailboxManager.createSystemSession(java.lang.String, org.slf4j.Logger)protected MailboxSession createSession(String userName, String password, org.slf4j.Logger log, MailboxSession.SessionType type)
userName - log - protected long randomId()
public char getDelimiter()
MailboxManagergetDelimiter in interface MailboxManagerMailboxManager.getDelimiter()public MailboxSession login(String userid, String passwd, org.slf4j.Logger log) throws BadCredentialsException, MailboxException
MailboxManagerlogin in interface MailboxManageruserid - user namepasswd - password suppliedlog - context sensitive logMailboxSession when the user is authentic and
authorized to accessBadCredentialsException - when system access is denighed for the given userMailboxException - when the creation fails for other reasonsMailboxManager.login(java.lang.String, java.lang.String, org.slf4j.Logger)public void logout(MailboxSession session, boolean force) throws MailboxException
MailboxSession if not nulllogout in interface MailboxManagersession - not nullforce - true when the session logout is forced by premature connection
terminationMailboxException - when logout failsprotected StoreMessageManager<Id> createMessageManager(Mailbox<Id> mailbox, MailboxSession session) throws MailboxException
MailboxManager for the given Mailbox. By default this will return a StoreMessageManager. If
your implementation needs something different, just override this methodmailbox - session - MailboxExceptionprotected Mailbox<Id> doCreateMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
SimpleMailbox.
If you need to return something more special just override this methodmailboxPath - session - MailboxExceptionpublic MessageManager getMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
MailboxManagergetMailbox in interface MailboxManagermailboxPath - the Path of the mailbox, not nullsession - the context for this call, not nullImapMailboxSession, not nullMailboxException - when the mailbox cannot be openedMailboxNotFoundException - when the given mailbox does not existMailboxManager.getMailbox(MailboxPath, MailboxSession)public void createMailbox(MailboxPath mailboxPath, MailboxSession mailboxSession) throws MailboxException
MailboxManagercreateMailbox in interface MailboxManagermailboxSession - the context for this call, not nullMailboxException - when creation failsMailboxManager.createMailbox(MailboxPath, MailboxSession)public void deleteMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
MailboxManagerdeleteMailbox in interface MailboxManagerMailboxExceptionMailboxManager.deleteMailbox(MailboxPath, MailboxSession)public void renameMailbox(MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException
MailboxManagerrenameMailbox in interface MailboxManagerfrom - original mailboxto - new mailboxsession - the context for this call, not nulMailboxException - otherwiseMailboxExistsException - when the to mailbox existsMailboxManager.renameMailbox(MailboxPath, MailboxPath, MailboxSession)public List<MessageRange> copyMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException
MailboxManagerMessageRange from one Mailbox to the other.
Be aware that the copied Messages MUST get the \RECENT flag set!copyMessages in interface MailboxManagerset - messages to copyfrom - name of the source mailboxto - name of the destination mailboxsession - MailboxSession, not nullMailboxExceptionMailboxManager.copyMessages(MessageRange, MailboxPath, MailboxPath, MailboxSession)public List<MailboxMetaData> search(MailboxQuery mailboxExpression, MailboxSession session) throws MailboxException
MailboxManagersearch in interface MailboxManagermailboxExpression - not nullsession - the context for this call, not nullMailboxExceptionMailboxManager.search(org.apache.james.mailbox.model.MailboxQuery, org.apache.james.mailbox.MailboxSession)public boolean mailboxExists(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
MailboxManagermailboxExists in interface MailboxManagermailboxPath - not nullsession - the context for this call, not nullMailboxExceptionMailboxManager.mailboxExists(MailboxPath, MailboxSession)public void addListener(MailboxPath path, MailboxListener listener, MailboxSession session) throws MailboxException
MailboxListenerSupportImplementations of Mailbox may interpret the fact that someone is listening and do some caching and even postpone persistence until everyone has removed itself.
addListener in interface MailboxListenerSupportpath - not nulllistener - not nullsession - not nullMailboxExceptionMailboxListenerSupport.addListener(MailboxPath, MailboxListener, MailboxSession)public void endProcessingRequest(MailboxSession session)
endProcessingRequest in interface RequestAwarepublic void startProcessingRequest(MailboxSession session)
startProcessingRequest in interface RequestAwarepublic List<MailboxPath> list(MailboxSession session) throws MailboxException
MailboxManagerList of MailboxPath objectslist in interface MailboxManagerMailboxExceptionMailboxManager.list(org.apache.james.mailbox.MailboxSession)public void addGlobalListener(MailboxListener listener, MailboxSession session) throws MailboxException
MailboxListenerSupportMailboxListener which get fired for ever
MailboxPathaddGlobalListener in interface MailboxListenerSupportMailboxExceptionMailboxListenerSupport.addGlobalListener(org.apache.james.mailbox.MailboxListener, org.apache.james.mailbox.MailboxSession)public void removeListener(MailboxPath mailboxPath, MailboxListener listener, MailboxSession session) throws MailboxException
MailboxListenerSupportMailboxListenerpublic void removeGlobalListener(MailboxListener listener, MailboxSession session) throws MailboxException
MailboxListenerSupportMailboxListenerremoveGlobalListener in interface MailboxListenerSupportMailboxExceptionCopyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.