org.apache.james.mailboxmanager.torque
Class TorqueMailbox

java.lang.Object
  extended by org.apache.james.api.imap.AbstractLogEnabled
      extended by org.apache.james.mailboxmanager.torque.TorqueMailbox
All Implemented Interfaces:
Mailbox

public class TorqueMailbox
extends AbstractLogEnabled
implements Mailbox


Field Summary
 
Fields inherited from interface org.apache.james.mailboxmanager.mailbox.Mailbox
ANONYMOUS_SESSION
 
Method Summary
 void addListener(MailboxListener listener)
          Implementations of Mailbox may interpret the fact that someone is listening and do some caching and even postpone persistence until everyone has removed itself.
 MessageResult appendMessage(javax.mail.internet.MimeMessage message, java.util.Date internalDate, MessageResult.FetchGroup fetchGroup, MailboxSession mailboxSession)
           
 void copyTo(MessageRange set, TorqueMailbox toMailbox, MailboxSession session)
           
 void deleted(MailboxSession session)
           
 java.util.Iterator expunge(MessageRange set, MessageResult.FetchGroup fetchGroup, MailboxSession mailboxSession)
           
 MessageResult fillMessageResult(MessageRow messageRow, MessageResult.FetchGroup result)
           
 MessageResult getFirstUnseen(MessageResult.FetchGroup fetchGroup, MailboxSession mailboxSession)
           
protected  MailboxRow getMailboxRow()
           
 int getMessageCount(MailboxSession mailboxSession)
           
 java.util.Iterator getMessages(MessageRange set, MessageResult.FetchGroup fetchGroup, MailboxSession mailboxSession)
          TODO: consolidate search and getMessages into a single method
 java.lang.String getName()
          Example #mail.paul.lists.apache.james-dev (3rd level folder of user paul)
 javax.mail.Flags getPermanentFlags()
           
protected  UidChangeTracker getUidChangeTracker()
           
 long getUidNext(MailboxSession mailboxSession)
           
 long getUidValidity(MailboxSession mailboxSession)
           
 int getUnseenCount(MailboxSession mailboxSession)
           
 boolean isWriteable()
           
 long[] recent(boolean reset, MailboxSession mailboxSession)
           
 void removeListener(MailboxListener mailboxListener)
           
 java.util.Iterator search(SearchQuery query, MessageResult.FetchGroup fetchGroup, MailboxSession mailboxSession)
           
 java.util.Iterator setFlags(javax.mail.Flags flags, boolean value, boolean replace, MessageRange set, MessageResult.FetchGroup fetchGroup, MailboxSession mailboxSession)
          this is much more straight forward for IMAP instead of setting Flags of an array of lazy-loading MimeMessages.
 void setLog(org.apache.commons.logging.Log log)
           
protected  void setMailboxRow(MailboxRow mailboxRow)
           
 
Methods inherited from class org.apache.james.api.imap.AbstractLogEnabled
getLog, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()
Description copied from interface: Mailbox
Example #mail.paul.lists.apache.james-dev (3rd level folder of user paul)

Specified by:
getName in interface Mailbox
Returns:
Full folder name with namespace

getMessageCount

public int getMessageCount(MailboxSession mailboxSession)
                    throws MailboxManagerException
Specified by:
getMessageCount in interface Mailbox
Throws:
MailboxManagerException

appendMessage

public MessageResult appendMessage(javax.mail.internet.MimeMessage message,
                                   java.util.Date internalDate,
                                   MessageResult.FetchGroup fetchGroup,
                                   MailboxSession mailboxSession)
                            throws MailboxManagerException
Specified by:
appendMessage in interface Mailbox
internalDate -

IMAP defines this as the time when the message has arrived to this server (by smtp). Clients are also allowed to set the internalDate on apppend.

Is this Mail.getLastUpdates() for James delivery? Should we use MimeMessage.getReceivedDate()?

fetchGroup - which fields to be returned in MessageResult or null for minimal fetch group only
mailboxSession - TODO
Returns:
MessageResult with the fields defined by result
  • IMAP, Javamail Folder: nothing required
  • UIDPlusFolder: requires to return appended Message or uid
  • UIDPLUS: requires to return appended uid
Throws:
MailboxManagerException - if anything went wrong

getMessages

public java.util.Iterator getMessages(MessageRange set,
                                      MessageResult.FetchGroup fetchGroup,
                                      MailboxSession mailboxSession)
                               throws MailboxManagerException
Description copied from interface: Mailbox
TODO: consolidate search and getMessages into a single method

Specified by:
getMessages in interface Mailbox
mailboxSession - TODO
Returns:
MessageResult with the fields defined by result
  • IMAP: a set of msn, uid, Flags, header lines, content, mime parts...
  • Javamail Folder: Message[]
