|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.syncml.client.TrackableSyncSource
com.funambol.syncml.client.FileSyncSource
com.funambol.syncml.client.TwoPhasesFileSyncSource
public class TwoPhasesFileSyncSource
An implementation of TrackableSyncSource, providing the ability to sync briefcases (files). The source can handle both raw files and OMA files (file objects). By default the source formats items according to the OMA file object spec, but it is capable of receiving also raw files, if their MIME type is not OMA file objects.
Nested Class Summary | |
---|---|
protected class |
TwoPhasesFileSyncSource.EmptyFileSyncItem
|
protected class |
TwoPhasesFileSyncSource.FileProperties
|
protected class |
TwoPhasesFileSyncSource.ProxySyncListener
|
Nested classes/interfaces inherited from class com.funambol.syncml.client.FileSyncSource |
---|
FileSyncSource.FileSyncItem |
Field Summary | |
---|---|
protected java.lang.String |
directory
|
protected java.util.Hashtable |
itemsToDelete
|
protected java.util.Vector |
itemsToUpload
|
protected int |
numRetries
|
protected TwoPhasesFileSyncSource.ProxySyncListener |
proxyListener
|
protected SyncConfig |
syncConfig
|
protected java.lang.String |
uploadUrl
|
Fields inherited from class com.funambol.syncml.client.FileSyncSource |
---|
extensions |
Fields inherited from class com.funambol.syncml.client.TrackableSyncSource |
---|
allItems, config, delItems, filter, globalStatus, newItems, syncMode, tracker, 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 | |
---|---|
TwoPhasesFileSyncSource(SourceConfig config,
ChangesTracker tracker,
java.lang.String directory,
SyncConfig syncConfig,
java.lang.String uploadUrl)
FileSyncSource constructor: initialize source config. |
Method Summary | |
---|---|
int |
addItem(SyncItem item)
Add an item to the local store. |
void |
beginSync(int syncMode)
Called after SyncManager preparation and initialization just before start the synchronization of the SyncSource. |
protected void |
closeFileProperties(TwoPhasesFileSyncSource.FileProperties fProp)
|
protected HttpUploader |
createUploader(SyncConfig config,
java.lang.String uploadUrl,
java.lang.String sourceUri,
SyncListener listener)
|
void |
endSync()
Called just before committing the synchronization process by the SyncManager. |
protected SyncItem |
getItemContent(SyncItem item)
TODO: is this still needed? This is still kind of strange, we don't really need to get the item content any longer but we just need to create a proper item from which the content can be read |
SyncItem |
getNextDeletedItem()
Returns a SyncItem containing the key of the first/next deleted item of the store (locally removed after the last sync, but not yet deleted on server) |
protected TwoPhasesFileSyncSource.FileProperties |
openFile(java.lang.String fileName)
This method opens a file and store its input stream and size into a FileProperties object. |
void |
setItemStatus(java.lang.String key,
int status)
Tell the SyncSource the status returned by the server for an Item previously sent. |
int |
updateItem(SyncItem item)
Update an item in the local store. |
protected void |
uploadItems()
|
Methods inherited from class com.funambol.syncml.client.FileSyncSource |
---|
applyFileObjectProperties, createSyncItem, deleteAllItems, deleteItem, filterFile, getAllItemsKeys, setSupportedExtensions |
Methods inherited from class com.funambol.syncml.client.TrackableSyncSource |
---|
dataReceived, getClientAddNumber, getClientDeleteNumber, getClientItemsNumber, getClientReplaceNumber, getConfig, getEncoding, getFilter, getLastAnchor, getListener, getName, getNextAnchor, getNextItem, getNextNewItem, getNextUpdatedItem, getServerItemsNumber, getSourceUri, getStatus, getSyncMode, getTracker, getType, setConfig, setFilter, setLastAnchor, setListener, setNextAnchor, setServerItemsNumber, setTracker |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int numRetries
protected java.lang.String directory
protected java.util.Vector itemsToUpload
protected java.lang.String uploadUrl
protected TwoPhasesFileSyncSource.ProxySyncListener proxyListener
protected SyncConfig syncConfig
protected java.util.Hashtable itemsToDelete
Constructor Detail |
---|
public TwoPhasesFileSyncSource(SourceConfig config, ChangesTracker tracker, java.lang.String directory, SyncConfig syncConfig, java.lang.String uploadUrl)
config
- the source configurationtracker
- the changes trackerdirectory
- the directory containing the filessyncConfig
- the SyncConfig. Note that this must be updated with the
current credentials of the user. If this is not the case, then the method
createUploader shall be redefined so that the HttpUploader is created
with an updated SyncConfiguploadUrl
- the upload url suffix (this is added to the sync url)Method Detail |
---|
public void beginSync(int syncMode) throws SyncException
SyncSource
beginSync
in interface SyncSource
beginSync
in class FileSyncSource
syncMode
- the synchronization type: one of the values in
sync4j.framework.core.AlertCode
SyncException
- in case of error. This will stop the sync processpublic int addItem(SyncItem item) throws SyncException
addItem
in interface SyncSource
addItem
in class FileSyncSource
item
- the received item
SyncException
- if an error occurs while applying the file
attributespublic int updateItem(SyncItem item) throws SyncException
updateItem
in interface SyncSource
updateItem
in class FileSyncSource
item
- the received item
SyncException
- if an error occurs while applying the file
attributespublic void setItemStatus(java.lang.String key, int status) throws SyncException
SyncSource
setItemStatus
in interface SyncSource
setItemStatus
in class TrackableSyncSource
key
- the key of the itemstatus
- the status code received for that item
SyncException
- if the SyncSource wants to stop the syncpublic SyncItem getNextDeletedItem() throws SyncException
SyncSource
getNextDeletedItem
in interface SyncSource
getNextDeletedItem
in class TrackableSyncSource
SyncException
public void endSync() throws SyncException
SyncSource
endSync
in interface SyncSource
endSync
in class TrackableSyncSource
SyncException
- in case of error, to stop the commit.protected void uploadItems() throws SyncException
SyncException
protected TwoPhasesFileSyncSource.FileProperties openFile(java.lang.String fileName) throws java.io.IOException
fileName
- the file name
java.io.IOException
protected void closeFileProperties(TwoPhasesFileSyncSource.FileProperties fProp)
protected HttpUploader createUploader(SyncConfig config, java.lang.String uploadUrl, java.lang.String sourceUri, SyncListener listener)
protected SyncItem getItemContent(SyncItem item) throws SyncException
getItemContent
in class FileSyncSource
SyncException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |