public class ImapHostManagerImpl extends java.lang.Object implements ImapHostManager, ImapConstants
InMemoryStore
implementation of Store
.
TODO: Make the underlying store configurable with Phoenix.BAD, BYE, CAPABILITIES, HIERARCHY_DELIMITER, HIERARCHY_DELIMITER_CHAR, INBOX_NAME, NAMESPACE_PREFIX, NAMESPACE_PREFIX_CHAR, NO, OK, SP, UNTAGGED, USER_NAMESPACE, VERSION
Constructor and Description |
---|
ImapHostManagerImpl()
Hack constructor which creates an in-memory store, and creates a console logger.
|
ImapHostManagerImpl(Store store) |
Modifier and Type | Method and Description |
---|---|
MailFolder |
createMailbox(GreenMailUser user,
java.lang.String mailboxName)
Returns a reference to a newly created Mailbox.
|
void |
createPrivateMailAccount(GreenMailUser user)
Registers a user with the ImapHost, creating a personal mail space and
INBOX for that user.
|
void |
deleteMailbox(GreenMailUser user,
java.lang.String mailboxName)
Deletes an existing MailBox.
|
java.util.List |
getAllMessages() |
MailFolder |
getFolder(GreenMailUser user,
java.lang.String mailboxName)
Returns a reference to an existing Mailbox.
|
MailFolder |
getFolder(GreenMailUser user,
java.lang.String mailboxName,
boolean mustExist)
Returns a reference to an existing Mailbox.
|
char |
getHierarchyDelimiter()
Returns the hierarchy delimiter for mailboxes on this host.
|
MailFolder |
getInbox(GreenMailUser user)
Returns a reference to the user's INBOX.
|
java.util.Collection |
listMailboxes(GreenMailUser user,
java.lang.String mailboxPattern)
Returns an collection of mailboxes on this host.
|
java.util.Collection |
listSubscribedMailboxes(GreenMailUser user,
java.lang.String mailboxPattern)
Returns an collection of mailboxes on this host.
|
void |
renameMailbox(GreenMailUser user,
java.lang.String oldMailboxName,
java.lang.String newMailboxName)
Renames an existing MailBox.
|
void |
subscribe(GreenMailUser user,
java.lang.String mailboxName)
Subscribes a user to a mailbox.
|
void |
unsubscribe(GreenMailUser user,
java.lang.String mailboxName)
Unsubscribes from a given mailbox.
|
public ImapHostManagerImpl()
public ImapHostManagerImpl(Store store)
public java.util.List getAllMessages()
getAllMessages
in interface ImapHostManager
public char getHierarchyDelimiter()
ImapHostManager
getHierarchyDelimiter
in interface ImapHostManager
public MailFolder getFolder(GreenMailUser user, java.lang.String mailboxName)
ImapHostManager
getFolder
in interface ImapHostManager
user
- User making the request.mailboxName
- String name of the target.ImapHostManager.getFolder(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
public MailFolder getFolder(GreenMailUser user, java.lang.String mailboxName, boolean mustExist) throws FolderException
ImapHostManager
null
in
this case.getFolder
in interface ImapHostManager
user
- User making the request.mailboxName
- String name of the target.mustExist
- Specified behaviour where a mailbox is missing or non-viewable.FolderException
- if mailbox does not exist locally, and mustExist is true.public MailFolder getInbox(GreenMailUser user) throws FolderException
ImapHostManager
ImapHostManager.createPrivateMailAccount(com.icegreen.greenmail.user.GreenMailUser)
method.getInbox
in interface ImapHostManager
user
- The user making the request.FolderException
- if the user doesn't have an inbox on this server.ImapHostManager.getInbox(com.icegreen.greenmail.user.GreenMailUser)
public void createPrivateMailAccount(GreenMailUser user) throws FolderException
ImapHostManager
createPrivateMailAccount
in interface ImapHostManager
user
- The user to register with the Host.FolderException
- if an error occurred creating the user account.ImapHostManager.createPrivateMailAccount(com.icegreen.greenmail.user.GreenMailUser)
public MailFolder createMailbox(GreenMailUser user, java.lang.String mailboxName) throws AuthorizationException, FolderException
ImapHostManager
createMailbox
in interface ImapHostManager
user
- User making the request.mailboxName
- String name of the targetAuthorizationException
- if mailbox could be created locally but
user does not have create rights.FolderException
- if mailbox already exists, locally or remotely,
or if mailbox cannot be created locally.ImapHostManager.createMailbox(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
public void deleteMailbox(GreenMailUser user, java.lang.String mailboxName) throws FolderException, AuthorizationException
ImapHostManager
deleteMailbox
in interface ImapHostManager
user
- User making the request.mailboxName
- String name of the targetFolderException
- if mailbox does not exist locally or is any
identities INBOX.AuthorizationException
- if mailbox exists locally but user does
not have rights to delete it.ImapHostManager.deleteMailbox(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
public void renameMailbox(GreenMailUser user, java.lang.String oldMailboxName, java.lang.String newMailboxName) throws FolderException, AuthorizationException
ImapHostManager
renameMailbox
in interface ImapHostManager
user
- User making the request.oldMailboxName
- String name of the existing mailboxnewMailboxName
- String target new nameFolderException
- if mailbox does not exist locally, or there
is an existing mailbox with the new name.AuthorizationException
- if user does not have rights to delete
the existing mailbox or create the new mailbox.ImapHostManager.renameMailbox(com.icegreen.greenmail.user.GreenMailUser, java.lang.String, java.lang.String)
public java.util.Collection listSubscribedMailboxes(GreenMailUser user, java.lang.String mailboxPattern) throws FolderException
ImapHostManager
The reference name must be non-empty. If the mailbox name is empty, implementations must not throw either exception but must return a single String (described below) if the reference name specifies a local mailbox accessible to the user and a one-character String containing the hierarchy delimiter of the referenced namespace, otherwise.
Each String returned should be a space seperated triple of name attributes, hierarchy delimiter and full mailbox name. The mailbox name should include the namespace and be relative to the specified user.
RFC comments: Implementations SHOULD return quickly. They SHOULD NOT go to excess trouble to calculate\Marked or \Unmarked status.
JAMES comment: By elimination, implementations should usually include \Noinferiors or \Noselect, if appropriate. Also, if the reference name and mailbox name resolve to a single local mailbox, implementations should establish all attributes.
Note that servers cannot unilaterally remove mailboxes from the subscribed list. A request that attempts to list a deleted, but subscribed, mailbox must return that mailbox with the \Noselect attribute.
listSubscribedMailboxes
in interface ImapHostManager
user
- User making the requestmailboxPattern
- String name of a mailbox possible including a
wildcard.FolderException
- if the referenceName is not local or if
referenceName and mailbox name resolve to a single mailbox which does
not exist locally.ImapHostManager.listSubscribedMailboxes(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
public java.util.Collection listMailboxes(GreenMailUser user, java.lang.String mailboxPattern) throws FolderException
ImapHostManager
The reference name must be non-empty. If the mailbox name is empty, implementations must not throw either exception but must return a single String (described below) if the reference name specifies a local mailbox accessible to the user and a one-character String containing the hierarchy delimiter of the referenced namespace, otherwise.
Each String returned should be a space seperated triple of name attributes, hierarchy delimiter and full mailbox name. The mailbox name should include the namespace and be relative to the specified user.
RFC comments: Implementations SHOULD return quickly. They SHOULD NOT go to excess trouble to calculate\Marked or \Unmarked status.
JAMES comment: By elimination, implementations should usually include \Noinferiors or \Noselect, if appropriate. Also, if the reference name and mailbox name resolve to a single local mailbox, implementations should establish all attributes.
listMailboxes
in interface ImapHostManager
user
- User making the requestmailboxPattern
- String name of a mailbox possible including a
wildcard.FolderException
- if the referenceName is not local or if
referenceName and mailbox name resolve to a single mailbox which does
not exist locally.ImapHostManager.listMailboxes(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
public void subscribe(GreenMailUser user, java.lang.String mailboxName) throws FolderException
ImapHostManager
subscribe
in interface ImapHostManager
user
- User making the requestmailboxName
- String representation of a mailbox name.FolderException
- if the mailbox does not exist locally (for the user).ImapHostManager.subscribe(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
public void unsubscribe(GreenMailUser user, java.lang.String mailboxName) throws FolderException
ImapHostManager
unsubscribe
in interface ImapHostManager
user
- String representation of an email addressmailboxName
- String representation of a mailbox name.FolderException
ImapHostManager.unsubscribe(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)