Class ImapHostManagerImpl
- java.lang.Object
-
- com.icegreen.greenmail.imap.ImapHostManagerImpl
-
- All Implemented Interfaces:
ImapConstants,ImapHostManager
public class ImapHostManagerImpl extends Object implements ImapHostManager, ImapConstants
An initial implementation of an ImapHost. By default, uses, theInMemoryStoreimplementation ofStore. TODO: Make the underlying store configurable with Phoenix.- Version:
- $Revision: 109034 $
- Author:
- Darrell DeBoer
-
-
Field Summary
-
Fields inherited from interface com.icegreen.greenmail.imap.ImapConstants
BAD, BYE, HIERARCHY_DELIMITER, HIERARCHY_DELIMITER_CHAR, INBOX_NAME, MESSAGES, NAMESPACE_PREFIX, NAMESPACE_PREFIX_CHAR, NO, OK, SP, STORAGE, UNTAGGED, USER_NAMESPACE, VERSION
-
-
Constructor Summary
Constructors Constructor Description ImapHostManagerImpl()Hack constructor which creates an in-memory store, and creates a console logger.ImapHostManagerImpl(Store store)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MailFoldercreateMailbox(GreenMailUser user, String mailboxName)Returns a reference to a newly created Mailbox.voidcreatePrivateMailAccount(GreenMailUser user)Registers a user with the ImapHost, creating a personal mail space and INBOX for that user.voiddeleteMailbox(GreenMailUser user, String mailboxName)Deletes an existing MailBox.voiddeletePrivateMailAccount(GreenMailUser user)Deletes given user data, such as mail boxes or quotas.List<StoredMessage>getAllMessages()Returns all messages.MailFoldergetFolder(GreenMailUser user, String mailboxName)Returns a reference to an existing Mailbox.MailFoldergetFolder(GreenMailUser user, String mailboxName, boolean mustExist)Returns a reference to an existing Mailbox.chargetHierarchyDelimiter()Returns the hierarchy delimiter for mailboxes on this host.MailFoldergetInbox(GreenMailUser user)Returns a reference to the user's INBOX.StoregetStore()Gets the store underneath.Collection<MailFolder>listMailboxes(GreenMailUser user, String mailboxPattern)Returns an collection of mailboxes on this host.Collection<MailFolder>listSubscribedMailboxes(GreenMailUser user, String mailboxPattern)Returns an collection of mailboxes on this host.voidrenameMailbox(GreenMailUser user, String oldMailboxName, String newMailboxName)Renames an existing MailBox.voidsubscribe(GreenMailUser user, String mailboxName)Subscribes a user to a mailbox.voidunsubscribe(GreenMailUser user, String mailboxName)Unsubscribes from a given mailbox.
-
-
-
Constructor Detail
-
ImapHostManagerImpl
public ImapHostManagerImpl()
Hack constructor which creates an in-memory store, and creates a console logger.
-
ImapHostManagerImpl
public ImapHostManagerImpl(Store store)
-
-
Method Detail
-
getAllMessages
public List<StoredMessage> getAllMessages()
Description copied from interface:ImapHostManagerReturns all messages.- Specified by:
getAllMessagesin interfaceImapHostManager- Returns:
- a list of messages.
-
getHierarchyDelimiter
public char getHierarchyDelimiter()
Description copied from interface:ImapHostManagerReturns the hierarchy delimiter for mailboxes on this host.- Specified by:
getHierarchyDelimiterin interfaceImapHostManager- Returns:
- The hierarchy delimiter character.
-
getFolder
public MailFolder getFolder(GreenMailUser user, String mailboxName)
Description copied from interface:ImapHostManagerReturns a reference to an existing Mailbox. The requested mailbox must already exists on this server and the requesting user must have at least lookup rights.TODO: should default behaviour be to return null?
- Specified by:
getFolderin interfaceImapHostManager- Parameters:
user- User making the request.mailboxName- String name of the target.- Returns:
- an Mailbox reference.
- See Also:
ImapHostManager.getFolder(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
-
getFolder
public MailFolder getFolder(GreenMailUser user, String mailboxName, boolean mustExist) throws FolderException
Description copied from interface:ImapHostManagerReturns a reference to an existing Mailbox. If mustExist == true, an exception is thrown if the requested mailbox doesn't exists on this server or the requesting user doesn't have at least lookup rights. If mustExist == false, simply returnsnullin this case.- Specified by:
getFolderin interfaceImapHostManager- Parameters:
user- User making the request.mailboxName- String name of the target.mustExist- Specified behaviour where a mailbox is missing or non-viewable.- Returns:
- an Mailbox reference.
- Throws:
FolderException- if mailbox does not exist locally, and mustExist is true.
-
getInbox
public MailFolder getInbox(GreenMailUser user)
Description copied from interface:ImapHostManagerReturns a reference to the user's INBOX. The user must have been registered on the server by theImapHostManager.createPrivateMailAccount(com.icegreen.greenmail.user.GreenMailUser)method.- Specified by:
getInboxin interfaceImapHostManager- Parameters:
user- The user making the request.- Returns:
- The user's Inbox.
- See Also:
ImapHostManager.getInbox(com.icegreen.greenmail.user.GreenMailUser)
-
createPrivateMailAccount
public void createPrivateMailAccount(GreenMailUser user) throws FolderException
Description copied from interface:ImapHostManagerRegisters a user with the ImapHost, creating a personal mail space and INBOX for that user.- Specified by:
createPrivateMailAccountin interfaceImapHostManager- Parameters:
user- The user to register with the Host.- Throws:
FolderException- if an error occurred creating the user account.- See Also:
ImapHostManager.createPrivateMailAccount(com.icegreen.greenmail.user.GreenMailUser)
-
deletePrivateMailAccount
public void deletePrivateMailAccount(GreenMailUser user)
Description copied from interface:ImapHostManagerDeletes given user data, such as mail boxes or quotas.- Specified by:
deletePrivateMailAccountin interfaceImapHostManager- Parameters:
user- the user.
-
createMailbox
public MailFolder createMailbox(GreenMailUser user, String mailboxName) throws FolderException
Description copied from interface:ImapHostManagerReturns a reference to a newly created Mailbox. The request should specify a mailbox that does not already exist on this server, that could exist on this server and that the user has rights to create. If a system allocates different namespaces to different hosts then a request to create a mailbox in a namespace not served by this host would be an error. It is an error to create a mailbox with the name of a mailbox that has been deleted, if that name is still in use.- Specified by:
createMailboxin interfaceImapHostManager- Parameters:
user- User making the request.mailboxName- String name of the target- Returns:
- an Mailbox reference.
- Throws:
FolderException- if mailbox already exists, locally or remotely, or if mailbox cannot be created locally.- See Also:
ImapHostManager.createMailbox(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
-
deleteMailbox
public void deleteMailbox(GreenMailUser user, String mailboxName) throws FolderException
Description copied from interface:ImapHostManagerDeletes an existing MailBox. Specified mailbox must already exist on this server, and the user must have rights to delete it. (Mailbox delete rights are implementation defined, one way is if the user would have the right to create it).- Specified by:
deleteMailboxin interfaceImapHostManager- Parameters:
user- User making the request.mailboxName- String name of the target- Throws:
FolderException- if mailbox does not exist locally or is any identities INBOX.- See Also:
ImapHostManager.deleteMailbox(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
-
renameMailbox
public void renameMailbox(GreenMailUser user, String oldMailboxName, String newMailboxName) throws FolderException
Description copied from interface:ImapHostManagerRenames an existing MailBox. The specified mailbox must already exist locally, the requested name must not exist locally already but must be able to be created locally and the user must have rights to delete the existing mailbox and create a mailbox with the new name. Any inferior hierarchical names must also be renamed. If INBOX is renamed, the contents of INBOX are transferred to a new folder with the new name, but INBOX is not deleted. If INBOX has inferior mailboxes these are not renamed. It is an error to create a mailbox with the name of a mailbox that has been deleted, if that name is still in use.- Specified by:
renameMailboxin interfaceImapHostManager- Parameters:
user- User making the request.oldMailboxName- String name of the existing mailboxnewMailboxName- String target new name- Throws:
FolderException- if mailbox does not exist locally, or there is an existing mailbox with the new name.- See Also:
ImapHostManager.renameMailbox(com.icegreen.greenmail.user.GreenMailUser, java.lang.String, java.lang.String)
-
listSubscribedMailboxes
public Collection<MailFolder> listSubscribedMailboxes(GreenMailUser user, String mailboxPattern) throws FolderException
Description copied from interface:ImapHostManagerReturns an collection of mailboxes on this host. The specified user must have at least lookup rights for each mailbox returned. If the subscribedOnly flag is set, only mailboxes to which the specified user is currently subscribed should be returned. Implementations that may export circular hierarchies SHOULD restrict the levels of hierarchy returned. The depth suggested by rfc 2683 is 20 hierarchy levels.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.
- Specified by:
listSubscribedMailboxesin interfaceImapHostManager- Parameters:
user- User making the requestmailboxPattern- String name of a mailbox possible including a wildcard.- Returns:
- Collection of mailboxes matching the pattern.
- Throws:
FolderException- if the referenceName is not local or if referenceName and mailbox name resolve to a single mailbox which does not exist locally.- See Also:
ImapHostManager.listSubscribedMailboxes(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
-
listMailboxes
public Collection<MailFolder> listMailboxes(GreenMailUser user, String mailboxPattern) throws FolderException
Description copied from interface:ImapHostManagerReturns an collection of mailboxes on this host. The specified user must have at least lookup rights for each mailbox returned. If the subscribedOnly flag is set, only mailboxes to which the specified user is currently subscribed should be returned. Implementations that may export circular hierarchies SHOULD restrict the levels of hierarchy returned. The depth suggested by rfc 2683 is 20 hierarchy levels.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.
- Specified by:
listMailboxesin interfaceImapHostManager- Parameters:
user- User making the requestmailboxPattern- String name of a mailbox possible including a wildcard.- Returns:
- Collection of mailboxes matching the pattern.
- Throws:
FolderException- if the referenceName is not local or if referenceName and mailbox name resolve to a single mailbox which does not exist locally.- See Also:
ImapHostManager.listMailboxes(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
-
subscribe
public void subscribe(GreenMailUser user, String mailboxName) throws FolderException
Description copied from interface:ImapHostManagerSubscribes a user to a mailbox. The mailbox must exist locally and the user must have at least lookup rights to it.- Specified by:
subscribein interfaceImapHostManager- Parameters:
user- User making the requestmailboxName- String representation of a mailbox name.- Throws:
FolderException- if the mailbox does not exist locally (for the user).- See Also:
ImapHostManager.subscribe(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
-
unsubscribe
public void unsubscribe(GreenMailUser user, String mailboxName) throws FolderException
Description copied from interface:ImapHostManagerUnsubscribes from a given mailbox.- Specified by:
unsubscribein interfaceImapHostManager- Parameters:
user- String representation of an email addressmailboxName- String representation of a mailbox name.- Throws:
FolderException- if the mailbox does not exist locally (for the user).- See Also:
ImapHostManager.unsubscribe(com.icegreen.greenmail.user.GreenMailUser, java.lang.String)
-
getStore
public Store getStore()
Description copied from interface:ImapHostManagerGets the store underneath.- Specified by:
getStorein interfaceImapHostManager- Returns:
- the store.
-
-