org.eclipse.ecf.provider.filetransfer.httpclient4
Class HttpClientRetrieveFileTransfer

java.lang.Object
  extended by org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
      extended by org.eclipse.ecf.provider.filetransfer.httpclient4.HttpClientRetrieveFileTransfer
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IIdentifiable, IFileTransfer, IFileTransferPausable, IIncomingFileTransfer, IRetrieveFileTransferContainerAdapter, IRetrieveFileTransfer

public class HttpClientRetrieveFileTransfer
extends AbstractRetrieveFileTransfer


Field Summary
protected static int DEFAULT_CONNECTION_TIMEOUT
           
protected static int DEFAULT_READ_TIMEOUT
           
protected  IFileID fileid
           
protected static java.lang.String HTTP
           
protected static int HTTP_PORT
           
protected static java.lang.String HTTPS
           
protected static int HTTPS_PORT
           
protected  int httpVersion
           
protected static int MAX_RETRY
           
protected  JREProxyHelper proxyHelper
           
protected static java.lang.String[] supportedProtocols
           
 
Fields inherited from class org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
buff_length, bytesReceived, CLOSE_TIMEOUT, closeOutputStream, connectContext, DEFAULT_BUF_LENGTH, done, downloadRateBytesPerSecond, exception, fileLength, job, jobLock, lastModifiedTime, listener, localFileContents, options, paused, POLLING_RETRY_ATTEMPTS, proxy, rangeSpecification, READ_TIMEOUT, remoteFileContents, remoteFileID, remoteFileURL, responseHeaders, TIMEOUT_INPUTSTREAM_BUFFER_SIZE, transferStartTime
 
Constructor Summary
HttpClientRetrieveFileTransfer(DefaultHttpClient httpClient)
           
 
Method Summary
 void cancel()
          Cancel this file transfer.
protected  void clearProxy()
          This method will clear out the proxy information (so that if this is reused for a request without a proxy, it will work correctly).
protected  void connectUsingJob(FileTransferJob cjob)
           
protected  java.lang.String createConnectJobName()
           
static NTCredentials createNTLMCredentials(Proxy p)
           
protected  boolean doPause()
          Subclass overridable version of AbstractRetrieveFileTransfer.pause().
protected  boolean doResume()
          Subclass overridable version of AbstractRetrieveFileTransfer.resume().
protected  void finalize()
           
protected  void fireConnectStartEvent()
           
protected  void fireReceiveResumedEvent()
           
protected  void fireTransferReceiveDataEvent()
           
protected  void fireTransferReceiveDoneEvent()
           
protected  void fireTransferReceivePausedEvent()
           
 java.lang.Object getAdapter(java.lang.Class adapter)
           
protected  int getConnectTimeout()
           
protected  Credentials getFileRequestCredentials()
           
protected static java.lang.String getHostFromURL(java.lang.String url)
           
 ID getID()
          Return the ID for this 'identifiable' object.
protected static java.lang.String getNTLMDomainName(Proxy p)
           
protected static java.lang.String getNTLMUserName(Proxy p)
           
protected static int getPortFromURL(java.lang.String url)
           
 java.lang.String getRemoteFileName()
          Obtains the name of the remote file if possible.
 int getResponseCode()
           
protected  void getResponseHeaderValues()
           
protected  void getResumeResponseHeaderValues()
           
protected  int getSocketReadTimeout()
           
protected  void hardClose()
           
protected  boolean hasForceNTLMProxyOption()
           
protected  boolean isConnected()
           
protected  void openStreams()
          Open incoming and outgoing streams associated with this file transfer.
protected  FileTransferJob prepareConnectJob(FileTransferJob cjob)
           
protected  void resetDoneAndException()
           
 void setConnectContextForAuthentication(IConnectContext connectContext)
          Set connect context for authentication upon subsequent IRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map).
protected  void setInputStream(java.io.InputStream ins)
           
protected  void setRequestHeaderValues()
           
protected  void setResumeRequestHeaderValues()
           
protected  void setupAuthentication(java.lang.String urlString)
           
protected  void setupProxies()
           
protected  void setupProxy(Proxy proxy)
          Setup ECF proxy.
static boolean supportsProtocol(java.lang.String protocolString)
           
protected static boolean urlUsesHttps(java.lang.String url)
           
