Class AbstractOutgoingFileTransfer

    • Field Detail

      • job

        protected org.eclipse.core.runtime.jobs.Job job
      • remoteFileURL

        protected URL remoteFileURL
      • remoteFileID

        protected IFileID remoteFileID
      • buff_length

        protected int buff_length
      • done

        protected boolean done
      • bytesSent

        protected long bytesSent
      • localFileContents

        protected InputStream localFileContents
      • remoteFileContents

        protected OutputStream remoteFileContents
      • options

        protected Map options
      • proxy

        protected Proxy proxy
    • Constructor Detail

      • AbstractOutgoingFileTransfer

        public AbstractOutgoingFileTransfer()
    • Method Detail

      • getRemoteFileURL

        protected URL getRemoteFileURL()
      • setInputStream

        protected void setInputStream​(InputStream ins)
      • setOutputStream

        protected void setOutputStream​(OutputStream outs)
      • getOptions

        protected Map getOptions()
      • getFinalStatus

        protected org.eclipse.core.runtime.IStatus getFinalStatus​(Throwable exception1)
      • hardClose

        protected void hardClose()
      • getID

        public ID getID()
        Description copied from interface: IIdentifiable
        Return the ID for this 'identifiable' object. The returned ID should be unique within its namespace. May return null.
        Specified by:
        getID in interface IIdentifiable
        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: IOutgoingFileTransfer
        Get 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:
        getBytesSent in 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
      • 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 an IFileTransferEvent being delivered to the IFileTransferListener indicating that transfer is done (IFileTransfer.isDone() returns true), and some exception will be made available
        Specified by:
        cancel in interface IFileTransfer
      • getException

        public Exception getException()
        Description copied from interface: IFileTransfer
        Get any exception associated with this file transfer. The value returned from this method is valid only if IFileTransfer.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), then IFileTransfer.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:
        getException in interface IFileTransfer
        Returns:
        Exception associated with this file transfer. null if transfer completed successfully, non-null if transfer completed with some exception. Only valid after IFileTransfer.isDone() returns true.
      • getPercentComplete

        public double getPercentComplete()
        Description copied from interface: IFileTransfer
        Get 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 the IFileTransfer.isDone() method should be consulted to determine if the file transfer has completed (with or without error).
        Specified by:
        getPercentComplete in 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
      • getFileLength

        public long getFileLength()
        Description copied from interface: IFileTransfer
        Return resulting file length (in bytes) for this file transfer instance. If the length is not known, -1 will be returned. Note that if a IFileRangeSpecification is provided that the returned file length is the expected file length of just the range retrieved (and not the entire file).
        Specified by:
        getFileLength in interface IFileTransfer
        Returns:
        long file length
      • isDone

        public boolean isDone()
        Description copied from interface: IFileTransfer
        Return 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 the IFileTransfer.getException() method.
        Specified by:
        isDone in interface IFileTransfer
        Returns:
        boolean true if file transfer is done, false if file transfer is still in progress.
      • getAdapter

        public Object getAdapter​(Class adapter)
        Specified by:
        getAdapter in interface org.eclipse.core.runtime.IAdaptable
      • openStreams

        protected abstract void openStreams()
                                     throws SendFileTransferException
        Open incoming and outgoing streams associated with this file transfer. Subclasses must implement this method to open input and output streams. The remoteFileContents and localFileContent must be non-null after successful completion of the implementation of this method.
        Throws:
        SendFileTransferException - if some problem
      • createJobName

        protected String createJobName()
      • setupAndScheduleJob

        protected void setupAndScheduleJob()
      • fireSendStartEvent

        protected void fireSendStartEvent()
      • setupProxy

        protected abstract void setupProxy​(Proxy proxy)
      • 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 be null.
        proxies - the proxies to select from. May be null or 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: ISendFileTransferContainerAdapter
        Send 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:
        sendOutgoingRequest in interface ISendFileTransferContainerAdapter
        Parameters:
        targetReceiver - the ID of the remote to receive the file transfer request. Must not be should not be null.
        localFileToSend - the IFileTransferInfo for the local file to send. Must not be should not be null.
        transferListener - a IFileTransferListener for responding to file transfer events. Must not be should not be null.. If the target receiver responds then an IOutgoingFileTransferResponseEvent 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 should not be null..
        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: ISendFileTransferContainerAdapter
        Send 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:
        sendOutgoingRequest in interface ISendFileTransferContainerAdapter
        Parameters:
        targetReceiver - the ID of the remote to receive the file transfer request. Must not be null.
        localFileToSend - the File for the local file to send. Must not be null.
        transferListener - a IFileTransferListener for 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