Handle Orbit content.
diff --git a/services/licenses.php b/services/licenses.php
index c8b4176..27726bc 100755
--- a/services/licenses.php
+++ b/services/licenses.php
@@ -56,10 +56,10 @@
/*
* Deal with Maven coordinates. There is a special case that we need to deal with
* because of Tycho using p2 repositories. When the coordinates start with
- * "p2.eclipse-plugin", we generate an id for p2/orbit.
+ * "p2.eclipse-plugin" or "p2.eclipse-feature", we generate an id for p2/orbit.
*/
if (preg_match('/([\w@\-.]+):([\w@\-.]+)(?::[\w@\-.]+)?:(\d+(?:\.\d+)*)/', $id, $matches)) {
- if ($matches[1] == 'p2.eclipse-plugin') {
+ if (preg_match('/^p2.eclipse-(?:plugin|feature)$/', $matches[1])) {
return "p2/orbit/{$matches[1]}/{$matches[2]}/{$matches[3]}";
}
return "maven/mavencentral/{$matches[1]}/{$matches[2]}/{$matches[3]}";
@@ -72,7 +72,7 @@
* maps to "maven/mavencentral/org.apache.ant/ant-jsch/1.10.5"
*/
if (preg_match('/p2.eclipse-plugin:([\w@\-.]+)(?::[\w@\-.]+)?:lib\/([\w@\-.]+).jar:(\d+(?:\.\d+)*)/', $id, $matches)) {
- return "maven/mavencentral/{$matches[2]}/{$matches[3]}/{$matches[4]}";
+ return "maven/mavencentral/{$matches[1]}/{$matches[2]}/{$matches[3]}";
}
// TODO add Purl coordinates
return null;
@@ -115,6 +115,19 @@
'authority' => 'eclipse',
'confidence' => 90
);
+ } elseif (preg_match('/^p2.eclipse-(?:plugin|feature)$/', $parts[2])) {
+ if (preg_match('/^org\.eclipse/', $parts[3])) {
+ unset($results['unmatched'][$id]);
+ $results['approved'][$id] = array(
+ 'id' => $id,
+ 'license' => '',
+ 'status' => 'approved',
+ 'sourceUrl' => '',
+ 'definitionUrl' => '',
+ 'authority' => 'eclipse',
+ 'confidence' => 90
+ );
+ }
}
}
}
@@ -271,7 +284,15 @@
function matchAgainstClearlyDefined(&$results) {
$licenses = Licenses::load();
- $unmatched = array_keys($results['unmatched']);
+ $unmatched = array();
+ foreach($results['unmatched'] as $id => $ignore) {
+ /*
+ * ClearlyDefined has a problem with resource types that it
+ * doesn't know about. Let's prune out the p2 ones.
+ */
+ if (preg_match('/^p2\//', $id)) continue;
+ $unmatched[] = $id;
+ }
if ($curl = curl_init('https://api.clearlydefined.io/definitions')) {
$options = array(
@@ -305,6 +326,11 @@
$json = json_decode($contents, true);
+ if (isset($json['error'])) {
+ $results['errors'][] = "ClearlyDefined: {$json['error']['message']}";
+ return;
+ }
+
foreach($json as $id => $record) {
// TODO Investigate why the record sometimes has the _id and sometimes does not.
$metadata = new ClearlyDefinedMetadata($id, $record);