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
directlyModifier 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
MailboxManager
MailboxException
public AbstractDelegatingMailboxListener getDelegationListener()
AbstractDelegatingMailboxListener
which is used by this MailboxManager
public MessageSearchIndex<Id> getMessageSearchIndex()
MessageSearchIndex
used by this MailboxManager
public MailboxEventDispatcher<Id> getEventDispatcher()
MailboxEventDispatcher
used by thei MailboxManager
public MailboxSessionMapperFactory<Id> getMapperFactory()
MailboxSessionMapperFactory
used by this MailboxManager
public 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)
MailboxManager
MailboxManager.login(String, String, Logger)
when accessing this API from a
protocol.createSystemSession
in interface MailboxManager
userName
- 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()
MailboxManager
getDelimiter
in interface MailboxManager
MailboxManager.getDelimiter()
public MailboxSession login(String userid, String passwd, org.slf4j.Logger log) throws BadCredentialsException, MailboxException
MailboxManager
login
in interface MailboxManager
userid
- 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 MailboxManager
session
- 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
- MailboxException
protected Mailbox<Id> doCreateMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
SimpleMailbox
.
If you need to return something more special just override this methodmailboxPath
- session
- MailboxException
public MessageManager getMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
MailboxManager
getMailbox
in interface MailboxManager
mailboxPath
- 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
MailboxManager
createMailbox
in interface MailboxManager
mailboxSession
- the context for this call, not nullMailboxException
- when creation failsMailboxManager.createMailbox(MailboxPath, MailboxSession)
public void deleteMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
MailboxManager
deleteMailbox
in interface MailboxManager
MailboxException
MailboxManager.deleteMailbox(MailboxPath, MailboxSession)
public void renameMailbox(MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException
MailboxManager
renameMailbox
in interface MailboxManager
from
- 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
MailboxManager
MessageRange
from one Mailbox to the other.
Be aware that the copied Messages MUST get the \RECENT flag set!copyMessages
in interface MailboxManager
set
- messages to copyfrom
- name of the source mailboxto
- name of the destination mailboxsession
- MailboxSession
, not nullMailboxException
MailboxManager.copyMessages(MessageRange, MailboxPath, MailboxPath, MailboxSession)
public List<MailboxMetaData> search(MailboxQuery mailboxExpression, MailboxSession session) throws MailboxException
MailboxManager
search
in interface MailboxManager
mailboxExpression
- not nullsession
- the context for this call, not nullMailboxException
MailboxManager.search(org.apache.james.mailbox.model.MailboxQuery, org.apache.james.mailbox.MailboxSession)
public boolean mailboxExists(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
MailboxManager
mailboxExists
in interface MailboxManager
mailboxPath
- not nullsession
- the context for this call, not nullMailboxException
MailboxManager.mailboxExists(MailboxPath, MailboxSession)
public void addListener(MailboxPath path, MailboxListener listener, MailboxSession session) throws MailboxException
MailboxListenerSupport
Implementations 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 MailboxListenerSupport
path
- not nulllistener
- not nullsession
- not nullMailboxException
MailboxListenerSupport.addListener(MailboxPath, MailboxListener, MailboxSession)
public void endProcessingRequest(MailboxSession session)
endProcessingRequest
in interface RequestAware
public void startProcessingRequest(MailboxSession session)
startProcessingRequest
in interface RequestAware
public List<MailboxPath> list(MailboxSession session) throws MailboxException
MailboxManager
List
of MailboxPath
objectslist
in interface MailboxManager
MailboxException
MailboxManager.list(org.apache.james.mailbox.MailboxSession)
public void addGlobalListener(MailboxListener listener, MailboxSession session) throws MailboxException
MailboxListenerSupport
MailboxListener
which get fired for ever
MailboxPath
addGlobalListener
in interface MailboxListenerSupport
MailboxException
MailboxListenerSupport.addGlobalListener(org.apache.james.mailbox.MailboxListener, org.apache.james.mailbox.MailboxSession)
public void removeListener(MailboxPath mailboxPath, MailboxListener listener, MailboxSession session) throws MailboxException
MailboxListenerSupport
MailboxListener
public void removeGlobalListener(MailboxListener listener, MailboxSession session) throws MailboxException
MailboxListenerSupport
MailboxListener
removeGlobalListener
in interface MailboxListenerSupport
MailboxException
Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.