protected  java.io.InputStream wrapTransferReadInputStream(java.io.InputStream inputStream, org.eclipse.core.runtime.IProgressMonitor monitor)
           
 
Methods inherited from class org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
createJobName, createRangeName, fireReceiveStartEvent, getBytesReceived, getException, getFileLength, getFileRangeSpecification, getFinalStatus, getListener, getOptions, getPercentComplete, getRemoteFileURL, getRemoteLastModified, getRetrieveNamespace, getSocketCloseTimeout, handleReceivedData, isCanceled, isDone, isPaused, newUserCancelledException, pause, resume, selectProxyFromProxies, sendRetrieveRequest, sendRetrieveRequest, setCloseOutputStream, setDone, setDoneCanceled, setDoneCanceled, setDoneException, setFileLength, setLastModifiedTime, setOutputStream, setProxy, setupAndScheduleJob, targetHasGzSuffix, toHumanReadableBytes
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONNECTION_TIMEOUT

protected static final int DEFAULT_CONNECTION_TIMEOUT

DEFAULT_READ_TIMEOUT

protected static final int DEFAULT_READ_TIMEOUT

HTTP_PORT

protected static final int HTTP_PORT
See Also:
Constant Field Values

HTTPS_PORT

protected static final int HTTPS_PORT
See Also:
Constant Field Values

MAX_RETRY

protected static final int MAX_RETRY
See Also:
Constant Field Values

HTTPS

protected static final java.lang.String HTTPS

HTTP

protected static final java.lang.String HTTP

supportedProtocols

protected static final java.lang.String[] supportedProtocols

httpVersion

protected int httpVersion

fileid

protected IFileID fileid

proxyHelper

protected JREProxyHelper proxyHelper
Constructor Detail

HttpClientRetrieveFileTransfer

public HttpClientRetrieveFileTransfer(DefaultHttpClient httpClient)
Since:
5.0
Method Detail

getRemoteFileName

public java.lang.String getRemoteFileName()
Description copied from interface: IIncomingFileTransfer
Obtains the name of the remote file if possible. The name will typically but not necessarily be the same as the leaf part of the path to the remote file.

Specified by:
getRemoteFileName in interface IIncomingFileTransfer
Overrides:
getRemoteFileName in class AbstractRetrieveFileTransfer
Returns:
The name of the remote file or null if no such name can be determined.

cancel

public void cancel()
Description copied from interface: IFileTransfer
Cancel this file transfer. If file transfer has already been completed, then this method has no effect. If the file transfer has not been completed then calling this method will result in an IFileTransferEvent being delivered to the IFileTransferListener indicating that transfer is done (IFileTransfer.isDone() returns true), and some exception will be made available

Specified by:
cancel in interface IFileTransfer
Overrides:
cancel in class AbstractRetrieveFileTransfer

hardClose

protected void hardClose()
Overrides:
hardClose in class AbstractRetrieveFileTransfer

getFileRequestCredentials

protected Credentials getFileRequestCredentials()
                                         throws UnsupportedCallbackException,
                                                java.io.IOException
Throws:
UnsupportedCallbackException
java.io.IOException
Since:
5.0

setupProxies

protected void setupProxies()
Overrides:
setupProxies in class AbstractRetrieveFileTransfer

resetDoneAndException

protected void resetDoneAndException()
Overrides:
resetDoneAndException in class AbstractRetrieveFileTransfer

setupAuthentication

protected void setupAuthentication(java.lang.String urlString)
                            throws UnsupportedCallbackException,
                                   java.io.IOException
Throws:
UnsupportedCallbackException
java.io.IOException

setRequestHeaderValues

protected void setRequestHeaderValues()
                               throws InvalidFileRangeSpecificationException
Throws:
InvalidFileRangeSpecificationException

getResponseCode

public int getResponseCode()

getID

public ID getID()
Description copied from interface: IIdentifiable
Return the ID for this 'identifiable' object. The returned ID should be unique within its namespace. May return null.

Specified by:
getID in interface IIdentifiable
Overrides:
getID in class AbstractRetrieveFileTransfer
Returns:
the ID for this identifiable object. May return null.

getResponseHeaderValues

protected void getResponseHeaderValues()
                                throws java.io.IOException
Throws:
java.io.IOException

setInputStream

protected void setInputStream(java.io.InputStream ins)
Overrides:
setInputStream in class AbstractRetrieveFileTransfer

wrapTransferReadInputStream

protected java.io.InputStream wrapTransferReadInputStream(java.io.InputStream inputStream,
                                                          org.eclipse.core.runtime.IProgressMonitor monitor)
Overrides:
wrapTransferReadInputStream in class AbstractRetrieveFileTransfer

hasForceNTLMProxyOption

protected boolean hasForceNTLMProxyOption()

getSocketReadTimeout

protected int getSocketReadTimeout()
Overrides:
getSocketReadTimeout in class AbstractRetrieveFileTransfer

getConnectTimeout

protected int getConnectTimeout()
Since:
4.0

openStreams

protected void openStreams()
                    throws IncomingFileTransferException
