diff options
author | slewis | 2007-04-18 05:42:38 +0000 |
---|---|---|
committer | slewis | 2007-04-18 05:42:38 +0000 |
commit | 88a2981566bd3c9f4bdc4c341c95db7ba6284b86 (patch) | |
tree | 902778206dfddbc541334ee68672218e77602d98 /providers/bundles/org.eclipse.ecf.provider.filetransfer.efs | |
parent | ee3231842f0ad18a39f891199cf482293a166f12 (diff) | |
download | org.eclipse.ecf-88a2981566bd3c9f4bdc4c341c95db7ba6284b86.tar.gz org.eclipse.ecf-88a2981566bd3c9f4bdc4c341c95db7ba6284b86.tar.xz org.eclipse.ecf-88a2981566bd3c9f4bdc4c341c95db7ba6284b86.zip |
Initial checkin of org.eclipse.ecf.provider.filetransfer.efs provider plugin
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.filetransfer.efs')
8 files changed, 258 insertions, 0 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/.classpath b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/.classpath new file mode 100644 index 000000000..751c8f2e5 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/.project b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/.project new file mode 100644 index 000000000..18555d4f4 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.ecf.provider.filetransfer.efs</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/META-INF/MANIFEST.MF new file mode 100644 index 000000000..a26358e7a --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: ECF EFS Filetransfer Provider +Bundle-SymbolicName: org.eclipse.ecf.provider.filetransfer.efs;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.ecf.internal.provider.filetransfer.efs.Activator +Bundle-Vendor: Eclipse.org +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ecf.filetransfer, + org.eclipse.ecf.provider.filetransfer, + org.eclipse.ecf, + org.eclipse.core.filesystem +Eclipse-LazyStart: true diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/build.properties b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/build.properties new file mode 100644 index 000000000..e9863e281 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/plugin.xml b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/plugin.xml new file mode 100644 index 000000000..5910ea982 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/plugin.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> +<plugin> + <extension + point="org.eclipse.ecf.provider.filetransfer.fileTransferProtocolFactory"> + <fileTransferProtocolFactory + class="org.eclipse.ecf.internal.provider.filetransfer.efs.EFSRetrieveFileTransferFactory" + protocol="efs"> + </fileTransferProtocolFactory> + </extension> + +</plugin> diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/Activator.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/Activator.java new file mode 100644 index 000000000..34bef4729 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/Activator.java @@ -0,0 +1,50 @@ +package org.eclipse.ecf.internal.provider.filetransfer.efs; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends Plugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.ecf.provider.filetransfer.efs"; + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRetrieveFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRetrieveFileTransfer.java new file mode 100644 index 000000000..96d684dcd --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRetrieveFileTransfer.java @@ -0,0 +1,130 @@ +/**************************************************************************** + * Copyright (c) 2004 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.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URI; + +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.core.security.IConnectContext; +import org.eclipse.ecf.core.util.Proxy; +import org.eclipse.ecf.filetransfer.IIncomingFileTransfer; +import org.eclipse.ecf.filetransfer.IncomingFileTransferException; +import org.eclipse.ecf.filetransfer.events.IIncomingFileTransferReceiveStartEvent; +import org.eclipse.ecf.filetransfer.identity.IFileID; +import org.eclipse.ecf.provider.filetransfer.identity.FileTransferID; +import org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer; + +/** + * + */ +public class EFSRetrieveFileTransfer extends AbstractRetrieveFileTransfer { + + IConnectContext connectContext; + Proxy proxy; + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer#openStreams() + */ + protected void openStreams() throws IncomingFileTransferException { + try { + IFileStore fileStore = EFS.getStore(new URI(getRemoteFileURL().getFile())); + IFileInfo info = fileStore.fetchInfo(); + setFileLength(info.getLength()); + setInputStream(fileStore.openInputStream(0, null)); + + listener + .handleTransferEvent(new IIncomingFileTransferReceiveStartEvent() { + private static final long serialVersionUID = 5693211912862160540L; + + public IFileID getFileID() { + return remoteFileID; + } + + public IIncomingFileTransfer receive( + File localFileToSave) throws IOException { + setOutputStream(new BufferedOutputStream( + new FileOutputStream(localFileToSave))); + job = new FileTransferJob(getRemoteFileURL() + .toString()); + job.schedule(); + return EFSRetrieveFileTransfer.this; + } + + public String toString() { + StringBuffer sb = new StringBuffer( + "IIncomingFileTransferReceiveStartEvent["); //$NON-NLS-1$ + sb.append("isdone=").append(done).append(";"); //$NON-NLS-1$ //$NON-NLS-2$ + sb.append("bytesReceived=").append( //$NON-NLS-1$ + bytesReceived).append("]"); //$NON-NLS-1$ + return sb.toString(); + } + + public void cancel() { + hardClose(); + } + + public IIncomingFileTransfer receive( + OutputStream streamToStore) throws IOException { + setOutputStream(streamToStore); + setCloseOutputStream(false); + job = new FileTransferJob(getRemoteFileURL() + .toString()); + job.schedule(); + return EFSRetrieveFileTransfer.this; + } + + }); + + } catch (Exception e) { + throw new IncomingFileTransferException(e); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.core.identity.IIdentifiable#getID() + */ + public ID getID() { + return new FileTransferID(getRetrieveNamespace(), getRemoteFileURL()); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.filetransfer.IRetrieveFileTransferContainerAdapter#setConnectContextForAuthentication(org.eclipse.ecf.core.security.IConnectContext) + */ + public void setConnectContextForAuthentication( + IConnectContext connectContext) { + this.connectContext = connectContext; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ecf.filetransfer.IRetrieveFileTransferContainerAdapter#setProxy(org.eclipse.ecf.core.util.Proxy) + */ + public void setProxy(Proxy proxy) { + this.proxy = proxy; + } + +} diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRetrieveFileTransferFactory.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRetrieveFileTransferFactory.java new file mode 100644 index 000000000..42cb08657 --- /dev/null +++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.efs/src/org/eclipse/ecf/internal/provider/filetransfer/efs/EFSRetrieveFileTransferFactory.java @@ -0,0 +1,13 @@ +package org.eclipse.ecf.internal.provider.filetransfer.efs; + +import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransfer; +import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory; + +public class EFSRetrieveFileTransferFactory implements + IRetrieveFileTransferFactory { + + public IRetrieveFileTransfer newInstance() { + return new EFSRetrieveFileTransfer(); + } + +} |