Class AbstractOutgoingFileTransfer
- java.lang.Object
- 
- org.eclipse.ecf.provider.filetransfer.outgoing.AbstractOutgoingFileTransfer
 
- 
- All Implemented Interfaces:
- org.eclipse.core.runtime.IAdaptable,- IIdentifiable,- IFileTransfer,- IOutgoingFileTransfer,- ISendFileTransferContainerAdapter,- ISendFileTransfer
 - Direct Known Subclasses:
- AbstractUrlConnectionOutgoingFileTransfer,- LocalFileOutgoingFileTransfer
 
 public abstract class AbstractOutgoingFileTransfer extends Object implements IOutgoingFileTransfer, ISendFileTransfer 
- 
- 
Field SummaryFields Modifier and Type Field Description protected intbuff_lengthprotected longbytesSentprotected IConnectContextconnectContextstatic intDEFAULT_BUF_LENGTHprotected booleandoneprotected Exceptionexceptionprotected IFileTransferInfofileTransferInfoprotected org.eclipse.core.runtime.jobs.Jobjobprotected IFileTransferListenerlistenerprotected InputStreamlocalFileContentsprotected Mapoptionsprotected Proxyproxyprotected OutputStreamremoteFileContentsprotected IFileIDremoteFileIDprotected URLremoteFileURL
 - 
Constructor SummaryConstructors Constructor Description AbstractOutgoingFileTransfer()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddListener(IIncomingFileTransferRequestListener l)Add incoming file transfer listener.voidcancel()Cancel this file transfer.protected StringcreateJobName()protected voidfireSendStartEvent()protected voidfireTransferSendDataEvent()protected voidfireTransferSendDoneEvent()ObjectgetAdapter(Class adapter)longgetBytesSent()Get the number of bytes sent for this outgoing file transfer.ExceptiongetException()Get any exception associated with this file transfer.longgetFileLength()Return resulting file length (in bytes) for this file transfer instance.protected IFileTransferInfogetFileTransferInfo()protected org.eclipse.core.runtime.IStatusgetFinalStatus(Throwable exception1)IDgetID()Return the ID for this 'identifiable' object.IFileTransferListenergetListener()protected MapgetOptions()NamespacegetOutgoingNamespace()Get namespace for outgoing file transfer.doublegetPercentComplete()Get the percent complete for this file transfer.protected URLgetRemoteFileURL()protected voidhardClose()booleanisDone()Return true if this file transfer is done, false if not yet completed.protected abstract voidopenStreams()Open incoming and outgoing streams associated with this file transfer.booleanremoveListener(IIncomingFileTransferRequestListener l)Remove incoming file transfer listenerprotected org.eclipse.core.net.proxy.IProxyDataselectProxyFromProxies(String protocol, org.eclipse.core.net.proxy.IProxyData[] proxies)Select a single proxy from a set of proxies available for the given host.voidsendOutgoingRequest(IFileID targetReceiver, File localFileToSend, IFileTransferListener transferListener, Map ops)Send request for outgoing file transfer.voidsendOutgoingRequest(IFileID targetReceiver, IFileTransferInfo localFileToSend, IFileTransferListener transferListener, Map ops)Send request for outgoing file transfer.voidsetConnectContextForAuthentication(IConnectContext connectContext)Set connect context for authentication upon subsequentISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).protected voidsetInputStream(InputStream ins)protected voidsetOutputStream(OutputStream outs)voidsetProxy(Proxy proxy)Set proxy for use upon subsequentISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).protected voidsetupAndScheduleJob()protected voidsetupProxies()protected abstract voidsetupProxy(Proxy proxy)
 
- 
- 
- 
Field Detail- 
DEFAULT_BUF_LENGTHpublic static final int DEFAULT_BUF_LENGTH - See Also:
- Constant Field Values
 
 - 
jobprotected org.eclipse.core.runtime.jobs.Job job 
 - 
remoteFileURLprotected URL remoteFileURL 
 - 
remoteFileIDprotected IFileID remoteFileID 
 - 
listenerprotected IFileTransferListener listener 
 - 
buff_lengthprotected int buff_length 
 - 
doneprotected boolean done 
 - 
bytesSentprotected long bytesSent 
 - 
localFileContentsprotected InputStream localFileContents 
 - 
remoteFileContentsprotected OutputStream remoteFileContents 
 - 
exceptionprotected Exception exception 
 - 
fileTransferInfoprotected IFileTransferInfo fileTransferInfo 
 - 
optionsprotected Map options 
 - 
connectContextprotected IConnectContext connectContext 
 - 
proxyprotected Proxy proxy 
 
- 
 - 
Method Detail- 
getRemoteFileURLprotected URL getRemoteFileURL() 
 - 
setInputStreamprotected void setInputStream(InputStream ins) 
 - 
setOutputStreamprotected void setOutputStream(OutputStream outs) 
 - 
