jfileupload.transfer.client.http
Class HTTPUploadTransfer

java.lang.Object
  extended by jfileupload.transfer.client.core.AbstractTransferController
      extended by jfileupload.transfer.client.http.HTTPTransfer
          extended by jfileupload.transfer.client.http.HTTPUploadTransfer
All Implemented Interfaces:
java.lang.Runnable, TransferController

public class HTTPUploadTransfer
extends HTTPTransfer
implements java.lang.Runnable

This class implements a TransferController for HTTP POST or PUT Upload. It relies on Commons-HTTPClient 3.x.


Field Summary
static java.lang.String ACCOUNT
           
protected  boolean cancelled
           
static java.lang.String CHUNKAMOUNT
           
static java.lang.String CHUNKBASE
           
static java.lang.String CHUNKEXTENSION
           
static java.lang.String CHUNKID
           
static java.lang.String CHUNKONFLY
           
static java.lang.String CHUNKONFLYOFFSET
           
static java.lang.String CHUNKONFLYSIZE
           
static java.lang.String DELETEAFTERUPLOAD
           
static java.lang.String EMPTYDIRECTORY
           
static java.lang.String FILETIMESTAMP
           
protected  java.io.FileOutputStream fout
           
static java.lang.String FULLFILENAME
           
static java.lang.String HEADEXTRAPARAMETERS
           
static java.lang.String HTTPMETHOD
           
static java.lang.String NOTIFYRELATIVEFILENAME
           
protected  CustomFilePart param
           
protected  java.io.FileInputStream pfin
           
protected  java.io.File processed
           
static java.lang.String RELATIVEFILENAME
           
protected  java.lang.String rfilename
           
static java.lang.String SELECTEDFULLFILENAME
           
protected  java.lang.String sfullfilename
           
protected  CustomFilePartSource source
           
protected  java.util.ArrayList uploadedfiles
           
protected  java.lang.String uploadurl
           
protected  java.io.File zip
           
 
Fields inherited from class jfileupload.transfer.client.http.HTTPTransfer
COOKIENAME, COOKIEOVERWRITE, COOKIEPATH, COOKIEVALUE, DEPRECATEDURL, ERRORHEADER, HTTPAUTHMETHOD, HTTPNTLMDOMAIN, HTTPNTLMHOST, HTTPPROXYHOST, HTTPPROXYNTLMDOMAIN, HTTPPROXYNTLMHOST, HTTPPROXYPASSWORD, HTTPPROXYPORT, HTTPPROXYUSERNAME, MIMETYPES, WEAKSSL
 
Fields inherited from class jfileupload.transfer.client.core.AbstractTransferController
BUFFERSIZE, GZIPEXTENSION, ZIPEXTENSION
 
Fields inherited from interface jfileupload.transfer.client.core.TransferController
COMPLETED_STATUS, MAX_AUTH_ATTEMPTS, PREPROCESSING_FILTER, RUNNING_STATUS, WAITING_STATUS
 
Constructor Summary
HTTPUploadTransfer()
          HTTP upload implementation.
 
Method Summary
 void begin()
          Start upload thread.
 void cancel()
          Cancel current upload.
 java.lang.Object execute()
          NOT IMPLEMENTED for HTTP UPLOAD transfer.
 java.util.HashMap getParameters(java.lang.String section)
           
protected  java.lang.String getRelativeFilename(java.io.File cfile, java.lang.String cname)
           
 java.lang.String getUploadurl()
           
 void init()
          Initialization.
 boolean isCancelled()
           
protected  void process(java.io.File current)
          Process upload tasks including filtering.
protected  void processFile(java.io.File current)
          Process basic upload tasks.
protected  void recurseProcess(java.io.File dir, long level, long depth)
          Recurse folders (and sub folders) and process upload tasks.
 void run()
          Main upload loop.
 void setUploadurl(java.lang.String uploadurl)
           
