Class AlfrescoImapHostManager

java.lang.Object
org.alfresco.repo.imap.AlfrescoImapHostManager
All Implemented Interfaces:
com.icegreen.greenmail.imap.ImapHostManager

public class AlfrescoImapHostManager extends Object implements com.icegreen.greenmail.imap.ImapHostManager
This Host Manager is assumed to be session local, i.e. there is one instance per IMAP TCP connection. This means that it can locally cache items being interacted with during the session and its knowledge of which folders / messages do or do not exist will match that of the client.
Author:
Mike Shavnev, David Ward
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.icegreen.greenmail.store.MailFolder
    createMailbox(com.icegreen.greenmail.user.GreenMailUser user, String mailboxName)
    Returns a reference to a newly created mailbox.
    void
    createPrivateMailAccount(com.icegreen.greenmail.user.GreenMailUser user)
    Not supported.
    void
    deleteMailbox(com.icegreen.greenmail.user.GreenMailUser user, String mailboxName)
    Deletes an existing MailBox.
    List<?>
    Not supported.
    com.icegreen.greenmail.store.MailFolder
    getFolder(com.icegreen.greenmail.user.GreenMailUser user, String mailboxName)
    Returns a reference to an existing Mailbox.
    com.icegreen.greenmail.store.MailFolder
    getFolder(com.icegreen.greenmail.user.GreenMailUser user, String mailboxName, boolean mustExist)
    char
    Returns the hierarchy delimiter for mailboxes on this host.
    com.icegreen.greenmail.store.MailFolder
    getInbox(com.icegreen.greenmail.user.GreenMailUser user)
    Returns a reference to the user's INBOX.
    Collection<com.icegreen.greenmail.store.MailFolder>
    listMailboxes(com.icegreen.greenmail.user.GreenMailUser user, String mailboxPattern)
    Returns an collection of mailboxes.
    Collection<com.icegreen.greenmail.store.MailFolder>
    listSubscribedMailboxes(com.icegreen.greenmail.user.GreenMailUser user, String mailboxPattern)
    Returns an collection of subscribed mailboxes.
    void
    renameMailbox(com.icegreen.greenmail.user.GreenMailUser user, String oldMailboxName, String newMailboxName)
    Renames an existing mailbox.
    void
    subscribe(com.icegreen.greenmail.user.GreenMailUser user, String mailbox)
    Subscribes a user to a mailbox.
    void
    unsubscribe(com.icegreen.greenmail.user.GreenMailUser user, String mailbox)
    Unsubscribes from a given mailbox.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AlfrescoImapHostManager

      public AlfrescoImapHostManager(ImapService imapService)
      Parameters:
      imapService - ImapService
  • Method Details

    • getHierarchyDelimiter

      public char getHierarchyDelimiter()
      Returns the hierarchy delimiter for mailboxes on this host.
      Specified by:
      getHierarchyDelimiter in interface com.icegreen.greenmail.imap.ImapHostManager
      Returns:
      The hierarchy delimiter character.
    • listMailboxes

      public Collection<com.icegreen.greenmail.store.MailFolder> listMailboxes(com.icegreen.greenmail.user.GreenMailUser user, String mailboxPattern) throws com.icegreen.greenmail.store.FolderException
      Returns an collection of mailboxes. Method searches mailboxes under mount points defined for a specific user. Mount points include user's IMAP Virtualised Views and Email Archive Views. This method serves LIST command of the IMAP protocol.
      Specified by:
      listMailboxes in interface com.icegreen.greenmail.imap.ImapHostManager
      Parameters:
      user - User making the request
      mailboxPattern - String name of a mailbox possible including a wildcard.
      Returns:
      Collection of mailboxes matching the pattern.
      Throws:
      com.icegreen.greenmail.store.FolderException
    • listSubscribedMailboxes

      public Collection<com.icegreen.greenmail.store.MailFolder> listSubscribedMailboxes(com.icegreen.greenmail.user.GreenMailUser user, String mailboxPattern) throws com.icegreen.greenmail.store.FolderException
      Returns an collection of subscribed mailboxes. To appear in search result mailboxes should have {http://www.alfresco.org/model/imap/1.0}subscribed property specified for user. Method searches subscribed mailboxes under mount points defined for a specific user. Mount points include user's IMAP Virtualised Views and Email Archive Views. This method serves LSUB command of the IMAP protocol.
      Specified by:
      listSubscribedMailboxes in interface com.icegreen.greenmail.imap.ImapHostManager
      Parameters:
      user - User making the request
      mailboxPattern - String name of a mailbox possible including a wildcard.
      Returns:
      Collection of mailboxes matching the pattern.
      Throws:
      com.icegreen.greenmail.store.FolderException
    • renameMailbox

      public void renameMailbox(com.icegreen.greenmail.user.GreenMailUser user, String oldMailboxName, String newMailboxName) throws com.icegreen.greenmail.store.FolderException, com.icegreen.greenmail.imap.AuthorizationException
      Renames an existing mailbox. The specified mailbox must already exist, the requested name must not exist already but must be able to be created 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 mailbox with the new name, but INBOX is not deleted. If INBOX has inferior mailbox these are not renamed. This method serves RENAME command of the IMAP protocol.

      Method searches mailbox under mount points defined for a specific user. Mount points include user's IMAP Virtualised Views and Email Archive Views.

      Specified by:
      renameMailbox in interface com.icegreen.greenmail.imap.ImapHostManager
      Parameters:
      user - User making the request.
      oldMailboxName - String name of the existing folder
      newMailboxName - String target new name
      Throws:
      com.icegreen.greenmail.store.FolderException - if an existing folder with the new name.
      AlfrescoImapFolderException - if user does not have rights to create the new mailbox.
      com.icegreen.greenmail.imap.AuthorizationException
    • createMailbox

      public com.icegreen.greenmail.store.MailFolder createMailbox(com.icegreen.greenmail.user.GreenMailUser user, String mailboxName) throws com.icegreen.greenmail.imap.AuthorizationException, com.icegreen.greenmail.store.FolderException
      Returns 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. This method serves CREATE command of the IMAP protocol.
      Specified by:
      createMailbox in interface com.icegreen.greenmail.imap.ImapHostManager
      Parameters:
      user - User making the request.
      mailboxName - String name of the target
      Returns:
      an Mailbox reference.
      Throws:
      com.icegreen.greenmail.store.FolderException - if mailbox already exists
      AlfrescoImapFolderException - if user does not have rights to create the new mailbox.
      com.icegreen.greenmail.imap.AuthorizationException
    • deleteMailbox

      public void deleteMailbox(com.icegreen.greenmail.user.GreenMailUser user, String mailboxName) throws com.icegreen.greenmail.store.FolderException, com.icegreen.greenmail.imap.AuthorizationException
      Deletes an existing MailBox. Specified mailbox must already exist on this server, and the user must have rights to delete it.

      This method serves DELETE command of the IMAP protocol.

      Specified by:
      deleteMailbox in interface com.icegreen.greenmail.imap.ImapHostManager
      Parameters:
      user - User making the request.
      mailboxName - String name of the target
      Throws:
      com.icegreen.greenmail.store.FolderException - if mailbox has a non-selectable store with children
      com.icegreen.greenmail.imap.AuthorizationException
    • getFolder

      public com.icegreen.greenmail.store.MailFolder getFolder(com.icegreen.greenmail.user.GreenMailUser user, String mailboxName)
      Returns 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.

      It is also can be used by to obtain hierarchy delimiter by the LIST command:

      C: 2 list "" ""

      S: * LIST () "." ""

      S: 2 OK LIST completed.

      Method searches mailbox under mount points defined for a specific user. Mount points include user's IMAP Virtualised Views and Email Archive Views.

      Specified by:
      getFolder in interface com.icegreen.greenmail.imap.ImapHostManager
      Parameters:
      user - User making the request.
      mailboxName - String name of the target.
      Returns:
      an Mailbox reference.
    • getFolder

      public com.icegreen.greenmail.store.MailFolder getFolder(com.icegreen.greenmail.user.GreenMailUser user, String mailboxName, boolean mustExist) throws com.icegreen.greenmail.store.FolderException
      Simply calls getFolder(GreenMailUser, String).

      Added to implement ImapHostManager.

      Specified by:
      getFolder in interface com.icegreen.greenmail.imap.ImapHostManager
      Throws:
      com.icegreen.greenmail.store.FolderException
    • getInbox

      public com.icegreen.greenmail.store.MailFolder getInbox(com.icegreen.greenmail.user.GreenMailUser user) throws com.icegreen.greenmail.store.FolderException
      Returns a reference to the user's INBOX.
      Specified by:
      getInbox in interface com.icegreen.greenmail.imap.ImapHostManager
      Parameters:
      user - The user making the request.
      Returns:
      The user's Inbox.
      Throws:
      com.icegreen.greenmail.store.FolderException
    • createPrivateMailAccount

      public void createPrivateMailAccount(com.icegreen.greenmail.user.GreenMailUser user) throws com.icegreen.greenmail.store.FolderException
      Not supported. May be used by GreenMailUser.create() method.

      Added to implement ImapHostManager.

      Specified by:
      createPrivateMailAccount in interface com.icegreen.greenmail.imap.ImapHostManager
      Throws:
      com.icegreen.greenmail.store.FolderException
    • subscribe

      public void subscribe(com.icegreen.greenmail.user.GreenMailUser user, String mailbox) throws com.icegreen.greenmail.store.FolderException
      Subscribes a user to a mailbox. The mailbox must exist locally and the user must have rights to modify it.

      This method serves SUBSCRIBE command of the IMAP protocol.

      Specified by:
      subscribe in interface com.icegreen.greenmail.imap.ImapHostManager
      Parameters:
      user - User making the request
      mailbox - String representation of a mailbox name.
      Throws:
      com.icegreen.greenmail.store.FolderException
    • unsubscribe

      public void unsubscribe(com.icegreen.greenmail.user.GreenMailUser user, String mailbox) throws com.icegreen.greenmail.store.FolderException
      Unsubscribes from a given mailbox.

      This method serves UNSUBSCRIBE command of the IMAP protocol.

      Specified by:
      unsubscribe in interface com.icegreen.greenmail.imap.ImapHostManager
      Parameters:
      user - User making the request
      mailbox - String representation of a mailbox name.
      Throws:
      com.icegreen.greenmail.store.FolderException
    • getAllMessages

      public List<?> getAllMessages()
      Not supported. Used by GreenMail class.
      Specified by:
      getAllMessages in interface com.icegreen.greenmail.imap.ImapHostManager