Search in sources :

Example 1 with Release

use of org.sonar.updatecenter.common.Release in project sonarqube by SonarSource.

the class UpgradesAction method writePluginsToUpdate.

private void writePluginsToUpdate(JsonWriter jsonWriter, List<Release> pluginsToUpgrade) {
    jsonWriter.name(ARRAY_REQUIRE_UPDATE).beginArray();
    for (Release release : pluginsToUpgrade) {
        jsonWriter.beginObject();
        pluginWSCommons.writePlugin(jsonWriter, (Plugin) release.getArtifact());
        String version = isNotBlank(release.getDisplayVersion()) ? release.getDisplayVersion() : release.getVersion().toString();
        jsonWriter.prop(PROPERTY_VERSION, version);
        jsonWriter.endObject();
    }
    jsonWriter.endArray();
}
Also used : Release(org.sonar.updatecenter.common.Release)

Example 2 with Release

use of org.sonar.updatecenter.common.Release in project sonarqube by SonarSource.

the class PluginWSCommons method writeUpdateProperties.

/**
   * Write the update properties to the specified jsonwriter.
   * <pre>
   * "status": "COMPATIBLE",
   * "requires": [
   *   {
   *     "key": "java",
   *     "name": "Java",
   *     "description": "SonarQube rule engine."
   *   }
   * ]
   * </pre>
   */
public void writeUpdateProperties(JsonWriter jsonWriter, PluginUpdate pluginUpdate) {
    jsonWriter.prop(PROPERTY_STATUS, toJSon(pluginUpdate.getStatus()));
    jsonWriter.name(ARRAY_REQUIRES).beginArray();
    Release release = pluginUpdate.getRelease();
    for (Plugin child : filter(transform(release.getOutgoingDependencies(), ReleaseToArtifact.INSTANCE), Plugin.class)) {
        jsonWriter.beginObject();
        jsonWriter.prop(PROPERTY_KEY, child.getKey());
        jsonWriter.prop(PROPERTY_NAME, child.getName());
        jsonWriter.prop(PROPERTY_DESCRIPTION, child.getDescription());
        jsonWriter.endObject();
    }
    jsonWriter.endArray();
}
Also used : Release(org.sonar.updatecenter.common.Release) Plugin(org.sonar.updatecenter.common.Plugin)

Example 3 with Release

use of org.sonar.updatecenter.common.Release in project sonarqube by SonarSource.

the class UpgradesActionTest method createSonar_51_update.

private static SonarUpdate createSonar_51_update() {
    Plugin brandingPlugin = Plugin.factory("branding").setCategory("Integration").setName("Branding").setDescription("Allows to add your own logo to the SonarQube UI.").setHomepageUrl("http://docs.codehaus.org/display/SONAR/Branding+Plugin").setLicense("GNU LGPL 3").setOrganization("SonarSource").setOrganizationUrl("http://www.sonarsource.com").setIssueTrackerUrl("http://jira.sonarsource.com/browse/SONARPLUGINS/component/14663").setSourcesUrl("https://github.com/SonarCommunity/sonar-branding");
    Plugin viewsPlugin = Plugin.factory("views").setName("Views").setCategory("Governance").setDescription("Create aggregation trees to group projects. Projects can for instance be grouped by applications,   applications by team, teams by department.").setHomepageUrl("https://redirect.sonarsource.com/plugins/views.html").setLicense("Commercial").setOrganization("SonarSource").setOrganizationUrl("http://www.sonarsource.com").setTermsConditionsUrl("http://dist.sonarsource.com/SonarSource_Terms_And_Conditions.pdf").setIssueTrackerUrl("http://jira.sonarsource.com/browse/VIEWS");
    release = new Release(new Sonar(), Version.create("5.1.0.5498")).setDate(DateUtils.parseDate("2015-04-02")).setDescription("New overall layout, merge Issues Drilldown [...]").setDownloadUrl("http://dist.sonar.codehaus.org/sonarqube-5.1.zip").setChangelogUrl("http://jira.sonarsource.com/secure/ReleaseNote.jspa?projectId=11694&version=20666");
    SonarUpdate sonarUpdate = new SonarUpdate(release);
    sonarUpdate.addIncompatiblePlugin(brandingPlugin);
    sonarUpdate.addPluginToUpgrade(new Release(viewsPlugin, Version.create("2.8.0.5498")).setDisplayVersion("2.8 (build 5498)"));
    return sonarUpdate;
}
Also used : Sonar(org.sonar.updatecenter.common.Sonar) Release(org.sonar.updatecenter.common.Release) Plugin(org.sonar.updatecenter.common.Plugin) SonarUpdate(org.sonar.updatecenter.common.SonarUpdate)

