Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2010-08-03 18:48:51 -0400
committerslewis2010-08-03 18:48:51 -0400
commitc9d6a9496f54dd39c403158f44b2ca1de0518db9 (patch)
tree48974da03ff3fed4ba5f4fe883b6d941141d0927 /providers/bundles/org.eclipse.ecf.provider.filetransfer
parent64a7a364b2b5c5b4fd361bf2ce0af9dfd4afcfdd (diff)
downloadorg.eclipse.ecf-c9d6a9496f54dd39c403158f44b2ca1de0518db9.tar.gz
org.eclipse.ecf-c9d6a9496f54dd39c403158f44b2ca1de0518db9.tar.xz
org.eclipse.ecf-c9d6a9496f54dd39c403158f44b2ca1de0518db9.zip
Enhancement to support IFileID.getURI(), and URI-based IFileIDs, rather than URL-based IDs only. Also added methods to IFileTransferProtocolMapper to specify use of URI (or URL) and added optional attribute to allow URIs to be used (rather than URLs). This addresses bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=268440
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.filetransfer')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/browseFileTransferProtocolFactory.exsd45
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/retrieveFileTransferProtocolFactory.exsd45
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/sendFileTransferProtocolFactory.exsd45
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/internal/provider/filetransfer/Activator.java58
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/IFileTransferProtocolToFactoryMapper.java69
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java42
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferNamespace.java7
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/MultiProtocolOutgoingAdapter.java37
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/MultiProtocolRetrieveAdapter.java34
10 files changed, 289 insertions, 95 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF
index 477c9acd1..cbf6a1cb7 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.provider.filetransfer;singleton:=true
-Bundle-Version: 3.1.0.qualifier
+Bundle-Version: 3.2.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.provider.filetransfer.Activator
Bundle-Vendor: %plugin.provider
Bundle-Localization: plugin
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/browseFileTransferProtocolFactory.exsd b/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/browseFileTransferProtocolFactory.exsd
index 2a0a9b381..c00183c25 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/browseFileTransferProtocolFactory.exsd
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/browseFileTransferProtocolFactory.exsd
@@ -2,15 +2,20 @@
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.ecf.provider.filetransfer" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appinfo>
+ <appInfo>
<meta.schema plugin="org.eclipse.ecf.provider.filetransfer" id="browseFileTransferProtocolFactory" name="browseFileTransferProtocolFactory"/>
- </appinfo>
+ </appInfo>
<documentation>
This extension point allows IRemoteFileSystemBrowserFactorys to be defined for given file transfer protocols.
</documentation>
</annotation>
<element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
<complexType>
<sequence>
<element ref="browseFileTransferProtocolFactory" minOccurs="0" maxOccurs="unbounded"/>
@@ -34,9 +39,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute translatable="true"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -61,9 +66,9 @@
<documentation>
The factory class to use for given protocol. Must implement &lt;b&gt;org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowserFactory&lt;/b&gt;
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowserFactory"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="priority" type="string">
@@ -73,22 +78,29 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="uri" type="boolean">
+ <annotation>
+ <documentation>
+ Flag to indicate that the protocol factory will use URIs (rather than URLs...which is the default). True indicates that URIs will be used, and *no* URLStreamHandler will be registered for the associated protocol. If false, URLs will be used and an URLStreamHandler will be registered for the given protocol factory. NOTE: If this flag is true, providers that attempt to access IFileID.getURL() may be unable to do so, since the URI may not be successfully parsed as a URL.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="since"/>
- </appinfo>
+ </appInfo>
<documentation>
1.0.0
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="examples"/>
- </appinfo>
+ </appInfo>
<documentation>
&lt;pre&gt;
&lt;extension
@@ -105,9 +117,9 @@
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="apiInfo"/>
- </appinfo>
+ </appInfo>
<documentation>
Here is the &lt;b&gt;org.eclipse.ecf.filetransfer.service.IRemoteFileSystemBrowserFactory&lt;/b&gt;
@@ -130,20 +142,19 @@ public interface IRemoteFileSystemBrowserFactory {
</documentation>
</annotation>
-
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="implementation"/>
- </appinfo>
+ </appInfo>
<documentation>
None
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="copyright"/>
- </appinfo>
+ </appInfo>
<documentation>
Copyright (c) 2004 Composent, Inc., IBM 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, IBM, Inc. - Initial API and implementation
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/retrieveFileTransferProtocolFactory.exsd b/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/retrieveFileTransferProtocolFactory.exsd
index 91f9ddb4a..b48263eeb 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/retrieveFileTransferProtocolFactory.exsd
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/retrieveFileTransferProtocolFactory.exsd
@@ -2,15 +2,20 @@
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.ecf.provider.filetransfer" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appinfo>
+ <appInfo>
<meta.schema plugin="org.eclipse.ecf.provider.filetransfer" id="retrieveFileTransferProtocolFactory" name="retrieveFileTransferProtocolFactory"/>
- </appinfo>
+ </appInfo>
<documentation>
This extension point allows IRetrieveFileTransferFactorys to be defined for given file transfer protocols.
</documentation>
</annotation>
<element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
<complexType>
<sequence>
<element ref="retrieveFileTransferProtocolFactory" minOccurs="0" maxOccurs="unbounded"/>
@@ -34,9 +39,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute translatable="true"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -61,9 +66,9 @@
<documentation>
The factory class to use for given protocol. Must implement &lt;b&gt;org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory&lt;/b&gt;
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="priority" type="string">
@@ -73,22 +78,29 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="uri" type="boolean">
+ <annotation>
+ <documentation>
+ Flag to indicate that the protocol factory will use URIs (rather than URLs...which is the default). True indicates that URIs will be used, and *no* URLStreamHandler will be registered for the associated protocol. If false, URLs will be used and an URLStreamHandler will be registered for the given protocol factory. NOTE: If this flag is true, providers that attempt to access IFileID.getURL() may be unable to do so, since the URI may not be successfully parsed as a URL.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="since"/>
- </appinfo>
+ </appInfo>
<documentation>
1.0.0
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="examples"/>
- </appinfo>
+ </appInfo>
<documentation>
&lt;pre&gt;
&lt;extension
@@ -109,9 +121,9 @@
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="apiInfo"/>
- </appinfo>
+ </appInfo>
<documentation>
Here is the &lt;b&gt;org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory&lt;/b&gt;
@@ -134,20 +146,19 @@ public interface IRetrieveFileTransferFactory {
</documentation>
</annotation>
-
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="implementation"/>
- </appinfo>
+ </appInfo>
<documentation>
None
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="copyright"/>
- </appinfo>
+ </appInfo>
<documentation>
Copyright (c) 2004 Composent, Inc., IBM 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, IBM, Inc. - Initial API and implementation
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/sendFileTransferProtocolFactory.exsd b/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/sendFileTransferProtocolFactory.exsd
index c6e22d722..376604f97 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/sendFileTransferProtocolFactory.exsd
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/schema/sendFileTransferProtocolFactory.exsd
@@ -2,15 +2,20 @@
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.ecf.provider.filetransfer" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
- <appinfo>
+ <appInfo>
<meta.schema plugin="org.eclipse.ecf.provider.filetransfer" id="sendFileTransferProtocolFactory" name="sendFileTransferProtocolFactory"/>
- </appinfo>
+ </appInfo>
<documentation>
This extension point allows IRetrieveFileTransferFactorys to be defined for given file transfer protocols.
</documentation>
</annotation>
<element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
<complexType>
<sequence>
<element ref="sendFileTransferProtocolFactory" minOccurs="0" maxOccurs="unbounded"/>
@@ -34,9 +39,9 @@
<documentation>
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute translatable="true"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
</complexType>
@@ -61,9 +66,9 @@
<documentation>
The factory class to use for given protocol. Must implement &lt;b&gt;org.eclipse.ecf.filetransfer.service.ISendFileTransferFactory&lt;/b&gt;
</documentation>
- <appinfo>
+ <appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.ecf.filetransfer.service.ISendFileTransferFactory"/>
- </appinfo>
+ </appInfo>
</annotation>
</attribute>
<attribute name="priority" type="string">
@@ -73,22 +78,29 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="uri" type="boolean">
+ <annotation>
+ <documentation>
+ Flag to indicate that the protocol factory will use URIs (rather than URLs...which is the default). True indicates that URIs will be used, and *no* URLStreamHandler will be registered for the associated protocol. If false, URLs will be used and an URLStreamHandler will be registered for the given protocol factory. NOTE: If this flag is true, providers that attempt to access IFileID.getURL() may be unable to do so, since the URI may not be successfully parsed as a URL.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="since"/>
- </appinfo>
+ </appInfo>
<documentation>
1.0.0
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="examples"/>
- </appinfo>
+ </appInfo>
<documentation>
&lt;pre&gt;
&lt;extension
@@ -105,9 +117,9 @@
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="apiInfo"/>
- </appinfo>
+ </appInfo>
<documentation>
Here is the &lt;b&gt;org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory&lt;/b&gt;
@@ -130,20 +142,19 @@ public interface IRetrieveFileTransferFactory {
</documentation>
</annotation>
-
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="implementation"/>
- </appinfo>
+ </appInfo>
<documentation>
None
</documentation>
</annotation>
<annotation>
- <appinfo>
+ <appInfo>
<meta.section type="copyright"/>
- </appinfo>
+ </appInfo>
<documentation>
Copyright (c) 2004 Composent, Inc., IBM 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, IBM, Inc. - Initial API and implementation
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/internal/provider/filetransfer/Activator.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/internal/provider/filetransfer/Activator.java
index b254937f4..9a2038170 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/internal/provider/filetransfer/Activator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/internal/provider/filetransfer/Activator.java
@@ -70,6 +70,7 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
private static final String PRIORITY_ATTR = "priority"; //$NON-NLS-1$
private static final int DEFAULT_PRIORITY = 100;
private static final String PROTOCOL_ATTR = "protocol"; //$NON-NLS-1$
+ private static final String URI_ATTR = "uri"; //$NON-NLS-1$
private static final String[] jvmSchemes = new String[] {Messages.FileTransferNamespace_Http_Protocol, Messages.FileTransferNamespace_Ftp_Protocol, Messages.FileTransferNamespace_File_Protocol, Messages.FileTransferNamespace_Jar_Protocol, Messages.FileTransferNamespace_Https_Protocol, Messages.FileTransferNamespace_Mailto_Protocol, Messages.FileTransferNamespace_Gopher_Protocol};
private static final String URL_HANDLER_PROTOCOL_NAME = "url.handler.protocol"; //$NON-NLS-1$
@@ -441,6 +442,8 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
final String protocol = configElements[i].getAttribute(PROTOCOL_ATTR);
if (protocol == null || "".equals(protocol)) //$NON-NLS-1$
return;
+ String uriStr = configElements[i].getAttribute(URI_ATTR);
+ boolean uri = (uriStr == null) ? false : Boolean.valueOf(uriStr).booleanValue();
String CONTRIBUTION_WARNING = "File retrieve contribution"; //$NON-NLS-1$
try {
String pluginId = configElements[i].getDeclaringExtension().getContributor().getName();
@@ -452,7 +455,7 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
int priority = getPriority(configElements[i], CONTRIBUTION_WARNING, protocol);
String contributorName = configElements[i].getDeclaringExtension().getContributor().getName();
// Now add new ProtocolFactory
- setRetrieveFileTransferFactory(protocol, contributorName, retrieveFactory, priority);
+ setRetrieveFileTransferFactory(protocol, contributorName, retrieveFactory, priority, uri);
} else {
Activator.getDefault().log(new Status(IStatus.WARNING, PLUGIN_ID, IStatus.WARNING, "Plugin " + pluginId + " excluded from contributing retrieve factory", null)); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -478,6 +481,8 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
final String protocol = configElements[i].getAttribute(PROTOCOL_ATTR);
if (protocol == null || "".equals(protocol)) //$NON-NLS-1$
return;
+ String uriStr = configElements[i].getAttribute(URI_ATTR);
+ boolean uri = (uriStr == null) ? false : Boolean.valueOf(uriStr).booleanValue();
String CONTRIBUTION_WARNING = "File send contribution"; //$NON-NLS-1$
try {
String pluginId = configElements[i].getDeclaringExtension().getContributor().getName();
@@ -487,7 +492,7 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
final ISendFileTransferFactory clazz = (ISendFileTransferFactory) configElements[i].createExecutableExtension(CLASS_ATTR);
// Get priority for new entry, if optional priority attribute specified
int priority = getPriority(configElements[i], CONTRIBUTION_WARNING, protocol);
- setSendFileTransferFactory(protocol, pluginId, clazz, priority);
+ setSendFileTransferFactory(protocol, pluginId, clazz, priority, uri);
} else {
Activator.getDefault().log(new Status(IStatus.WARNING, PLUGIN_ID, IStatus.WARNING, "Plugin " + pluginId + " excluded from contributing send factory", null)); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -513,6 +518,8 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
final String protocol = configElements[i].getAttribute(PROTOCOL_ATTR);
if (protocol == null || "".equals(protocol)) //$NON-NLS-1$
return;
+ String uriStr = configElements[i].getAttribute(URI_ATTR);
+ boolean uri = (uriStr == null) ? false : Boolean.valueOf(uriStr).booleanValue();
String CONTRIBUTION_WARNING = "File browse contribution"; //$NON-NLS-1$
try {
String pluginId = configElements[i].getDeclaringExtension().getContributor().getName();
@@ -522,7 +529,7 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
final IRemoteFileSystemBrowserFactory clazz = (IRemoteFileSystemBrowserFactory) configElements[i].createExecutableExtension(CLASS_ATTR);
// Get priority for new entry, if optional priority attribute specified
int priority = getPriority(configElements[i], CONTRIBUTION_WARNING, protocol);
- setBrowseFileTransferFactory(protocol, pluginId, clazz, priority);
+ setBrowseFileTransferFactory(protocol, pluginId, clazz, priority, uri);
} else {
Activator.getDefault().log(new Status(IStatus.WARNING, PLUGIN_ID, IStatus.WARNING, "Plugin " + pluginId + " excluded from contributing browse factory", null)); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -647,6 +654,10 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
}
public boolean setRetrieveFileTransferFactory(String protocol, String id, IRetrieveFileTransferFactory factory, int priority) {
+ return setRetrieveFileTransferFactory(protocol, id, factory, priority, false);
+ }
+
+ public boolean setRetrieveFileTransferFactory(String protocol, String id, IRetrieveFileTransferFactory factory, int priority, boolean uri) {
if (protocol == null || "".equals(protocol)) //$NON-NLS-1$
return false;
if (id == null)
@@ -675,10 +686,13 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
Activator.getDefault().log(new Status(IStatus.WARNING, PLUGIN_ID, IStatus.WARNING, NLS.bind("{0} for protocol {1} from {2} will be used in preference to existing handler. New handler has higher priority={3}<{4}.", new Object[] {CONTRIBUTION_WARNING, protocol, id, new Integer(priority), new Integer(oldProtocolFactory.priority)}), null)); //$NON-NLS-1$
}
}
- String[] existingSchemes = getPlatformSupportedSchemes();
- if (!isSchemeRegistered(protocol, existingSchemes))
- registerScheme(protocol);
- // Finally, put clazz in map with protocol as key
+ // If !uri, then check/register protocol as URLStreamHandlerService
+ if (!uri) {
+ String[] existingSchemes = getPlatformSupportedSchemes();
+ if (!isSchemeRegistered(protocol, existingSchemes))
+ registerScheme(protocol);
+ }
+ // Finally, put protocol factory in map with protocol as key
retrieveFileTransferProtocolMap.put(protocol, newProtocolFactory);
return true;
}
@@ -727,6 +741,10 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
}
public boolean setBrowseFileTransferFactory(String protocol, String id, IRemoteFileSystemBrowserFactory factory, int priority) {
+ return setBrowseFileTransferFactory(protocol, id, factory, priority, false);
+ }
+
+ public boolean setBrowseFileTransferFactory(String protocol, String id, IRemoteFileSystemBrowserFactory factory, int priority, boolean uri) {
if (protocol == null || "".equals(protocol)) //$NON-NLS-1$
return false;
if (id == null)
@@ -755,10 +773,13 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
Activator.getDefault().log(new Status(IStatus.WARNING, PLUGIN_ID, IStatus.WARNING, NLS.bind("{0} for protocol {1} from {2} will be used in preference to existing handler. New handler has higher priority={3}<{4}.", new Object[] {CONTRIBUTION_WARNING, protocol, id, new Integer(priority), new Integer(oldProtocolFactory.priority)}), null)); //$NON-NLS-1$
}
}
- String[] existingSchemes = getPlatformSupportedSchemes();
- if (!isSchemeRegistered(protocol, existingSchemes))
- registerScheme(protocol);
- // Finally, put clazz in map with protocol as key
+ // If !uri, then check/register protocol as URLStreamHandlerService
+ if (!uri) {
+ String[] existingSchemes = getPlatformSupportedSchemes();
+ if (!isSchemeRegistered(protocol, existingSchemes))
+ registerScheme(protocol);
+ }
+ // Finally, put protocol factory in map with protocol as key
browseFileTransferProtocolMap.put(protocol, newProtocolFactory);
return true;
}
@@ -807,6 +828,10 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
}
public boolean setSendFileTransferFactory(String protocol, String id, ISendFileTransferFactory factory, int priority) {
+ return setSendFileTransferFactory(protocol, id, factory, priority, false);
+ }
+
+ public boolean setSendFileTransferFactory(String protocol, String id, ISendFileTransferFactory factory, int priority, boolean uri) {
if (protocol == null || "".equals(protocol)) //$NON-NLS-1$
return false;
if (id == null)
@@ -835,10 +860,13 @@ public class Activator implements BundleActivator, IFileTransferProtocolToFactor
Activator.getDefault().log(new Status(IStatus.WARNING, PLUGIN_ID, IStatus.WARNING, NLS.bind("{0} for protocol {1} from {2} will be used in preference to existing handler. New handler has higher priority={3}<{4}.", new Object[] {CONTRIBUTION_WARNING, protocol, id, new Integer(priority), new Integer(oldProtocolFactory.priority)}), null)); //$NON-NLS-1$
}
}
- String[] existingSchemes = getPlatformSupportedSchemes();
- if (!isSchemeRegistered(protocol, existingSchemes))
- registerScheme(protocol);
- // Finally, put clazz in map with protocol as key
+ // If !uri, then check/register protocol as URLStreamHandlerService
+ if (!uri) {
+ String[] existingSchemes = getPlatformSupportedSchemes();
+ if (!isSchemeRegistered(protocol, existingSchemes))
+ registerScheme(protocol);
+ }
+ // Finally, put protocol factory in map with protocol as key
sendFileTransferProtocolMap.put(protocol, newProtocolFactory);
return true;
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/IFileTransferProtocolToFactoryMapper.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/IFileTransferProtocolToFactoryMapper.java
index 42bdf82cc..8f6f7ecdb 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/IFileTransferProtocolToFactoryMapper.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/IFileTransferProtocolToFactoryMapper.java
@@ -38,6 +38,29 @@ public interface IFileTransferProtocolToFactoryMapper {
public boolean setRetrieveFileTransferFactory(String protocol, String id, IRetrieveFileTransferFactory factory, int priority);
/**
+ * <p>
+ * For the given protocol, set the given factory to be used for retrieve file transfer. If successful, subsequent retrieve
+ * requests for the given protocol will use the given factory. </p>
+ * <p>For this method to be successful the protocol has to be
+ * non-null, the id has to be non-null and unique (should probably be set to the bundle symbolic name of the bundle calling this
+ * method), the factory must be non-null, and the priority must be higher (a *smaller number*) than any existing factory for the
+ * given protocol. The default priority is 100, and the highest priority is 0.
+ * </p>
+ * @param protocol the protocol (e.g. http/https) to map the factory to.
+ * @param id a unique id for the factory (should be bundle symbolic name of bundle calling method)
+ * @param factory the factory to associate with the given protocol
+ * @param priority priority (highest = 0) to use for this factory relative to any existing factories.
+ * @param uri if <code>true</code> the factory is added as a URI rather than a URL, meaning that <b>no</b> URLStreamHandler is
+ * registered for the given protocol. This is in contrast to the {@link #setRetrieveFileTransferFactory(String, String, IRetrieveFileTransferFactory, int)},
+ * which automatically registers an URLStreamHandler for the given protocol. If false, URLs will be used and an URLStreamHandler will be registered for the
+ * given protocol factory. NOTE: If this flag is true, providers that attempt to access IFileID.getURL() may be unable to do so, since the
+ * URI may not be successfully parsed as a URL.
+ *
+ * @return <code>true</code> if the given factory was set for this protocol, <code>false</code> if not
+ */
+ public boolean setRetrieveFileTransferFactory(String protocol, String id, IRetrieveFileTransferFactory factory, int priority, boolean uri);
+
+ /**
* Get the factory id of the active factory for the given protocol. If the given protocol does not have an
* active factory, returns <code>null</code>.
*
@@ -81,6 +104,29 @@ public interface IFileTransferProtocolToFactoryMapper {
public boolean setBrowseFileTransferFactory(String protocol, String id, IRemoteFileSystemBrowserFactory factory, int priority);
/**
+ * <p>
+ * For the given protocol, set the given factory to be used for retrieve file transfer. If successful, subsequent retrieve
+ * requests for the given protocol will use the given factory. </p>
+ * <p>For this method to be successful the protocol has to be
+ * non-null, the id has to be non-null and unique (should probably be set to the bundle symbolic name of the bundle calling this
+ * method), the factory must be non-null, and the priority must be higher (a *smaller number*) than any existing factory for the
+ * given protocol. The default priority is 100, and the highest priority is 0.
+ * </p>
+ * @param protocol the protocol (e.g. http/https) to map the factory to.
+ * @param id a unique id for the factory (should be bundle symbolic name of bundle calling method)
+ * @param factory the factory to associate with the given protocol
+ * @param priority priority (highest = 0) to use for this factory relative to any existing factories.
+ * @param uri if <code>true</code> the factory is added as a URI rather than a URL, meaning that <b>no</b> URLStreamHandler is
+ * registered for the given protocol. This is in contrast to the {@link #setRetrieveFileTransferFactory(String, String, IRetrieveFileTransferFactory, int)},
+ * which automatically registers an URLStreamHandler for the given protocol. If false, URLs will be used and an URLStreamHandler will be registered for the
+ * given protocol factory. NOTE: If this flag is true, providers that attempt to access IFileID.getURL() may be unable to do so, since the
+ * URI may not be successfully parsed as a URL.
+ *
+ * @return <code>true</code> if the given factory was set for this protocol, <code>false</code> if not
+ */
+ public boolean setBrowseFileTransferFactory(String protocol, String id, IRemoteFileSystemBrowserFactory factory, int priority, boolean uri);
+
+ /**
* Get the factory id of the active factory for the given protocol. If the given protocol does not have an
* active factory, returns <code>null</code>.
*
@@ -124,6 +170,29 @@ public interface IFileTransferProtocolToFactoryMapper {
public boolean setSendFileTransferFactory(String protocol, String id, ISendFileTransferFactory factory, int priority);
/**
+ * <p>
+ * For the given protocol, set the given factory to be used for retrieve file transfer. If successful, subsequent retrieve
+ * requests for the given protocol will use the given factory. </p>
+ * <p>For this method to be successful the protocol has to be
+ * non-null, the id has to be non-null and unique (should probably be set to the bundle symbolic name of the bundle calling this
+ * method), the factory must be non-null, and the priority must be higher (a *smaller number*) than any existing factory for the
+ * given protocol. The default priority is 100, and the highest priority is 0.
+ * </p>
+ * @param protocol the protocol (e.g. http/https) to map the factory to.
+ * @param id a unique id for the factory (should be bundle symbolic name of bundle calling method)
+ * @param factory the factory to associate with the given protocol
+ * @param priority priority (highest = 0) to use for this factory relative to any existing factories.
+ * @param uri if <code>true</code> the factory is added as a URI rather than a URL, meaning that <b>no</b> URLStreamHandler is
+ * registered for the given protocol. This is in contrast to the {@link #setRetrieveFileTransferFactory(String, String, IRetrieveFileTransferFactory, int)},
+ * which automatically registers an URLStreamHandler for the given protocol. If false, URLs will be used and an URLStreamHandler will be registered for the
+ * given protocol factory. NOTE: If this flag is true, providers that attempt to access IFileID.getURL() may be unable to do so, since the
+ * URI may not be successfully parsed as a URL.
+ *
+ * @return <code>true</code> if the given factory was set for this protocol, <code>false</code> if not
+ */
+ public boolean setSendFileTransferFactory(String protocol, String id, ISendFileTransferFactory factory, int priority, boolean uri);
+
+ /**
* Get the factory id of the active factory for the given protocol. If the given protocol does not have an
* active factory, returns <code>null</code>.
*
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java
index 378c1f370..3b3edb2bb 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferID.java
@@ -10,6 +10,9 @@
*****************************************************************************/
package org.eclipse.ecf.provider.filetransfer.identity;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.identity.BaseID;
@@ -22,6 +25,7 @@ public class FileTransferID extends BaseID implements IFileID {
private static final long serialVersionUID = 1274308869502156992L;
URL fileURL;
+ URI fileURI;
public FileTransferID(Namespace namespace, URL url) {
super(namespace);
@@ -29,28 +33,47 @@ public class FileTransferID extends BaseID implements IFileID {
this.fileURL = url;
}
+ /**
+ * @since 3.2
+ */
+ public FileTransferID(Namespace namespace, URI uri) {
+ super(namespace);
+ Assert.isNotNull(uri, "FileTransferID URI cannot be null"); //$NON-NLS-1$
+ this.fileURI = uri;
+ }
+
protected int namespaceCompareTo(BaseID o) {
- return this.fileURL.toExternalForm().compareTo(((FileTransferID) o).toExternalForm());
+ if (o == null)
+ return 1;
+ if (!(o instanceof FileTransferID))
+ return 1;
+
+ return (fileURI != null) ? fileURI.compareTo(((FileTransferID) o).fileURI) : fileURL.toExternalForm().compareTo(((FileTransferID) o).toExternalForm());
}
protected boolean namespaceEquals(BaseID o) {
- return this.fileURL.equals(((FileTransferID) o).fileURL);
+ if (o == null)
+ return false;
+ if (!(o instanceof FileTransferID))
+ return false;
+
+ return (fileURI != null) ? fileURI.equals(((FileTransferID) o).fileURI) : fileURL.equals(((FileTransferID) o).fileURL);
}
protected String namespaceGetName() {
- return this.fileURL.toExternalForm();
+ return (fileURI != null) ? fileURI.toASCIIString() : fileURL.toExternalForm();
}
protected int namespaceHashCode() {
- return this.fileURL.hashCode();
+ return (fileURI != null) ? fileURI.hashCode() : this.fileURL.hashCode();
}
public String getFilename() {
return getFileNameOnly();
}
- public URL getURL() {
- return this.fileURL;
+ public URL getURL() throws MalformedURLException {
+ return (fileURI != null) ? fileURI.toURL() : fileURL;
}
protected String getFileNameOnly() {
@@ -64,4 +87,11 @@ public class FileTransferID extends BaseID implements IFileID {
b.append("]"); //$NON-NLS-1$
return b.toString();
}
+
+ /**
+ * @since 3.2
+ */
+ public URI getURI() throws URISyntaxException {
+ return (fileURI != null) ? fileURI : new URI(fileURL.toExternalForm());
+ }
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferNamespace.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferNamespace.java
index cc1cedeb1..5252af1d7 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/identity/FileTransferNamespace.java
@@ -8,6 +8,7 @@
******************************************************************************/
package org.eclipse.ecf.provider.filetransfer.identity;
+import java.net.URI;
import java.net.URL;
import java.util.HashSet;
import java.util.Set;
@@ -51,11 +52,13 @@ public class FileTransferNamespace extends Namespace {
try {
String init = getInitFromExternalForm(args);
if (init != null)
- return new FileTransferID(this, new URL(init));
+ return new FileTransferID(this, new URI(init));
if (args[0] instanceof URL)
return new FileTransferID(this, (URL) args[0]);
if (args[0] instanceof String)
- return new FileTransferID(this, new URL((String) args[0]));
+ return new FileTransferID(this, new URI((String) args[0]));
+ if (args[0] instanceof URI)
+ return new FileTransferID(this, (URI) args[0]);
} catch (Exception e) {
throw new IDCreateException(Messages.FileTransferNamespace_Exception_Create_Instance, e);
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/MultiProtocolOutgoingAdapter.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/MultiProtocolOutgoingAdapter.java
index 466038c00..38b0b247b 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/MultiProtocolOutgoingAdapter.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/outgoing/MultiProtocolOutgoingAdapter.java
@@ -13,7 +13,9 @@ package org.eclipse.ecf.provider.filetransfer.outgoing;
import java.io.File;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.util.Map;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.Namespace;
@@ -67,15 +69,23 @@ public class MultiProtocolOutgoingAdapter implements ISendFileTransfer {
}
public void sendOutgoingRequest(IFileID targetID, File outgoingFile, IFileTransferListener transferListener, Map options) throws SendFileTransferException {
+
+ Assert.isNotNull(targetID);
+ Assert.isNotNull(outgoingFile);
+ Assert.isNotNull(transferListener);
+
String protocol = null;
try {
- protocol = targetID.getURL().getProtocol();
- } catch (final MalformedURLException e) {
- throw new SendFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
+ protocol = targetID.getURI().getScheme();
+ } catch (URISyntaxException e) {
+ try {
+ protocol = targetID.getURL().getProtocol();
+ } catch (final MalformedURLException e1) {
+ throw new SendFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
+ }
}
- ISendFileTransferContainerAdapter fileTransfer = null;
- fileTransfer = Activator.getDefault().getSendFileTransfer(protocol);
+ ISendFileTransferContainerAdapter fileTransfer = Activator.getDefault().getSendFileTransfer(protocol);
// If no handler setup for this protocol then throw
if (fileTransfer == null) {
@@ -111,15 +121,22 @@ public class MultiProtocolOutgoingAdapter implements ISendFileTransfer {
* @see org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter#sendOutgoingRequest(org.eclipse.ecf.filetransfer.identity.IFileID, org.eclipse.ecf.filetransfer.IFileTransferInfo, org.eclipse.ecf.filetransfer.IFileTransferListener, java.util.Map)
*/
public void sendOutgoingRequest(IFileID targetID, IFileTransferInfo localFileToSend, IFileTransferListener transferListener, Map options) throws SendFileTransferException {
+ Assert.isNotNull(targetID);
+ Assert.isNotNull(localFileToSend);
+ Assert.isNotNull(transferListener);
+
String protocol = null;
try {
- protocol = targetID.getURL().getProtocol();
- } catch (final MalformedURLException e) {
- throw new SendFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
+ protocol = targetID.getURI().getScheme();
+ } catch (URISyntaxException e) {
+ try {
+ protocol = targetID.getURL().getProtocol();
+ } catch (final MalformedURLException e1) {
+ throw new SendFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
+ }
}
- ISendFileTransferContainerAdapter fileTransfer = null;
- fileTransfer = Activator.getDefault().getSendFileTransfer(protocol);
+ ISendFileTransferContainerAdapter fileTransfer = Activator.getDefault().getSendFileTransfer(protocol);
// If no handler setup for this protocol then throw
if (fileTransfer == null) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/MultiProtocolRetrieveAdapter.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/MultiProtocolRetrieveAdapter.java
index b3f1cd3d4..1fcf76c23 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/MultiProtocolRetrieveAdapter.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer/src/org/eclipse/ecf/provider/filetransfer/retrieve/MultiProtocolRetrieveAdapter.java
@@ -12,7 +12,9 @@
package org.eclipse.ecf.provider.filetransfer.retrieve;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.util.Map;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.Namespace;
@@ -73,15 +75,21 @@ public class MultiProtocolRetrieveAdapter implements IRetrieveFileTransfer {
*/
public void sendRetrieveRequest(IFileID remoteFileID, IFileTransferListener transferListener, Map options) throws IncomingFileTransferException {
+ Assert.isNotNull(remoteFileID);
+ Assert.isNotNull(transferListener);
+
String protocol = null;
try {
- protocol = remoteFileID.getURL().getProtocol();
- } catch (final MalformedURLException e) {
- throw new IncomingFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
+ protocol = remoteFileID.getURI().getScheme();
+ } catch (URISyntaxException e) {
+ try {
+ protocol = remoteFileID.getURL().getProtocol();
+ } catch (final MalformedURLException e1) {
+ throw new IncomingFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
+ }
}
- IRetrieveFileTransferContainerAdapter fileTransfer = null;
- fileTransfer = Activator.getDefault().getFileTransfer(protocol);
+ IRetrieveFileTransferContainerAdapter fileTransfer = Activator.getDefault().getFileTransfer(protocol);
// We will default to JRE-provided file transfer if nothing else
// available
@@ -107,15 +115,21 @@ public class MultiProtocolRetrieveAdapter implements IRetrieveFileTransfer {
* org.eclipse.ecf.filetransfer.IFileTransferListener, java.util.Map)
*/
public void sendRetrieveRequest(IFileID remoteFileID, IFileRangeSpecification rangeSpecification, IFileTransferListener transferListener, Map options) throws IncomingFileTransferException {
+ Assert.isNotNull(remoteFileID);
+ Assert.isNotNull(transferListener);
+
String protocol = null;
try {
- protocol = remoteFileID.getURL().getProtocol();
- } catch (final MalformedURLException e) {
- throw new IncomingFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
+ protocol = remoteFileID.getURI().getScheme();
+ } catch (URISyntaxException e) {
+ try {
+ protocol = remoteFileID.getURL().getProtocol();
+ } catch (final MalformedURLException e1) {
+ throw new IncomingFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
+ }
}
- IRetrieveFileTransferContainerAdapter fileTransfer = null;
- fileTransfer = Activator.getDefault().getFileTransfer(protocol);
+ IRetrieveFileTransferContainerAdapter fileTransfer = Activator.getDefault().getFileTransfer(protocol);
// We will default to JRE-provided file transfer if nothing else
// available

Back to the top