getFileTransferInfoprotected IFileTransferInfo getFileTransferInfo() 
 - 
getOptionsprotected Map getOptions() 
 - 
getFinalStatusprotected org.eclipse.core.runtime.IStatus getFinalStatus(Throwable exception1) 
 - 
hardCloseprotected void hardClose() 
 - 
getIDpublic ID 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 interface- IIdentifiable
- Returns:
- the ID for this identifiable object.  May return null.
 
 - 
fireTransferSendDoneEventprotected void fireTransferSendDoneEvent() 
 - 
fireTransferSendDataEventprotected void fireTransferSendDataEvent() 
 - 
getBytesSentpublic long getBytesSent() Description copied from interface:IOutgoingFileTransferGet the number of bytes sent for this outgoing file transfer. Returns 0 if transfer has not be started, and -1 if underlying provider does not support reporting number of bytes sent during transfer.- Specified by:
- getBytesSentin interface- IOutgoingFileTransfer
- Returns:
- number of bytes sent. Returns 0 if the outgoing file transfer has not been started, and -1 if provider does not support reporting of number of bytes received during transfer
 
 - 
cancelpublic 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 interface- IFileTransfer
 
 - 
getExceptionpublic Exception getException() Description copied from interface:IFileTransferGet any exception associated with this file transfer. The value returned from this method is valid only ifIFileTransfer.isDone()method returns true. If the file transfer completed successfully,IFileTransfer.isDone()will return true, and this method will return null. If the file transfer completed unsuccessfully (some exception occurred), thenIFileTransfer.isDone()will return true, and this method will return a non-null Exception instance that occurred.If the the file transfer was canceled by the user, then the exception returned will be an instance of UserCancelledException.- Specified by:
- getExceptionin interface- IFileTransfer
- Returns:
- Exception associated with this file transfer. nullif transfer completed successfully, non-null if transfer completed with some exception. Only valid afterIFileTransfer.isDone()returns true.
 
 - 
getPercentCompletepublic double getPercentComplete() Description copied from interface:IFileTransferGet the percent complete for this file transfer. The returned value will be either -1.0, meaning that the underlying provider does not support reporting percent complete for this file transfer, or a value between 0 and 1 reflecting the percent complete for this file transfer. If 0.0 no data has been sent, if 1.0, the file transfer is 100 percent complete. The value returned from this method should not be used to determine whether the transfer has completed, as it may not show completion in the event of an transfer failure. Note that theIFileTransfer.isDone()method should be consulted to determine if the file transfer has completed (with or without error).- Specified by:
- getPercentCompletein interface- IFileTransfer
- Returns:
- double percent complete. Returns -1.0 if the underlying provider does not support reporting percentage complete, or between 0 and 1 to indicate actual percent complete for this file transfer
 
 - 
getFileLengthpublic long getFileLength() Description copied from interface:IFileTransferReturn resulting file length (in bytes) for this file transfer instance. If the length is not known, -1 will be returned. Note that if aIFileRangeSpecificationis provided that the returned file length is the expected file length of just the range retrieved (and not the entire file).- Specified by:
- getFileLengthin interface- IFileTransfer
- Returns:
- long file length
 
 - 
isDonepublic boolean isDone() Description copied from interface:IFileTransferReturn true if this file transfer is done, false if not yet completed. The file transfer can be completed successfully, or an exception can occur and the file transfer will have failed. In either case of successful or unsuccessful transfer, this method will return true when the file transfer is complete. To determine whether the transfer completed successfully, it is necessary to also consult theIFileTransfer.getException()method.- Specified by:
- isDonein interface- IFileTransfer
- Returns:
- boolean true if file transfer is done, false if file transfer is still in progress.
 
 - 
getAdapterpublic Object getAdapter(Class adapter) - Specified by:
- getAdapterin interface- org.eclipse.core.runtime.IAdaptable
 
 - 
openStreamsprotected abstract void openStreams() throws SendFileTransferExceptionOpen 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.- Throws:
- SendFileTransferException- if some problem
 
 - 
getOutgoingNamespacepublic Namespace getOutgoingNamespace() Description copied from interface:ISendFileTransferContainerAdapterGet namespace for outgoing file transfer.- Specified by:
- getOutgoingNamespacein interface- ISendFileTransferContainerAdapter
- Returns:
- Namespace for outgoing IFileID instances.  Will not return null.
 
 - 
getListenerpublic IFileTransferListener getListener() 
 - 
createJobNameprotected String createJobName() 
 - 
setupAndScheduleJobprotected void setupAndScheduleJob() 
 - 
fireSendStartEventprotected void fireSendStartEvent() 
 - 
setupProxyprotected abstract void setupProxy(Proxy proxy) 
 - 
setupProxiesprotected void setupProxies() 
 - 
