com.funambol.email.engine.source
Class EmailSyncSource

java.lang.Object
  extended bycom.funambol.framework.engine.source.AbstractSyncSource
      extended bycom.funambol.email.engine.cache.CrcCachedSyncSource
          extended bycom.funambol.email.engine.source.EmailSyncSource
All Implemented Interfaces:
com.funambol.framework.engine.source.FilterableSyncSource, com.funambol.framework.tools.beans.LazyInitBean, java.io.Serializable, com.funambol.framework.engine.source.SyncSource
Direct Known Subclasses:
PopEmailSyncSource

public abstract class EmailSyncSource
extends CrcCachedSyncSource
implements com.funambol.framework.engine.source.FilterableSyncSource, java.io.Serializable

This class implements common methods of

  EmailIMAPSyncSource
  EmailPOPSyncSource
 

version $Id: EmailSyncSource.java,v 1.32 2006/06/14 08:33:09 gbmiglia Exp $

See Also:
Serialized Form

Field Summary
protected  boolean allMailboxActivation
          Should the channel be allMailboxActivation?
protected  DefaultFolder defaultFolder
           
protected  com.funambol.framework.server.Sync4jDevice device
          Property for sync session
protected  java.lang.String deviceCharset
          Property for sync session
protected  java.util.TimeZone deviceTimeZone
          Property for sync session
protected  java.lang.String deviceTimeZoneDescr
          Property for sync session
protected  boolean draftActivation
          Should the channel be draftActivation
protected  EntityManager em
           
protected  EmailFilter filter
           
protected static com.funambol.server.tools.IdSpaceGenerator idFolderSpace
           
protected static com.funambol.server.tools.IdSpaceGenerator idSentSpace
           
protected  boolean inboxActivation
          Should the channel be inboxActivation?
protected  java.lang.String inHost
          Property Incoming Server
protected  java.lang.String inPort
          Property Incoming Server Port
protected  java.lang.String keystorePassphrase
          Property keystorePassphrase
protected  java.lang.String keystorePath
          Property keystorePath
protected  java.util.logging.Logger log
           
protected  IMailServerWrapper mswf
          wrapper for the Mail Server
protected  boolean outboxActivation
          Should the channel be outboxActivation?
protected  java.lang.String outHost
          Property Incoming Server
protected  java.lang.String outPort
          Property Incoming Server Port
protected  java.security.Principal principal
          Property Principal
protected  java.lang.String protocol
          Property Mail Server Server protocol
protected  boolean sentActivation
          Should the channel be sentActivation?
protected  boolean smtpAuth
          Property Outgoing authentication required
protected  boolean ssl
          Should the channel be ssl?
protected  int syncMode
          Property syncMode
protected  boolean trashActivation
          Should the channel be trashActivation
 
Fields inherited from class com.funambol.email.engine.cache.CrcCachedSyncSource
itemsSent, jndiDataSourceName
 
Fields inherited from class com.funambol.framework.engine.source.AbstractSyncSource
howManyAdded, howManyDeleted, howManyUpdated, info, LOG_NAME, name, sourceQuery, sourceURI, type
 
Constructor Summary
EmailSyncSource()
           
 
Method Summary
 void beginSync(com.funambol.framework.engine.source.SyncContext context)
          Begin Sync Method

before starting sync the method set the filter

main folder filter T D S O I 0 0 0 0 1 --> 1 inbox 0 0 0 1 1 --> 3 inbox + outbox 0 0 1 1 1 --> 7 inbox + outbox + sent 0 1 1 1 1 --> 15 inbox + outbox + sent + draft 1 1 1 1 1 --> 31 inbox + outbox + sent + draft + trash

time filter (timeFilter) null --> all "i.e. 20-10-2005" --> filter

