use of org.eclipse.ecf.filetransfer.identity.IFileID in project ecf by eclipse.
the class FileIDFactoryTest method testCreateFromString.
public void testCreateFromString() throws Exception {
final IFileID fileID = createFileID(getRetrieveAdapter().getRetrieveNamespace(), "http://www.eclipse.org/ecf");
assertNotNull(fileID);
}
use of org.eclipse.ecf.filetransfer.identity.IFileID in project ecf by eclipse.
the class AbstractBrowseTestCase method verifyRemoteFiles.
/**
* @param remoteFiles
*/
protected void verifyRemoteFiles(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());
assertTrue(firstInfo.getLastModified() > 0);
trace("lastModified=" + new SimpleDateFormat().format(new Date(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 URLRetrieveTestWithCustomJob method testReceive.
protected void testReceive(String url) throws Exception {
assertNotNull(retrieveAdapter);
final IFileTransferListener listener = createFileTransferListener();
final IFileID fileID = createFileID(new URL(url));
fileTransferJob = new FileTransferJob(fileID.getName());
fileTransferJob.addJobChangeListener(new JobChangeTraceListener(startTime));
retrieveAdapter.sendRetrieveRequest(fileID, listener, null);
waitForDone(10000);
final IStatus result = fileTransferJob.getResult();
System.out.println("job=" + fileTransferJob.getName() + " result=" + result);
assertTrue(result != null);
assertHasEvent(startEvents, IIncomingFileTransferReceiveStartEvent.class);
assertHasMoreThanEventCount(dataEvents, IIncomingFileTransferReceiveDataEvent.class, 0);
assertDoneOK();
assertTrue(tmpFile.exists());
assertTrue(tmpFile.length() > 0);
}
use of org.eclipse.ecf.filetransfer.identity.IFileID in project ecf by eclipse.
the class XMPPCompoundContributionItem method sendFileToTarget.
private void sendFileToTarget(ISendFileTransferContainerAdapter fileTransfer, final ID targetID) {
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final FileDialog fd = new FileDialog(shell, SWT.OPEN);
// XXX this should be some default path set by preferences
// $NON-NLS-1$
fd.setFilterPath(System.getProperty("user.home"));
fd.setText(NLS.bind(Messages.XMPPCompoundContributionItem_CHOOSE_FILE, targetID.getName()));
final String res = fd.open();
if (res != null) {
final File aFile = new File(res);
try {
final IFileID targetFileID = FileIDFactory.getDefault().createFileID(fileTransfer.getOutgoingNamespace(), new Object[] { targetID, res });
fileTransfer.sendOutgoingRequest(targetFileID, aFile, new IFileTransferListener() {
public void handleTransferEvent(final IFileTransferEvent event) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// bar?)
if (event instanceof IOutgoingFileTransferResponseEvent) {
if (!((IOutgoingFileTransferResponseEvent) event).requestAccepted())
MessageDialog.openInformation(shell, Messages.XMPPCompoundContributionItem_FILE_SEND_REFUSED_TITLE, NLS.bind(Messages.XMPPCompoundContributionItem_FILE_SEND_REFUSED_MESSAGE, res, targetID.getName()));
}
}
});
}
}, null);
} catch (final Exception e) {
MessageDialog.openError(shell, Messages.XMPPCompoundContributionItem_SEND_ERROR_TITLE, NLS.bind(Messages.XMPPCompoundContributionItem_SEND_ERROR_MESSAGE, res, e.getLocalizedMessage()));
}
}
}
use of org.eclipse.ecf.filetransfer.identity.IFileID 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;
}
};
}
Aggregations