Class MultiProtocolRetrieveAdapter
- java.lang.Object
-
- org.eclipse.ecf.provider.filetransfer.retrieve.MultiProtocolRetrieveAdapter
-
- All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable,IRetrieveFileTransferContainerAdapter,IRetrieveFileTransfer
public class MultiProtocolRetrieveAdapter extends Object implements IRetrieveFileTransfer
Multi protocol handler for retrieve file transfer. Multiplexes between Apache httpclient 3.0.1-based file retriever and the URLConnection-based file retriever.
-
-
Constructor Summary
Constructors Constructor Description MultiProtocolRetrieveAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetAdapter(Class<T> adapter)NamespacegetRetrieveNamespace()Get namespace to be used for creation of remoteFileID for retrieve request.voidsendRetrieveRequest(IFileID remoteFileID, IFileRangeSpecification rangeSpecification, IFileTransferListener transferListener, Map options)Send request for transfer of a remote file to local file storage.voidsendRetrieveRequest(IFileID remoteFileID, IFileTransferListener transferListener, Map options)Send request for transfer of a remote file to local file storage.voidsetConnectContextForAuthentication(IConnectContext connectContext)Set connect context for authentication upon subsequentIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map).voidsetProxy(Proxy proxy)Set proxy for use upon subsequentIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map).
-
-
-
Method Detail
-
getRetrieveNamespace
public Namespace getRetrieveNamespace()
Description copied from interface:IRetrieveFileTransferContainerAdapterGet namespace to be used for creation of remoteFileID for retrieve request. Result typically used as first parameter forIDFactory.createID(Namespace, String)to be used as first inIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map)- Specified by:
getRetrieveNamespacein interfaceIRetrieveFileTransferContainerAdapter- Returns:
- Namespace to use for ID creation via
IDFactory.createID(Namespace, String). Will not benull.
-
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- Parameters:
connectContext- the connect context to use for authenticating during subsequent call toIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map). Ifnull, then no authentication will be attempted.
-
setProxy
public void setProxy(Proxy proxy)
Description copied from interface:IRetrieveFileTransferContainerAdapterSet proxy for use upon subsequentIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map). This method should be called with proxy to allow the given proxy to be used in subsequent calls toIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map).When proxy is
nullor has not been called providers must use theorg.eclipse.core.netproxy API to obtain proxy information and proxy credentials if they support proxies of the type(s) supported by that API. The API is provided by an OSGi service of typeorg.eclipse.core.net.proxy.IProxyService.If no information is available via
IProxyServiceproviders may use other defaults.- Specified by:
setProxyin interfaceIRetrieveFileTransferContainerAdapter- Parameters:
proxy- the proxy to use for subsequent calls toIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map). Ifnull, then proxy information is obtained fromIProxyServiceif available. Otherwise provider defined defaults may be used.
-
sendRetrieveRequest
public void sendRetrieveRequest(IFileID remoteFileID, IFileTransferListener transferListener, Map options) throws IncomingFileTransferException
Description copied from interface:IRetrieveFileTransferContainerAdapterSend request for transfer of a remote file to local file storage. This method is used to initiate a file retrieve for a remoteFileID (first parameter). File transfer events are asynchronously delivered a file transfer listener (second parameter). The given remoteFileID and transferListener must not be null.NOTE: if this method completes successfully, the given transferListener will be asynchronously notified via an IIncomingFileTransferReceiveDoneEvent (along with other possible events). All implementations are required to issue this event whether successful or failed. Listeners can consult
IIncomingFileTransferReceiveDoneEvent.getException()to determine whether the transfer operation completed successfully.- Specified by:
sendRetrieveRequestin interfaceIRetrieveFileTransferContainerAdapter- Parameters:
remoteFileID- reference to the remote target file (e.g. http://www.eclipse.org/index.html) or a reference to a resource that specifies the location of a target file. Implementing providers will determine what protocol schemes are supported (e.g. ftp, http, torrent, file, etc) and the required format of the scheme-specific information. If a protocol is specified that is not supported, or the scheme-specific information is not well-formed, then an IncomingFileTransferException will be thrown. Typically, callers will create IFileID instances via calls such as:IFileID remoteFileID = FileIDFactory.getDefault().createID( ftc.getRetrieveNamespace(), "http://www.composent.com/index.html");Must not benull.transferListener- a listener for file transfer events. Must not be null. Must not be null. See Note above.options- a Map of options associated with sendRetrieveRequest. The particular name/value pairs will be unique to the individual providers. May benull.- Throws:
IncomingFileTransferException- if the provider is not connected or is not in the correct state for initiating file transfer
-
sendRetrieveRequest
public void sendRetrieveRequest(IFileID remoteFileID, IFileRangeSpecification rangeSpecification, IFileTransferListener transferListener, Map options) throws IncomingFileTransferException
Description copied from interface:IRetrieveFileTransferContainerAdapterSend request for transfer of a remote file to local file storage. This method is used to initiate a file retrieve for a remoteFileID (first parameter). File transfer events are asynchronously delivered a file transfer listener (third parameter). The given remoteFileID and transferListener must not be null.NOTE: if this method completes successfully, the given transferListener will be asynchronously notified via an IIncomingFileTransferReceiveDoneEvent (along with other possible events). All implementations are required to issue this event whether successful or failed. Listeners can consult
IIncomingFileTransferReceiveDoneEvent.getException()to determine whether the transfer operation completed successfully.- Specified by:
sendRetrieveRequestin interfaceIRetrieveFileTransferContainerAdapter- Parameters:
remoteFileID- reference to the remote target file (e.g. http://www.eclipse.org/index.html) or a reference to a resource that specifies the location of a target file. Implementing providers will determine what protocol schemes are supported (e.g. ftp, http, torrent, file, etc) and the required format of the scheme-specific information. If a protocol is specified that is not supported, or the scheme-specific information is not well-formed, then an IncomingFileTransferException will be thrown. Typically, callers will create IFileID instances via calls such as:IFileID remoteFileID = FileIDFactory.getDefault().createID( ftc.getRetrieveNamespace(), "http://www.composent.com/index.html");Must not benull.rangeSpecification- a range specification for retrieving a portion of the given remote file. Ifnullthe entire file will be retrieved (as perIRetrieveFileTransferContainerAdapter.sendRetrieveRequest(IFileID, IFileTransferListener, Map). If non-nullthe given file range will be used to retrieve the given file. For example, if the rangeSpecification has a start value of 1 and end value of 3, and the total length of the file is 5 bytes with content [a, b, c, d, e], a successful retrieve request would transfer bytes 'b', 'c', and 'd', but not 'a', and 'e'.transferListener- a listener for file transfer events. Must not be null. See Note above.options- a Map of options associated with sendRetrieveRequest. The particular name/value pairs will be unique to the individual providers. May benull.- Throws:
IncomingFileTransferException- if the provider is not connected or is not in the correct state for initiating file transfer
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdaptable
-
-