protected  void splitAndTransfer(java.io.File currentfile)
          Split file (if needed) and transfer each chunk with meta data (chunkid, chunkamount, chunkabase).
protected  void transfer(java.io.File currentfile, java.util.HashMap meta)
          Upload current file with optional additional HTTP parameters.
protected  void transferAndRetry(java.io.File current, java.util.HashMap meta)
          Upload file with optional retry attempts if it fails.
 
Methods inherited from class jfileupload.transfer.client.http.HTTPTransfer
authenticate, autoDetectProxy, getClient, getCustomFilenameMap, getCustomParameters, getHostname, headInfo, parseAuthenticateHeader, registerSSLSocketFactory, setProxyAuthentication, setWWWAuthentication
 
Methods inherited from class jfileupload.transfer.client.core.AbstractTransferController
addChecksumListener, addCompressListener, addFilterListener, addProtocolListener, addSplitListener, addTransferListener, authenticate, checksumCompletedNotification, checksumStartedNotification, checkZipMaxSize, cleanFilter, cleanFilter, compress, compress, compressFolder, compressingNotification, compressionFailedNotification, computeChecksum, executeFilter, executeFilter, getAllowedSourceFiles, getAuthentication, getBlackList, getChecksumListeners, getChunks, getChunkSize, getCompressListeners, getCRC32, getEncoding, getExt, getFilter, getFilter, getFilterChain, getFilterIDs, getFilterImpl, getFilterImpl, getFilterListeners, getHidden, getLastChunkSize, getLong, getMaxDepth, getMaxFiles, getMaxSize, getMD5, getMinSize, getOverwrite, getParamFile, getPassword, getPolicy, getPreProcessingFilter, getPreProcessingFilterImpl, getProtocolListeners, getRawConf, getResume, getResumeOffset, getRetry, getRetryDelay, getRootDir, getServerUrl, getSource, getSplitListeners, getStatus, getTarget, getTemplate, getTimeOut, getTmpDir, getTmpFolder, getTransferFileFilter, getTransferListeners, getUsername, getWhiteList, getZipFolder, getZipIgnoreList, getZipMaxSize, getZipOnFly, hexDump, isAllowed, isThreaded, recurse, recursiveCompress, removeChecksumListener, removeCompressListener, removeFilterListener, removeProtocolListener, removeSplitListener, removeTransferListener, rename, setAuthentication, setBlackList, setChunkSize, setEncoding, setExt, setFilter, setFilter, setFilterChain, setFilterIDs, setFilterImpl, setFilterImpl, setHidden, setMaxDepth, setMaxFiles, setMaxSize, setMinSize, setOverwrite, setParameters, setParamFile, setPassword, setPolicy, setPreProcessingFilter, setPreProcessingFilterImpl, setRawConf, setResume, setResumeOffset, setRetry, setRetryDelay, setRootDir, setServerUrl, setSource, setStatus, setTarget, setTemplate, setThreaded, setTimeOut, setTmpDir, setUsername, setWhiteList, setZipFolder, setZipIgnoreList, setZipMaxSize, setZipOnFly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RELATIVEFILENAME

public static java.lang.String RELATIVEFILENAME

NOTIFYRELATIVEFILENAME

public static java.lang.String NOTIFYRELATIVEFILENAME

FULLFILENAME

public static java.lang.String FULLFILENAME

SELECTEDFULLFILENAME

public static java.lang.String SELECTEDFULLFILENAME

FILETIMESTAMP

public static java.lang.String FILETIMESTAMP

EMPTYDIRECTORY

public static java.lang.String EMPTYDIRECTORY

CHUNKID

public static java.lang.String CHUNKID

CHUNKAMOUNT

public static java.lang.String CHUNKAMOUNT

CHUNKBASE

public static java.lang.String CHUNKBASE

CHUNKONFLY

public static java.lang.String CHUNKONFLY

CHUNKONFLYOFFSET

public static java.lang.String CHUNKONFLYOFFSET

