com.funambol.email.items.dao
Class ImapEntityDAO

java.lang.Object
  extended by com.funambol.email.items.dao.EntityDAO
      extended by com.funambol.email.items.dao.ImapEntityDAO

public class ImapEntityDAO
extends EntityDAO

This class implements methods to access data in Mail Server datastore.


Field Summary
protected  com.funambol.framework.logging.FunambolLogger log
           
static ImapSemaphore uid_has_been_set
           
 
Fields inherited from class com.funambol.email.items.dao.EntityDAO
jndiDataSourceName, serverType
 
Constructor Summary
ImapEntityDAO()
           
ImapEntityDAO(java.lang.String jndiDataSourceName, java.lang.String serverType)
           
 
Method Summary
 long addEmailByListener(com.sun.mail.imap.IMAPFolder f, javax.mail.Message msg)
          This method insert an given message to an given folder and returns its message UID using com.funambol.email.transport.ImapMessageCountListener
 long addEmailByNextUID(com.sun.mail.imap.IMAPFolder f, javax.mail.Message msg)
          This method insert an given message to an given folder and returns its message UID using com.sun.mail.imap.IMAPFolder.getUIDNext()
 java.lang.String addFolder(java.lang.String fullPath, java.lang.String parentId, javax.mail.Folder folderToInsert, int type, com.funambol.server.tools.id.DBIDGenerator idFolderSpace, java.lang.String source_uri, long principalId)
          This method inserts the folder in the MailServer and the path in the Local DB.
 java.lang.String[] getAllDefaultFolders(java.lang.String idFilter, java.util.Date timeFilter)
          gets all default Folder
 ItemFolder[] getAllDefaultFoldersInfo(java.lang.String idFilter, java.util.Date timeFilter)
          gets all default folder infos
 javax.mail.Message[] getAllEmails(com.sun.mail.imap.IMAPFolder f, java.lang.String FID, EmailFilter filter)
          gets all Messages for the caching system
 java.lang.String[] getAllFolders(EmailFilter filter, com.sun.mail.imap.IMAPFolder folder, java.lang.String defFullpath, java.lang.String source_uri, long principalId)
          gets all Folder
 java.util.HashMap getAllFoldersInfo(EmailFilter filter, com.sun.mail.imap.IMAPFolder folder, ItemFolder defFolder, java.lang.String source_uri, long principalId)
          gets all folder infos
 java.lang.String getEmailFromMessageID(com.sun.mail.imap.IMAPFolder f, java.lang.String FID, java.lang.String message_id)
          serch a document using the header Message-ID
 javax.mail.Message getEmailFromUID(com.sun.mail.imap.IMAPFolder f, java.lang.String FID, long uid)
          serch a document using UID; for IMAP4 protocol UID is long
 java.lang.String getServerType()
           
 void removeAllEmail(com.sun.mail.imap.IMAPFolder f)
           
 void removeEmail(com.sun.mail.imap.IMAPFolder f, long uid)
           
 void removeFolderInServer(com.sun.mail.imap.IMAPFolder f)
           
 void searchSubFolderFullNames(com.sun.mail.imap.IMAPFolder folder, java.util.ArrayList fs)
           
 void setServerType(java.lang.String serverType)
           
 UpdatedMessage updateEmail(java.lang.String FID, java.lang.String FMID, com.sun.mail.imap.IMAPFolder f, javax.mail.Message msgNew, FlagProperties fp)
          This method handles the update procedure of an email.
 
Methods inherited from class com.funambol.email.items.dao.EntityDAO
checkMessageIDforDrafts, getAllEmailsInbox, getDefaultFolder, getFolderFromUID, getFullPathFromFID, getFullPathFromGUID, getGUIDFromFullPath, insertCustomFolder, insertDefaultFolderInDB, insertDefaultFolderInMailServer, insertFolder, insertInvalidItemInCache, removeEmailFromInbox, removeEmailFromServerItems, removeFolder, setDeletedEmailInInbox, updateEmailInDB
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected com.funambol.framework.logging.FunambolLogger log

uid_has_been_set

public static ImapSemaphore uid_has_been_set
Constructor Detail

ImapEntityDAO

public ImapEntityDAO()

ImapEntityDAO

public ImapEntityDAO(java.lang.String jndiDataSourceName,
                     java.lang.String serverType)
Parameters:
jndiDataSourceName - String
Method Detail

getAllEmails

public javax.mail.Message[] getAllEmails(com.sun.mail.imap.IMAPFolder f,
                                         java.lang.String FID,
                                         EmailFilter filter)
                                  throws EntityException
gets all Messages for the caching system

Parameters:
f - IMAPFolder
filter - EmailFilter
Returns:
Message[]
Throws:
EntityException

getAllDefaultFoldersInfo

public ItemFolder[] getAllDefaultFoldersInfo(java.lang.String idFilter,
                                             java.util.Date timeFilter)
                                      throws EntityException
gets all default folder infos

Parameters:
idFilter - String
timeFilter - Date
Returns:
ItemFolder[]
Throws:
EntityException

