com.funambol.email.engine.source
Class EmailGeneric

java.lang.Object
  extended by com.funambol.email.engine.source.EmailGeneric
All Implemented Interfaces:
IEmailGeneric
Direct Known Subclasses:
EmailImap, EmailPop

public abstract class EmailGeneric
extends java.lang.Object
implements IEmailGeneric

This class implements common methods of EmailPOPSyncSource version $Id: EmailGeneric.java,v 1.9 2007/01/26 17:39:55 gbmiglia Exp $


Field Summary
protected  EntityManager em
           
protected  EmailSyncSource ess
           
protected  com.funambol.framework.logging.FunambolLogger log
           
 
Constructor Summary
EmailGeneric()
           
EmailGeneric(EmailSyncSourceWrapper _essc)
           
 
Method Summary
abstract  com.funambol.framework.engine.SyncItem addSyncItem(com.funambol.framework.engine.SyncItem syncItem)
           
 void checkMessageIDforDrafts(java.lang.String sURI, long pID)
          check if in the Drafts folder therse is an item without message-id
abstract  void clearServerInfo()
           
protected  com.funambol.framework.engine.SyncItem createSyncItem(EmailSyncSource ess, Email email, char status, java.util.TimeZone deviceTimeZone, java.lang.String deviceCharset)
           
protected  com.funambol.framework.engine.SyncItem createSyncItem(EmailSyncSource ess, Folder folder, char status, java.util.TimeZone deviceTimeZone, java.lang.String deviceCharset)
           
abstract  java.util.HashMap getAllSyncItemInfo()
           
abstract  com.funambol.framework.engine.SyncItemKey[] getAllSyncItemKeys()
           
 com.funambol.framework.engine.SyncItemKey[] getDeletedSyncItemKeys(java.sql.Timestamp since, java.sql.Timestamp to)
           
 com.funambol.framework.engine.SyncItemKey[] getNewSyncItemKeys(java.sql.Timestamp since, java.sql.Timestamp to)
           
abstract  com.funambol.framework.engine.SyncItem getSyncItemFromId(com.funambol.framework.engine.SyncItemKey syncItemKey)
           
abstract  com.funambol.framework.engine.SyncItemKey[] getSyncItemKeysFromTwin(com.funambol.framework.engine.SyncItem syncItem)
           
 char getSyncItemStateFromId(com.funambol.framework.engine.SyncItemKey syncItemKey)
           
 com.funambol.framework.engine.SyncItemKey[] getUpdatedSyncItemKeys(java.sql.Timestamp since, java.sql.Timestamp to)
           
 void insertDefaultFolder(DefaultFolder df, EmailFilter filter, java.lang.String protocol, java.lang.String sURI, long pID)
          insert the default folder if needed
protected  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)
          insert the invalid item in the cache.
protected  boolean isEmailFromContent(java.lang.String content)
          Returns true if the syncitem is a Mail, false if the sycItem is a Folder
protected  boolean isEmailFromKey(java.lang.String parentId, java.lang.String objectId, java.lang.String sourceURI, long principalId)
          Returns true if the syncitem is a Mail false if the sycItem is a Folder

the key is composed by: parentId/objId (mailid or folderid) The key is created by the connector and it always creates the syncItemKey using parentId and mailId

abstract  boolean isSyncItemInFilterClause(com.funambol.framework.engine.SyncItem syncItem)
           
abstract  boolean isSyncItemInFilterClause(com.funambol.framework.engine.SyncItemKey syncItemKey)
           
protected  boolean isValidItem(java.lang.String key)
           
abstract  void removeSyncItem(com.funambol.framework.engine.SyncItemKey syncItemKey, java.sql.Timestamp s, boolean engineSoftDelete)
           
 void setOperationStatus(java.lang.String operation, int statusCode, com.funambol.framework.engine.SyncItemKey[] keys)
           
abstract  com.funambol.framework.engine.SyncItem updateSyncItem(com.funambol.framework.engine.SyncItem syncItem)
           
 
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

