Class HttpClientRetrieveFileTransfer
java.lang.Object
org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
org.eclipse.ecf.provider.filetransfer.httpclient45.HttpClientRetrieveFileTransfer
- All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable,IIdentifiable,IFileTransfer,IFileTransferPausable,IIncomingFileTransfer,IRetrieveFileTransferContainerAdapter,IRetrieveFileTransfer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IFileIDprotected static final Stringprotected static final intprotected static final Stringprotected static final intprotected intprotected static final intprotected JREProxyHelperprotected 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
ConstructorsConstructorDescriptionHttpClientRetrieveFileTransfer(org.apache.http.impl.client.CloseableHttpClient client) -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Cancel this file transfer.protected voidThis method will clear out the proxy information (so that if this is reused for a request without a proxy, it will work correctly).protected voidprotected Stringprotected booleandoPause()Subclass overridable version ofAbstractRetrieveFileTransfer.pause().protected booleandoResume()Subclass overridable version ofAbstractRetrieveFileTransfer.resume().protected voidprotected voidprotected voidprotected voidprotected void<T> TgetAdapter(Class<T> adapter) protected intprotected org.apache.http.auth.Credentialsprotected static StringgetHostFromURL(String url) getID()Return the ID for this 'identifiable' object.protected static intgetPortFromURL(String url) Obtains the name of the remote file if possible.intprotected voidprotected voidprotected intprotected voidprotected booleanprotected voidOpen incoming and outgoing streams associated with this file transfer.protected FileTransferJobprotected voidvoidsetConnectContextForAuthentication(IConnectContext connectContext) Set connect context for authentication upon subsequentIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map).protected voidprotected voidprotected voidprotected voidsetupAuthentication(String urlString) protected voidprotected voidsetupProxy(Proxy proxy) Setup ECF proxy.static booleansupportsProtocol(String protocolString) protected static booleanurlUsesHttps(String url) protected InputStreamwrapTransferReadInputStream(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.http.impl.client.CloseableHttpClient client)
-
-
Method Details
-
getRemoteFileName
Description copied from interface:IIncomingFileTransferObtains 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:
getRemoteFileNamein interfaceIIncomingFileTransfer- Overrides:
getRemoteFileNamein classAbstractRetrieveFileTransfer- Returns:
- The name of the remote file or
nullif no such name can be determined.
-
cancel
public void cancel()Description copied from interface:IFileTransferCancel 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 anIFileTransferEventbeing delivered to theIFileTransferListenerindicating that transfer is done (IFileTransfer.isDone()returns true), and some exception will be made available- Specified by:
cancelin interfaceIFileTransfer- Overrides:
cancelin classAbstractRetrieveFileTransfer
-
hardClose
protected void hardClose()- Overrides:
hardClosein classAbstractRetrieveFileTransfer
-
getFileRequestCredentials
protected org.apache.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:
setupProxiesin classAbstractRetrieveFileTransfer
-
resetDoneAndException
protected void resetDoneAndException()- Overrides:
resetDoneAndExceptionin classAbstractRetrieveFileTransfer
-
setupAuthentication
protected void setupAuthentication(String urlString) throws UnsupportedCallbackException, IOException -
setRequestHeaderValues
-
getResponseCode
public int getResponseCode() -
getID
Description copied from interface:IIdentifiableReturn the ID for this 'identifiable' object. The returned ID should be unique within its namespace. May returnnull.- Specified by:
getIDin interfaceIIdentifiable- Overrides:
getIDin classAbstractRetrieveFileTransfer- Returns:
- the ID for this identifiable object. May return
null.
-
getResponseHeaderValues
- Throws:
IOException
-
setInputStream
- Overrides:
setInputStreamin classAbstractRetrieveFileTransfer
-
wrapTransferReadInputStream
protected InputStream wrapTransferReadInputStream(InputStream inputStream, org.eclipse.core.runtime.IProgressMonitor monitor) - Overrides:
wrapTransferReadInputStreamin classAbstractRetrieveFileTransfer
-
getSocketReadTimeout
protected int getSocketReadTimeout()- Overrides:
getSocketReadTimeoutin classAbstractRetrieveFileTransfer
-
getConnectTimeout
protected int getConnectTimeout()- Returns:
- int connect timeout
- Since:
- 4.0
-
openStreams
Description copied from class:AbstractRetrieveFileTransferOpen incoming and outgoing streams associated with this file transfer. Subclasses must implement this method to open input and output streams. TheremoteFileContentsandlocalFileContentmust be non-nullafter successful completion of the implementation of this method.- Specified by:
openStreamsin classAbstractRetrieveFileTransfer- Throws:
IncomingFileTransferException- if some problem
-
setConnectContextForAuthentication
Description copied from interface:IRetrieveFileTransferContainerAdapterSet 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:
setConnectContextForAuthenticationin interfaceIRetrieveFileTransferContainerAdapter- Overrides:
setConnectContextForAuthenticationin 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:AbstractRetrieveFileTransferSubclass overridable version ofAbstractRetrieveFileTransfer.pause(). Subclasses must provide an implementation of this method to supportIFileTransferPausable.- Specified by:
doPausein classAbstractRetrieveFileTransfer- Returns:
- true if the pause is successful.
falseotherwise.
-
doResume
protected boolean doResume()Description copied from class:AbstractRetrieveFileTransferSubclass overridable version ofAbstractRetrieveFileTransfer.resume(). Subclasses must provide an implementation of this method to supportIFileTransferPausable.- Specified by:
doResumein classAbstractRetrieveFileTransfer- Returns:
- true if the resume is successful.
falseotherwise.
-
setResumeRequestHeaderValues
protected void setResumeRequestHeaderValues() throws IOException, InvalidFileRangeSpecificationException -
getResumeResponseHeaderValues
- Throws:
IOException
-
getAdapter
- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdaptable- Overrides:
getAdapterin classAbstractRetrieveFileTransfer
-
setupProxy
Description copied from class:AbstractRetrieveFileTransferSetup 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:
setupProxyin 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:
fireReceiveResumedEventin classAbstractRetrieveFileTransfer
-
fireTransferReceiveDataEvent
protected void fireTransferReceiveDataEvent()- Overrides:
fireTransferReceiveDataEventin classAbstractRetrieveFileTransfer
-
fireTransferReceiveDoneEvent
protected void fireTransferReceiveDoneEvent()- Overrides:
fireTransferReceiveDoneEventin classAbstractRetrieveFileTransfer
-
fireTransferReceivePausedEvent
protected void fireTransferReceivePausedEvent()- Overrides:
fireTransferReceivePausedEventin classAbstractRetrieveFileTransfer
-