com.funambol.email.items.manager
Class EntityManager

java.lang.Object
  extended by com.funambol.email.items.manager.EntityManager
Direct Known Subclasses:
EntityManagerFilter

public class EntityManager
extends java.lang.Object


Field Summary
protected  CommonMailServerWrapper cmsw
           
 EntityDAO ed
           
protected  com.funambol.framework.logging.FunambolLogger log
           
protected  java.lang.String serverType
           
protected  long timeStart
           
protected  long timeStop
           
 
Constructor Summary
EntityManager()
           
EntityManager(EmailSyncSource ess)
           
 
Method Summary
 void checkMessageIDforDrafts(java.lang.String source_uri, long principalId)
          check if in the Drafts folder there is an item without the message-id
 Folder createFoundationFolder(ItemFolder f)
          create the foundation folder object
 Email createFoundationMail(ItemMessage im)
           
 javax.mail.Message createMessage(javax.mail.Session s, Email ctmp, java.lang.String FID, boolean toBeSend, FlagProperties fp)
          create a javaMail Message from a funambol foundation Email
 javax.mail.Message createMessageWithoutSignature(javax.mail.Message msgIn, javax.mail.Session session, java.lang.String from, java.lang.String firstname, java.lang.String lastname)
          create a javaMail Message from a funambol foundation Email
 javax.mail.Message createMessageWithSignature(javax.mail.Message msgIn, javax.mail.Session session, java.lang.String sign, java.lang.String from, java.lang.String firstname, java.lang.String lastname)
          create a javaMail Message from a funambol foundation Email
 java.lang.String[] getAllEmails(EmailFilter filter, java.util.HashMap si)
          Return all email ids.
 java.lang.String getEmailFromClause(javax.mail.Session session, java.util.HashMap serverItems, java.lang.String parentId, Email ctmp)
          Checks if an email is already inserted in the db and returns the GUID.
protected  boolean hasMatchedDate(java.util.Date msgdate, EmailFilter filter)
           
protected  boolean hasMatchedSize(javax.mail.Message msg, EmailFilter filter)
           
 void insertCustomFolder(IMailServerWrapper msw, boolean allMailboxActivation, com.funambol.server.tools.id.DBIDGenerator idFolderSpace, java.lang.String source_uri, long principalId)
          Check if the local DB folders are consistent with the MailBox folders
 void insertDefaultFolder(DefaultFolder df, EmailFilter filter, java.lang.String protocol, java.lang.String source_uri, long pID)
          insert the default folder if needed
 void insertInvalidItem(java.lang.String GUID, java.lang.String messageId, java.util.Date headerDate, java.util.Date received, java.lang.String subject, java.lang.String sender, java.lang.String isEmail, java.lang.String source_uri, long pID)
          insert invalid item
 boolean isEmail(java.lang.String parentId, java.lang.String objectId, java.lang.String source_uri, long principalId)
          Check if the item is a folder or an email using the SyncItemKey
 boolean isEmailInFilter(Email email, EmailFilter filter, java.lang.String GUID, java.lang.String FID, java.lang.String FMID, javax.mail.Session session, java.util.Locale loc, java.lang.String source_uri, long principalId)
          checks if a mail match the filter
 void sendEmail(javax.mail.Message msg, javax.mail.Session session, java.lang.String funSignature, java.lang.String from, java.lang.String firstname, java.lang.String lastname)
          this method creates the message with the Funambol 'signature' and it sends the email
 ItemFolder setItemFolder(java.lang.String GUID, java.lang.String name, java.lang.String FID, java.lang.String folderRole, java.lang.String creationDate)
          convert Message into ServerMessages
 ItemMessage setItemMessage(java.lang.String GUID, java.lang.String parentId, javax.mail.Message msg, FlagProperties fp, java.util.Locale loc, java.lang.String encodingType, Ext ext)
          convert Message into ServerMessages
 
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

cmsw

protected CommonMailServerWrapper cmsw

ed

public EntityDAO ed

serverType

protected java.lang.String serverType

timeStart

protected long timeStart

timeStop

protected long timeStop
Constructor Detail

EntityManager

public EntityManager()

EntityManager

public EntityManager(EmailSyncSource ess)
              throws EmailAccessException
Parameters:
ess - EmailSyncSource
Throws:
EmailAccessException
Method Detail

getAllEmails

public java.lang.String[] getAllEmails(EmailFilter filter,
                                       java.util.HashMap si)
                                throws EntityException
Return all email ids. it uses the CrcSyncItemInfo[], this array is set by the caching system method in the beginSync method. the si param includes inbox/sent folders info for the POP3 SyncSource and inbox/outbox/sent/drafts/trash folders info for the IMAP SyncSource.

Parameters:
filter - EmailFilter
si - mail server info
Returns:
The all items fulfilling the filter requirements as an array of Strings.
Throws:
EntityException

createMessageWithSignature

public javax.mail.Message createMessageWithSignature(javax.mail.Message msgIn,
                                                     javax.mail.Session session,
                                                     java.lang.String sign,
                                                     java.lang.String from,
                                                     java.lang.String firstname,
                                                     java.lang.String lastname)
                                              throws EntityException
create a javaMail Message from a funambol foundation Email

Parameters:
msgIn - Message
session - Session
sign - String
Returns:
Message
Throws:
EntityException

createMessageWithoutSignature

public javax.mail.Message createMessageWithoutSignature(javax.mail.Message msgIn,
                                                        javax.mail.Session session,
                                                        java.lang.String from,
                                                        java.lang.String firstname,
                                                        java.lang.String lastname)
                                                 throws java.lang.Exception
create a javaMail Message from a funambol foundation Email

