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. The folder is identified by a qualifiedMailboxName and versioned with a version number called UIDVALIDITY.

See Also:
Serialized Form

Nested Class Summary
 class AlfrescoImapFolder.GenerateUidValidityWork
          Generate UID validity In general this class will return a long UID value but if there is no ASPECT_IMAP_FOLDER then running this method will add the aspect and add initial values.
 class AlfrescoImapFolder.GetUidValidityWork
          Read only transaction to get uidvalidity
 
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(java.lang.String qualifiedMailboxName, FileInfo folderInfo, java.lang.String folderName, AlfrescoImapConst.ImapViewMode viewMode, org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String mountPointName, boolean extractAttachmentsEnabled, ServiceRegistry serviceRegistry)
          Constructs AlfrescoImapFolder object.
AlfrescoImapFolder(java.lang.String qualifiedMailboxName, FileInfo folderInfo, java.lang.String folderName, AlfrescoImapConst.ImapViewMode viewMode, org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String mountPointName, ServiceRegistry serviceRegistry, java.lang.Boolean selectable, boolean extractAttachmentsEnabled)
          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.
protected  com.icegreen.greenmail.store.SimpleStoredMessage createImapMessage(FileInfo fileInfo, java.lang.Long key, boolean generateBody)
           
 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.
protected  int getFirstUnseenInternal()
          Returns the number of the first unseen message.
 FileInfo getFolderInfo()
           
protected  java.lang.String getFullNameInternal()
          Returns full name of the folder with namespace and full path delimited with the hierarchy delimiter (see AlfrescoImapConst.HIERARCHY_DELIMITER)

E.g.:
#mail.admin."Repository_archive.Data Dictionary.Space Templates.Software Engineering Project"
This is required by GreenMail implementation.

protected  int getMessageCountInternal()
          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.
protected  long[] getMessageUidsInternal()
          Returns UIDs of all messages in the folder.
protected  int getMsnInternal(long uid)
          Returns message sequence number in the folder by its UID.
protected  java.lang.String getNameInternal()
          Returns folder name.
protected  java.util.List getNonDeletedMessagesInternal()
          Returns the list of messages that have no Flags.Flag#DELETED flag set for current user.
protected  javax.mail.Flags getPermanentFlagsInternal()
          Returns permanent flags.
protected  int getRecentCountInternal(boolean reset)
          Returns count of messages with Flags.Flag#RECENT flag.
protected  long getUidNextInternal()
          Returns UIDNEXT value of the folder.
protected  long getUidValidityInternal()
          Returns UIDVALIDITY value of the folder.
protected  int getUnseenCountInternal()
          Returns count of the messages with Flags.Flag#SEEN in the folder for the current user.
 AlfrescoImapConst.ImapViewMode getViewMode()
           
 boolean isExtractAttachmentsEnabled()
           
protected  boolean isReadOnly()
          Whether the folder is read-only for user.
protected  boolean isSelectableInternal()
          Whether the folder is selectable.
 boolean isStale()
           
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.
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.
 void setFolderName(java.lang.String folderName)
           
 void setMountParent(org.alfresco.service.cmr.repository.NodeRef mountParent)
           
 void setMountPointName(java.lang.String mountPointName)
           
 void setSelectable(boolean selectable)
          Sets AlfrescoImapFolder.selectable property.
 void setViewMode(AlfrescoImapConst.ImapViewMode viewMode)
           
 
Methods inherited from class org.alfresco.repo.imap.AbstractImapFolder
addListener, appendMessage, checkParameter, copyMessage, deleteAllMessages, expunge, getFirstUnseen, getFullName, getMessage, getMessageCount, getMessages, getMessages, getMessageUids, getMsn, getName, getNonDeletedMessages, getPermanentFlags, getRecentCount, getUidNext, getUidValidity, getUnseenCount, isSelectable, 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(java.lang.String qualifiedMailboxName,
                          FileInfo folderInfo,
                          java.lang.String folderName,
                          AlfrescoImapConst.ImapViewMode viewMode,
                          org.alfresco.service.cmr.repository.NodeRef rootNodeRef,
                          java.lang.String mountPointName,
                          boolean extractAttachmentsEnabled,
                          ServiceRegistry serviceRegistry)
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(java.lang.String qualifiedMailboxName,
                          FileInfo folderInfo,
                          java.lang.String folderName,
                          AlfrescoImapConst.ImapViewMode viewMode,
                          org.alfresco.service.cmr.repository.NodeRef rootNodeRef,
                          java.lang.String mountPointName,
                          ServiceRegistry serviceRegistry,
                          java.lang.Boolean selectable,
                          boolean extractAttachmentsEnabled)
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()

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