Description copied from class: AbstractRetrieveFileTransfer
Open incoming and outgoing streams associated with this file transfer. Subclasses must implement this method to open input and output streams. The remoteFileContents and localFileContent must be non-null after successful completion of the implementation of this method.

Specified by:
openStreams in class AbstractRetrieveFileTransfer
Throws:
IncomingFileTransferException

setConnectContextForAuthentication

public void setConnectContextForAuthentication(IConnectContext connectContext)
Description copied from interface: IRetrieveFileTransferContainerAdapter
Set connect context for authentication upon subsequent IRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map). This method should be called with a non-null connectContext in order to allow authentication to occur during call to IRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map).

Specified by:
setConnectContextForAuthentication in interface IRetrieveFileTransferContainerAdapter
Overrides:
setConnectContextForAuthentication in class AbstractRetrieveFileTransfer
Parameters:
connectContext - the connect context to use for authenticating during subsequent call to IRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map). If null, then no authentication will be attempted.

getHostFromURL

protected static java.lang.String getHostFromURL(java.lang.String url)

getPortFromURL

protected static int getPortFromURL(java.lang.String url)

urlUsesHttps

protected static boolean urlUsesHttps(java.lang.String url)

supportsProtocol

public static boolean supportsProtocol(java.lang.String protocolString)

isConnected

protected boolean isConnected()

doPause

protected boolean doPause()
Description copied from class: AbstractRetrieveFileTransfer
Subclass overridable version of AbstractRetrieveFileTransfer.pause(). Subclasses must provide an implementation of this method to support IFileTransferPausable .

Specified by:
doPause in class AbstractRetrieveFileTransfer
Returns:
true if the pause is successful. false otherwise.

doResume

protected boolean doResume()
Description copied from class: AbstractRetrieveFileTransfer
Subclass overridable version of AbstractRetrieveFileTransfer.resume(). Subclasses must provide an implementation of this method to support IFileTransferPausable.

Specified by:
doResume in class AbstractRetrieveFileTransfer
Returns:
true if the resume is successful. false otherwise.

setResumeRequestHeaderValues

protected void setResumeRequestHeaderValues()
                                     throws java.io.IOException
Throws:
java.io.IOException

getResumeResponseHeaderValues

protected void getResumeResponseHeaderValues()
                                      throws java.io.IOException
Throws:
java.io.IOException

getAdapter

public java.lang.Object getAdapter(java.lang.Class adapter)
Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable
Overrides:
getAdapter in class AbstractRetrieveFileTransfer

setupProxy

protected void setupProxy(Proxy proxy)
Description copied from class: AbstractRetrieveFileTransfer
Setup ECF proxy. Subclasses must override this method to do appropriate proxy setup. This method will be called from within AbstractRetrieveFileTransfer.sendRetrieveRequest(IFileID, IFileTransferListener, Map) and AbstractRetrieveFileTransfer.sendRetrieveRequest(IFileID, IFileRangeSpecification, IFileTransferListener, Map) , prior to the actual call to AbstractRetrieveFileTransfer.openStreams().

Specified by:
setupProxy in class AbstractRetrieveFileTransfer
Parameters:
proxy - the proxy to be setup. Will not be null.

clearProxy

protected void clearProxy()
This method will clear out the proxy information (so that if this is reused for a request without a proxy, it will work correctly).

Since:
5.0

createNTLMCredentials

public static NTCredentials createNTLMCredentials(Proxy p)
Since:
5.0

getNTLMDomainName

protected static java.lang.String getNTLMDomainName(Proxy p)

getNTLMUserName

protected static java.lang.String getNTLMUserName(Proxy p)

fireConnectStartEvent

protected void fireConnectStartEvent()

createConnectJobName

protected java.lang.String createConnectJobName()

prepareConnectJob

protected FileTransferJob prepareConnectJob(FileTransferJob cjob)

connectUsingJob

protected void connectUsingJob(FileTransferJob cjob)

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

fireReceiveResumedEvent

protected void fireReceiveResumedEvent()
Overrides:
fireReceiveResumedEvent in class AbstractRetrieveFileTransfer

fireTransferReceiveDataEvent

protected void fireTransferReceiveDataEvent()
Overrides:
fireTransferReceiveDataEvent in class AbstractRetrieveFileTransfer

fireTransferReceiveDoneEvent

protected void fireTransferReceiveDoneEvent()
Overrides:
fireTransferReceiveDoneEvent in class AbstractRetrieveFileTransfer

fireTransferReceivePausedEvent

protected void fireTransferReceivePausedEvent()
Overrides:
fireTransferReceivePausedEvent in class AbstractRetrieveFileTransfer