Parameters:
msgIn - Message
session - Session
sign - String
Returns:
Message
Throws:
EntityException
java.lang.Exception

createMessage

public javax.mail.Message createMessage(javax.mail.Session s,
                                        Email ctmp,
                                        java.lang.String FID,
                                        boolean toBeSend,
                                        FlagProperties fp)
                                 throws EntityException
create a javaMail Message from a funambol foundation Email

Parameters:
s - Session
ctmp - Email
FID - String
toBeSend - boolean
fp, - all flags info FlagProperties
Returns:
Message
Throws:
EntityException

createFoundationMail

public Email createFoundationMail(ItemMessage im)
                           throws EntityException
Parameters:
im - ItemMessage
Returns:
Email
Throws:
EntityException

createFoundationFolder

public Folder createFoundationFolder(ItemFolder f)
                              throws EntityException
create the foundation folder object

Parameters:
f - ItemFolder
Returns:
Folder
Throws:
EntityException

insertDefaultFolder

public void insertDefaultFolder(DefaultFolder df,
                                EmailFilter filter,
                                java.lang.String protocol,
                                java.lang.String source_uri,
                                long pID)
                         throws EntityException
insert the default folder if needed

Parameters:
df - DefaultFolder
source_uri - String
pID - principal ID long
Throws:
EntityException

isEmailInFilter

public boolean isEmailInFilter(Email email,
                               EmailFilter filter,
                               java.lang.String GUID,
                               java.lang.String FID,
                               java.lang.String FMID,
                               javax.mail.Session session,
                               java.util.Locale loc,
                               java.lang.String source_uri,
                               long principalId)
                        throws EntityException
checks if a mail match the filter

Parameters:
email - Email
filter - EmailFilter
GUID - String
FID - String
FMID - String
session - Session
loc - Locale
source_uri - String
principalId - long
Returns:
true if the message match the filter
Throws:
EntityException

insertInvalidItem

public void insertInvalidItem(java.lang.String GUID,
                              java.lang.String messageId,
                              java.util.Date headerDate,
                              java.util.Date received,
                              java.lang.String subject,
                              java.lang.String sender,
                              java.lang.String isEmail,
                              java.lang.String source_uri,
                              long pID)
                       throws EntityException
insert invalid item

Parameters:
GUID - String
source_uri - String
pID - principal ID long
Throws:
EntityException

getEmailFromClause

public java.lang.String getEmailFromClause(javax.mail.Session session,
                                           java.util.HashMap serverItems,
                                           java.lang.String parentId,
                                           Email ctmp)
                                    throws EntityException
Checks if an email is already inserted in the db and returns the GUID.

Parameters:
session - mail server session
serverItems - all server items info CrcSyncItemInfo[] (I need the Message-ID)
parentId - parent if of the email
ctmp - the Email to check
Returns:
the GUID
Throws:
EntityException

checkMessageIDforDrafts

public void checkMessageIDforDrafts(java.lang.String source_uri,
                                    long principalId)
                             throws EntityException
check if in the Drafts folder there is an item without the message-id

Parameters:
source_uri - String
principalId - long
Throws:
EntityException

insertCustomFolder

public void insertCustomFolder(IMailServerWrapper msw,
                               boolean allMailboxActivation,
                               com.funambol.server.tools.id.DBIDGenerator idFolderSpace,
                               java.lang.String source_uri,
                               long principalId)
                        throws EntityException
Check if the local DB folders are consistent with the MailBox folders

Parameters:
source_uri - String
principalId - long
Throws:
EntityException

isEmail

public boolean isEmail(java.lang.String parentId,
                       java.lang.String objectId,
                       java.lang.String source_uri,
                       long principalId)
                throws EntityException
Check if the item is a folder or an email using the SyncItemKey

Parameters:
parentId - String
objectId - String
source_uri - String
principalId - long
Returns:
boolean
Throws:
EntityException

setItemFolder

public ItemFolder setItemFolder(java.lang.String GUID,
                                java.lang.String name,
                                java.lang.String FID,
                                java.lang.String folderRole,
                                java.lang.String creationDate)
                         throws EntityException
convert Message into ServerMessages

Parameters:
GUID - unique folder id
name - folder name
FID - parent id
Returns:
ItemFolder
Throws:
EntityException

setItemMessage

public ItemMessage setItemMessage(java.lang.String GUID,
                                  java.lang.String parentId,
                                  javax.mail.Message msg,
                                  FlagProperties fp,
                                  java.util.Locale loc,
                                  java.lang.String encodingType,
                                  Ext ext)
                           throws EntityException
convert Message into ServerMessages

Parameters:
GUID - unique mail id
parentId - String
msg - Message
fp, - flags of the email FlagProperties
loc - Locale
encodingType - String
ext, - extension fields Ext
Returns:
ItemMessage
Throws:
EntityException

sendEmail

public void sendEmail(javax.mail.Message msg,
                      javax.mail.Session session,
                      java.lang.String funSignature,
                      java.lang.String from,
                      java.lang.String firstname,
                      java.lang.String lastname)
               throws SendingException,
                      EntityException
this method creates the message with the Funambol 'signature' and it sends the email

Parameters:
msg - javaMail message to send; Message
session - Mail Server opened Session
funSignature - String
Throws:
SendingException
EntityException

hasMatchedDate

protected boolean hasMatchedDate(java.util.Date msgdate,
                                 EmailFilter filter)
Parameters:
msgdate - Message
filter - EmailFilter
Returns:
true if message date match the filter date

hasMatchedSize

protected boolean hasMatchedSize(javax.mail.Message msg,
                                 EmailFilter filter)
Parameters:
msg - Message
filter - EmailFilter
Returns:
true if message date match the filter date


Copyright © 2005-2006 Funambol.