Class AlfrescoImapFolder

java.lang.Object
org.alfresco.repo.imap.AbstractImapFolder
org.alfresco.repo.imap.AlfrescoImapFolder
All Implemented Interfaces:
com.icegreen.greenmail.store.MailFolder, Serializable

public class AlfrescoImapFolder extends AbstractImapFolder implements 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:
  • Constructor Details

  • Method Details

    • isExtractAttachmentsEnabled

      public boolean isExtractAttachmentsEnabled()
    • getFullName

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

      public 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
    • getFolderStatus

      protected ImapService.FolderStatus getFolderStatus()
    • appendMessageInternal

      protected long appendMessageInternal(jakarta.mail.internet.MimeMessage message, jakarta.mail.Flags flags, Date internalDate) throws FileExistsException, FileNotFoundException, IOException, jakarta.mail.MessagingException
      Appends message to the folder.
      Specified by:
      appendMessageInternal in class AbstractImapFolder
      Parameters:
      message - - message.
      flags - - message flags.
      internalDate - - not used. Current date used instead.
      Throws:
      FileExistsException
      FileNotFoundException
      IOException
      jakarta.mail.MessagingException
    • copyMessageInternal

      protected long copyMessageInternal(long uid, com.icegreen.greenmail.store.MailFolder toFolder) throws jakarta.mail.MessagingException, FileExistsException, FileNotFoundException, IOException
      Copies message with the given UID to the specified MailFolder.
      Specified by:
      copyMessageInternal in class AbstractImapFolder
      Parameters:
      uid - - UID of the message
      toFolder - - reference to the destination folder.
      Throws:
      jakarta.mail.MessagingException
      IOException
      FileNotFoundException
      FileExistsException
    • deleteAllMessagesInternal

      public void deleteAllMessagesInternal() throws com.icegreen.greenmail.store.FolderException
      Marks all messages in the folder as deleted using javax.mail.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 javax.mail.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 Exception
      Deletes messages marked with javax.mail.Flags.Flag#DELETED. Note that this message deletes the message with current uid
      Specified by:
      expungeInternal in class AbstractImapFolder
      Throws:
      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 jakarta.mail.MessagingException
      Returns message by its UID.
      Specified by:
      getMessageInternal in class AbstractImapFolder
      Parameters:
      uid - - UID of the message.
      Returns:
      message.
      Throws:
      jakarta.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 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 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 List<com.icegreen.greenmail.store.SimpleStoredMessage> getNonDeletedMessagesInternal()
      Returns the list of messages that have no javax.mail.Flags.Flag#DELETED flag set for current user.
      Specified by:
      getNonDeletedMessagesInternal in class AbstractImapFolder
      Returns:
      the list of non-deleted messages.
    • getPermanentFlags

      public jakarta.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 javax.mail.Flags.Flag#RECENT flag. If reset parameter is true - removes javax.mail.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 javax.mail.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 javax.mail.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(jakarta.mail.Flags flags, long uid, com.icegreen.greenmail.store.FolderListener silentListener, boolean addUid) throws com.icegreen.greenmail.store.FolderException, jakarta.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
      jakarta.mail.MessagingException
    • searchInternal

      protected long[] searchInternal(jakarta.mail.search.SearchTerm searchTerm)
      Specified by:
      searchInternal in class AbstractImapFolder
    • setFlagsInternal

      protected void setFlagsInternal(jakarta.mail.Flags flags, boolean value, long uid, com.icegreen.greenmail.store.FolderListener silentListener, boolean addUid) throws jakarta.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:
      jakarta.mail.MessagingException
      com.icegreen.greenmail.store.FolderException
    • getFolderPath

      public 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
    • getViewMode

      public AlfrescoImapConst.ImapViewMode getViewMode()