public interface MailboxManager extends RequestAware, MailboxListenerSupport
Central MailboxManager which creates, lists, provides, renames and deletes Mailboxes
An important goal is to be JavaMail feature compatible. That means JavaMail could be used in both directions: As a backend for e.g. accessing a Maildir JavaMail store or as a frontend to access a JDBC MailboxManager through JavaMail. This should be possible by not too complicated wrapper classes. Due to the complexity of JavaMail it might be impossible to avoid some limitations.
Internally MailboxManager deals with named repositories that could have different implementations. E.g. JDBC connections to different hosts or Maildir / Mbox like stores. These repositories are identified by their names and maybe are configured in config.xml. The names of the mailboxes have to be mapped to the corresponding repository name. For user mailboxes this could be done by a "User.getRepositoryName()" property. It is imaginable that repositories lookup further properties from the user object like a path name for a file based storage method. Until Milestone 6 there is only one named repository: "default".
The only operation that requires dealing with the named repositories directly is the quota management. It is probably really difficult to implement a quota system that spans multiple repository implementations. That is why quotas are created for a specific repository. To be able to administer, repositories and theier belonging mailboxes can be listet.
Modifier and Type | Method and Description |
---|---|
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.
|
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 login(String, String, Logger) when accessing this API from a
protocol. |
void |
deleteMailbox(MailboxPath mailboxPath,
MailboxSession session)
Delete the mailbox with the name
|
char |
getDelimiter()
Return the delimiter to use for folders
|
MessageManager |
getMailbox(MailboxPath mailboxPath,
MailboxSession session)
Gets an session suitable for IMAP.
|
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)
Logs the session out, freeing any resources.
|
boolean |
mailboxExists(MailboxPath mailboxPath,
MailboxSession session)
Does the given mailbox exist?
|
void |
renameMailbox(MailboxPath from,
MailboxPath to,
MailboxSession session)
Renames a mailbox.
|
List<MailboxMetaData> |
search(MailboxQuery expression,
MailboxSession session)
Searches for mailboxes matching the given query.
|
endProcessingRequest, startProcessingRequest
addGlobalListener, addListener, removeGlobalListener, removeListener
char getDelimiter()
MessageManager getMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
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 existvoid createMailbox(MailboxPath mailboxPath, MailboxSession mailboxSession) throws MailboxException
mailboxPath
- mailboxSession
- the context for this call, not nullMailboxException
- when creation failsvoid deleteMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
mailboxPath
- session
- MailboxException
void renameMailbox(MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException
from
- original mailboxto
- new mailboxsession
- the context for this call, not nulMailboxException
- otherwiseMailboxExistsException
- when the to
mailbox existsMailboxNotFound
- when the from
mailbox does not existList<MessageRange> copyMessages(MessageRange set, MailboxPath from, MailboxPath to, MailboxSession session) throws MailboxException
MessageRange
from one Mailbox to the other.
Be aware that the copied Messages MUST get the \RECENT flag set!set
- messages to copyfrom
- name of the source mailboxto
- name of the destination mailboxsession
- MailboxSession
, not nullMailboxException
List<MailboxMetaData> search(MailboxQuery expression, MailboxSession session) throws MailboxException
expression
- not nullsession
- the context for this call, not nullMailboxException
boolean mailboxExists(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
mailboxPath
- not nullsession
- the context for this call, not nullMailboxException
MailboxSession createSystemSession(String userName, org.slf4j.Logger log) throws BadCredentialsException, MailboxException
login(String, String, Logger)
when accessing this API from a
protocol.userName
- the name of the user whose session is being createdlog
- context sensitive logMailboxSession
, not nullBadCredentialsException
- when system access is not allowed for the given userMailboxException
- when the creation fails for other reasonsMailboxSession login(String userid, String passwd, org.slf4j.Logger log) throws BadCredentialsException, MailboxException
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 reasonsvoid logout(MailboxSession session, boolean force) throws MailboxException
Logs the session out, freeing any resources. Clients who open session should make best efforts to call this when the session is closed.
Note that clients may not always be able to call logout (whether forced
or not). Mailboxes that create sessions which are expensive to maintain
MUST
retain a reference and periodically check
MailboxSession.isOpen()
.
Note that implementations much be aware that it is possible that this method may be called more than once with the same session.
session
- not nullforce
- true when the session logout is forced by premature connection
terminationMailboxException
- when logout failsList<MailboxPath> list(MailboxSession session) throws MailboxException
List
of MailboxPath
objectssession
- MailboxException
Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.