size filter (sizeFilter / numbytes) 000001 --> 1 FILTER_SIZE_H 000011 --> 3 FILTER_SIZE_H_PERC 000101 --> 5 FILTER_SIZE_H_B 001111 --> 15 FILTER_SIZE_H_B_PERC 010101 --> 21 FILTER_SIZE_H_B_A 111111 --> 63 FILTER_SIZE_H_B_A_PERC

protected  com.funambol.framework.engine.SyncItem createSyncItem(Email email, char status)
           
protected  com.funambol.framework.engine.SyncItem createSyncItem(Folder folder, char status)
           
 void endSync()
          End Sync Method
 DefaultFolder getDefaultFolder()
          Getter for property defaultFolder.
protected  com.funambol.framework.server.Sync4jDevice getDevice(java.lang.String deviceId)
          Return the device with the given deviceId
 Folder getFoundationFolderFromXML(java.lang.String content)
          Get Data from XML message converting the xml item into a Folder object
 Email getFoundationMailFromXML(java.lang.String content)
          Get Data from XML message converting the xml item into a Email object
 java.lang.String getInHost()
          Getter for property Incoming Mail Server Host.
 java.lang.String getInPort()
          Getter for property Incoming Mail Server Port.
 java.lang.String getKeystorePassphrase()
          Getter for property keystorePassphrase
 java.lang.String getKeystorePath()
          Getter for property keystorePath
 java.lang.String getOutHost()
          Getter for property Outgoing Mail Server Host.
 java.lang.String getOutPort()
          Getter for property Outgoing Mail Server Port.
 java.lang.String getProtocol()
          Getter for property Mail Server protocol.
 java.lang.String getXMLFromFoundationFolder(Folder folder)
          Get Data from foundation.pdi.mail.Folder converting the Folder object into an xml item
 java.lang.String getXMLFromFoundationMail(Email mail)
          Get Data from sync4j.foundation.pdi.mail.Email converting the Contact object into an xml item
protected  void insertCustomFolder()
          insert the default folder if needed
protected  void insertDefaultFolder()
          insert the default folder if needed
 boolean isAllMailboxActivation()
          Getter for property allMailboxActivation.
 boolean isDraftActivation()
          Getter for property draftActivation.
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)
          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

 boolean isInboxActivation()
          Getter for property inboxActivation.
 boolean isOutboxActivation()
          Getter for property outboxActivation.
 boolean isSentActivation()
          Getter for property sentActivation.
 boolean isSmtpAuth()
          Getter for property Outgoing authentication required
 boolean isSSL()
          Getter for property ssl.
 boolean isTrashActivation()
          Getter for property trashActivation.
 void setAllMailboxActivation(boolean allMailboxActivation)
          Setter for property allMailboxActivation.
 void setDefaultFolder(DefaultFolder defaultFolder)
          Setter for property defaultFolder.
 void setDraftActivation(boolean draftActivation)
          Setter for property draftActivation.
 void setInboxActivation(boolean inboxActivation)
          Setter for property inboxActivation.
 void setInHost(java.lang.String inHost)
          Setter for property Incoming Mail Server.
 void setInPort(java.lang.String inPort)
          Setter for property Incoming Mail Server Port.
 void setKeystorePassphrase(java.lang.String keystorePassphrase)
          Setter for keystorePassphrase
 void setKeystorePath(java.lang.String keystorePath)
          Setter for property keystorePath
 void setOutboxActivation(boolean outboxActivation)
          Setter for property outboxActivation.
 void setOutHost(java.lang.String outHost)
          Setter for property Outgoing Mail Server.
 void setOutPort(java.lang.String outPort)
          Setter for property Outgoing Mail Server Port.
 void setProtocol(java.lang.String protocol)
          Setter for property Mail Server protocol.
 void setSentActivation(boolean sentActivation)
          Setter for property sentActivation.
 void setSmtpAuth(boolean smtpAuth)
          Setter for property Outgoing authentication required
 void setSSL(boolean ssl)
          Setter for property ssl.
 void setTrashActivation(boolean trashActivation)
          Setter for property trashActivation.
 
