| <?php |
| /******************************************************************************* |
| * Copyright (c) 2018 Eclipse Foundation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| *******************************************************************************/ |
| require_once(dirname(__FILE__) . "/../../eclipse.org-common/system/app.class.php"); |
| $App = new App(); |
| require_once(dirname(__FILE__) . "/../classes/common.php"); |
| require_once(dirname(__FILE__) . "/../classes/debug.php"); |
| require_once(dirname(__FILE__) . "/../classes/database.inc"); |
| |
| function getSource($url) { |
| if (preg_match('/https:\/\/github.com\/.*\/commit\/([0-9a-f]+)$/', $url, $matches)) { |
| return array( |
| 'url' => $url, |
| 'type' => 'git', |
| 'provider' => 'github', |
| 'revision' => $matches[1] |
| ); |
| } elseif (preg_match('/https:\/\/git-wip-us\.apache\.org\/repos\/asf\?.*p=([^;]*)\.git.*h=([0-9a-f]+)/', $url, $matches)) { |
| return array( |
| 'url' => "https://github.com/apache/{$matches[1]}/commit/{$matches[2]}", |
| 'type' => 'git', |
| 'provider' => 'github', |
| 'revision' => $matches[2] |
| ); |
| } |
| return null; |
| } |
| |
| $sql = " |
| select |
| CQ.id, |
| description, |
| CQ.version, |
| sourceUrl, |
| spdx as license, |
| mvn.pattern as mvn, |
| mvn.groupid as groupid, |
| mvn.artifactid as artifactid, |
| mvn.version as mvnversion |
| from CQ left |
| join CQMavenMap as mvn on CQ.id=mvn.cq |
| where cq_type='thirdparty' |
| and mvn.groupid is not null |
| and mvn.artifactid is not null |
| and mvn.artifactid != '*' |
| and mvn.groupid not like 'org.eclipse.orbit%' |
| and CQ.version != '' |
| and licenses != '' |
| and (spdx='Apache-2.0' or licenses=spdx)"; |
| $values = array(); |
| query('dashboard', $sql, array(), function($row) use (&$values) { |
| $coordinates = "maven/mavencentral/{$row['groupid']}/{$row['artifactid']}"; |
| $source = getSource($row['sourceUrl']); |
| if ($source) { |
| if (!isset($values[$coordinates])) { |
| $values[$coordinates] = array( |
| 'coordinates' => array( |
| 'name' => $row['artifactid'], |
| 'namespace' => $row['groupid'], |
| 'provider' => 'mavencentral', |
| 'type' => 'maven' |
| ) |
| ); |
| } |
| $values[$coordinates]['revisions'][$row['version']] = $source; |
| $values[$coordinates]['revisions'][$row['version']]['licensed']['declared'] = $row['license']; |
| } |
| }); |
| |
| echo json_encode($values, true); |
| ?> |