Package org.alfresco.repo.imap
Class AlfrescoImapFolder
- java.lang.Object
-
- org.alfresco.repo.imap.AbstractImapFolder
-
- 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.- Author:
- Mike Shavnev, David Ward
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.alfresco.repo.imap.AbstractImapFolder
AbstractImapFolder.CommandCallback<T>
-
-
Field Summary
-
Fields inherited from class org.alfresco.repo.imap.AbstractImapFolder
logger, MAX_RETRIES, serviceRegistry
-
-
Constructor Summary
Constructors Constructor Description 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)ConstructsAlfrescoImapFolderobject.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)ConstructsAlfrescoImapFolderobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected longappendMessageInternal(javax.mail.internet.MimeMessage message, javax.mail.Flags flags, java.util.Date internalDate)Appends message to the folder.protected longcopyMessageInternal(long uid, com.icegreen.greenmail.store.MailFolder toFolder)Copies message with the given UID to the specifiedMailFolder.voiddeleteAllMessagesInternal()Marks all messages in the folder as deleted usingFlags.Flag.DELETEDflag.protected voidexpungeInternal()Deletes messages marked withFlags.Flag.DELETED.protected voidexpungeInternal(long uid)Deletes messages marked withFlags.Flag.DELETED.intgetFirstUnseen()Returns the MSN number of the first unseen message.FileInfogetFolderInfo()java.lang.StringgetFolderPath()protected ImapService.FolderStatusgetFolderStatus()java.lang.StringgetFullName()intgetMessageCount()Returns count of the messages in the folder.protected com.icegreen.greenmail.store.SimpleStoredMessagegetMessageInternal(long uid)Returns message by its UID.protected java.util.List<com.icegreen.greenmail.store.SimpleStoredMessage>getMessagesInternal()Returns list of all messages in the folder.protected java.util.List<com.icegreen.greenmail.store.SimpleStoredMessage>getMessagesInternal(com.icegreen.greenmail.foedus.util.MsgRangeFilter msgRangeFilter)Returns list of messages by filter.long[]getMessageUids()Returns UIDs of all messages in the folder.intgetMsn(long uid)Returns message sequence number in the folder by its UID.java.lang.StringgetName()protected java.util.List<com.icegreen.greenmail.store.SimpleStoredMessage>getNonDeletedMessagesInternal()Returns the list of messages that have noFlags.Flag.DELETEDflag set for current user.javax.mail.FlagsgetPermanentFlags()Returns permanent flags.intgetRecentCount(boolean reset)Returns count of messages withFlags.Flag.RECENTflag.longgetUidNext()Returns UIDNEXT value of the folder.longgetUidValidity()Returns UIDVALIDITY value of the folder.intgetUnseenCount()Returns count of the messages withFlags.Flag.SEENin the folder for the current user.AlfrescoImapConst.ImapViewModegetViewMode()booleanisExtractAttachmentsEnabled()booleanisMarked()protected booleanisReadOnly()Whether the folder is read-only for user.booleanisSelectable()protected voidreplaceFlagsInternal(javax.mail.Flags flags, long uid, com.icegreen.greenmail.store.FolderListener silentListener, boolean addUid)Replaces flags for the message with the given UID.booleanreset()Invalidates the current cached stateprotected long[]searchInternal(javax.mail.search.SearchTerm searchTerm)protected voidsetFlagsInternal(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, expunge, getMessage, getMessages, getMessages, getNonDeletedMessages, notifyFlagUpdate, removeListener, replaceFlags, search, setFlags, signalDeletion, store, store
-
-
-
-
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)
ConstructsAlfrescoImapFolderobject.- Parameters:
folderInfo- - reference to theFileInfoobject 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.ARCHIVEorAlfrescoImapConst.ImapViewMode.VIRTUAL.extractAttachmentsEnabled- booleanimapService- ImapServiceserviceRegistry- ServiceRegistrymountPointId- - 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)
ConstructsAlfrescoImapFolderobject.- Parameters:
folderInfo- - reference to theFileInfoobject 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.ARCHIVEorAlfrescoImapConst.ImapViewMode.VIRTUAL.imapService- - the IMAP service.serviceRegistry- ServiceRegistryselectable- - defines whether the folder is selectable or not.extractAttachmentsEnabled- booleanmountPointId- int
-
-
Method Detail
-
isExtractAttachmentsEnabled
public boolean isExtractAttachmentsEnabled()
-
getFullName
public java.lang.String getFullName()
- Specified by:
getFullNamein interfacecom.icegreen.greenmail.store.MailFolder
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfacecom.icegreen.greenmail.store.MailFolder
-
isSelectable
public boolean isSelectable()
- Specified by:
isSelectablein interfacecom.icegreen.greenmail.store.MailFolder
-
reset
public boolean reset()
Invalidates the current cached state- Returns:
trueif 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.MessagingExceptionAppends message to the folder.- Specified by:
appendMessageInternalin classAbstractImapFolder- Parameters:
message- - message.flags- - message flags.internalDate- - not used. Current date used instead.- Throws:
FileExistsExceptionFileNotFoundExceptionjava.io.IOExceptionjavax.mail.MessagingException
-
copyMessageInternal
protected long copyMessageInternal(long uid, com.icegreen.greenmail.store.MailFolder toFolder) throws javax.mail.MessagingException, FileExistsException, FileNotFoundException, java.io.IOExceptionCopies message with the given UID to the specifiedMailFolder.- Specified by:
copyMessageInternalin classAbstractImapFolder- Parameters:
uid- - UID of the messagetoFolder- - reference to the destination folder.- Throws:
javax.mail.MessagingExceptionjava.io.IOExceptionFileNotFoundExceptionFileExistsException
-
deleteAllMessagesInternal
public void deleteAllMessagesInternal() throws com.icegreen.greenmail.store.FolderExceptionMarks all messages in the folder as deleted usingFlags.Flag.DELETEDflag.- Specified by:
deleteAllMessagesInternalin classAbstractImapFolder- Throws:
com.icegreen.greenmail.store.FolderException
-
expungeInternal
protected void expungeInternal() throws com.icegreen.greenmail.store.FolderExceptionDeletes messages marked withFlags.Flag.DELETED. Note that this message deletes all messages with this flag.- Specified by:
expungeInternalin classAbstractImapFolder- Throws:
com.icegreen.greenmail.store.FolderException
-
expungeInternal
protected void expungeInternal(long uid) throws java.lang.ExceptionDeletes messages marked withFlags.Flag.DELETED. Note that this message deletes the message with current uid- Specified by:
expungeInternalin classAbstractImapFolder- Throws:
java.lang.Exception
-
getFirstUnseen
public int getFirstUnseen()
Returns the MSN number of the first unseen message.- Specified by:
getFirstUnseenin interfacecom.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.MessagingExceptionReturns message by its UID.- Specified by:
getMessageInternalin classAbstractImapFolder- 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:
getMessageCountin interfacecom.icegreen.greenmail.store.MailFolder- Returns:
- Count of the messages.
-
getMessageUids
public long[] getMessageUids()
Returns UIDs of all messages in the folder.- Specified by:
getMessageUidsin interfacecom.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:
getMessagesInternalin classAbstractImapFolder- Returns:
- list of
SimpleStoredMessageobjects.
-
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:
getMessagesInternalin classAbstractImapFolder- Parameters:
msgRangeFilter- -MsgRangeFilterobject representing filter.- Returns:
- list of filtered messages.
-
getMsn
public int getMsn(long uid) throws com.icegreen.greenmail.store.FolderExceptionReturns message sequence number in the folder by its UID.- Specified by:
getMsnin interfacecom.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 noFlags.Flag.DELETEDflag set for current user.- Specified by:
getNonDeletedMessagesInternalin classAbstractImapFolder- Returns:
- the list of non-deleted messages.
-
getPermanentFlags
public javax.mail.Flags getPermanentFlags()
Returns permanent flags.- Specified by:
getPermanentFlagsin interfacecom.icegreen.greenmail.store.MailFolder- Returns:
Flagsobject containing flags.
-
getRecentCount
public int getRecentCount(boolean reset)
Returns count of messages withFlags.Flag.RECENTflag. Ifresetparameter istrue- removesFlags.Flag.RECENTflag from the message for current user.- Specified by:
getRecentCountin interfacecom.icegreen.greenmail.store.MailFolder- Parameters:
reset- - if true theFlags.Flag.RECENTwill 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:
getUidNextin interfacecom.icegreen.greenmail.store.MailFolder- Returns:
- UIDNEXT value.
-
getUidValidity
public long getUidValidity()
Returns UIDVALIDITY value of the folder.- Specified by:
getUidValidityin interfacecom.icegreen.greenmail.store.MailFolder- Returns:
- UIDVALIDITY value.
-
getUnseenCount
public int getUnseenCount()
Returns count of the messages withFlags.Flag.SEENin the folder for the current user.- Specified by:
getUnseenCountin interfacecom.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.MessagingExceptionReplaces flags for the message with the given UID. IfaddUidis set totrueFolderListenerobjects defined for this folder will be notified.silentListenercan be provided - this listener wouldn't be notified.- Specified by:
replaceFlagsInternalin classAbstractImapFolder- 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.FolderExceptionjavax.mail.MessagingException
-
searchInternal
protected long[] searchInternal(javax.mail.search.SearchTerm searchTerm)
- Specified by:
searchInternalin classAbstractImapFolder
-
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.FolderExceptionSets flags for the message with the given UID. IfaddUidis set totrueFolderListenerobjects defined for this folder will be notified.silentListenercan be provided - this listener wouldn't be notified.- Specified by:
setFlagsInternalin classAbstractImapFolder- 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.MessagingExceptioncom.icegreen.greenmail.store.FolderException
-
getFolderPath
public java.lang.String getFolderPath()
-
getFolderInfo
public FileInfo getFolderInfo()
-
isMarked
public boolean isMarked()
- Specified by:
isMarkedin interfacecom.icegreen.greenmail.store.MailFolder
-
isReadOnly
protected boolean isReadOnly()
Whether the folder is read-only for user.- Specified by:
isReadOnlyin classAbstractImapFolder- Returns:
boolean
-
getViewMode
public AlfrescoImapConst.ImapViewMode getViewMode()
-
-