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
-
Field Summary
Modifier and TypeFieldDescriptionprotected IFileID
protected static final String
protected static final int
protected static final String
protected static final int
protected int
protected static final int
protected JREProxyHelper
protected static final String[]
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
ConstructorDescriptionHttpClientRetrieveFileTransfer
(org.apache.hc.client5.http.impl.classic.CloseableHttpClient client) -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancel this file transfer.protected void
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
protected String
protected boolean
doPause()
Subclass overridable version ofAbstractRetrieveFileTransfer.pause()
.protected boolean
doResume()
Subclass overridable version ofAbstractRetrieveFileTransfer.resume()
.protected void
protected void
protected void
protected void
protected void
<T> T
getAdapter
(Class<T> adapter) protected int
protected org.apache.hc.client5.http.auth.Credentials
protected static String
getHostFromURL
(String url) getID()
Return the ID for this 'identifiable' object.protected static int
getPortFromURL
(String url) Obtains the name of the remote file if possible.int
protected void
protected void
protected int
protected void
protected boolean
protected void
Open incoming and outgoing streams associated with this file transfer.protected FileTransferJob
protected void
void
setConnectContextForAuthentication
(IConnectContext connectContext) Set connect context for authentication upon subsequentIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map)
.protected void
protected void
protected void
protected void
setupAuthentication
(String urlString) protected void
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
-
Field Details
-
HTTP_PORT
protected static final int HTTP_PORT- See Also:
-
HTTPS_PORT
protected static final int HTTPS_PORT- See Also:
-
MAX_RETRY
protected static final int MAX_RETRY- See Also:
-
HTTPS
- See Also:
-
HTTP
- See Also:
-
supportedProtocols
-
httpVersion
protected int httpVersion -
fileid
-
proxyHelper
-
-
Constructor Details
-
HttpClientRetrieveFileTransfer
public HttpClientRetrieveFileTransfer(org.apache.hc.client5.http.impl.classic.CloseableHttpClient client)
-
-
Method Details
-
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 interfaceIIncomingFileTransfer
- Overrides:
getRemoteFileName
in classAbstractRetrieveFileTransfer
- 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 anIFileTransferEvent
being delivered to theIFileTransferListener
indicating that transfer is done (IFileTransfer.isDone()
returns true), and some exception will be made available- Specified by:
cancel
in interfaceIFileTransfer
- Overrides:
cancel
in classAbstractRetrieveFileTransfer
-
hardClose
protected void hardClose()- Overrides:
hardClose
in classAbstractRetrieveFileTransfer
-
getFileRequestCredentials
protected org.apache.hc.client5.http.auth.Credentials getFileRequestCredentials() throws UnsupportedCallbackException, IOException- Returns:
- Credentials file request credentials
- Throws:
UnsupportedCallbackException
- if some problemIOException
- if some problem- Since:
- 5.0
-
setupProxies
protected void setupProxies()- Overrides:
setupProxies
in classAbstractRetrieveFileTransfer
-
resetDoneAndException
protected void resetDoneAndException()- Overrides:
resetDoneAndException
in classAbstractRetrieveFileTransfer
-
setupAuthentication
protected void setupAuthentication(String urlString) throws UnsupportedCallbackException, IOException -
setRequestHeaderValues
-
getResponseCode
public int getResponseCode() -
getID
Description copied from interface:IIdentifiable
Return the ID for this 'identifiable' object. The returned ID should be unique within its namespace. May returnnull
.- Specified by:
getID
in interfaceIIdentifiable
- Overrides:
getID
in classAbstractRetrieveFileTransfer
- Returns:
- the ID for this identifiable object. May return
null
.
-
getResponseHeaderValues
- Throws:
IOException
-
setInputStream
- Overrides:
setInputStream
in classAbstractRetrieveFileTransfer
-
wrapTransferReadInputStream
protected InputStream wrapTransferReadInputStream(InputStream inputStream, org.eclipse.core.runtime.IProgressMonitor monitor) - Overrides:
wrapTransferReadInputStream
in classAbstractRetrieveFileTransfer
-
getSocketReadTimeout
protected int getSocketReadTimeout()- Overrides:
getSocketReadTimeout
in classAbstractRetrieveFileTransfer
-
getConnectTimeout
protected int getConnectTimeout()- Returns:
- int connect timeout
- Since:
- 4.0
-
openStreams
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. TheremoteFileContents
andlocalFileContent
must be non-null
after successful completion of the implementation of this method.- Specified by:
openStreams
in classAbstractRetrieveFileTransfer
- Throws:
IncomingFileTransferException
- if some problem
-
setConnectContextForAuthentication
Description copied from interface:IRetrieveFileTransferContainerAdapter
Set connect context for authentication upon subsequentIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map)
. This method should be called with a non-null connectContext in order to allow authentication to occur during call toIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map)
.- Specified by:
setConnectContextForAuthentication
in interfaceIRetrieveFileTransferContainerAdapter
- Overrides:
setConnectContextForAuthentication
in classAbstractRetrieveFileTransfer
- Parameters:
connectContext
- the connect context to use for authenticating during subsequent call toIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map)
. Ifnull
, then no authentication will be attempted.
-
getHostFromURL
-
getPortFromURL
-
urlUsesHttps
-
supportsProtocol
-
isConnected
protected boolean isConnected() -
doPause
protected boolean doPause()Description copied from class:AbstractRetrieveFileTransfer
Subclass overridable version ofAbstractRetrieveFileTransfer.pause()
. Subclasses must provide an implementation of this method to supportIFileTransferPausable
.- Specified by:
doPause
in classAbstractRetrieveFileTransfer
- Returns:
- true if the pause is successful.
false
otherwise.
-
doResume
protected boolean doResume()Description copied from class:AbstractRetrieveFileTransfer
Subclass overridable version ofAbstractRetrieveFileTransfer.resume()
. Subclasses must provide an implementation of this method to supportIFileTransferPausable
.- Specified by:
doResume
in classAbstractRetrieveFileTransfer
- Returns:
- true if the resume is successful.
false
otherwise.
-
setResumeRequestHeaderValues
protected void setResumeRequestHeaderValues() throws IOException, InvalidFileRangeSpecificationException -
getResumeResponseHeaderValues
- Throws:
IOException
-
getAdapter
- Specified by:
getAdapter
in interfaceorg.eclipse.core.runtime.IAdaptable
- Overrides:
getAdapter
in classAbstractRetrieveFileTransfer
-
setupProxy
Description copied from class:AbstractRetrieveFileTransfer
Setup ECF proxy. Subclasses must override this method to do appropriate proxy setup. This method will be called from withinAbstractRetrieveFileTransfer.sendRetrieveRequest(IFileID, IFileTransferListener, Map)
andAbstractRetrieveFileTransfer.sendRetrieveRequest(IFileID, IFileRangeSpecification, IFileTransferListener, Map)
, prior to the actual call toAbstractRetrieveFileTransfer.openStreams()
.- Specified by:
setupProxy
in classAbstractRetrieveFileTransfer
- Parameters:
proxy
- the proxy to be setup. Will not benull
.
-
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
-
prepareConnectJob
-
connectUsingJob
-
fireReceiveResumedEvent
protected void fireReceiveResumedEvent()- Overrides:
fireReceiveResumedEvent
in classAbstractRetrieveFileTransfer
-
fireTransferReceiveDataEvent
protected void fireTransferReceiveDataEvent()- Overrides:
fireTransferReceiveDataEvent
in classAbstractRetrieveFileTransfer
-
fireTransferReceiveDoneEvent
protected void fireTransferReceiveDoneEvent()- Overrides:
fireTransferReceiveDoneEvent
in classAbstractRetrieveFileTransfer
-
fireTransferReceivePausedEvent
protected void fireTransferReceivePausedEvent()- Overrides:
fireTransferReceivePausedEvent
in classAbstractRetrieveFileTransfer
-