org.apache.james.mailbox
Interface MessageManager


public interface MessageManager

Interface which represent a Mailbox A MessageManager should be valid for the whole MailboxSession


Nested Class Summary
static interface MessageManager.MetaData
          Meta data about the current state of the mailbox.
 
Method Summary
 long appendMessage(java.io.InputStream msgIn, java.util.Date internalDate, MailboxSession mailboxSession, boolean isRecent, javax.mail.Flags flags)
          Appends a message to this mailbox.
 java.util.Iterator<java.lang.Long> expunge(MessageRange set, MailboxSession mailboxSession)
          Expunges messages in the given range from this mailbox.
 long getMessageCount(MailboxSession mailboxSession)
          Return the count
 java.util.Iterator<MessageResult> getMessages(MessageRange set, MessageResult.FetchGroup fetchGroup, MailboxSession mailboxSession)
          Gets messages in the given range.
 MessageManager.MetaData getMetaData(boolean resetRecent, MailboxSession mailboxSession, MessageManager.MetaData.FetchGroup fetchGroup)
          Gets current meta data for the mailbox.
 boolean isWriteable(MailboxSession session)
          Return if the Mailbox is writable
 java.util.Iterator<java.lang.Long> search(SearchQuery searchQuery, MailboxSession mailboxSession)
          Searches for messages matching the given query.
 java.util.Map<java.lang.Long,javax.mail.Flags> setFlags(javax.mail.Flags flags, boolean value, boolean replace, MessageRange set, MailboxSession mailboxSession)
          Sets flags on messages within the given range.
 

Method Detail

getMessageCount

long getMessageCount(MailboxSession mailboxSession)
                     throws MailboxException
Return the count

Parameters:
mailboxSession -
Returns:
count
Throws:
MailboxException

isWriteable

boolean isWriteable(MailboxSession session)
Return if the Mailbox is writable

Parameters:
session -
Returns:
writable

search

java.util.Iterator<java.lang.Long> search(SearchQuery searchQuery,
                                          MailboxSession mailboxSession)
                                          throws MailboxException
Searches for messages matching the given query. The result must be ordered

Parameters:
mailboxSession - not null
Returns:
uid iterator
Throws:
UnsupportedCriteriaException - when any of the search parameters are not supported by this mailbox
MailboxException - when search fails for other reasons

expunge

java.util.Iterator<java.lang.Long> expunge(MessageRange set,
                                           MailboxSession mailboxSession)
                                           throws MailboxException
Expunges messages in the given range from this mailbox.

Parameters:
set - not null
mailboxSession - not null
Returns:
Throws:
MailboxException - if anything went wrong

setFlags

java.util.Map<java.lang.Long,javax.mail.Flags> setFlags(javax.mail.Flags flags,
                                                        boolean value,
                                                        boolean replace,
                                                        MessageRange set,
                                                        MailboxSession mailboxSession)
                                                        throws MailboxException
Sets flags on messages within the given range. The new flags are returned for each message altered.

Parameters:
flags - Flags to be set
value - true = set, false = unset
replace - replace all Flags with this flags, value has to be true
set - the range of messages
mailboxSession - not null
Returns:
new flags indexed by UID
Throws:
MailboxException

appendMessage

long appendMessage(java.io.InputStream msgIn,
                   java.util.Date internalDate,
                   MailboxSession mailboxSession,
                   boolean isRecent,
                   javax.mail.Flags flags)
                   throws MailboxException
Appends a message to this mailbox.

Parameters:
internalDate - the time of addition to be set, not null
mailboxSession - not null
isRecent - true when the message should be marked recent, false otherwise
flags - optionally set these flags on created message, or null when no additional flags should be set
Returns:
uid for the newly added message
Throws:
MailboxException - when message cannot be appended

getMessages

java.util.Iterator<MessageResult> getMessages(MessageRange set,
                                              MessageResult.FetchGroup fetchGroup,
                                              MailboxSession mailboxSession)
                                              throws MailboxException
Gets messages in the given range.

Parameters:
set -
mailboxSession - not null
Returns:
MessageResult with the fields defined by FetchGroup
Throws:
MailboxException

getMetaData

MessageManager.MetaData getMetaData(boolean resetRecent,
                                    MailboxSession mailboxSession,
                                    MessageManager.MetaData.FetchGroup fetchGroup)
                                    throws MailboxException
Gets current meta data for the mailbox. Consolidates common calls together to allow improved performance. The meta-data returned should be immutable and represent the current state of the mailbox.

Parameters:
resetRecent - true when recent flags should be reset, false otherwise
mailboxSession - context, not null
fetchGroup - describes which optional data should be returned
Returns:
meta data, not null
Throws:
MailboxException


Copyright © 2002-2010 The Apache Software Foundation. All Rights Reserved.