com.hs.mail.imap.mailbox
Class DefaultMailboxManager

java.lang.Object
  extended by com.hs.mail.imap.mailbox.DefaultMailboxManager
All Implemented Interfaces:
MailboxManager, org.springframework.beans.factory.DisposableBean

public class DefaultMailboxManager
extends Object
implements MailboxManager, org.springframework.beans.factory.DisposableBean

Since:
Feb 2, 2010
Author:
WonChul Doh

Constructor Summary
DefaultMailboxManager()
           
 
Method Summary
 void addEventListener(EventListener listener)
           
 void addMessage(long ownerID, MailMessage message, String mailboxName)
          Appends a message to the user's INBOX.
 void addSubscription(long userID, long mailboxID, String mailboxName)
          Subscribe the user to the given mailbox.
 void appendMessage(long mailboxID, Date internalDate, javax.mail.Flags flags, File file)
          Appends a message to this mailbox.
 void copyMessage(long uid, long mailboxID)
          Copies a message to the given mailbox.
 Mailbox createMailbox(long ownerID, String mailboxName)
          Creates a new mailbox.
 void deleteMailbox(long ownerID, long mailboxID, boolean delete)
          Delete or empty a mailbox from store.
 void deleteMessage(long uid)
          Deletes the given message.
 void deleteSubscription(long userID, String mailboxName)
          Unsubscribes the user from the given mailbox.
 void destroy()
           
 List<Long> expunge(long mailboxID)
          Gets the UIDs of messages which has /Deleted flag.
 List<Mailbox> getChildren(long userID, long ownerID, String mailboxName, boolean subscribed)
           
 EventDispatcher getEventDispatcher()
           
 javax.mail.Flags getFlags(long uid)
           
 Map<String,String> getHeader(long physMessageID)
          Gets the headers of the message.
 Map<String,String> getHeader(long physMessageID, String[] fields)
          Gets the headers of the message.
 Mailbox getMailbox(long ownerID, String mailboxName)
          Returns user's Mailbox with a given path
 List<Long> getMailboxIDList(String mailboxName)
           
 FetchData getMessageFetchData(long uid)
           
 List<Long> getMessageIDList(long mailboxID)
           
 org.springframework.transaction.support.TransactionTemplate getTransactionTemplate()
           
 boolean hasChildren(Mailbox mailbox)
          Does the mailbox have inferior child mailboxes?
 boolean isSubscribed(long userID, String mailboxName)
          Check if given mailbox is subscribed to user
 boolean mailboxExists(long ownerID, String mailboxName)
          Check if given mailbox exists.
 void removeEventListener(EventListener listener)
           
 void renameMailbox(Mailbox source, String targetName)
          Renames a mailbox.
 void resetRecent(long mailboxID)
           
 List<Long> search(UidToMsnMapper map, long mailboxID, SearchKey key)
          Searches for the messages matching the given query.
 void setFetchDataCache(net.sf.ehcache.Ehcache cache)
           
 void setFlags(long uid, javax.mail.Flags flags, boolean replace, boolean set)
          Sets flags on this message.
 void setHeaderCache(net.sf.ehcache.Ehcache cache)
           
 void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMailboxManager

public DefaultMailboxManager()
Method Detail

setTransactionManager

public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)

getTransactionTemplate

public org.springframework.transaction.support.TransactionTemplate getTransactionTemplate()

setFetchDataCache

public void setFetchDataCache(net.sf.ehcache.Ehcache cache)

setHeaderCache

public void setHeaderCache(net.sf.ehcache.Ehcache cache)

getEventDispatcher

public EventDispatcher getEventDispatcher()
Specified by:
getEventDispatcher in interface MailboxManager

addEventListener

public void addEventListener(EventListener listener)
Specified by:
addEventListener in interface MailboxManager

removeEventListener

public void removeEventListener(EventListener listener)
Specified by:
removeEventListener in interface MailboxManager

getMailbox

public Mailbox getMailbox(long ownerID,
                          String mailboxName)
Description copied from interface: MailboxManager
Returns user's Mailbox with a given path

Specified by:
getMailbox in interface MailboxManager
Parameters:
ownerID - owner of the mailbox
mailboxName - path to the mailbox
Returns:
the mailbox as Mailbox

mailboxExists

public boolean mailboxExists(long ownerID,
                             String mailboxName)
Description copied from interface: MailboxManager
Check if given mailbox exists.

Specified by:
mailboxExists in interface MailboxManager
Parameters:
ownerID - owner of this mailbox
mailboxName - the name of mailbox for checking existence
Returns:
true when the mailbox exists, false otherwise

getChildren

public List<Mailbox> getChildren(long userID,
                                 long ownerID,
                                 String mailboxName,
                                 boolean subscribed)
Specified by:
getChildren in interface MailboxManager

getMailboxIDList

public List<Long> getMailboxIDList(String mailboxName)
Specified by:
getMailboxIDList in interface MailboxManager

hasChildren

public boolean hasChildren(Mailbox mailbox)
Description copied from interface: MailboxManager
Does the mailbox have inferior child mailboxes?

Specified by:
hasChildren in interface MailboxManager
Parameters:
mailbox - ID of the mailbox
Returns:
true when the mailbox has children, false otherwise

expunge

