Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-12-23 00:54:36 -0500
committerslewis2007-12-23 00:54:36 -0500
commit5bb63271eba504065a90271614b22af1abfbb3b5 (patch)
treed09c5b1b6056c2cfdc4251a80a69175e4b4f0ddf
parent55558f8b6d3eff1d0e7c38d8ec5c6e2178551e17 (diff)
downloadorg.eclipse.ecf-5bb63271eba504065a90271614b22af1abfbb3b5.tar.gz
org.eclipse.ecf-5bb63271eba504065a90271614b22af1abfbb3b5.tar.xz
org.eclipse.ecf-5bb63271eba504065a90271614b22af1abfbb3b5.zip
Added efs-based send file transfer and directory browsing.
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java125
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/FileSystemBrowser.java124
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/LocalFileAttributes.java6
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/MultiProtocolFileSystemBrowserAdapter.java2
4 files changed, 146 insertions, 111 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java
new file mode 100644
index 000000000..46e9bc706
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/AbstractFileSystemBrowser.java
@@ -0,0 +1,125 @@
+/****************************************************************************
+ * 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.provider.filetransfer.browse;
+
+import java.util.Arrays;
+import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ecf.filetransfer.*;
+import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemDirectoryEvent;
+import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemEvent;
+import org.eclipse.ecf.filetransfer.identity.IFileID;
+import org.eclipse.ecf.internal.provider.filetransfer.Messages;
+
+/**
+ *
+ */
+public abstract class AbstractFileSystemBrowser {
+
+ protected IFileID directoryID = null;
+ protected IRemoteFileSystemListener listener = null;
+
+ Job job = null;
+ protected Exception exception = null;
+ protected IRemoteFile[] remoteFiles = null;
+
+ Object lock = new Object();
+
+ class DirectoryJob extends Job {
+
+ public DirectoryJob() {
+ super(directoryID.getName());
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ if (monitor.isCanceled())
+ throw new UserCancelledException(Messages.AbstractRetrieveFileTransfer_Exception_User_Cancelled);
+ runDirectoryRequest();
+ } catch (Exception e) {
+ AbstractFileSystemBrowser.this.exception = e;
+ } finally {
+ listener.handleRemoteFileEvent(createRemoteFileEvent());
+ cleanUp();
+ }
+ return Status.OK_STATUS;
+ }
+
+ }
+
+ protected void cleanUp() {
+ synchronized (lock) {
+ job = null;
+ }
+ }
+
+ protected abstract void runDirectoryRequest() throws Exception;
+
+ public AbstractFileSystemBrowser(IFileID directoryID2, IRemoteFileSystemListener listener) {
+ Assert.isNotNull(directoryID2);
+ this.directoryID = directoryID2;
+ Assert.isNotNull(listener);
+ this.listener = listener;
+ }
+
+ public IRemoteFileSystemRequest sendDirectoryRequest() {
+ job = new DirectoryJob();
+ job.schedule();
+ return new IRemoteFileSystemRequest() {
+
+ public void cancel() {
+ synchronized (lock) {
+ if (job != null)
+ job.cancel();
+ }
+ }
+
+ public IFileID getDirectoryID() {
+ return directoryID;
+ }
+
+ public IRemoteFileSystemListener getRemoteFileListener() {
+ return listener;
+ }
+
+ };
+
+ }
+
+ /**
+ * @return file system directory event
+ */
+ protected IRemoteFileSystemEvent createRemoteFileEvent() {
+ return new IRemoteFileSystemDirectoryEvent() {
+
+ public IFileID getDirectory() {
+ return directoryID;
+ }
+
+ public Exception getException() {
+ return exception;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("RemoteFileSystemDirectoryEvent["); //$NON-NLS-1$
+ buf.append("directoryID=").append(directoryID).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("files=" + Arrays.asList(remoteFiles)).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ return buf.toString();
+ }
+
+ public IRemoteFile[] getRemoteFiles() {
+ return remoteFiles;
+ }
+ };
+ }
+
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/FileSystemBrowser.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/FileSystemBrowser.java
index 8d569291c..4b1befc46 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/FileSystemBrowser.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/FileSystemBrowser.java
@@ -12,13 +12,9 @@
package org.eclipse.ecf.provider.filetransfer.browse;
import java.io.File;
-import java.net.URL;
-import java.util.Arrays;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.ecf.filetransfer.*;
-import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemDirectoryEvent;
-import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemEvent;
+import java.net.MalformedURLException;
+import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
+import org.eclipse.ecf.filetransfer.RemoteFileSystemException;
import org.eclipse.ecf.filetransfer.identity.IFileID;
import org.eclipse.ecf.internal.provider.filetransfer.Messages;
import org.eclipse.osgi.util.NLS;
@@ -26,59 +22,25 @@ import org.eclipse.osgi.util.NLS;
/**
*
*/
-public class FileSystemBrowser {
+public class FileSystemBrowser extends AbstractFileSystemBrowser {
- IFileID directoryID = null;
- URL directoryURL = null;
- IRemoteFileSystemListener listener = null;
- File localDirectory;
-
- Job job = null;
- Exception exception = null;
- IRemoteFile[] remoteFiles = null;
-
- Object lock = new Object();
+ protected File localDirectory;
/**
* @param listener
- * @param url
* @param directoryID2
*/
- public FileSystemBrowser(IFileID directoryID2, URL url, IRemoteFileSystemListener listener) {
- Assert.isNotNull(directoryID2);
- this.directoryID = directoryID2;
- Assert.isNotNull(url);
- this.directoryURL = url;
- Assert.isNotNull(listener);
- this.listener = listener;
- }
-
- class DirectoryJob extends Job {
-
- public DirectoryJob() {
- super(directoryID.getName());
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- try {
- if (monitor.isCanceled())
- throw new UserCancelledException(Messages.AbstractRetrieveFileTransfer_Exception_User_Cancelled);
- runDirectoryRequest();
- } catch (Exception e) {
- FileSystemBrowser.this.exception = e;
- } finally {
- listener.handleRemoteFileEvent(createRemoteFileEvent());
- cleanUp();
- }
- return Status.OK_STATUS;
- }
-
- }
-
- void cleanUp() {
- synchronized (lock) {
- job = null;
+ public FileSystemBrowser(IFileID directoryID2, IRemoteFileSystemListener listener) throws RemoteFileSystemException {
+ super(directoryID2, listener);
+ try {
+ localDirectory = new File(directoryID2.getURL().getPath());
+ } catch (MalformedURLException e) {
+ throw new RemoteFileSystemException(e);
}
+ if (!localDirectory.exists())
+ throw new RemoteFileSystemException(NLS.bind(Messages.FileSystemBrowser_EXCEPTION_DIRECTORY_DOES_NOT_EXIST, localDirectory));
+ if (!localDirectory.isDirectory())
+ throw new RemoteFileSystemException(NLS.bind(Messages.FileSystemBrowser_EXCEPTION_NOT_DIRECTORY, localDirectory));
}
protected void runDirectoryRequest() throws Exception {
@@ -89,60 +51,4 @@ public class FileSystemBrowser {
}
}
- public IRemoteFileSystemRequest sendDirectoryRequest() throws RemoteFileSystemException {
- localDirectory = new File(directoryURL.getPath());
- if (!localDirectory.exists())
- throw new RemoteFileSystemException(NLS.bind(Messages.FileSystemBrowser_EXCEPTION_DIRECTORY_DOES_NOT_EXIST, localDirectory));
- if (!localDirectory.isDirectory())
- throw new RemoteFileSystemException(NLS.bind(Messages.FileSystemBrowser_EXCEPTION_NOT_DIRECTORY, localDirectory));
-
- job = new DirectoryJob();
- job.schedule();
- return new IRemoteFileSystemRequest() {
-
- public void cancel() {
- synchronized (lock) {
- if (job != null)
- job.cancel();
- }
- }
-
- public IFileID getDirectoryID() {
- return directoryID;
- }
-
- public IRemoteFileSystemListener getRemoteFileListener() {
- return listener;
- }
-
- };
-
- }
-
- /**
- * @return file system directory event
- */
- IRemoteFileSystemEvent createRemoteFileEvent() {
- return new IRemoteFileSystemDirectoryEvent() {
-
- public IFileID getDirectory() {
- return directoryID;
- }
-
- public Exception getException() {
- return exception;
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer("RemoteFileSystemDirectoryEvent["); //$NON-NLS-1$
- buf.append("directoryID=").append(directoryID).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
- buf.append("files=" + Arrays.asList(remoteFiles)).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
- return buf.toString();
- }
-
- public IRemoteFile[] getRemoteFiles() {
- return remoteFiles;
- }
- };
- }
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/LocalFileAttributes.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/LocalFileAttributes.java
index 6fb92bfca..a1b8c4a50 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/LocalFileAttributes.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/LocalFileAttributes.java
@@ -22,7 +22,7 @@ public class LocalFileAttributes implements IRemoteFileAttributes {
File file = null;
- static String[] fileAttributes = {IRemoteFileAttributes.READ_ATTRIBUTE, IRemoteFileAttributes.WRITE_ATTRIBUTE, IRemoteFileAttributes.HIDDEN_ATTRIBUTE};
+ 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));
public LocalFileAttributes(File file) {
@@ -44,6 +44,10 @@ public class LocalFileAttributes implements IRemoteFileAttributes {
} else if (key.equals(IRemoteFileAttributes.HIDDEN_ATTRIBUTE)) {
if (file.isHidden())
return Boolean.TRUE.toString();
+ } else if (key.equals(IRemoteFileAttributes.EXEC_ATTRIBUTE)) {
+ return Boolean.TRUE.toString();
+ } else if (key.equals(IRemoteFileAttributes.ARCHIVE_ATTRIBUTE)) {
+ return Boolean.TRUE.toString();
}
return null;
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/MultiProtocolFileSystemBrowserAdapter.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/MultiProtocolFileSystemBrowserAdapter.java
index c7d9bf8a4..0054f799e 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/MultiProtocolFileSystemBrowserAdapter.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/browse/MultiProtocolFileSystemBrowserAdapter.java
@@ -78,7 +78,7 @@ public class MultiProtocolFileSystemBrowserAdapter implements IRemoteFileSystemB
if (fileSystemBrowser == null) {
if (url.getProtocol().equalsIgnoreCase("file")) { //$NON-NLS-1$
- FileSystemBrowser fsb = new FileSystemBrowser(directoryID, url, listener);
+ FileSystemBrowser fsb = new FileSystemBrowser(directoryID, listener);
return fsb.sendDirectoryRequest();
}
throw new RemoteFileSystemException(NLS.bind(Messages.MultiProtocolOutgoingAdapter_EXCEPTION_NO_PROTOCOL_HANDER, directoryID));

Back to the top