CHUNKONFLYSIZE

public static java.lang.String CHUNKONFLYSIZE

CHUNKEXTENSION

public static java.lang.String CHUNKEXTENSION

HTTPMETHOD

public static java.lang.String HTTPMETHOD

ACCOUNT

public static java.lang.String ACCOUNT

HEADEXTRAPARAMETERS

public static java.lang.String HEADEXTRAPARAMETERS

DELETEAFTERUPLOAD

public static java.lang.String DELETEAFTERUPLOAD

cancelled

protected boolean cancelled

source

protected CustomFilePartSource source

param

protected CustomFilePart param

fout

protected java.io.FileOutputStream fout

pfin

protected java.io.FileInputStream pfin

uploadurl

protected java.lang.String uploadurl

sfullfilename

protected java.lang.String sfullfilename

rfilename

protected java.lang.String rfilename

uploadedfiles

protected java.util.ArrayList uploadedfiles

zip

protected java.io.File zip

processed

protected java.io.File processed
Constructor Detail

HTTPUploadTransfer

public HTTPUploadTransfer()
HTTP upload implementation.

Method Detail

init

public void init()
          throws ClientException
Initialization.

Specified by:
init in interface TransferController
Overrides:
init in class HTTPTransfer
Throws:
ClientException

begin

public void begin()
Start upload thread.

Specified by:
begin in interface TransferController
Specified by:
begin in class HTTPTransfer

run

public void run()
Main upload loop.

Specified by:
run in interface java.lang.Runnable

process

protected void process(java.io.File current)
                throws ClientException
Process upload tasks including filtering.

Parameters:
current -
Throws:
ClientException

processFile

protected void processFile(java.io.File current)
                    throws ClientException
Process basic upload tasks. Optional compression on fly Optional split in chunks Optional retry attempts

Parameters:
current -
Throws:
ClientException

recurseProcess

protected void recurseProcess(java.io.File dir,
                              long level,
                              long depth)
                       throws ClientException
Recurse folders (and sub folders) and process upload tasks. Empty folders are ignored.

Parameters:
dir - directory
level - current depth
depth - ax depth allowed
Throws:
ClientException

splitAndTransfer

protected void splitAndTransfer(java.io.File currentfile)
                         throws ClientException
Split file (if needed) and transfer each chunk with meta data (chunkid, chunkamount, chunkabase). Temporary chunks are created and deleted after upload.

Parameters:
currentfile -
Throws:
ClientException

transferAndRetry

protected void transferAndRetry(java.io.File current,
                                java.util.HashMap meta)
                         throws ClientException
Upload file with optional retry attempts if it fails.

Parameters:
current -
meta -
Throws:
ClientException

transfer

protected void transfer(java.io.File currentfile,
                        java.util.HashMap meta)
                 throws ClientException
Upload current file with optional additional HTTP parameters.

Parameters:
currentfile -
meta - HTTP parameters
Throws:
ClientException

cancel

public void cancel()
Cancel current upload.

Specified by:
cancel in interface TransferController
Specified by:
cancel in class HTTPTransfer

isCancelled

public boolean isCancelled()

getRelativeFilename

protected java.lang.String getRelativeFilename(java.io.File cfile,
                                               java.lang.String cname)

execute

public java.lang.Object execute()
                         throws ClientException
NOT IMPLEMENTED for HTTP UPLOAD transfer. No need for synchronous transfer.

Specified by:
execute in interface TransferController
Specified by:
execute in class HTTPTransfer
Throws:
ClientException

getUploadurl

public java.lang.String getUploadurl()
Returns:
Returns the uploadurl.

setUploadurl

public void setUploadurl(java.lang.String uploadurl)
Parameters:
uploadurl - The uploadurl to set.

getParameters

public java.util.HashMap getParameters(java.lang.String section)
Specified by:
getParameters in interface TransferController
Overrides:
getParameters in class AbstractTransferController