Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-12-23 00:54:37 -0500
committerslewis2007-12-23 00:54:37 -0500
commit3f5bcfdf1cc2a4c8e25107268ca0e06c426df7e0 (patch)
tree7bcaa2919857109aaf4ab560853279678b46eeb4
parent5bb63271eba504065a90271614b22af1abfbb3b5 (diff)
downloadorg.eclipse.ecf-3f5bcfdf1cc2a4c8e25107268ca0e06c426df7e0.tar.gz
org.eclipse.ecf-3f5bcfdf1cc2a4c8e25107268ca0e06c426df7e0.tar.xz
org.eclipse.ecf-3f5bcfdf1cc2a4c8e25107268ca0e06c426df7e0.zip
Added efs-based send file transfer and directory browsing.
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/plugin.xml2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSFileAttributes.java85
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteBrowse.java71
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteFile.java57
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteFileInfo.java90
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/FileStoreBrowser.java59
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/RetrieveFileTransfer.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/SendFileTransfer.java2
8 files changed, 365 insertions, 3 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/plugin.xml b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/plugin.xml
index 21eec7d64..d379a9ba2 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/plugin.xml
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/plugin.xml
@@ -11,7 +11,7 @@
<extension
point="org.eclipse.ecf.provider.filetransfer.sendFileTransferProtocolFactory">
- <sendFileTransferProtocolFactory
+ <sendFileTransferProtocolFactory
class="org.eclipse.ecf.internal.provider.filetransfer.efs.SendFileTransferFactory"
protocol="efs">
</sendFileTransferProtocolFactory>
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSFileAttributes.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSFileAttributes.java
new file mode 100644
index 000000000..a6565d04d
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSFileAttributes.java
@@ -0,0 +1,85 @@
+/****************************************************************************
+ * Copyright (c) 2007 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.internal.provider.filetransfer.efs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.ecf.filetransfer.IRemoteFileAttributes;
+
+/**
+ *
+ */
+public class EFSFileAttributes implements IRemoteFileAttributes {
+
+ static String[] fileAttributes = {IRemoteFileAttributes.READ_ATTRIBUTE, IRemoteFileAttributes.WRITE_ATTRIBUTE, IRemoteFileAttributes.HIDDEN_ATTRIBUTE, IRemoteFileAttributes.EXEC_ATTRIBUTE, IRemoteFileAttributes.ARCHIVE_ATTRIBUTE};
+ static List attributeKeys = new ArrayList(Arrays.asList(fileAttributes));
+
+ IFileInfo fileInfo;
+
+ public EFSFileAttributes(IFileInfo fileInfo) {
+ this.fileInfo = fileInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileAttributes#getAttribute(java.lang.String)
+ */
+ public String getAttribute(String key) {
+ if (key == null)
+ return null;
+ if (key.equalsIgnoreCase(IRemoteFileAttributes.READ_ATTRIBUTE)) {
+ if (fileInfo.getAttribute(EFS.ATTRIBUTE_READ_ONLY))
+ return Boolean.TRUE.toString();
+ else
+ return Boolean.FALSE.toString();
+ } else if (key.equalsIgnoreCase(IRemoteFileAttributes.WRITE_ATTRIBUTE)) {
+ if (!fileInfo.getAttribute(EFS.ATTRIBUTE_READ_ONLY))
+ return Boolean.TRUE.toString();
+ else
+ return Boolean.FALSE.toString();
+ } else if (key.equals(IRemoteFileAttributes.HIDDEN_ATTRIBUTE)) {
+ if (fileInfo.getAttribute(EFS.ATTRIBUTE_HIDDEN))
+ return Boolean.TRUE.toString();
+ else
+ return Boolean.FALSE.toString();
+ } else if (key.equals(IRemoteFileAttributes.EXEC_ATTRIBUTE)) {
+ if (fileInfo.getAttribute(EFS.ATTRIBUTE_EXECUTABLE))
+ return Boolean.TRUE.toString();
+ else
+ return Boolean.FALSE.toString();
+ } else if (key.equals(IRemoteFileAttributes.ARCHIVE_ATTRIBUTE)) {
+ if (fileInfo.getAttribute(EFS.ATTRIBUTE_ARCHIVE))
+ return Boolean.TRUE.toString();
+ else
+ return Boolean.FALSE.toString();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileAttributes#getAttributeKeys()
+ */
+ public Iterator getAttributeKeys() {
+ return attributeKeys.iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileAttributes#setAttribute(java.lang.String, java.lang.String)
+ */
+ public void setAttribute(String key, String value) {
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteBrowse.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteBrowse.java
new file mode 100644
index 000000000..63fb785c4
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteBrowse.java
@@ -0,0 +1,71 @@
+/****************************************************************************
+ * Copyright (c) 2007 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.internal.provider.filetransfer.efs;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
+import org.eclipse.ecf.filetransfer.IRemoteFileSystemRequest;
+import org.eclipse.ecf.filetransfer.RemoteFileSystemException;
+import org.eclipse.ecf.filetransfer.identity.IFileID;
+import org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowser;
+import org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowserFactory;
+import org.eclipse.ecf.provider.filetransfer.identity.FileTransferNamespace;
+
+/**
+ *
+ */
+public class EFSRemoteBrowse implements IRemoteFileSystemBrowserFactory {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowserFactory#newInstance()
+ */
+ public IRemoteFileSystemBrowser newInstance() {
+ return new IRemoteFileSystemBrowser() {
+
+ public Namespace getDirectoryNamespace() {
+ return IDFactory.getDefault().getNamespaceByName(FileTransferNamespace.PROTOCOL);
+ }
+
+ public IRemoteFileSystemRequest sendDirectoryRequest(IFileID directoryID, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
+ Assert.isNotNull(directoryID);
+ Assert.isNotNull(listener);
+ IFileStore directoryStore;
+ URL efsDirectory = null;
+ try {
+ efsDirectory = directoryID.getURL();
+ directoryStore = EFS.getStore(new URI(efsDirectory.getPath()));
+ } catch (final Exception e) {
+ throw new RemoteFileSystemException(e);
+ }
+ final IFileInfo directoryStoreInfo = directoryStore.fetchInfo();
+ if (!directoryStoreInfo.isDirectory())
+ throw new RemoteFileSystemException("{0} is not a directory.");
+ final FileStoreBrowser rfs = new FileStoreBrowser(directoryStore, efsDirectory, directoryID, listener);
+ return rfs.sendDirectoryRequest();
+
+ }
+
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+ };
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteFile.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteFile.java
new file mode 100644
index 000000000..7d5708776
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteFile.java
@@ -0,0 +1,57 @@
+/****************************************************************************
+ * Copyright (c) 2007 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.internal.provider.filetransfer.efs;
+
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.ecf.filetransfer.IRemoteFile;
+import org.eclipse.ecf.filetransfer.IRemoteFileInfo;
+import org.eclipse.ecf.filetransfer.identity.IFileID;
+
+/**
+ *
+ */
+public class EFSRemoteFile implements IRemoteFile {
+
+ private final IFileID fileID;
+ private final EFSRemoteFileInfo remoteFileInfo;
+
+ /**
+ * @param fileID
+ * @param remoteFile
+ */
+ public EFSRemoteFile(IFileID fileID, IFileInfo remoteFile) {
+ this.fileID = fileID;
+ this.remoteFileInfo = new EFSRemoteFileInfo(remoteFile);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFile#getID()
+ */
+ public IFileID getID() {
+ return fileID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFile#getInfo()
+ */
+ public IRemoteFileInfo getInfo() {
+ return remoteFileInfo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteFileInfo.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteFileInfo.java
new file mode 100644
index 000000000..650322a47
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRemoteFileInfo.java
@@ -0,0 +1,90 @@
+/****************************************************************************
+ * Copyright (c) 2007 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.internal.provider.filetransfer.efs;
+
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.filetransfer.IRemoteFileAttributes;
+import org.eclipse.ecf.filetransfer.IRemoteFileInfo;
+
+/**
+ *
+ */
+public class EFSRemoteFileInfo implements IRemoteFileInfo {
+
+ IFileInfo efsFileInfo;
+
+ IRemoteFileAttributes fileAttributes;
+
+ /**
+ * @param remoteFileInfo
+ */
+ public EFSRemoteFileInfo(IFileInfo remoteFileInfo) {
+ Assert.isNotNull(remoteFileInfo);
+ this.efsFileInfo = remoteFileInfo;
+ this.fileAttributes = new EFSFileAttributes(efsFileInfo);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileInfo#getAttributes()
+ */
+ public IRemoteFileAttributes getAttributes() {
+ return fileAttributes;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileInfo#getLastModified()
+ */
+ public long getLastModified() {
+ return efsFileInfo.getLastModified();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileInfo#getLength()
+ */
+ public long getLength() {
+ return efsFileInfo.getLength();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileInfo#getName()
+ */
+ public String getName() {
+ return efsFileInfo.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileInfo#isDirectory()
+ */
+ public boolean isDirectory() {
+ return efsFileInfo.isDirectory();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileInfo#setAttributes(org.eclipse.ecf.filetransfer.IRemoteFileAttributes)
+ */
+ public void setAttributes(IRemoteFileAttributes attributes) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileInfo#setLastModified(long)
+ */
+ public void setLastModified(long time) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.filetransfer.IRemoteFileInfo#setName(java.lang.String)
+ */
+ public void setName(String name) {
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/FileStoreBrowser.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/FileStoreBrowser.java
new file mode 100644
index 000000000..da9ccdd37
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/FileStoreBrowser.java
@@ -0,0 +1,59 @@
+/****************************************************************************
+ * Copyright (c) 2007 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.internal.provider.filetransfer.efs;
+
+import java.net.URL;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.ecf.filetransfer.IRemoteFile;
+import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
+import org.eclipse.ecf.filetransfer.RemoteFileSystemException;
+import org.eclipse.ecf.filetransfer.identity.FileIDFactory;
+import org.eclipse.ecf.filetransfer.identity.IFileID;
+import org.eclipse.ecf.provider.filetransfer.browse.AbstractFileSystemBrowser;
+
+/**
+ *
+ */
+public class FileStoreBrowser extends AbstractFileSystemBrowser {
+
+ IFileStore fileStore;
+ URL efsDirectory;
+
+ /**
+ * @param store
+ * @param efsDirectory
+ * @param directoryID2
+ * @param listener
+ * @throws RemoteFileSystemException
+ *
+ */
+ public FileStoreBrowser(IFileStore store, URL efsDirectory, IFileID directoryID2, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
+ super(directoryID2, listener);
+ this.fileStore = store;
+ this.efsDirectory = efsDirectory;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.provider.filetransfer.browse.FileSystemBrowser#runDirectoryRequest()
+ */
+ protected void runDirectoryRequest() throws Exception {
+ final IFileInfo[] fileInfos = fileStore.childInfos(EFS.NONE, null);
+ remoteFiles = new IRemoteFile[fileInfos.length];
+ for (int i = 0; i < fileInfos.length; i++) {
+ remoteFiles[i] = new EFSRemoteFile(FileIDFactory.getDefault().createFileID(directoryID.getNamespace(), new URL(efsDirectory + "/" + fileInfos[i].getName())), fileInfos[i]);
+ }
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/RetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/RetrieveFileTransfer.java
index 492e2b301..1f62a68b5 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/RetrieveFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/RetrieveFileTransfer.java
@@ -59,7 +59,7 @@ public class RetrieveFileTransfer extends AbstractRetrieveFileTransfer {
*/
protected void openStreams() throws IncomingFileTransferException {
try {
- final IFileStore fileStore = EFS.getStore(new URI(getRemoteFileURL().getFile()));
+ final IFileStore fileStore = EFS.getStore(new URI(getRemoteFileURL().getPath()));
final IFileInfo info = fileStore.fetchInfo();
setFileLength(info.getLength());
setInputStream(fileStore.openInputStream(0, null));
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/SendFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/SendFileTransfer.java
index 705f89c85..51b4a9237 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/SendFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/SendFileTransfer.java
@@ -55,7 +55,7 @@ public class SendFileTransfer extends AbstractOutgoingFileTransfer {
// Get/open input file
setInputStream(new BufferedInputStream(new FileInputStream(getFileTransferInfo().getFile())));
// Open target
- final IFileStore fileStore = EFS.getStore(new URI(getRemoteFileURL().getFile()));
+ final IFileStore fileStore = EFS.getStore(new URI(getRemoteFileURL().getPath()));
setOutputStream(fileStore.openOutputStream(0, null));
// Notify listener
listener.handleTransferEvent(new IOutgoingFileTransferResponseEvent() {

Back to the top