selectProxyFromProxiesprotected org.eclipse.core.net.proxy.IProxyData selectProxyFromProxies(String protocol, org.eclipse.core.net.proxy.IProxyData[] proxies) Select a single proxy from a set of proxies available for the given host. This implementation selects in the following manner: 1) If proxies provided is null or array of 0 length, null is returned. If only one proxy is available (array of length 1) then the entry is returned. If proxies provided is length greater than 1, then if the type of a proxy in the array matches the given protocol (e.g. http, https), then the first matching proxy is returned. If the protocol does not match any of the proxies, then the *first* proxy (i.e. proxies[0]) is returned. Subclasses may override if desired.- Parameters:
- protocol- the target protocol (e.g. http, https, scp, etc). Will not be- null.
- proxies- the proxies to select from. May be- nullor array of length 0.
- Returns:
- proxy data selected from the proxies provided.
 
 - 
sendOutgoingRequestpublic void sendOutgoingRequest(IFileID targetReceiver, IFileTransferInfo localFileToSend, IFileTransferListener transferListener, Map ops) throws SendFileTransferException Description copied from interface:ISendFileTransferContainerAdapterSend request for outgoing file transfer. This method is used to initiate a file transfer to a targetReceiver (first parameter) of the localFileToSend (second parameter). File transfer events are asynchronously delivered to the file transferListener (third parameter)- Specified by:
- sendOutgoingRequestin interface- ISendFileTransferContainerAdapter
- Parameters:
- targetReceiver- the ID of the remote to receive the file transfer request. Must not be should not be- null.
- localFileToSend- the- IFileTransferInfofor the local file to send. Must not be should not be- null.
- transferListener- a- IFileTransferListenerfor responding to file transfer events. Must not be should not be- null.. If the target receiver responds then an- IOutgoingFileTransferResponseEventwill be delivered to the listener
- ops- a Map of options associated with sendOutgoingRequest. The particular name/value pairs will be unique to the individual providers. May be should not be- null..
- Throws:
- SendFileTransferException- if the provider is not connected or is not in the correct state for initiating file transfer
 
 - 
sendOutgoingRequestpublic void sendOutgoingRequest(IFileID targetReceiver, File localFileToSend, IFileTransferListener transferListener, Map ops) throws SendFileTransferException Description copied from interface:ISendFileTransferContainerAdapterSend request for outgoing file transfer. This method is used to initiate a file transfer to a targetReceiver (first parameter) of the localFileToSend (second parameter). File transfer events are asynchronously delivered to the file transferListener (third parameter)- Specified by:
- sendOutgoingRequestin interface- ISendFileTransferContainerAdapter
- Parameters:
- targetReceiver- the ID of the remote to receive the file transfer request. Must not be- null.
- localFileToSend- the- Filefor the local file to send. Must not be- null.
- transferListener- a- IFileTransferListenerfor responding to file transfer events. Must not be- null. If the target receiver responds then an IOutgoingFileTransfer will be delivered to the listener
- ops- a Map of options associated with sendOutgoingRequest. The particular name/value pairs will be unique to the individual providers. May be- null.
- Throws:
- SendFileTransferException- if the provider is not connected or is not in the correct state for initiating file transfer
 
 - 
addListenerpublic void addListener(IIncomingFileTransferRequestListener l) Description copied from interface:ISendFileTransferContainerAdapterAdd incoming file transfer listener. If the underlying provider supports receiving file transfer requests- Specified by:
- addListenerin interface- ISendFileTransferContainerAdapter
- Parameters:
- l- to receive incoming file transfer request events. Must not be- null.
 
 - 
removeListenerpublic boolean removeListener(IIncomingFileTransferRequestListener l) Description copied from interface:ISendFileTransferContainerAdapterRemove incoming file transfer listener- Specified by:
- removeListenerin interface- ISendFileTransferContainerAdapter
- Parameters:
- l- the listener to remove. Must not be- null.
- Returns:
- true if listener actually removed, false otherwise
 
 - 
setConnectContextForAuthenticationpublic void setConnectContextForAuthentication(IConnectContext connectContext) Description copied from interface:ISendFileTransferContainerAdapterSet connect context for authentication upon subsequentISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). This method should be called with a non-null connectContext in order to allow authentication to occur during call toISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).- Specified by:
- setConnectContextForAuthenticationin interface- ISendFileTransferContainerAdapter
- Parameters:
- connectContext- the connect context to use for authenticating during subsequent call to- ISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). If- null, then no authentication will be attempted.
 
 - 
setProxypublic void setProxy(Proxy proxy) Description copied from interface:ISendFileTransferContainerAdapterSet proxy for use upon subsequentISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). This method should be called with a non-null proxy to allow the given proxy to be used in subsequent calls toISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).- Specified by:
- setProxyin interface- ISendFileTransferContainerAdapter
- Parameters:
- proxy- the proxy to use for subsequent calls to- ISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). If- null, then no proxy will be used.
 
 
- 
 
-