Class UrlConnectionRetrieveFileTransfer
- java.lang.Object
-
- org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
-
- org.eclipse.ecf.provider.filetransfer.retrieve.UrlConnectionRetrieveFileTransfer
-
- All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable,IIdentifiable,IFileTransfer,IFileTransferPausable,IIncomingFileTransfer,IRetrieveFileTransferContainerAdapter,IRetrieveFileTransfer
public class UrlConnectionRetrieveFileTransfer extends AbstractRetrieveFileTransfer
-
-
Field Summary
Fields Modifier and Type Field Description protected inthttpVersionprotected Stringpasswordprotected intresponseCodeprotected StringresponseMessageprotected URLConnectionurlConnectionprotected Stringusername-
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 Constructor Description UrlConnectionRetrieveFileTransfer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconnect()protected booleandoPause()Subclass overridable version ofAbstractRetrieveFileTransfer.pause().protected booleandoResume()Subclass overridable version ofAbstractRetrieveFileTransfer.resume().<T> TgetAdapter(Class<T> adapter)protected StringgetConnectTimeout()StringgetRemoteFileName()Obtains the name of the remote file if possible.intgetResponseCode()protected voidgetResponseHeaderValues()protected voidgetResumeResponseHeaderValues()protected voidhardClose()protected booleanisConnected()protected voidopenStreams()Open incoming and outgoing streams associated with this file transfer.voidsetConnectContextForAuthentication(IConnectContext connectContext)Set connect context for authentication upon subsequentIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map).protected voidsetRequestHeaderValues()protected voidsetResumeRequestHeaderValues()protected voidsetupAuthentication()protected voidsetupProxy(Proxy proxy2)Setup ECF proxy.-
Methods inherited from class org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer
cancel, createJobName, createRangeName, fireReceiveResumedEvent, fireReceiveStartEvent, fireTransferReceiveDataEvent, fireTransferReceiveDoneEvent, fireTransferReceivePausedEvent, getBytesReceived, getException, getFileLength, getFileRangeSpecification, getFinalStatus, getID, getListener, getOptions, getPercentComplete, getRemoteFileURL, getRemoteLastModified, getRetrieveNamespace, getSocketCloseTimeout, getSocketReadTimeout, handleReceivedData, isCanceled, isDone, isPaused, newUserCancelledException, pause, resetDoneAndException, resume, selectProxyFromProxies, sendRetrieveRequest, sendRetrieveRequest, setCloseOutputStream, setDone, setDoneCanceled, setDoneCanceled, setDoneException, setFileLength, setInputStream, setLastModifiedTime, setOutputStream, setProxy, setupAndScheduleJob, setupProxies, targetHasGzSuffix, toHumanReadableBytes, wrapTransferReadInputStream
-
-
-
-
Field Detail
-
urlConnection
protected URLConnection urlConnection
-
httpVersion
protected int httpVersion
-
responseCode
protected int responseCode
-
responseMessage
protected String responseMessage
-
username
protected String username
-
password
protected String password
-
-
Method Detail
-
getRemoteFileName
public String 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.
-
connect
protected void connect() throws IOException- Throws:
IOException
-
isConnected
protected boolean isConnected()
-
setResumeRequestHeaderValues
protected void setResumeRequestHeaderValues() throws IOException- Throws:
IOException
-
setRequestHeaderValues
protected void setRequestHeaderValues() throws InvalidFileRangeSpecificationException
-
getResponseCode
public int getResponseCode()
-
getResponseHeaderValues
protected void getResponseHeaderValues() throws IOException- Throws:
IOException
-
getResumeResponseHeaderValues
protected void getResumeResponseHeaderValues() throws IOException- Throws:
IOException
-
setupProxy
protected void setupProxy(Proxy proxy2)
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:
proxy2- the ECF proxy to setup
-
setupAuthentication
protected void setupAuthentication() throws IOException, UnsupportedCallbackException
-
setConnectContextForAuthentication
public void setConnectContextForAuthentication(IConnectContext connectContext)
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.
-
openStreams
protected void openStreams() throws IncomingFileTransferExceptionDescription 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
-
hardClose
protected void hardClose()
- Overrides:
hardClosein classAbstractRetrieveFileTransfer
-
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.
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdaptable- Overrides:
getAdapterin classAbstractRetrieveFileTransfer
-
getConnectTimeout
protected String getConnectTimeout()
-
-