public List<Long> expunge(long mailboxID)
Description copied from interface: MailboxManager
Gets the UIDs of messages which has /Deleted flag.

Specified by:
expunge in interface MailboxManager
Parameters:
mailboxID - ID of mailbox
Returns:
list of UIDs of messages which has /Deleted flag

search

public List<Long> search(UidToMsnMapper map,
                         long mailboxID,
                         SearchKey key)
Description copied from interface: MailboxManager
Searches for the messages matching the given query.

Specified by:
search in interface MailboxManager
Parameters:
map - UID to MSN converting map
mailboxID - ID of mailbox to search
key - the search query
Returns:
list of UIDs of messages searched

createMailbox

public Mailbox createMailbox(long ownerID,
                             String mailboxName)
Description copied from interface: MailboxManager
Creates a new mailbox. Any intermediary mailboxes missing from the hierarchy will be created.

Specified by:
createMailbox in interface MailboxManager
Parameters:
ownerID - owner of the mailbox
mailboxName - the name of mailbox to create
Returns:
Mailbox created

renameMailbox

public void renameMailbox(Mailbox source,
                          String targetName)
Description copied from interface: MailboxManager
Renames a mailbox.

Specified by:
renameMailbox in interface MailboxManager
Parameters:
source - original mailbox
targetName - new name for the mailbox

deleteMailbox

public void deleteMailbox(long ownerID,
                          long mailboxID,
                          boolean delete)
Description copied from interface: MailboxManager
Delete or empty a mailbox from store.

Specified by:
deleteMailbox in interface MailboxManager
Parameters:
ownerID - ID of the user who owns the mailbox
mailboxID - ID of the mailbox
delete - true when delete, false when empty

isSubscribed

public boolean isSubscribed(long userID,
                            String mailboxName)
Description copied from interface: MailboxManager
Check if given mailbox is subscribed to user

Specified by:
isSubscribed in interface MailboxManager
Parameters:
userID - ID of user
Returns:
true if mailbox is subscribed, otherwise false

addSubscription

public void addSubscription(long userID,
                            long mailboxID,
                            String mailboxName)
Description copied from interface: MailboxManager
Subscribe the user to the given mailbox.

Specified by:
addSubscription in interface MailboxManager
Parameters:
userID - ID of the user
mailboxID - ID of the mailbox to subscribe

deleteSubscription

public void deleteSubscription(long userID,
                               String mailboxName)
Description copied from interface: MailboxManager
Unsubscribes the user from the given mailbox.

Specified by:
deleteSubscription in interface MailboxManager

getMessageFetchData

public FetchData getMessageFetchData(long uid)
Specified by:
getMessageFetchData in interface MailboxManager

getFlags

public javax.mail.Flags getFlags(long uid)
Specified by:
getFlags in interface MailboxManager

getMessageIDList

public List<Long> getMessageIDList(long mailboxID)
Specified by:
getMessageIDList in interface MailboxManager

addMessage

public void addMessage(long ownerID,
                       MailMessage message,
                       String mailboxName)
Description copied from interface: MailboxManager
Appends a message to the user's INBOX. This method is called by MDA.

Specified by:
addMessage in interface MailboxManager

appendMessage

public void appendMessage(long mailboxID,
                          Date internalDate,
                          javax.mail.Flags flags,
                          File file)
                   throws IOException
Description copied from interface: MailboxManager
Appends a message to this mailbox.

Specified by:
appendMessage in interface MailboxManager
Parameters:
mailboxID - ID of mailbox to append a message
internalDate - the time of addition to be set
flags - optionally set these flags on created message, or null when no additional flags should be set
file - the file containing the mail contents
Throws:
IOException

deleteMessage

public void deleteMessage(long uid)
Description copied from interface: MailboxManager
Deletes the given message.

Specified by:
deleteMessage in interface MailboxManager
Parameters:
uid - ID of the message to delete

copyMessage

public void copyMessage(long uid,
                        long mailboxID)
Description copied from interface: MailboxManager
Copies a message to the given mailbox.

Specified by:
copyMessage in interface MailboxManager
Parameters:
uid - ID of the message to copy
mailboxID - ID of mailbox where message will be copied

resetRecent

public void resetRecent(long mailboxID)
Specified by:
resetRecent in interface MailboxManager

setFlags

public void setFlags(long uid,
                     javax.mail.Flags flags,
                     boolean replace,
                     boolean set)
Description copied from interface: MailboxManager
Sets flags on this message.

Specified by:
setFlags in interface MailboxManager
Parameters:
uid - ID of the message to set flags
flags - flags to be set
replace - true if to replace
set - true if to set, false to reset

getHeader

public Map<String,String> getHeader(long physMessageID)
Gets the headers of the message.

Specified by:
getHeader in interface MailboxManager
Parameters:
physMessageID - ID of the physical message
Returns:
map containing header name and value entries

getHeader

public Map<String,String> getHeader(long physMessageID,
                                    String[] fields)
Description copied from interface: MailboxManager
Gets the headers of the message.

Specified by:
getHeader in interface MailboxManager
Parameters:
physMessageID - ID of the physical message
fields - Array of fields to retrieve
Returns:
map containing header name and value entries

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
Exception


Copyright © 2011. All Rights Reserved.