getFirstUnseenInternal

protected int getFirstUnseenInternal()
Returns the number of the first unseen message.

Specified by:
getFirstUnseenInternal in class AbstractImapFolder
Returns:
Number of the first unseen message.

getFullNameInternal

protected java.lang.String getFullNameInternal()
                                        throws FileNotFoundException
Returns full name of the folder with namespace and full path delimited with the hierarchy delimiter (see AlfrescoImapConst.HIERARCHY_DELIMITER)

E.g.:
#mail.admin."Repository_archive.Data Dictionary.Space Templates.Software Engineering Project"
This is required by GreenMail implementation.

Specified by:
getFullNameInternal in class AbstractImapFolder
Throws:
FileNotFoundException

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

getMessageCountInternal

protected int getMessageCountInternal()
Returns count of the messages in the folder.

Specified by:
getMessageCountInternal in class AbstractImapFolder
Returns:
Count of the messages.

getMessageUidsInternal

protected long[] getMessageUidsInternal()
Returns UIDs of all messages in the folder.

Specified by:
getMessageUidsInternal in class AbstractImapFolder
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.

createImapMessage

protected com.icegreen.greenmail.store.SimpleStoredMessage createImapMessage(FileInfo fileInfo,
                                                                             java.lang.Long key,
                                                                             boolean generateBody)
                                                                      throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

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.

getMsnInternal

protected int getMsnInternal(long uid)
                      throws com.icegreen.greenmail.store.FolderException
Returns message sequence number in the folder by its UID.

Specified by:
getMsnInternal in class AbstractImapFolder
Parameters:
uid - - message UID.
Returns:
message sequence number.
Throws:
com.icegreen.greenmail.store.FolderException - if no message with given UID.

getNameInternal

protected java.lang.String getNameInternal()
Returns folder name.

Specified by:
getNameInternal in class AbstractImapFolder
Returns:
folder name.

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.

getPermanentFlagsInternal

protected javax.mail.Flags getPermanentFlagsInternal()
Returns permanent flags.

Specified by:
getPermanentFlagsInternal in class AbstractImapFolder
Returns:
Flags object containing flags.

getRecentCountInternal

protected int getRecentCountInternal(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:
getRecentCountInternal in class AbstractImapFolder
Parameters:
reset - - if true the Flags.Flag#RECENT will be deleted for current user if exists.
Returns:
returns count of recent messages.

getUidNextInternal

protected long getUidNextInternal()
Returns UIDNEXT value of the folder.

Specified by:
getUidNextInternal in class AbstractImapFolder
Returns:
UIDNEXT value.

isStale

public boolean isStale()

getUidValidityInternal

protected long getUidValidityInternal()
Returns UIDVALIDITY value of the folder.

Specified by:
getUidValidityInternal in class AbstractImapFolder
Returns:
UIDVALIDITY value.

getUnseenCountInternal

protected int getUnseenCountInternal()
Returns count of the messages with Flags.Flag#SEEN in the folder for the current user.

Specified by:
getUnseenCountInternal in class AbstractImapFolder
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

getFolderInfo

public FileInfo getFolderInfo()

setFolderName

public void setFolderName(java.lang.String folderName)

setViewMode

public void setViewMode(AlfrescoImapConst.ImapViewMode viewMode)

setMountPointName

public void setMountPointName(java.lang.String mountPointName)

setMountParent

public void setMountParent(org.alfresco.service.cmr.repository.NodeRef mountParent)

isSelectableInternal

protected boolean isSelectableInternal()
Whether the folder is selectable.

Specified by:
isSelectableInternal in class AbstractImapFolder
Returns:
boolean.

setSelectable

public void setSelectable(boolean selectable)
Sets AlfrescoImapFolder.selectable property.

Parameters:
selectable - - boolean.

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.