com.funambol.syncml.client
Class ConfigSyncSource

java.lang.Object
  extended by com.funambol.syncml.client.BaseSyncSource
      extended by com.funambol.syncml.client.TrackableSyncSource
          extended by com.funambol.syncml.client.ConfigSyncSource
All Implemented Interfaces:
SyncSource

public class ConfigSyncSource
extends TrackableSyncSource

An implementation of TrackableSyncSource, providing the ability to sync Funambol's client configuration


Field Summary
 
Fields inherited from class com.funambol.syncml.client.TrackableSyncSource
tracker
 
Fields inherited from class com.funambol.syncml.client.BaseSyncSource
allIndex, allItems, config, delIndex, delItems, filter, globalStatus, newIndex, newItems, syncMode, updIndex, updItems
 
Fields inherited from interface com.funambol.syncml.spds.SyncSource
ENCODING_B64, ENCODING_NONE, STATUS_CONNECTION_ERROR, STATUS_RECV_ERROR, STATUS_SEND_ERROR, STATUS_SERVER_ERROR, STATUS_SUCCESS
 
Constructor Summary
ConfigSyncSource(SourceConfig config, ChangesTracker tracker, StringKeyValueStore store)
          ConfigSyncSource constructor
 
Method Summary
 int addItem(SyncItem item)
          Add a new SyncItem to this source backend.
 void beginSync(int syncMode)
          Called after SyncManager preparation and initialization just before start the synchronization of the SyncSource.
 int deleteItem(java.lang.String key)
          Delete a SyncItem stored in the source backend.
 void endSync()
          Called just before committing the synchronization process by the SyncManager.
protected  java.util.Enumeration getAllItemsKeys()
           
protected  SyncItem getItemContent(SyncItem item)
          This function gets the item content in the backend database and returns a complete item.
 int updateItem(SyncItem item)
          Update a given SyncItem stored in the source backend.
 
Methods inherited from class com.funambol.syncml.client.TrackableSyncSource
initAllItems, initChangedItems, initDelItems, initNewItems, initUpdItems, setItemStatus
 
Methods inherited from class com.funambol.syncml.client.BaseSyncSource
dataReceived, getClientAddNumber, getClientDeleteNumber, getClientItemsNumber, getClientReplaceNumber, getConfig, getEncoding, getFilter, getLastAnchor, getListener, getName, getNextAnchor, getNextDeletedItem, getNextItem, getNextNewItem, getNextUpdatedItem, getServerItemsNumber, getSourceUri, getStatus, getSyncMode, getType, setConfig, setFilter, setLastAnchor, setListener, setNextAnchor, setServerItemsNumber
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigSyncSource

public ConfigSyncSource(SourceConfig config,
                        ChangesTracker tracker,
                        StringKeyValueStore store)
ConfigSyncSource constructor

Method Detail

beginSync

public void beginSync(int syncMode)
               throws SyncException
Description copied from class: BaseSyncSource
Called after SyncManager preparation and initialization just before start the synchronization of the SyncSource.

Specified by:
beginSync in interface SyncSource
Overrides:
beginSync in class TrackableSyncSource
Parameters:
syncMode - the synchronization type: one of the values in sync4j.framework.core.AlertCode
Throws:
SyncException - in case of error. This will stop the sync process

endSync

public void endSync()
             throws SyncException
Description copied from class: BaseSyncSource
Called just before committing the synchronization process by the SyncManager. The SyncSource can stop the commit phase raising an exception here.

Specified by:
endSync in interface SyncSource
Overrides:
endSync in class TrackableSyncSource
Throws:
SyncException - in case of error, to stop the commit.

getAllItemsKeys

protected java.util.Enumeration getAllItemsKeys()
                                         throws SyncException
Specified by:
getAllItemsKeys in class TrackableSyncSource
Throws:
SyncException

addItem

public int addItem(SyncItem item)
            throws SyncException
Description copied from class: BaseSyncSource
Add a new SyncItem to this source backend. The item key after a successful add must contain the local UID, that is used by the engine to send the mappings to the server. The source must then change the item key accordingly before return.

Specified by:
addItem in interface SyncSource
Specified by:
addItem in class BaseSyncSource
Parameters:
item - the SyncItem to add, with the GUID sent by the server. The source is resposible to set it to the LUID before returning a successful status code.
Returns:
the status code of the operation. It will be returned to the server in the response for this item.
Throws:
SyncException - if an unrecoverable error occur, to stop the sync

updateItem

public int updateItem(SyncItem item)
               throws SyncException
Description copied from class: BaseSyncSource
Update a given SyncItem stored in the source backend.

Specified by:
updateItem in interface SyncSource
Specified by:
updateItem in class BaseSyncSource
Parameters:
item - the SyncItem to update. The key of the item is already the LUID.
Returns:
the status code of the operation. It will be returned to the server in the response for this item.
Throws:
SyncException - if an unrecoverable error occur, to stop the sync

deleteItem

public int deleteItem(java.lang.String key)
               throws SyncException
Description copied from class: BaseSyncSource
Delete a SyncItem stored in the source backend.

Specified by:
deleteItem in interface SyncSource
Specified by:
deleteItem in class BaseSyncSource
Parameters:
key - The key of the item to delete.
Returns:
the status code of the operation. It will be returned to the server in the response for this item.
Throws:
SyncException - if an unrecoverable error occur, to stop the sync

getItemContent

protected SyncItem getItemContent(SyncItem item)
                           throws SyncException
Description copied from class: BaseSyncSource
This function gets the item content in the backend database and returns a complete item. The parameter item is marked final because should not be used for the filled item: it is a reference to the array entry, and filling it would cause the array to keep all the filled items at the end (the gc will not dispose them).

The content of the item depends also from the encoding of this SyncSource:

  • if the encoding is none, it must be a String, converted with getBytes(), so the engine will send it unchanged.
  • if the encoding is b64, the content can be binary, and the type should be set accordingly, so that the receiving source can handle it. In this way, the binary content is transferred encoded in the SyncML message. This encoding can be applied to a test item too, to avoid problems with charset or other, like what is done with the SIF format.

    Specified by:
    getItemContent in class BaseSyncSource
    Throws:
    SyncException


  • Copyright © 2006 Funambol.