Throws:
MailboxManagerException

fillMessageResult

public MessageResult fillMessageResult(MessageRow messageRow,
                                       MessageResult.FetchGroup result)
                                throws org.apache.torque.TorqueException,
                                       javax.mail.MessagingException,
                                       MailboxManagerException
Throws:
org.apache.torque.TorqueException
javax.mail.MessagingException
MailboxManagerException

getPermanentFlags

public javax.mail.Flags getPermanentFlags()
Specified by:
getPermanentFlags in interface Mailbox
Returns:
Flags that can be stored

recent

public long[] recent(boolean reset,
                     MailboxSession mailboxSession)
              throws MailboxManagerException
Specified by:
recent in interface Mailbox
Throws:
MailboxManagerException

getFirstUnseen

public MessageResult getFirstUnseen(MessageResult.FetchGroup fetchGroup,
                                    MailboxSession mailboxSession)
                             throws MailboxManagerException
Specified by:
getFirstUnseen in interface Mailbox
Throws:
MailboxManagerException

getUnseenCount

public int getUnseenCount(MailboxSession mailboxSession)
                   throws MailboxManagerException
Specified by:
getUnseenCount in interface Mailbox
Throws:
MailboxManagerException

expunge

public java.util.Iterator expunge(MessageRange set,
                                  MessageResult.FetchGroup fetchGroup,
                                  MailboxSession mailboxSession)
                           throws MailboxManagerException
Specified by:
expunge in interface Mailbox
Parameters:
set -
  • IMAP, Javamail: not required, always expunge all
  • UIDPLUS: requires the possibility of defining a uid range
fetchGroup - which fields to be returned in MessageResult
mailboxSession - TODO
Returns:
MessageResult Iterator with the fields defined by result
  • IMAP, UIDPLUS: nothing required
  • Javamail Folder: requires the expunged Message[]
Throws:
MailboxManagerException - if anything went wrong

setFlags

public java.util.Iterator setFlags(javax.mail.Flags flags,
                                   boolean value,
                                   boolean replace,
                                   MessageRange set,
                                   MessageResult.FetchGroup fetchGroup,
                                   MailboxSession mailboxSession)
                            throws MailboxManagerException
Description copied from interface: Mailbox
this is much more straight forward for IMAP instead of setting Flags of an array of lazy-loading MimeMessages.
required by IMAP

Specified by:
setFlags in interface Mailbox
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
fetchGroup - fetch group for results
mailboxSession - TODO
Returns:
MessageResult Iterator containing messages whose flags have been updated, not null
Throws:
MailboxManagerException

addListener

public void addListener(MailboxListener listener)
                 throws MailboxManagerException
Description copied from interface: Mailbox
Implementations of Mailbox may interpret the fact that someone is listening and do some caching and even postpone persistence until everyone has removed itself.

Specified by:
addListener in interface Mailbox
Throws:
MailboxManagerException

removeListener

public void removeListener(MailboxListener mailboxListener)
Specified by:
removeListener in interface Mailbox

getUidValidity

public long getUidValidity(MailboxSession mailboxSession)
                    throws MailboxManagerException
Specified by:
getUidValidity in interface Mailbox
Throws:
MailboxManagerException

getUidNext

public long getUidNext(MailboxSession mailboxSession)
                throws MailboxManagerException
Specified by:
getUidNext in interface Mailbox
Parameters:
mailboxSession - TODO
Returns:
the uid that will be assigned to the next appended message
Throws:
MailboxManagerException

getUidChangeTracker

protected UidChangeTracker getUidChangeTracker()

getMailboxRow

protected MailboxRow getMailboxRow()

setMailboxRow

protected void setMailboxRow(MailboxRow mailboxRow)

search

public java.util.Iterator search(SearchQuery query,
                                 MessageResult.FetchGroup fetchGroup,
                                 MailboxSession mailboxSession)
                          throws MailboxManagerException
Specified by:
search in interface Mailbox
fetchGroup - which fields to be returned in MessageResult
mailboxSession - TODO
Returns:
MessageResult with the fields defined by result
  • IMAP: msn or (msn and uid)
  • Javamail Folder: Message[]
Throws:
MailboxManagerException - if anything went wrong
UnsupportedCriteriaException - when any of the search parameters are not supported by this mailbox

isWriteable

public boolean isWriteable()
Specified by:
isWriteable in interface Mailbox

setLog

public void setLog(org.apache.commons.logging.Log log)
Overrides:
setLog in class AbstractLogEnabled

copyTo

public void copyTo(MessageRange set,
                   TorqueMailbox toMailbox,
                   MailboxSession session)
            throws MailboxManagerException
Throws:
MailboxManagerException

deleted

public void deleted(MailboxSession session)


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