From: Godin Date: Thu, 4 Nov 2010 14:51:33 +0000 (+0000) Subject: Write warning to log file, when a plugin can't be installed. Add URL to message. X-Git-Tag: 2.6~659 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=31bd637bfc71b907dab84803d3845c3a243a1e11;p=sonarqube.git Write warning to log file, when a plugin can't be installed. Add URL to message. --- diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java b/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java index 390e34ecf12..f3d9c23c631 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java @@ -19,22 +19,23 @@ */ package org.sonar.server.plugins; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.ServerComponent; import org.sonar.api.utils.HttpDownloader; +import org.sonar.api.utils.Logs; import org.sonar.api.utils.SonarException; import org.sonar.server.platform.DefaultServerFileSystem; import org.sonar.updatecenter.common.Plugin; import org.sonar.updatecenter.common.Release; import org.sonar.updatecenter.common.Version; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - public class PluginDownloader implements ServerComponent { private UpdateCenterClient center; @@ -74,12 +75,12 @@ public class PluginDownloader implements ServerComponent { } public boolean hasDownloads() { - return getDownloads().size()>0; + return getDownloads().size() > 0; } public List getDownloads() { List names = new ArrayList(); - List files = (List)FileUtils.listFiles(downloadDir, new String[]{"jar"}, false); + List files = (List) FileUtils.listFiles(downloadDir, new String[] { "jar" }, false); for (File file : files) { names.add(file.getName()); } @@ -89,12 +90,16 @@ public class PluginDownloader implements ServerComponent { public void download(String pluginKey, Version version) { Plugin plugin = center.getCenter().getPlugin(pluginKey); if (plugin == null) { - throw new SonarException("This plugin does not exist: " + pluginKey); + String message = "This plugin does not exist: " + pluginKey; + Logs.INFO.warn(message); + throw new SonarException(message); } Release release = plugin.getRelease(version); - if (release == null || release.getDownloadUrl() == null) { - throw new SonarException("This release can not be installed: " + pluginKey + ", version " + version); + if (release == null || StringUtils.isBlank(release.getDownloadUrl())) { + String message = "This release can not be installed: " + pluginKey + ", version " + version; + Logs.INFO.warn(message); + throw new SonarException(message); } try { @@ -103,7 +108,9 @@ public class PluginDownloader implements ServerComponent { downloader.download(uri, new File(downloadDir, filename)); } catch (Exception e) { - throw new SonarException("Fail to download the plugin: " + pluginKey + ", version " + version, e); + String message = "Fail to download the plugin (" + pluginKey + ", version " + version + ") from " + release.getDownloadUrl(); + Logs.INFO.warn(message, e); + throw new SonarException(message, e); } } }