em

protected EntityManager em

ess

protected EmailSyncSource ess
Constructor Detail

EmailGeneric

public EmailGeneric()

EmailGeneric

public EmailGeneric(EmailSyncSourceWrapper _essc)
             throws com.funambol.framework.engine.source.SyncSourceException
Throws:
com.funambol.framework.engine.source.SyncSourceException
Method Detail

isSyncItemInFilterClause

public abstract boolean isSyncItemInFilterClause(com.funambol.framework.engine.SyncItem syncItem)
                                          throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
isSyncItemInFilterClause in interface IEmailGeneric
Returns:
boolean
Throws:
com.funambol.framework.engine.source.SyncSourceException

isSyncItemInFilterClause

public abstract boolean isSyncItemInFilterClause(com.funambol.framework.engine.SyncItemKey syncItemKey)
                                          throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
isSyncItemInFilterClause in interface IEmailGeneric
Returns:
boolean
Throws:
com.funambol.framework.engine.source.SyncSourceException

setOperationStatus

public void setOperationStatus(java.lang.String operation,
                               int statusCode,
                               com.funambol.framework.engine.SyncItemKey[] keys)
Specified by:
setOperationStatus in interface IEmailGeneric
Parameters:
operation - String
statusCode - int
keys - SyncItemKey[]

removeSyncItem

public abstract void removeSyncItem(com.funambol.framework.engine.SyncItemKey syncItemKey,
                                    java.sql.Timestamp s,
                                    boolean engineSoftDelete)
                             throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
removeSyncItem in interface IEmailGeneric
Throws:
com.funambol.framework.engine.source.SyncSourceException

getSyncItemFromId

public abstract com.funambol.framework.engine.SyncItem getSyncItemFromId(com.funambol.framework.engine.SyncItemKey syncItemKey)
                                                                  throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
getSyncItemFromId in interface IEmailGeneric
Parameters:
syncItemKey - SyncItemKey
Returns:
SyncItem
Throws:
com.funambol.framework.engine.source.SyncSourceException
See Also:
SyncSource

getAllSyncItemKeys

public abstract com.funambol.framework.engine.SyncItemKey[] getAllSyncItemKeys()
                                                                        throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
getAllSyncItemKeys in interface IEmailGeneric
Returns:
SyncItemKey[]
Throws:
com.funambol.framework.engine.source.SyncSourceException

getAllSyncItemInfo

public abstract java.util.HashMap getAllSyncItemInfo()
                                              throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
getAllSyncItemInfo in interface IEmailGeneric
Returns:
HashMap
Throws:
com.funambol.framework.engine.source.SyncSourceException

clearServerInfo

public abstract void clearServerInfo()
                              throws com.funambol.framework.engine.source.SyncSourceException
Throws:
com.funambol.framework.engine.source.SyncSourceException

getSyncItemKeysFromTwin

public abstract com.funambol.framework.engine.SyncItemKey[] getSyncItemKeysFromTwin(com.funambol.framework.engine.SyncItem syncItem)
                                                                             throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
getSyncItemKeysFromTwin in interface IEmailGeneric
Parameters:
syncItem - SyncItem
Returns:
SyncItemKey[]
Throws:
com.funambol.framework.engine.source.SyncSourceException

addSyncItem

public abstract com.funambol.framework.engine.SyncItem addSyncItem(com.funambol.framework.engine.SyncItem syncItem)
                                                            throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
addSyncItem in interface IEmailGeneric
Returns:
SyncItem
Throws:
com.funambol.framework.engine.source.SyncSourceException

updateSyncItem

public abstract com.funambol.framework.engine.SyncItem updateSyncItem(com.funambol.framework.engine.SyncItem syncItem)
                                                               throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
updateSyncItem in interface IEmailGeneric
Returns:
SyncItem
Throws:
com.funambol.framework.engine.source.SyncSourceException

