[Releng] Improve the RepositoryIntegrityAnalyzer
Avoid using raw.githubusercontent.com because of rate limit problems.
diff --git a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/RepositoryIntegrityAnalyzer.java b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/RepositoryIntegrityAnalyzer.java
index e573474..c881ab4 100644
--- a/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/RepositoryIntegrityAnalyzer.java
+++ b/plugins/org.eclipse.oomph.p2.core/src/org/eclipse/oomph/p2/internal/core/RepositoryIntegrityAnalyzer.java
@@ -3990,14 +3990,12 @@
}
}
- public static final ILicense SUA_10 = load(URI.createURI("https://www.eclipse.org/legal/epl-v10.html"),
- URI.createURI("https://raw.githubusercontent.com/eclipse-cbi/epl-license-feature/license-1.0.0.v20131003-1638/org.eclipse.license/feature.properties"));
+ public static final ILicense SUA_10 = loadLicence(URI.createURI("https://www.eclipse.org/legal/epl-v10.html"), "license-1.0.0.v20131003-1638");
- public static final ILicense SUA_11 = load(URI.createURI("https://www.eclipse.org/legal/epl-v10.html"),
- URI.createURI("https://raw.githubusercontent.com/eclipse-cbi/epl-license-feature/license-1.0.1.v20140414-1359/org.eclipse.license/feature.properties"));
+ public static final ILicense SUA_11 = loadLicence(URI.createURI("https://www.eclipse.org/legal/epl-v10.html"), "license-1.0.1.v20140414-1359");
- public static final ILicense SUA_20 = load(URI.createURI("https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html"),
- URI.createURI("https://raw.githubusercontent.com/eclipse-cbi/epl-license-feature/license-2.0.1.v20180423-1114/org.eclipse.license/feature.properties"));
+ public static final ILicense SUA_20 = loadLicence(URI.createURI("https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html"),
+ "license-2.0.1.v20180423-1114");
public static final List<ILicense> SUAS = Collections.unmodifiableList(Arrays.asList(new ILicense[] { SUA_10, SUA_11, SUA_20 }));
@@ -4227,23 +4225,28 @@
@Override
public abstract String getTitle();
- private static ILicense load(URI licenseURI, URI uri)
+ private static ILicense loadLicence(URI licenseURI, String tag)
{
InputStream in = null;
try
{
- in = URIConverter.INSTANCE.createInputStream(uri);
- Properties properties = new Properties();
- Reader reader = new InputStreamReader(in, "UTF-8");
- properties.load(reader);
- Object license = properties.get("license");
- return MetadataFactory.createLicense(new java.net.URI(licenseURI.toString()), license.toString());
+ in = URIConverter.INSTANCE.createInputStream(
+ URI.createURI("https://api.github.com/repos/eclipse-cbi/epl-license-feature/contents/org.eclipse.license/feature.properties?ref=" + tag));
+ String json = IOUtil.readUTF8(in);
+ Matcher matcher = Pattern.compile("\"content\"\\s*:\\s*\"([^\"]+)\"").matcher(json);
+ if (matcher.find())
+ {
+ String content = matcher.group(1);
+ byte[] bytes = XMLTypeFactory.eINSTANCE.createBase64Binary(content.replace("\\n", ""));
+ Properties properties = new Properties();
+ Reader reader = new InputStreamReader(new ByteArrayInputStream(bytes), "UTF-8");
+ properties.load(reader);
+ Object license = properties.get("license");
+ return MetadataFactory.createLicense(new java.net.URI(licenseURI.toString()), license.toString());
+ }
+ throw new IORuntimeException("No content: " + json);
}
- catch (IOException ex)
- {
- throw new IORuntimeException(ex);
- }
- catch (URISyntaxException ex)
+ catch (Exception ex)
{
throw new IORuntimeException(ex);
}