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();
}
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();
}
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();
}
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;
}
Aggregations