getUpdatedSyncItemKeys

public com.funambol.framework.engine.SyncItemKey[] getUpdatedSyncItemKeys(java.sql.Timestamp since,
                                                                          java.sql.Timestamp to)
                                                                   throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
getUpdatedSyncItemKeys in interface IEmailGeneric
Returns:
SyncItemKey[]
Throws:
com.funambol.framework.engine.source.SyncSourceException

getNewSyncItemKeys

public com.funambol.framework.engine.SyncItemKey[] getNewSyncItemKeys(java.sql.Timestamp since,
                                                                      java.sql.Timestamp to)
                                                               throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
getNewSyncItemKeys in interface IEmailGeneric
Returns:
SyncItemKey[]
Throws:
com.funambol.framework.engine.source.SyncSourceException

getDeletedSyncItemKeys

public com.funambol.framework.engine.SyncItemKey[] getDeletedSyncItemKeys(java.sql.Timestamp since,
                                                                          java.sql.Timestamp to)
                                                                   throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
getDeletedSyncItemKeys in interface IEmailGeneric
Returns:
SyncItemKey[]
Throws:
com.funambol.framework.engine.source.SyncSourceException

getSyncItemStateFromId

public char getSyncItemStateFromId(com.funambol.framework.engine.SyncItemKey syncItemKey)
                            throws com.funambol.framework.engine.source.SyncSourceException
Specified by:
getSyncItemStateFromId in interface IEmailGeneric
Parameters:
syncItemKey - SyncItemKey
Returns:
char
Throws:
com.funambol.framework.engine.source.SyncSourceException

checkMessageIDforDrafts

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

Specified by:
checkMessageIDforDrafts in interface IEmailGeneric
Throws:
com.funambol.framework.engine.source.SyncSourceException
EntityException

insertDefaultFolder

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

Specified by:
insertDefaultFolder in interface IEmailGeneric
Parameters:
df - defaulFolder object
sURI - sourceURI
pID - principal ID
Throws:
EntityException

createSyncItem

protected com.funambol.framework.engine.SyncItem createSyncItem(EmailSyncSource ess,
                                                                Folder folder,
                                                                char status,
                                                                java.util.TimeZone deviceTimeZone,
                                                                java.lang.String deviceCharset)
                                                         throws EntityException
Parameters:
folder - Folder
status - char
Returns:
SyncItem
Throws:
EntityException

createSyncItem

protected com.funambol.framework.engine.SyncItem createSyncItem(EmailSyncSource ess,
                                                                Email email,
                                                                char status,
                                                                java.util.TimeZone deviceTimeZone,
                                                                java.lang.String deviceCharset)
                                                         throws EntityException
Parameters:
email - Email
status - char
Returns:
SyncItem
Throws:
EntityException

isValidItem

protected boolean isValidItem(java.lang.String key)
Parameters:
key - GUID String
Returns:
true if the item is valid boolean

isEmailFromKey

protected boolean isEmailFromKey(java.lang.String parentId,
                                 java.lang.String objectId,
                                 java.lang.String sourceURI,
                                 long principalId)
                          throws EntityException
Returns true if the syncitem is a Mail false if the sycItem is a Folder

the key is composed by: parentId/objId (mailid or folderid) The key is created by the connector and it always creates the syncItemKey using parentId and mailId

Parameters:
parentId - String
objectId - String
Returns:
boolean
Throws:
com.funambol.framework.engine.source.SyncSourceException
EntityException

isEmailFromContent

protected boolean isEmailFromContent(java.lang.String content)
Returns true if the syncitem is a Mail, false if the sycItem is a Folder

Parameters:
content - String
Returns:
boolean

insertInvalidItem

protected 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)
                          throws EntityException
insert the invalid item in the cache. in the next syncs this item will not be handled

Throws:
com.funambol.framework.engine.source.SyncSourceException
EntityException


Copyright © 2005-2006 Funambol.