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 Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected longprotected IConnectContextstatic final intprotected booleanprotected Exceptionprotected IFileTransferInfoprotected org.eclipse.core.runtime.jobs.Jobprotected IFileTransferListenerprotected InputStreamprotected Mapprotected Proxyprotected OutputStreamprotected IFileIDprotected URL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd incoming file transfer listener.voidcancel()Cancel this file transfer.protected Stringprotected voidprotected voidprotected voidgetAdapter(Class adapter) longGet the number of bytes sent for this outgoing file transfer.Get any exception associated with this file transfer.longReturn resulting file length (in bytes) for this file transfer instance.protected IFileTransferInfoprotected org.eclipse.core.runtime.IStatusgetFinalStatus(Throwable exception1) getID()Return the ID for this 'identifiable' object.protected MapGet namespace for outgoing file transfer.doubleGet the percent complete for this file transfer.protected URLprotected voidbooleanisDone()Return true if this file transfer is done, false if not yet completed.protected abstract voidOpen incoming and outgoing streams associated with this file transfer.booleanRemove 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 voidprotected voidsetOutputStream(OutputStream outs) voidSet proxy for use upon subsequentISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map).protected voidprotected voidprotected abstract voidsetupProxy(Proxy proxy)
-
Field Details
-
DEFAULT_BUF_LENGTH
public static final int DEFAULT_BUF_LENGTH- See Also:
-
job
protected org.eclipse.core.runtime.jobs.Job job -
remoteFileURL
-
remoteFileID
-
listener
-
buff_length
protected int buff_length -
done
protected boolean done -
bytesSent
protected long bytesSent -
localFileContents
-
remoteFileContents
-
exception
-
fileTransferInfo
-
options
-
connectContext
-
proxy
-
-
Constructor Details
-
AbstractOutgoingFileTransfer
public AbstractOutgoingFileTransfer()
-
-
Method Details
-
getRemoteFileURL
-
setInputStream
-
setOutputStream
-
getFileTransferInfo
-
getOptions
-
getFinalStatus
-
hardClose
protected void hardClose() -
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- Returns:
- the ID for this identifiable object. May return
null.
-
fireTransferSendDoneEvent
protected void fireTransferSendDoneEvent() -
fireTransferSendDataEvent
protected void fireTransferSendDataEvent() -
getBytesSent
public 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 interfaceIOutgoingFileTransfer- 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
-
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
-
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 interfaceIFileTransfer- 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.
-
getPercentComplete
public 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 interfaceIFileTransfer- 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
-
getFileLength
public 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 interfaceIFileTransfer- Returns:
- long file length
-
isDone
public 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 interfaceIFileTransfer- Returns:
- boolean true if file transfer is done, false if file transfer is still in progress.
-
getAdapter
- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdaptable
-
openStreams
Open 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
-
getOutgoingNamespace
Description copied from interface:ISendFileTransferContainerAdapterGet namespace for outgoing file transfer.- Specified by:
getOutgoingNamespacein interfaceISendFileTransferContainerAdapter- Returns:
- Namespace for outgoing IFileID instances. Will not return
null.
-
getListener
-
createJobName
-
setupAndScheduleJob
protected void setupAndScheduleJob() -
fireSendStartEvent
protected void fireSendStartEvent() -
setupProxy
-
setupProxies
protected void setupProxies() -
selectProxyFromProxies
protected 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 benull.proxies- the proxies to select from. May benullor array of length 0.- Returns:
- proxy data selected from the proxies provided.
-
sendOutgoingRequest
public 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 interfaceISendFileTransferContainerAdapter- Parameters:
targetReceiver- the ID of the remote to receive the file transfer request. Must not be should not benull.localFileToSend- theIFileTransferInfofor the local file to send. Must not be should not benull.transferListener- aIFileTransferListenerfor responding to file transfer events. Must not be should not benull.. If the target receiver responds then anIOutgoingFileTransferResponseEventwill be delivered to the listenerops- a Map of options associated with sendOutgoingRequest. The particular name/value pairs will be unique to the individual providers. May be should not benull..- Throws:
SendFileTransferException- if the provider is not connected or is not in the correct state for initiating file transfer
-
sendOutgoingRequest
public 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 interfaceISendFileTransferContainerAdapter- Parameters:
targetReceiver- the ID of the remote to receive the file transfer request. Must not benull.localFileToSend- theFilefor the local file to send. Must not benull.transferListener- aIFileTransferListenerfor responding to file transfer events. Must not benull. If the target receiver responds then an IOutgoingFileTransfer will be delivered to the listenerops- a Map of options associated with sendOutgoingRequest. The particular name/value pairs will be unique to the individual providers. May benull.- Throws:
SendFileTransferException- if the provider is not connected or is not in the correct state for initiating file transfer
-
addListener
Description copied from interface:ISendFileTransferContainerAdapterAdd incoming file transfer listener. If the underlying provider supports receiving file transfer requests- Specified by:
addListenerin interfaceISendFileTransferContainerAdapter- Parameters:
l- to receive incoming file transfer request events. Must not benull.
-
removeListener
Description copied from interface:ISendFileTransferContainerAdapterRemove incoming file transfer listener- Specified by:
removeListenerin interfaceISendFileTransferContainerAdapter- Parameters:
l- the listener to remove. Must not benull.- Returns:
- true if listener actually removed, false otherwise
-
setConnectContextForAuthentication
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 interfaceISendFileTransferContainerAdapter- Parameters:
connectContext- the connect context to use for authenticating during subsequent call toISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). Ifnull, then no authentication will be attempted.
-
setProxy
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 interfaceISendFileTransferContainerAdapter- Parameters:
proxy- the proxy to use for subsequent calls toISendFileTransferContainerAdapter.sendOutgoingRequest(IFileID, IFileTransferInfo, IFileTransferListener, Map). Ifnull, then no proxy will be used.
-