Search in sources :

Example 1 with RemoteFileSystemException

use of org.eclipse.ecf.filetransfer.RemoteFileSystemException in project ecf by eclipse.

the class EFSRemoteFileSystemBrowser method sendBrowseRequest.

public IRemoteFileSystemRequest sendBrowseRequest(IFileID directoryOrFileID, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
    Assert.isNotNull(directoryOrFileID);
    Assert.isNotNull(listener);
    URL efsDirectory = null;
    FileStoreBrowser fsb = null;
    try {
        efsDirectory = directoryOrFileID.getURL();
        // $NON-NLS-1$ //$NON-NLS-2$
        final String path = StringUtils.replaceAll(efsDirectory.getPath(), " ", "%20");
        fsb = new FileStoreBrowser(EFS.getStore(new URI(path)), efsDirectory, directoryOrFileID, listener);
    } catch (final Exception e) {
        throw new RemoteFileSystemException(e);
    }
    return fsb.sendBrowseRequest();
}
Also used : RemoteFileSystemException(org.eclipse.ecf.filetransfer.RemoteFileSystemException) URI(java.net.URI) URL(java.net.URL) RemoteFileSystemException(org.eclipse.ecf.filetransfer.RemoteFileSystemException)

Example 2 with RemoteFileSystemException

use of org.eclipse.ecf.filetransfer.RemoteFileSystemException in project ecf by eclipse.

the class MultiProtocolFileSystemBrowserAdapter method sendBrowseRequest.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.filetransfer.IRemoteFileSystemBrowserContainerAdapter#sendDirectoryRequest(org.eclipse.ecf.filetransfer.identity.IFileID, org.eclipse.ecf.filetransfer.IRemoteFileSystemListener)
	 */
public IRemoteFileSystemRequest sendBrowseRequest(IFileID directoryOrFileID, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
    Assert.isNotNull(directoryOrFileID);
    Assert.isNotNull(listener);
    URL url;
    try {
        url = directoryOrFileID.getURL();
    } catch (final MalformedURLException e) {
        throw new RemoteFileSystemException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
    }
    IRemoteFileSystemBrowserContainerAdapter fileSystemBrowser = null;
    fileSystemBrowser = Activator.getDefault().getBrowseFileTransfer(url.getProtocol());
    if (fileSystemBrowser == null) {
        if (url.getProtocol().equalsIgnoreCase("file")) {
            // $NON-NLS-1$
            LocalFileSystemBrowser fsb = new LocalFileSystemBrowser(directoryOrFileID, listener);
            return fsb.sendBrowseRequest();
        }
        URLFileSystemBrowser ufsb = new URLFileSystemBrowser(directoryOrFileID, listener, url, connectContext, proxy);
        return ufsb.sendBrowseRequest();
    }
    // Set connect context
    fileSystemBrowser.setConnectContextForAuthentication(connectContext);
    // Set Proxy
    fileSystemBrowser.setProxy(proxy);
    return fileSystemBrowser.sendBrowseRequest(directoryOrFileID, listener);
}
Also used : RemoteFileSystemException(org.eclipse.ecf.filetransfer.RemoteFileSystemException) IRemoteFileSystemBrowserContainerAdapter(org.eclipse.ecf.filetransfer.IRemoteFileSystemBrowserContainerAdapter) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL)

Example 3 with RemoteFileSystemException

use of org.eclipse.ecf.filetransfer.RemoteFileSystemException in project ecf by eclipse.

the class HttpClientBrowseFileTransferFactory method newInstance.

public IRemoteFileSystemBrowser newInstance() {
    return new IRemoteFileSystemBrowser() {

        private Proxy proxy;

        private IConnectContext connectContext;

        public Namespace getBrowseNamespace() {
            return IDFactory.getDefault().getNamespaceByName(FileTransferNamespace.PROTOCOL);
        }

        public IRemoteFileSystemRequest sendBrowseRequest(IFileID directoryOrFileId, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
            Assert.isNotNull(directoryOrFileId);
            Assert.isNotNull(listener);
            URL url;
            try {
                url = directoryOrFileId.getURL();
            } catch (final MalformedURLException e) {
                // $NON-NLS-1$
                throw new RemoteFileSystemException(NLS.bind("Exception creating URL for {0}", directoryOrFileId));
            }
            HttpClientFileSystemBrowser browser = new HttpClientFileSystemBrowser(new SNIAwareHttpClient(), directoryOrFileId, listener, url, connectContext, proxy);
            return browser.sendBrowseRequest();
        }

        public void setConnectContextForAuthentication(IConnectContext connectContext) {
            this.connectContext = connectContext;
        }

        public void setProxy(Proxy proxy) {
            this.proxy = proxy;
        }

        public Object getAdapter(Class adapter) {
            return null;
        }
    };
}
Also used : IConnectContext(org.eclipse.ecf.core.security.IConnectContext) RemoteFileSystemException(org.eclipse.ecf.filetransfer.RemoteFileSystemException) IRemoteFileSystemBrowser(org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser) Proxy(org.eclipse.ecf.core.util.Proxy) MalformedURLException(java.net.MalformedURLException) IFileID(org.eclipse.ecf.filetransfer.identity.IFileID) IRemoteFileSystemListener(org.eclipse.ecf.filetransfer.IRemoteFileSystemListener) URL(java.net.URL)

Aggregations

URL (java.net.URL)3 RemoteFileSystemException (org.eclipse.ecf.filetransfer.RemoteFileSystemException)3 MalformedURLException (java.net.MalformedURLException)2 URI (java.net.URI)1 IConnectContext (org.eclipse.ecf.core.security.IConnectContext)1 Proxy (org.eclipse.ecf.core.util.Proxy)1 IRemoteFileSystemBrowserContainerAdapter (org.eclipse.ecf.filetransfer.IRemoteFileSystemBrowserContainerAdapter)1 IRemoteFileSystemListener (org.eclipse.ecf.filetransfer.IRemoteFileSystemListener)1 IFileID (org.eclipse.ecf.filetransfer.identity.IFileID)1 IRemoteFileSystemBrowser (org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser)1