Search in sources :

Example 11 with IFileID

use of org.eclipse.ecf.filetransfer.identity.IFileID in project ecf by eclipse.

the class ScpBrowseFileTransferFactory 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) {
                throw new RemoteFileSystemException(NLS.bind("Exception creating URL for {0}", // $NON-NLS-1$
                directoryOrFileId));
            }
            ScpFileSystemBrowser browser = new ScpFileSystemBrowser(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) 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) URL(java.net.URL)

Example 12 with IFileID

use of org.eclipse.ecf.filetransfer.identity.IFileID in project ecf by eclipse.

the class AbstractFileSendAction method sendFileToTarget.

protected void sendFileToTarget() throws Exception {
    IFileID target = getTargetReceiver();
    // $NON-NLS-1$
    Assert.isNotNull(target, Messages.getString("AbstractFileSendAction.RECEIVER_NOT_NULL"));
    ISendFileTransferContainerAdapter adapter = getOutgoingFileTransferAdapter();
    // $NON-NLS-1$
    Assert.isNotNull(adapter, Messages.getString("AbstractFileSendAction.ADAPTER_NOT_NULL"));
    IFileTransferListener listener = getFileTransferListener();
    if (listener == null)
        listener = createDefaultFileTransferListener();
    // $NON-NLS-1$
    Assert.isNotNull(listener, Messages.getString("AbstractFileSendAction.LISTENER_NOT_NULL"));
    IFileTransferInfo info = getFileTransferInfo();
    // $NON-NLS-1$
    Assert.isNotNull(info, Messages.getString("AbstractFileSendAction.FILE_NOT_NULL"));
    // Now call
    adapter.sendOutgoingRequest(target, info, listener, this.options);
}
Also used : IFileID(org.eclipse.ecf.filetransfer.identity.IFileID)

Example 13 with IFileID

use of org.eclipse.ecf.filetransfer.identity.IFileID in project ecf by eclipse.

the class URLBrowseTest method verifyRemoteFilesWithoutLastModifiedAndContentLength.

protected void verifyRemoteFilesWithoutLastModifiedAndContentLength(final IRemoteFile[] remoteFiles) {
    for (int i = 0; i < remoteFiles.length; i++) {
        final IRemoteFile first = remoteFiles[i];
        final IRemoteFileInfo firstInfo = first.getInfo();
        assertNotNull(firstInfo);
        final IFileID firstID = first.getID();
        assertNotNull(firstID);
        trace("firstID=" + firstID);
        // Now check out info
        assertNotNull(firstInfo.getName());
        // TODO: should this be -1
        assertEquals(0, firstInfo.getLastModified());
        trace("length=" + firstInfo.getLength());
        trace("isDirectory=" + firstInfo.isDirectory());
        final IRemoteFileAttributes attributes = firstInfo.getAttributes();
        assertNotNull(attributes);
        final Iterator attrNames = attributes.getAttributeKeys();
        for (; attrNames.hasNext(); ) {
            final String key = (String) attrNames.next();
            String s = "attrname=" + key;
            s += " attrvalue=" + attributes.getAttribute(key);
            trace(s);
        }
    }
}
Also used : IFileID(org.eclipse.ecf.filetransfer.identity.IFileID) IRemoteFileInfo(org.eclipse.ecf.filetransfer.IRemoteFileInfo) IRemoteFile(org.eclipse.ecf.filetransfer.IRemoteFile) Iterator(java.util.Iterator) IRemoteFileAttributes(org.eclipse.ecf.filetransfer.IRemoteFileAttributes)

Example 14 with IFileID

use of org.eclipse.ecf.filetransfer.identity.IFileID in project ecf by eclipse.

the class URLRetrieveTest method testReceiveFails.

protected void testReceiveFails(String url) throws Exception {
    assertNotNull(retrieveAdapter);
    final IFileTransferListener listener = createFileTransferListener();
    try {
        final IFileID fileID = createFileID(new URL(url));
        retrieveAdapter.sendRetrieveRequest(fileID, listener, null);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.toString());
    }
    waitForDone(10000);
    assertHasNoEvent(startEvents, IIncomingFileTransferReceiveStartEvent.class);
    assertHasNoEvent(dataEvents, IIncomingFileTransferReceiveDataEvent.class);
    assertHasDoneEvent();
}
Also used : IFileID(org.eclipse.ecf.filetransfer.identity.IFileID) IFileTransferListener(org.eclipse.ecf.filetransfer.IFileTransferListener) URL(java.net.URL) IOException(java.io.IOException) ConnectException(java.net.ConnectException)

Example 15 with IFileID

use of org.eclipse.ecf.filetransfer.identity.IFileID in project ecf by eclipse.

the class URLRetrieveTest method testReceive.

protected void testReceive(String url) throws Exception {
    assertNotNull(retrieveAdapter);
    final IFileTransferListener listener = createFileTransferListener();
    final IFileID fileID = createFileID(new URL(url));
    retrieveAdapter.sendRetrieveRequest(fileID, listener, null);
    waitForDone(360000);
    assertHasEvent(startEvents, IIncomingFileTransferReceiveStartEvent.class);
    assertHasMoreThanEventCount(dataEvents, IIncomingFileTransferReceiveDataEvent.class, 0);
    assertDoneOK();
    assertTrue(tmpFile.exists());
    assertTrue(tmpFile.length() > 0);
}
Also used : IFileID(org.eclipse.ecf.filetransfer.identity.IFileID) IFileTransferListener(org.eclipse.ecf.filetransfer.IFileTransferListener) URL(java.net.URL)

Aggregations

IFileID (org.eclipse.ecf.filetransfer.identity.IFileID)20 URL (java.net.URL)10 IFileTransferListener (org.eclipse.ecf.filetransfer.IFileTransferListener)7 File (java.io.File)3 IOException (java.io.IOException)3 FileTransferJob (org.eclipse.ecf.filetransfer.FileTransferJob)3 IIncomingFileTransferReceiveStartEvent (org.eclipse.ecf.filetransfer.events.IIncomingFileTransferReceiveStartEvent)3 MalformedURLException (java.net.MalformedURLException)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 IConnectContext (org.eclipse.ecf.core.security.IConnectContext)2 Proxy (org.eclipse.ecf.core.util.Proxy)2 IRemoteFile (org.eclipse.ecf.filetransfer.IRemoteFile)2 IRemoteFileAttributes (org.eclipse.ecf.filetransfer.IRemoteFileAttributes)2 IRemoteFileInfo (org.eclipse.ecf.filetransfer.IRemoteFileInfo)2 IFileTransferEvent (org.eclipse.ecf.filetransfer.events.IFileTransferEvent)2 IRemoteFileSystemBrowser (org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser)2 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 ConnectException (java.net.ConnectException)1