Search in sources :

Example 6 with PluginUpdate

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

the class AvailableAction method writePlugins.

private void writePlugins(JsonWriter jsonWriter, Optional<UpdateCenter> updateCenter) {
    jsonWriter.name(ARRAY_PLUGINS).beginArray();
    if (updateCenter.isPresent()) {
        for (PluginUpdate pluginUpdate : retrieveAvailablePlugins(updateCenter.get())) {
            pluginWSCommons.writePluginUpdate(jsonWriter, pluginUpdate);
        }
    }
    jsonWriter.endArray();
}
Also used : PluginUpdate(org.sonar.updatecenter.common.PluginUpdate)

Example 7 with PluginUpdate

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

the class InstallAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    userSession.checkIsSystemAdministrator();
    String key = request.mandatoryParam(PARAM_KEY);
    PluginUpdate pluginUpdate = findAvailablePluginByKey(key);
    pluginDownloader.download(key, pluginUpdate.getRelease().getVersion());
    response.noContent();
}
Also used : PluginUpdate(org.sonar.updatecenter.common.PluginUpdate)

Example 8 with PluginUpdate

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

the class UpdateAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    userSession.checkIsSystemAdministrator();
    String key = request.mandatoryParam(PARAM_KEY);
    PluginUpdate pluginUpdate = findPluginUpdateByKey(key);
    pluginDownloader.download(key, pluginUpdate.getRelease().getVersion());
    response.noContent();
}
Also used : PluginUpdate(org.sonar.updatecenter.common.PluginUpdate)

Example 9 with PluginUpdate

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

the class UpdateAction method findPluginUpdateByKey.

@Nonnull
private PluginUpdate findPluginUpdateByKey(String key) {
    Optional<UpdateCenter> updateCenter = updateCenterFactory.getUpdateCenter(false);
    PluginUpdate pluginUpdate = MISSING_PLUGIN;
    if (updateCenter.isPresent()) {
        pluginUpdate = Iterables.find(updateCenter.get().findPluginUpdates(), new PluginKeyPredicate(key), MISSING_PLUGIN);
    }
    if (pluginUpdate == MISSING_PLUGIN) {
        throw new IllegalArgumentException(format("No plugin with key '%s' or plugin '%s' is already in latest compatible version", key, key));
    }
    return pluginUpdate;
}
Also used : UpdateCenter(org.sonar.updatecenter.common.UpdateCenter) PluginUpdate(org.sonar.updatecenter.common.PluginUpdate) Nonnull(javax.annotation.Nonnull)

Aggregations

PluginUpdate (org.sonar.updatecenter.common.PluginUpdate)9 Test (org.junit.Test)2 UpdateCenter (org.sonar.updatecenter.common.UpdateCenter)2 Nonnull (javax.annotation.Nonnull)1 Plugin (org.sonar.updatecenter.common.Plugin)1 Release (org.sonar.updatecenter.common.Release)1