Methods inherited from class com.funambol.email.engine.cache.CrcCachedSyncSource
clearServerInfo, getAllSyncItemInfo, getDeletedSyncItemKeys, getNewSyncItemKeys, getSyncItemStateFromId, getUpdatedSyncItemKeys, init
 
Methods inherited from class com.funambol.framework.engine.source.AbstractSyncSource
addSyncItem, commitSync, getAllSyncItemKeys, getInfo, getName, getSourceQuery, getSourceURI, getSyncItemFromId, getSyncItemKeysFromTwin, getType, removeSyncItem, setInfo, setName, setOperationStatus, setSourceURI, setType, toString, updateSyncItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.funambol.framework.engine.source.FilterableSyncSource
getSyncItemStateFromId, isSyncItemInFilterClause, isSyncItemInFilterClause
 
Methods inherited from interface com.funambol.framework.engine.source.SyncSource
addSyncItem, commitSync, getAllSyncItemKeys, getDeletedSyncItemKeys, getInfo, getName, getNewSyncItemKeys, getSourceURI, getSyncItemFromId, getSyncItemKeysFromTwin, getType, getUpdatedSyncItemKeys, removeSyncItem, setOperationStatus, updateSyncItem
 

Field Detail

log

protected java.util.logging.Logger log

device

protected com.funambol.framework.server.Sync4jDevice device
Property for sync session


deviceTimeZoneDescr

protected java.lang.String deviceTimeZoneDescr
Property for sync session


deviceTimeZone

protected java.util.TimeZone deviceTimeZone
Property for sync session


deviceCharset

protected java.lang.String deviceCharset
Property for sync session


principal

protected java.security.Principal principal
Property Principal


syncMode

protected int syncMode
Property syncMode


mswf

protected IMailServerWrapper mswf
wrapper for the Mail Server


em

protected EntityManager em

filter

protected EmailFilter filter

idSentSpace

protected static com.funambol.server.tools.IdSpaceGenerator idSentSpace

idFolderSpace

protected static com.funambol.server.tools.IdSpaceGenerator idFolderSpace

ssl

protected boolean ssl
Should the channel be ssl?


keystorePath

protected java.lang.String keystorePath
Property keystorePath


keystorePassphrase

protected java.lang.String keystorePassphrase
Property keystorePassphrase


allMailboxActivation

protected boolean allMailboxActivation
Should the channel be allMailboxActivation?


inboxActivation

protected boolean inboxActivation
Should the channel be inboxActivation?


outboxActivation

protected boolean outboxActivation
Should the channel be outboxActivation?


sentActivation

protected boolean sentActivation
Should the channel be sentActivation?


draftActivation

protected boolean draftActivation
Should the channel be draftActivation


trashActivation

protected boolean trashActivation
Should the channel be trashActivation


inHost

protected java.lang.String inHost
Property Incoming Server


inPort

protected java.lang.String inPort
Property Incoming Server Port


outHost

protected java.lang.String outHost
Property Incoming Server


outPort

protected java.lang.String outPort
Property Incoming Server Port


smtpAuth

protected boolean smtpAuth
Property Outgoing authentication required


protocol

protected java.lang.String protocol
Property Mail Server Server protocol


defaultFolder

protected DefaultFolder defaultFolder
Constructor Detail

EmailSyncSource

public EmailSyncSource()
Method Detail

isSSL

public boolean isSSL()
Getter for property ssl.

Returns:
Value of property ssl.

setSSL

public void setSSL(boolean ssl)
Setter for property ssl.

Parameters:
ssl - New value of property ssl.

getKeystorePath

public java.lang.String getKeystorePath()
Getter for property keystorePath

Returns:
Value of property keystorePath

setKeystorePath

public void setKeystorePath(java.lang.String keystorePath)
Setter for property keystorePath