getAllFoldersInfo

public java.util.HashMap getAllFoldersInfo(EmailFilter filter,
                                           com.sun.mail.imap.IMAPFolder folder,
                                           ItemFolder defFolder,
                                           java.lang.String source_uri,
                                           long principalId)
                                    throws EntityException
gets all folder infos

Parameters:
filter - EmailFilter
folder - IMAPFolder
defFolder - ItemFolder
source_uri - String
principalId - long
Returns:
map with all the info about the folder in the mail server
Throws:
EntityException

getAllDefaultFolders

public java.lang.String[] getAllDefaultFolders(java.lang.String idFilter,
                                               java.util.Date timeFilter)
                                        throws EntityException
gets all default Folder

Parameters:
idFilter - String
timeFilter - Date
Returns:
String[]
Throws:
EntityException

getAllFolders

public java.lang.String[] getAllFolders(EmailFilter filter,
                                        com.sun.mail.imap.IMAPFolder folder,
                                        java.lang.String defFullpath,
                                        java.lang.String source_uri,
                                        long principalId)
                                 throws EntityException
gets all Folder

Parameters:
filter - EmailFilter
folder - IMAPFolder
defFullpath - String
source_uri - String
principalId - long
Returns:
String[]
Throws:
EntityException

getEmailFromMessageID

public java.lang.String getEmailFromMessageID(com.sun.mail.imap.IMAPFolder f,
                                              java.lang.String FID,
                                              java.lang.String message_id)
                                       throws EntityException
serch a document using the header Message-ID

Parameters:
f - IMAPFolder
FID - String
message_id - String
Returns:
EISMessage
Throws:
EntityException

removeEmail

public void removeEmail(com.sun.mail.imap.IMAPFolder f,
                        long uid)
                 throws EntityException
Parameters:
f - IMAPFolder
uid - long
Throws:
EntityException

removeAllEmail

public void removeAllEmail(com.sun.mail.imap.IMAPFolder f)
                    throws EntityException
Parameters:
f - IMAPFolder
Throws:
EntityException

removeFolderInServer

public void removeFolderInServer(com.sun.mail.imap.IMAPFolder f)
                          throws EntityException
Parameters:
f - IMAPFolder
Throws:
EntityException

updateEmail

public UpdatedMessage updateEmail(java.lang.String FID,
                                  java.lang.String FMID,
                                  com.sun.mail.imap.IMAPFolder f,
                                  javax.mail.Message msgNew,
                                  FlagProperties fp)
                           throws EntityException
This method handles the update procedure of an email. Maybe the email can change only for DRAFTS. In the rest of the folders we can change only the properties i.e. read, forworded.

Parameters:
FID - String
FMID - String
f - IMAPFolder
msgNew - Message
fp - FlagProperties
Returns:
UpdatedMessage
Throws:
EntityException

addEmailByListener

public long addEmailByListener(com.sun.mail.imap.IMAPFolder f,
                               javax.mail.Message msg)
                        throws EntityException
This method insert an given message to an given folder and returns its message UID using com.funambol.email.transport.ImapMessageCountListener

Parameters:
f - IMAPFolder
msg - Message
Returns:
EISMessage
Throws:
EntityException

addEmailByNextUID

public long addEmailByNextUID(com.sun.mail.imap.IMAPFolder f,
                              javax.mail.Message msg)
                       throws EntityException
This method insert an given message to an given folder and returns its message UID using com.sun.mail.imap.IMAPFolder.getUIDNext()

Parameters:
f - IMAPFolder
msg - Message
Returns:
EISMessage
Throws:
EntityException

addFolder

public java.lang.String addFolder(java.lang.String fullPath,
                                  java.lang.String parentId,
                                  javax.mail.Folder folderToInsert,
                                  int type,
                                  com.funambol.server.tools.id.DBIDGenerator idFolderSpace,
                                  java.lang.String source_uri,
                                  long principalId)
                           throws EntityException
This method inserts the folder in the MailServer and the path in the Local DB. Return the ID using the IdSpaceGenerator.

Parameters:
fullPath - String
parentId - String
folderToInsert - Folder
type - int
idFolderSpace - IdSpaceGenerator
source_uri - String
principalId - long
Returns:
String
Throws:
EntityException

getEmailFromUID

public javax.mail.Message getEmailFromUID(com.sun.mail.imap.IMAPFolder f,
                                          java.lang.String FID,
                                          long uid)
                                   throws EntityException
serch a document using UID; for IMAP4 protocol UID is long

Parameters:
f - IMAP Folder
uid - email imap id
Returns:
Message
Throws:
EntityException

searchSubFolderFullNames

public void searchSubFolderFullNames(com.sun.mail.imap.IMAPFolder folder,
                                     java.util.ArrayList fs)
                              throws javax.mail.MessagingException
Parameters:
folder - starting folder
fs - all folders container
Throws:
javax.mail.MessagingException

getServerType

public java.lang.String getServerType()

setServerType

public void setServerType(java.lang.String serverType)


Copyright © 2005-2006 Funambol.