com.funambol.syncml.client
Class HttpUploader

java.lang.Object
  extended by com.funambol.syncml.client.HttpUploader

public class HttpUploader
extends java.lang.Object

This class is a file uploader for a two phases sync source. This class in particular is responsible for uploading an item and notifying a SyncListener about what is going on. It is important to note that this uploader is specific for the sync and it is not a generic uploader. During the upload phase the process can be interrupted, but this class must be derived and uploadCancelled shall be reimplemented to notify when the sync must be stopped.


Nested Class Summary
 class HttpUploader.HttpUploadStatus
          This subclass represents the result of the upload operation.
 
Field Summary
protected  int chunkSize
           
protected  ConnectionManager connectionManager
           
 
Constructor Summary
HttpUploader(SyncConfig syncConfig, java.lang.String uploadUrl, java.lang.String remoteUri, SyncListener listener)
           
 
Method Summary
protected  java.lang.String createUploadUrl(java.lang.String sessionId, java.lang.String key)
           
 void setChunkSize(int chunkSize)
           
 void setConnectionManager(ConnectionManager connectionManager)
           
 void upload(java.lang.String key, java.io.InputStream fileStream, int size, java.lang.String contentType, HttpUploader.HttpUploadStatus status)
          Upload an item to the HTTP server.
protected  boolean uploadCancelled()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chunkSize

protected int chunkSize

connectionManager

protected ConnectionManager connectionManager
Constructor Detail

HttpUploader

public HttpUploader(SyncConfig syncConfig,
                    java.lang.String uploadUrl,
                    java.lang.String remoteUri,
                    SyncListener listener)
Method Detail

setConnectionManager

public void setConnectionManager(ConnectionManager connectionManager)

setChunkSize

public void setChunkSize(int chunkSize)

upload

public void upload(java.lang.String key,
                   java.io.InputStream fileStream,
                   int size,
                   java.lang.String contentType,
                   HttpUploader.HttpUploadStatus status)
            throws HttpUploaderException
Upload an item to the HTTP server. The item is identified by a key and its content is made available via the given stream. Note that the stream is not closed at the end of the transfer, so it is up to the caller to close it properly.

Parameters:
key - the item identifier (the LUID used during the sync)
fileStream - the item stream
size - the item size
contentType - is the content type of the item to upload (if a null value is given, a default application/octect-stream type is used)
previousStatus - this is the status of the previous upload for this same item (it is null on the first attempt and has a value for successive ones)
Throws:
HttpUploaderException

createUploadUrl

protected java.lang.String createUploadUrl(java.lang.String sessionId,
                                           java.lang.String key)

uploadCancelled

protected boolean uploadCancelled()


Copyright © 2001-2009 Funambol.