Package org.eclipse.ecf.provider.filetransfer.httpclient5

## Class HttpClientRetrieveFileTransfer

- java.lang.Object
- - org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
  - - org.eclipse.ecf.provider.filetransfer.httpclient5.HttpClientRetrieveFileTransfer

All Implemented Interfaces:
  `org.eclipse.core.runtime.IAdaptable`, `IIdentifiable`, `IFileTransfer`, `IFileTransferPausable`, `IIncomingFileTransfer`, `IRetrieveFileTransferContainerAdapter`, `IRetrieveFileTransfer`

    public class HttpClientRetrieveFileTransfer
    extends AbstractRetrieveFileTransfer

### Field Summary

Fields
`protected IFileID` `fileid`
`protected static String` `HTTP`
`protected static int` `HTTP_PORT`
`protected static String` `HTTPS`
`protected static int` `HTTPS_PORT`
`protected int` `httpVersion`
`protected static int` `MAX_RETRY`
`protected JREProxyHelper` `proxyHelper`
`protected static 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

Constructors
`HttpClientRetrieveFileTransfer​(org.apache.hc.client5.http.impl.classic.CloseableHttpClient client)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`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 String` `createConnectJobName()`
`protected boolean` `doPause()` Subclass overridable version of `AbstractRetrieveFileTransfer.pause()`.
`protected boolean` `doResume()` Subclass overridable version of `AbstractRetrieveFileTransfer.resume()`.
`protected void` `fireConnectStartEvent()`
`protected void` `fireReceiveResumedEvent()`
`protected void` `fireTransferReceiveDataEvent()`
`protected void` `fireTransferReceiveDoneEvent()`
`protected void` `fireTransferReceivePausedEvent()`
`<T> T` `getAdapter​(Class<T> adapter)`
`protected int` `getConnectTimeout()`
`protected org.apache.hc.client5.http.auth.Credentials` `getFileRequestCredentials()`
`protected static String` `getHostFromURL​(String url)`
`ID` `getID()` Return the ID for this 'identifiable' object.
`protected static int` `getPortFromURL​(String url)`
`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` `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​(InputStream ins)`
`protected void` `setRequestHeaderValues()`
`protected void` `setResumeRequestHeaderValues()`
`protected void` `setupAuthentication​(String urlString)`
`protected void` `setupProxies()`
`protected void` `setupProxy​(Proxy proxy)` Setup ECF proxy.
`static boolean` `supportsProtocol​(String protocolString)`
`protected static boolean` `urlUsesHttps​(String url)`
`protected InputStream` `wrapTransferReadInputStream​(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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### 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 String HTTPS

See Also:
  Constant Field Values

#### HTTP

    protected static final String HTTP

See Also:
  Constant Field Values

#### supportedProtocols

    protected static final String[] supportedProtocols

#### httpVersion

    protected int httpVersion

#### fileid

    protected IFileID fileid

#### proxyHelper

    protected JREProxyHelper proxyHelper

### Constructor Detail

#### HttpClientRetrieveFileTransfer

    public HttpClientRetrieveFileTransfer​(org.apache.hc.client5.http.impl.classic.CloseableHttpClient client)

### Method Detail

#### getRemoteFileName

    public 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 org.apache.hc.client5.http.auth.Credentials getFileRequestCredentials()
                                                                             throws UnsupportedCallbackException,
                                                                                    IOException

Returns:
  Credentials file request credentials
Throws:
  `UnsupportedCallbackException` - if some problem
  `IOException` - if some problem
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​(String urlString)
                                throws UnsupportedCallbackException,
                                       IOException

Throws:
  `UnsupportedCallbackException`
  `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 IOException

Throws:
  `IOException`

#### setInputStream

    protected void setInputStream​(InputStream ins)

Overrides:
  `setInputStream` in class `AbstractRetrieveFileTransfer`

#### wrapTransferReadInputStream

    protected InputStream wrapTransferReadInputStream​(InputStream inputStream,
                                                      org.eclipse.core.runtime.IProgressMonitor monitor)

Overrides:
  `wrapTransferReadInputStream` in class `AbstractRetrieveFileTransfer`

#### getSocketReadTimeout

    protected int getSocketReadTimeout()

Overrides:
  `getSocketReadTimeout` in class `AbstractRetrieveFileTransfer`

#### getConnectTimeout

    protected int getConnectTimeout()

Returns:
  int connect timeout
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` - if some problem

#### 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 String getHostFromURL​(String url)

#### getPortFromURL

    protected static int getPortFromURL​(String url)

#### urlUsesHttps

    protected static boolean urlUsesHttps​(String url)

#### supportsProtocol

    public static boolean supportsProtocol​(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 IOException,
                                                InvalidFileRangeSpecificationException

Throws:
  `IOException`
  `InvalidFileRangeSpecificationException`

#### getResumeResponseHeaderValues

    protected void getResumeResponseHeaderValues()
                                          throws IOException

Throws:
  `IOException`

#### getAdapter

    public <T> T getAdapter​(Class<T> 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

#### fireConnectStartEvent

    protected void fireConnectStartEvent()

#### createConnectJobName

    protected String createConnectJobName()

#### prepareConnectJob

    protected FileTransferJob prepareConnectJob​(FileTransferJob cjob)

#### connectUsingJob

    protected void connectUsingJob​(FileTransferJob cjob)

#### 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`