diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse')
4 files changed, 40 insertions, 28 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java index 2e32d3a3d..bb0a87c5e 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 IBM Corporation and others. + * Copyright (c) 2007, 2010 IBM Corporation 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 @@ -15,7 +15,6 @@ import java.net.*; import java.util.List; import org.eclipse.core.runtime.*; import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.p2.core.helpers.URLUtil; import org.eclipse.equinox.internal.p2.update.*; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; import org.eclipse.equinox.p2.core.ProvisionException; @@ -115,12 +114,7 @@ public class PlatformConfigurationWrapper { */ private Site createSite(URI location, String policy) { Site result = new Site(); - try { - result.setUrl(URIUtil.toURL(location).toExternalForm()); - } catch (MalformedURLException e) { - // TODO - result.setUrl(location.toString()); - } + result.setUrl(location.toString()); result.setPolicy(policy); result.setEnabled(true); return result; @@ -135,12 +129,12 @@ public class PlatformConfigurationWrapper { File file = URIUtil.toFile(url); for (Site nextSite : sites) { try { - File nextFile = URLUtil.toFile(new URL(nextSite.getUrl())); + File nextFile = URIUtil.toFile(new URI(nextSite.getUrl())); if (nextFile == null) continue; if (nextFile.equals(file)) return nextSite; - } catch (MalformedURLException e) { + } catch (URISyntaxException e) { //ignore incorrectly formed site } } diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java index 4e2cbd18c..14e9f5085 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. + * Copyright (c) 2007, 2010 IBM Corporation 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 @@ -11,11 +11,11 @@ package org.eclipse.equinox.internal.p2.update; import java.io.*; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.*; import java.util.ArrayList; import java.util.StringTokenizer; import javax.xml.parsers.*; +import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.osgi.util.NLS; import org.w3c.dom.*; @@ -128,8 +128,16 @@ public class ConfigurationParser implements ConfigurationConstants { if (updateable != null) result.setUpdateable(Boolean.valueOf(updateable).booleanValue()); String url = getAttribute(node, ATTRIBUTE_URL); - if (url != null) - result.setUrl(getLocation(url)); + if (url != null) { + try { + // do this to ensure the location is an encoded URI + URI uri = URIUtil.fromString(url); + URI osgiURI = URIUtil.toURI(osgiInstallArea); + result.setUrl(getLocation(uri, osgiURI).toString()); + } catch (URISyntaxException e) { + result.setUrl(url); + } + } String linkFile = getAttribute(node, ATTRIBUTE_LINKFILE); if (linkFile != null) result.setLinkFile(linkFile); @@ -146,12 +154,12 @@ public class ConfigurationParser implements ConfigurationConstants { * platform:/base/ then return a string which represents the osgi * install area. */ - private String getLocation(String urlString) { - if (osgiInstallArea == null) - return urlString; - if (PLATFORM_BASE.equals(urlString)) - return osgiInstallArea.toExternalForm(); - return PathUtil.makeAbsolute(urlString, osgiInstallArea); + private URI getLocation(URI location, URI osgiArea) { + if (osgiArea == null) + return location; + if (PLATFORM_BASE.equals(location.toString())) + return osgiArea; + return URIUtil.makeAbsolute(location, osgiArea); } /* diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java index a66cedc6c..7ee7ae534 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 2010 IBM Corporation 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 @@ -11,12 +11,10 @@ package org.eclipse.equinox.internal.p2.update; import java.io.*; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.*; import java.util.HashMap; import java.util.Map; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.core.helpers.URLUtil; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Activator; @@ -88,8 +86,14 @@ public class ConfigurationWriter implements ConfigurationConstants { args.put(ATTRIBUTE_POLICY, value); value = site.getUrl(); - if (value != null) + if (value != null) { + try { + value = URIUtil.toUnencodedString(new URI(value)); + } catch (URISyntaxException e) { + // ignore this error and just use the value straight as-is + } args.put(ATTRIBUTE_URL, getLocation(value, osgiInstallArea)); + } value = toString(site.getList()); if (value != null) diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java index ff1f55396..10411b29c 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 2010 IBM Corporation 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 @@ -80,6 +80,9 @@ public class Site { return policy; } + /** + * Note the string that we are returning is an <em>ENCODED</em> URI string. + */ public String getUrl() { return url; } @@ -108,6 +111,9 @@ public class Site { this.updateable = updateable; } + /** + * Note that the string should be an <em>ENCODED</em> URI string. + */ public void setUrl(String url) { this.url = url; } |