org.apache.james.mailboxmanager.manager
Interface MailboxManager

All Known Implementing Classes:
TorqueMailboxManager

public interface MailboxManager

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. This repositories are identified by its 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.


Field Summary
static char HIERARCHY_DELIMITER
           
static java.lang.String INBOX
           
static java.lang.String USER_NAMESPACE
           
 
Method Summary
 void copyMessages(MessageRange set, java.lang.String from, java.lang.String to, MailboxSession session)
          this is done by the MailboxRepository because maybe this operation could be optimized in the corresponding store.
 void createMailbox(java.lang.String mailboxName)
          Creates a new mailbox.
 MailboxSession createSession()
          Creates a new session.
 void deleteMailbox(java.lang.String mailboxName, MailboxSession session)
           
 boolean existsMailbox(java.lang.String mailboxName)
           
 Mailbox getMailbox(java.lang.String mailboxName, boolean autocreate)
          Gets an session suitable for IMAP.
 boolean isAuthentic(java.lang.String userid, java.lang.String passwd)
          Autenticates the given user against the given password.
 ListResult[] list(MailboxExpression expression)
          TODO: Expression requires parsing.
 void renameMailbox(java.lang.String from, java.lang.String to)
          Renames a mailbox.
 java.lang.String resolve(java.lang.String userName, java.lang.String mailboxPath)
           Resolves a path for the given user.
 void subscribe(java.lang.String user, java.lang.String mailbox)
          Subscribes the user to the given mailbox.
 java.util.Collection subscriptions(java.lang.String user)
          Lists current subscriptions for the given user.
 void unsubscribe(java.lang.String user, java.lang.String mailbox)
          Unsubscribes the user from the given mailbox.
 

Field Detail

HIERARCHY_DELIMITER

static final char HIERARCHY_DELIMITER
See Also:
Constant Field Values

USER_NAMESPACE

static final java.lang.String USER_NAMESPACE
See Also:
Constant Field Values

INBOX

static final java.lang.String INBOX
See Also:
Constant Field Values
Method Detail

resolve

java.lang.String resolve(java.lang.String userName,
                         java.lang.String mailboxPath)

Resolves a path for the given user.

TODO: Think about replacing this operation TODO: More elegant to pass in the username TODO: Or switch to URLs


getMailbox

Mailbox getMailbox(java.lang.String mailboxName,
                   boolean autocreate)
                   throws MailboxManagerException
Gets an session suitable for IMAP.

Parameters:
mailboxName - the name of the mailbox, not null
autocreate - create this mailbox if it doesn't exist
Returns:
ImapMailboxSession, not null
Throws:
MailboxManagerException - when the mailbox cannot be opened
MailboxNotFoundException - when the given mailbox does not exist

createMailbox

void createMailbox(java.lang.String mailboxName)
                   throws MailboxManagerException
Creates a new mailbox. Any intermediary mailboxes missing from the hierarchy should be created.

Parameters:
mailboxName - name, not null
Throws:
MailboxManagerException

deleteMailbox

void deleteMailbox(java.lang.String mailboxName,
                   MailboxSession session)
                   throws MailboxManagerException
Throws:
MailboxManagerException

renameMailbox

void renameMailbox(java.lang.String from,
                   java.lang.String to)
                   throws MailboxManagerException
Renames a mailbox.

Parameters:
from - original name for the mailbox
to - new name for the mailbox
Throws:
MailboxManagerException
MailboxExistsException - when the to mailbox exists
MailboxNotFound - when the from mailbox does not exist

copyMessages

void copyMessages(MessageRange set,
                  java.lang.String from,
                  java.lang.String to,
                  MailboxSession session)
                  throws MailboxManagerException
this is done by the MailboxRepository because maybe this operation could be optimized in the corresponding store.

Parameters:
set - messages to copy
from - name of the source mailbox
to - name of the destination mailbox
session - MailboxSession, not null
Throws:
MailboxManagerException

list

ListResult[] list(MailboxExpression expression)
                  throws MailboxManagerException
TODO: Expression requires parsing. Probably easier for the caller to parse the expression into an object representation and use that instead.

Parameters:
expression - MailboxExpression used to select mailboxes to be returned
Throws:
MailboxManagerException

existsMailbox

boolean existsMailbox(java.lang.String mailboxName)
                      throws MailboxManagerException
Throws:
MailboxManagerException

createSession

MailboxSession createSession()
Creates a new session.

Returns:
MailboxSession, not null

isAuthentic

boolean isAuthentic(java.lang.String userid,
                    java.lang.String passwd)
Autenticates the given user against the given password.

Parameters:
userid - user name
passwd - password supplied
Returns:
true if the user is authenticated

subscribe

void subscribe(java.lang.String user,
               java.lang.String mailbox)
               throws SubscriptionException
Subscribes the user to the given mailbox.

Parameters:
user - the user name, not null
mailbox - the mailbox name, not null
Throws:
SubscriptionException

unsubscribe

void unsubscribe(java.lang.String user,
                 java.lang.String mailbox)
                 throws SubscriptionException
Unsubscribes the user from the given mailbox.

Parameters:
user - the user name, not null
mailbox - the mailbox name, not null
Throws:
SubscriptionException

subscriptions

java.util.Collection subscriptions(java.lang.String user)
                                   throws SubscriptionException
Lists current subscriptions for the given user.

Parameters:
user - the user name, not null
Returns:
a Collection of mailbox names
Throws:
SubscriptionException


Copyright © 2002-2008 The Apache Software Foundation. All Rights Reserved.