org.alfresco.repo.imap
Class AlfrescoImapFolder

java.lang.Object
  extended by org.alfresco.repo.imap.AbstractImapFolder
      extended by org.alfresco.repo.imap.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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.alfresco.repo.imap.AbstractImapFolder
AbstractImapFolder.CommandCallback
 
Field Summary
 
Fields inherited from class org.alfresco.repo.imap.AbstractImapFolder
MAX_RETRIES, serviceRegistry
 
Constructor Summary
AlfrescoImapFolder(FileInfo folderInfo, java.lang.String userName, java.lang.String folderName, java.lang.String folderPath, AlfrescoImapConst.ImapViewMode viewMode, boolean extractAttachmentsEnabled, ServiceRegistry serviceRegistry, int mountPointId)
          Constructs AlfrescoImapFolder object.
AlfrescoImapFolder(FileInfo folderInfo, java.lang.String userName, java.lang.String folderName, java.lang.String folderPath, AlfrescoImapConst.ImapViewMode viewMode, ServiceRegistry serviceRegistry, java.lang.Boolean selectable, boolean extractAttachmentsEnabled, int mountPointId)
          Constructs AlfrescoImapFolder object.
 
Method Summary
protected  long appendMessageInternal(javax.mail.internet.MimeMessage message, javax.mail.Flags flags, java.util.Date internalDate)
          Appends message to the folder.
protected  void copyMessageInternal(long uid, com.icegreen.greenmail.store.MailFolder toFolder)
          Copies message with the given UID to the specified MailFolder.
 void deleteAllMessagesInternal()
          Marks all messages in the folder as deleted using Flags.Flag#DELETED flag.
protected  void expungeInternal()
          Deletes messages marked with Flags.Flag#DELETED.
 int getFirstUnseen()
          Returns the MSN number of the first unseen message.
 FileInfo getFolderInfo()
           
 java.lang.String getFolderPath()
           
protected  ImapService.FolderStatus getFolderStatus()
           
 java.lang.String getFullName()
           
 int getMessageCount()
          Returns count of the messages in the folder.
protected  com.icegreen.greenmail.store.SimpleStoredMessage getMessageInternal(long uid)
          Returns message by its UID.
protected  java.util.List getMessagesInternal()
          Returns list of all messages in the folder.
protected  java.util.List getMessagesInternal(com.icegreen.greenmail.foedus.util.MsgRangeFilter msgRangeFilter)
          Returns list of messages by filter.
 long[] getMessageUids()
          Returns UIDs of all messages in the folder.
 int getMsn(long uid)
          Returns message sequence number in the folder by its UID.
 java.lang.String getName()
           
protected  java.util.List getNonDeletedMessagesInternal()
          Returns the list of messages that have no Flags.Flag#DELETED flag set for current user.
 javax.mail.Flags getPermanentFlags()
          Returns permanent flags.
 int getRecentCount(boolean reset)
          Returns count of messages with Flags.Flag#RECENT flag.
 long getUidNext()
          Returns UIDNEXT value of the folder.
 long getUidValidity()
          Returns UIDVALIDITY value of the folder.
 int getUnseenCount()
          Returns count of the messages with Flags.Flag#SEEN in the folder for the current user.
 AlfrescoImapConst.ImapViewMode getViewMode()
           
 boolean isExtractAttachmentsEnabled()
           
 boolean isMarked()
           
protected  boolean isReadOnly()
          Whether the folder is read-only for user.
 boolean isSelectable()
           
protected  void replaceFlagsInternal(javax.mail.Flags flags, long uid, com.icegreen.greenmail.store.FolderListener silentListener, boolean addUid)
          Replaces flags for the message with the given UID.
 boolean reset()
          Invalidates the current cached state
protected  void setFlagsInternal(javax.mail.Flags flags, boolean value, long uid, com.icegreen.greenmail.store.FolderListener silentListener, boolean addUid)
          Sets flags for the message with the given UID.
 
Methods inherited from class org.alfresco.repo.imap.AbstractImapFolder
addListener, appendMessage, checkParameter, copyMessage, deleteAllMessages, expunge, getMessage, getMessages, getMessages, getNonDeletedMessages, notifyFlagUpdate, removeListener, replaceFlags, search, setFlags, signalDeletion, store, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlfrescoImapFolder

public AlfrescoImapFolder(FileInfo folderInfo,
                          java.lang.String userName,
                          java.lang.String folderName,
                          java.lang.String folderPath,
                          AlfrescoImapConst.ImapViewMode viewMode,
                          boolean extractAttachmentsEnabled,
                          ServiceRegistry serviceRegistry,
                          int mountPointId)
Constructs AlfrescoImapFolder object.

Parameters:
qualifiedMailboxName - - name of the mailbox (e.g. "admin" for admin user).
folderInfo - - reference to the FileInfo object representing the folder.
folderName - - name of the folder.
viewMode - - defines view mode. Can be one of the following: AlfrescoImapConst#MODE_ARCHIVE or AlfrescoImapConst#MODE_VIRTUAL.
rootNodeRef - - reference to the root node of the store where folder is placed.
mountPointName - - name of the mount point.

AlfrescoImapFolder

public AlfrescoImapFolder(FileInfo folderInfo,
                          java.lang.String userName,
                          java.lang.String folderName,
                          java.lang.String folderPath,
                          AlfrescoImapConst.ImapViewMode viewMode,
                          ServiceRegistry serviceRegistry,
                          java.lang.Boolean selectable,
                          boolean extractAttachmentsEnabled,
                          int mountPointId)
Constructs AlfrescoImapFolder object.

Parameters:
qualifiedMailboxName - - name of the mailbox (e.g. "admin" for admin user).
folderInfo - - reference to the FileInfo object representing the folder.
folderName - - name of the folder.
viewMode - - defines view mode. Can be one of the following: AlfrescoImapConst#MODE_ARCHIVE or AlfrescoImapConst#MODE_VIRTUAL.
rootNodeRef - - reference to the root node of the store where folder is placed.
mountPointName - - name of the mount point.
imapService - - reference to the ImapHelper object.
selectable - - defines whether the folder is selectable or not.
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

getFolderStatus

protected ImapService.FolderStatus getFolderStatus()

appendMessageInternal

protected long appendMessageInternal(javax.mail.internet.MimeMessage message,
                                     javax.mail.Flags flags,
                                     java.util.Date internalDate)
                              throws FileExistsException,
                                     FileNotFoundException,
                                     java.io.IOException,
                                     javax.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
java.io.IOException
javax.mail.MessagingException

copyMessageInternal

protected void copyMessageInternal(long uid,
                                   com.icegreen.greenmail.store.MailFolder toFolder)
                            throws javax.mail.MessagingException,
                                   FileExistsException,
                                   FileNotFoundException,
                                   java.io.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:
javax.mail.MessagingException
java.io.IOException
FileNotFoundException
FileExistsException

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

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 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 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 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

getViewMode

public AlfrescoImapConst.ImapViewMode getViewMode()


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.