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;
}
};
}
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);
}
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);
}
}
}
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();
}
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);
}
Aggregations