Parameters:
keystorePath - String. New value of property keystorePath

getKeystorePassphrase

public java.lang.String getKeystorePassphrase()
Getter for property keystorePassphrase

Returns:
Value of property keystorePassphrase

setKeystorePassphrase

public void setKeystorePassphrase(java.lang.String keystorePassphrase)
Setter for keystorePassphrase

Parameters:
keystorePassphrase - String. New value of property keystorePassphrase

isAllMailboxActivation

public boolean isAllMailboxActivation()
Getter for property allMailboxActivation.

Returns:
Value of property allMailboxActivation.

setAllMailboxActivation

public void setAllMailboxActivation(boolean allMailboxActivation)
Setter for property allMailboxActivation.

Parameters:
allMailboxActivation - New value of property allMailboxActivation.

isInboxActivation

public boolean isInboxActivation()
Getter for property inboxActivation.

Returns:
Value of property inboxActivation.

setInboxActivation

public void setInboxActivation(boolean inboxActivation)
Setter for property inboxActivation.

Parameters:
inboxActivation - New value of property inboxActivation.

isOutboxActivation

public boolean isOutboxActivation()
Getter for property outboxActivation.

Returns:
Value of property outboxActivation.

setOutboxActivation

public void setOutboxActivation(boolean outboxActivation)
Setter for property outboxActivation.

Parameters:
outboxActivation - New value of property outboxActivation.

isSentActivation

public boolean isSentActivation()
Getter for property sentActivation.

Returns:
Value of property sentActivation.

setSentActivation

public void setSentActivation(boolean sentActivation)
Setter for property sentActivation.

Parameters:
sentActivation - New value of property sentActivation.

isDraftActivation

public boolean isDraftActivation()
Getter for property draftActivation.

Returns:
Value of property draftActivation.

setDraftActivation

public void setDraftActivation(boolean draftActivation)
Setter for property draftActivation.

Parameters:
draftActivation - New value of property draftActivation.

isTrashActivation

public boolean isTrashActivation()
Getter for property trashActivation.

Returns:
Value of property trashActivation.

setTrashActivation

public void setTrashActivation(boolean trashActivation)
Setter for property trashActivation.

Parameters:
trashActivation - New value of property trashActivation.

getInHost

public java.lang.String getInHost()
Getter for property Incoming Mail Server Host.

Returns:
Value of property Incoming Mail Server Host.

setInHost

public void setInHost(java.lang.String inHost)
Setter for property Incoming Mail Server.

Parameters:
inHost - String New value of property Incoming Mail Server.

getInPort

public java.lang.String getInPort()
Getter for property Incoming Mail Server Port.

Returns:
Value of property Incoming Mail Server Port.

setInPort

public void setInPort(java.lang.String inPort)
Setter for property Incoming Mail Server Port.

Parameters:
inPort - String New value of property Incoming Mail Server Port.

getOutHost

public java.lang.String getOutHost()
Getter for property Outgoing Mail Server Host.

Returns:
Value of property Outgoing Mail Server Host.

setOutHost

public void setOutHost(java.lang.String outHost)
Setter for property Outgoing Mail Server.

Parameters:
outHost - String New value of property Outgoing Mail Server.

getOutPort

public java.lang.String getOutPort()
Getter for property Outgoing Mail Server Port.

Returns:
Value of property Incoming Mail Server Port.

setOutPort

public void setOutPort(java.lang.String outPort)
Setter for property Outgoing Mail Server Port.

Parameters:
outPort - String New value of property Outgoing Mail Server Port.

isSmtpAuth

public boolean isSmtpAuth()
Getter for property Outgoing authentication required

Returns:
Value of property Outgoing authentication required.

setSmtpAuth

public void setSmtpAuth(boolean smtpAuth)
Setter for property Outgoing authentication required

Parameters:
smtpAuth - boolean New value of property Outgoing authentication required.

getProtocol