Example 4 with Release

use of org.sonar.updatecenter.common.Release in project sonarqube by SonarSource.

the class PluginDownloaderTest method download_from_redirect_url.

/**
   * SONAR-4685
   */
@Test
public void download_from_redirect_url() {
    Plugin test = Plugin.factory("plugintest");
    Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/redirect?r=release&g=test&a=test&v=1.0&e=jar");
    test.addRelease(test10);
    when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10));
    pluginDownloader.start();
    pluginDownloader.download("foo", create("1.0"));
    // SONAR-4523: do not corrupt JAR files when restarting the server while a plugin is being downloaded.
    // The JAR file is downloaded in a temp file
    verify(httpDownloader).download(any(URI.class), argThat(new HasFileName("plugintest-1.0.jar.tmp")));
    assertThat(new File(downloadDir, "plugintest-1.0.jar")).exists();
    assertThat(new File(downloadDir, "plugintest-1.0.jar.tmp")).doesNotExist();
}
Also used : URI(java.net.URI) File(java.io.File) Release(org.sonar.updatecenter.common.Release) Plugin(org.sonar.updatecenter.common.Plugin) Test(org.junit.Test)

Example 5 with Release

use of org.sonar.updatecenter.common.Release in project sonarqube by SonarSource.

the class PluginDownloaderTest method download_common_transitive_dependency.

// SONAR-5011
@Test
public void download_common_transitive_dependency() {
    Plugin test1 = Plugin.factory("test1");
    Release test1R = new Release(test1, "1.0").setDownloadUrl("http://server/test1-1.0.jar");
    test1.addRelease(test1R);
    Plugin test2 = Plugin.factory("test2");
    Release test2R = new Release(test2, "1.0").setDownloadUrl("http://server/test2-1.0.jar");
    test2.addRelease(test2R);
    Plugin testDep = Plugin.factory("testdep");
    Release testDepR = new Release(testDep, "1.0").setDownloadUrl("http://server/testdep-1.0.jar");
    testDep.addRelease(testDepR);
    when(updateCenter.findInstallablePlugins("test1", create("1.0"))).thenReturn(newArrayList(test1R, testDepR));
    when(updateCenter.findInstallablePlugins("test2", create("1.0"))).thenReturn(newArrayList(test2R, testDepR));
    pluginDownloader.start();
    pluginDownloader.download("test1", create("1.0"));
    pluginDownloader.download("test2", create("1.0"));
    assertThat(new File(downloadDir, "test1-1.0.jar")).exists();
    assertThat(new File(downloadDir, "test2-1.0.jar")).exists();
    assertThat(new File(downloadDir, "testdep-1.0.jar")).exists();
}
Also used : File(java.io.File) Release(org.sonar.updatecenter.common.Release) Plugin(org.sonar.updatecenter.common.Plugin) Test(org.junit.Test)

Aggregations

Release (org.sonar.updatecenter.common.Release)14 Test (org.junit.Test)10 Plugin (org.sonar.updatecenter.common.Plugin)9 File (java.io.File)5 URI (java.net.URI)4 SonarException (org.sonar.api.utils.SonarException)3 Version (org.sonar.updatecenter.common.Version)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 WsTester (org.sonar.server.ws.WsTester)1 PluginUpdate (org.sonar.updatecenter.common.PluginUpdate)1 Sonar (org.sonar.updatecenter.common.Sonar)1 SonarUpdate (org.sonar.updatecenter.common.SonarUpdate)1 UpdateCenter (org.sonar.updatecenter.common.UpdateCenter)1