diff options
author | Simon Kaegi | 2009-03-02 17:50:24 +0000 |
---|---|---|
committer | Simon Kaegi | 2009-03-02 17:50:24 +0000 |
commit | fd33e5395cd299fbc19400cca8e501390533bf2f (patch) | |
tree | a7895c1070aa6192272e3be58f9af921d8108989 /bundles | |
parent | d6128dc758dc59349f33ab2c663c8314a12e19c4 (diff) | |
download | rt.equinox.p2-fd33e5395cd299fbc19400cca8e501390533bf2f.tar.gz rt.equinox.p2-fd33e5395cd299fbc19400cca8e501390533bf2f.tar.xz rt.equinox.p2-fd33e5395cd299fbc19400cca8e501390533bf2f.zip |
Bug 266527 metadata XML in 3.5 has changed and is using "uri" instead of "url" for a few elements
Diffstat (limited to 'bundles')
2 files changed, 32 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java index 7344d0ec6..418928960 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java +++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java @@ -11,6 +11,8 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata.repository; +import java.net.MalformedURLException; + import java.io.*; import java.net.URL; import java.util.Iterator; @@ -159,6 +161,15 @@ public class MetadataRepositoryIO { private void writeRepositoryReference(RepositoryReference reference) { start(REPOSITORY_REFERENCE_ELEMENT); attribute(URI_ATTRIBUTE, reference.Location.toString()); + + try { + // we write the URL attribute for backwards compatibility with 3.4.x + // this attribute should be removed if we make a breaking format change. + attribute(URL_ATTRIBUTE, URIUtil.toURL(reference.Location).toExternalForm()); + } catch (MalformedURLException e) { + attribute(URL_ATTRIBUTE, reference.Location.toString()); + } + attribute(TYPE_ATTRIBUTE, Integer.toString(reference.Type)); attribute(OPTIONS_ATTRIBUTE, Integer.toString(reference.Options)); end(REPOSITORY_REFERENCE_ELEMENT); diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java index 3c2c9a344..7afc97afb 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java +++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java @@ -13,10 +13,10 @@ package org.eclipse.equinox.internal.p2.metadata.repository.io; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; import java.util.Iterator; 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.metadata.repository.Activator; import org.eclipse.equinox.internal.p2.persistence.XMLWriter; @@ -258,8 +258,17 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants { start(LICENSES_ELEMENT); attribute(COLLECTION_SIZE_ATTRIBUTE, 1); start(LICENSE_ELEMENT); - if (license.getLocation() != null) + if (license.getLocation() != null) { attribute(URI_ATTRIBUTE, license.getLocation().toString()); + + try { + // we write the URL attribute for backwards compatibility with 3.4.x + // this attribute should be removed if we make a breaking format change. + attribute(URL_ATTRIBUTE, URIUtil.toURL(license.getLocation()).toExternalForm()); + } catch (MalformedURLException e) { + attribute(URL_ATTRIBUTE, license.getLocation().toString()); + } + } cdata(license.getBody(), true); end(LICENSE_ELEMENT); end(LICENSES_ELEMENT); @@ -270,8 +279,16 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants { if (copyright != null) { start(COPYRIGHT_ELEMENT); try { - if (copyright.getLocation() != null) + if (copyright.getLocation() != null) { attribute(URI_ATTRIBUTE, copyright.getLocation().toString()); + try { + // we write the URL attribute for backwards compatibility with 3.4.x + // this attribute should be removed if we make a breaking format change. + attribute(URL_ATTRIBUTE, URIUtil.toURL(copyright.getLocation()).toExternalForm()); + } catch (MalformedURLException e) { + attribute(URL_ATTRIBUTE, copyright.getLocation().toString()); + } + } } catch (IllegalStateException ise) { LogHelper.log(new Status(IStatus.INFO, Activator.ID, "Error writing the copyright URL: " + copyright.getLocation())); //$NON-NLS-1$ } |