public java.lang.String getProtocol()
Getter for property Mail Server protocol.

Returns:
Value of property Mail Server protocol.

setProtocol

public void setProtocol(java.lang.String protocol)
Setter for property Mail Server protocol.

Parameters:
protocol - String. New value of property Mail Server protocol.

getDefaultFolder

public DefaultFolder getDefaultFolder()
Getter for property defaultFolder.

Returns:
Value of property defaultFolder.

setDefaultFolder

public void setDefaultFolder(DefaultFolder defaultFolder)
Setter for property defaultFolder.

Parameters:
defaultFolder - DefaultFolder

beginSync

public void beginSync(com.funambol.framework.engine.source.SyncContext context)
               throws com.funambol.framework.engine.source.SyncSourceException
Begin Sync Method

before starting sync the method set the filter

main folder filter

time filter (timeFilter)

size filter (sizeFilter / numbytes)

Specified by:
beginSync in interface com.funambol.framework.engine.source.SyncSource
Overrides:
beginSync in class CrcCachedSyncSource
Parameters:
context - SyncContext
Throws:
com.funambol.framework.engine.source.SyncSourceException

endSync

public void endSync()
             throws com.funambol.framework.engine.source.SyncSourceException
End Sync Method

Specified by:
endSync in interface com.funambol.framework.engine.source.SyncSource
Overrides:
endSync in class CrcCachedSyncSource
Throws:
com.funambol.framework.engine.source.SyncSourceException

getXMLFromFoundationMail

public java.lang.String getXMLFromFoundationMail(Email mail)
                                          throws EntityException
Get Data from sync4j.foundation.pdi.mail.Email converting the Contact object into an xml item

Parameters:
mail - Email
Returns:
String
Throws:
EntityException

getXMLFromFoundationFolder

public java.lang.String getXMLFromFoundationFolder(Folder folder)
                                            throws EntityException
Get Data from foundation.pdi.mail.Folder converting the Folder object into an xml item

Parameters:
folder - Folder
Returns:
String
Throws:
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

isEmailFromKey

protected boolean isEmailFromKey(java.lang.String parentId,
                                 java.lang.String objectId)
                          throws com.funambol.framework.engine.source.SyncSourceException
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

insertDefaultFolder

protected void insertDefaultFolder()
                            throws com.funambol.framework.engine.source.SyncSourceException
insert the default folder if needed

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

insertCustomFolder

protected void insertCustomFolder()
                           throws com.funambol.framework.engine.source.SyncSourceException
insert the default folder if needed

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

getDevice

protected com.funambol.framework.server.Sync4jDevice getDevice(java.lang.String deviceId)
                                                        throws com.funambol.framework.server.store.PersistentStoreException
Return the device with the given deviceId

Parameters:
deviceId - String
Returns:
Sync4jDevice
Throws:
com.funambol.framework.server.store.PersistentStoreException

getFoundationMailFromXML

public Email getFoundationMailFromXML(java.lang.String content)
                               throws EntityException
Get Data from XML message converting the xml item into a Email object

Parameters:
content - String
Returns:
Email
Throws:
EntityException

getFoundationFolderFromXML

public Folder getFoundationFolderFromXML(java.lang.String content)
                                  throws EntityException
Get Data from XML message converting the xml item into a Folder object

Parameters:
content - String
Returns:
Folder
Throws:
EntityException

createSyncItem

protected com.funambol.framework.engine.SyncItem createSyncItem(Email email,
                                                                char status)
                                                         throws EntityException
Parameters:
email - Email
status - char
Returns:
SyncItem
Throws:
EntityException

createSyncItem

protected com.funambol.framework.engine.SyncItem createSyncItem(Folder folder,
                                                                char status)
                                                         throws EntityException
Parameters:
folder - Folder
status - char
Returns:
SyncItem
Throws:
EntityException


Copyright © 2003-2006 Funambol.