Class AlfrescoImapFolder

  • All Implemented Interfaces:
    com.icegreen.greenmail.store.MailFolder, java.io.Serializable

    public class AlfrescoImapFolder
    extends AbstractImapFolder
    implements java.io.Serializable
    Implementation of greenmail MailFolder. It represents an Alfresco content folder and handles appendMessage, copyMessage, expunge (delete), getMessages, getMessage and so requests.
    Author:
    Mike Shavnev, David Ward
    See Also:
    Serialized Form
    • Constructor Detail

      • AlfrescoImapFolder

        public AlfrescoImapFolder​(FileInfo folderInfo,
                                  java.lang.String userName,
                                  java.lang.String folderName,
                                  java.lang.String folderPath,
                                  AlfrescoImapConst.ImapViewMode viewMode,
                                  boolean extractAttachmentsEnabled,
                                  ImapService imapService,
                                  ServiceRegistry serviceRegistry,
                                  int mountPointId)
        Constructs AlfrescoImapFolder object.
        Parameters:
        folderInfo - - reference to the FileInfo object representing the folder.
        userName - - name of user (e.g. "admin" for admin user).
        folderName - - name of the folder.
        folderPath - - path of the folder.
        viewMode - - defines view mode. Can be one of the following: AlfrescoImapConst.ImapViewMode.ARCHIVE or AlfrescoImapConst.ImapViewMode.VIRTUAL.
        extractAttachmentsEnabled - boolean
        imapService - ImapService
        serviceRegistry - ServiceRegistry
        mountPointId - - id of the mount point.
      • AlfrescoImapFolder

        public AlfrescoImapFolder​(FileInfo folderInfo,
                                  java.lang.String userName,
                                  java.lang.String folderName,
                                  java.lang.String folderPath,
                                  AlfrescoImapConst.ImapViewMode viewMode,
                                  ImapService imapService,
                                  ServiceRegistry serviceRegistry,
                                  java.lang.Boolean selectable,
                                  boolean extractAttachmentsEnabled,
                                  int mountPointId)
        Constructs AlfrescoImapFolder object.
        Parameters:
        folderInfo - - reference to the FileInfo object representing the folder.
        userName - - name of the user (e.g. "admin" for admin user).
        folderName - - name of the folder.
        folderPath - - path of the folder.
        viewMode - - defines view mode. Can be one of the following: AlfrescoImapConst.ImapViewMode.ARCHIVE or AlfrescoImapConst.ImapViewMode.VIRTUAL.
        imapService - - the IMAP service.
        serviceRegistry - ServiceRegistry
        selectable - - defines whether the folder is selectable or not.
        extractAttachmentsEnabled - boolean
        mountPointId - int
    • Method Detail

      • isExtractAttachmentsEnabled

        public boolean isExtractAttachmentsEnabled()
      • getFullName

        public java.lang.String getFullName()
        Specified by:
        getFullName in interface com.icegreen.greenmail.store.MailFolder
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface com.icegreen.greenmail.store.MailFolder
      • isSelectable

        public boolean isSelectable()
        Specified by:
        isSelectable in interface com.icegreen.greenmail.store.MailFolder
      • reset

        public boolean reset()
        Invalidates the current cached state
        Returns:
        true if this instance is still valid for reuse
      • deleteAllMessagesInternal

        public void deleteAllMessagesInternal()
                                       throws com.icegreen.greenmail.store.FolderException
        Marks all messages in the folder as deleted using Flags.Flag.DELETED flag.
        Specified by:
        deleteAllMessagesInternal in class AbstractImapFolder
        Throws:
        com.icegreen.greenmail.store.FolderException
      • expungeInternal

        protected void expungeInternal()
                                throws com.icegreen.greenmail.store.FolderException
        Deletes messages marked with Flags.Flag.DELETED. Note that this message deletes all messages with this flag.
        Specified by:
        expungeInternal in class AbstractImapFolder
        Throws:
        com.icegreen.greenmail.store.FolderException
      • expungeInternal

        protected void expungeInternal​(long uid)
                                throws java.lang.Exception
        Deletes messages marked with Flags.Flag.DELETED. Note that this message deletes the message with current uid
        Specified by:
        expungeInternal in class AbstractImapFolder
        Throws:
        java.lang.Exception
      • getFirstUnseen

        public int getFirstUnseen()
        Returns the MSN number of the first unseen message.
        Specified by:
        getFirstUnseen in interface com.icegreen.greenmail.store.MailFolder
        Returns:
        MSN number of the first unseen message.
      • getMessageInternal

        protected com.icegreen.greenmail.store.SimpleStoredMessage getMessageInternal​(long uid)
                                                                               throws javax.mail.MessagingException
        Returns message by its UID.
        Specified by:
        getMessageInternal in class AbstractImapFolder
        Parameters:
        uid - - UID of the message.
        Returns:
        message.
        Throws:
        javax.mail.MessagingException
      • getMessageCount

        public int getMessageCount()
        Returns count of the messages in the folder.
        Specified by:
        getMessageCount in interface com.icegreen.greenmail.store.MailFolder
        Returns:
        Count of the messages.
      • getMessageUids

        public long[] getMessageUids()
        Returns UIDs of all messages in the folder.
        Specified by:
        getMessageUids in interface com.icegreen.greenmail.store.MailFolder
        Returns:
        UIDS of the messages.
      • getMessagesInternal

        protected java.util.List<com.icegreen.greenmail.store.SimpleStoredMessage> getMessagesInternal()
        Returns list of all messages in the folder.
        Specified by:
        getMessagesInternal in class AbstractImapFolder
        Returns:
        list of SimpleStoredMessage objects.
      • getMessagesInternal

        protected java.util.List<com.icegreen.greenmail.store.SimpleStoredMessage> getMessagesInternal​(com.icegreen.greenmail.foedus.util.MsgRangeFilter msgRangeFilter)
        Returns list of messages by filter.
        Specified by:
        getMessagesInternal in class AbstractImapFolder
        Parameters:
        msgRangeFilter - - MsgRangeFilter object representing filter.
        Returns:
        list of filtered messages.
      • getMsn

        public int getMsn​(long uid)
                   throws com.icegreen.greenmail.store.FolderException
        Returns message sequence number in the folder by its UID.
        Specified by:
        getMsn in interface com.icegreen.greenmail.store.MailFolder
        Parameters:
        uid - - message UID.
        Returns:
        message sequence number.
        Throws:
        com.icegreen.greenmail.store.FolderException - if no message with given UID.
      • getNonDeletedMessagesInternal

        protected java.util.List<com.icegreen.greenmail.store.SimpleStoredMessage> getNonDeletedMessagesInternal()
        Returns the list of messages that have no Flags.Flag.DELETED flag set for current user.
        Specified by:
        getNonDeletedMessagesInternal in class AbstractImapFolder
        Returns:
        the list of non-deleted messages.
      • getPermanentFlags

        public javax.mail.Flags getPermanentFlags()
        Returns permanent flags.
        Specified by:
        getPermanentFlags in interface com.icegreen.greenmail.store.MailFolder
        Returns:
        Flags object containing flags.
      • getRecentCount

        public int getRecentCount​(boolean reset)
        Returns count of messages with Flags.Flag.RECENT flag. If reset parameter is true - removes Flags.Flag.RECENT flag from the message for current user.
        Specified by:
        getRecentCount in interface com.icegreen.greenmail.store.MailFolder
        Parameters:
        reset - - if true the Flags.Flag.RECENT will be deleted for current user if exists.
        Returns:
        returns count of recent messages.
      • getUidNext

        public long getUidNext()
        Returns UIDNEXT value of the folder.
        Specified by:
        getUidNext in interface com.icegreen.greenmail.store.MailFolder
        Returns:
        UIDNEXT value.
      • getUidValidity

        public long getUidValidity()
        Returns UIDVALIDITY value of the folder.
        Specified by:
        getUidValidity in interface com.icegreen.greenmail.store.MailFolder
        Returns:
        UIDVALIDITY value.
      • getUnseenCount

        public int getUnseenCount()
        Returns count of the messages with Flags.Flag.SEEN in the folder for the current user.
        Specified by:
        getUnseenCount in interface com.icegreen.greenmail.store.MailFolder
        Returns:
        Count of the unseen messages for current user.
      • replaceFlagsInternal

        protected void replaceFlagsInternal​(javax.mail.Flags flags,
                                            long uid,
                                            com.icegreen.greenmail.store.FolderListener silentListener,
                                            boolean addUid)
                                     throws com.icegreen.greenmail.store.FolderException,
                                            javax.mail.MessagingException
        Replaces flags for the message with the given UID. If addUid is set to true FolderListener objects defined for this folder will be notified. silentListener can be provided - this listener wouldn't be notified.
        Specified by:
        replaceFlagsInternal in class AbstractImapFolder
        Parameters:
        flags - - new flags.
        uid - - message UID.
        silentListener - - listener that shouldn't be notified.
        addUid - - defines whether or not listeners be notified.
        Throws:
        com.icegreen.greenmail.store.FolderException
        javax.mail.MessagingException
      • setFlagsInternal

        protected void setFlagsInternal​(javax.mail.Flags flags,
                                        boolean value,
                                        long uid,
                                        com.icegreen.greenmail.store.FolderListener silentListener,
                                        boolean addUid)
                                 throws javax.mail.MessagingException,
                                        com.icegreen.greenmail.store.FolderException
        Sets flags for the message with the given UID. If addUid is set to true FolderListener objects defined for this folder will be notified. silentListener can be provided - this listener wouldn't be notified.
        Specified by:
        setFlagsInternal in class AbstractImapFolder
        Parameters:
        flags - - new flags.
        value - - flags value.
        uid - - message UID.
        silentListener - - listener that shouldn't be notified.
        addUid - - defines whether or not listeners be notified.
        Throws:
        javax.mail.MessagingException
        com.icegreen.greenmail.store.FolderException
      • getFolderPath

        public java.lang.String getFolderPath()
      • getFolderInfo

        public FileInfo getFolderInfo()
      • isMarked

        public boolean isMarked()
        Specified by:
        isMarked in interface com.icegreen.greenmail.store.MailFolder
      • isReadOnly

        protected boolean isReadOnly()
        Whether the folder is read-only for user.
        Specified by:
        isReadOnly in class AbstractImapFolder
        Returns:
        boolean