diff options
author | Godin <mandrikov@gmail.com> | 2010-11-04 14:51:33 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-11-04 14:51:33 +0000 |
commit | 31bd637bfc71b907dab84803d3845c3a243a1e11 (patch) | |
tree | 8dae3ec291fab3580220d41ff88028728e87a72a | |
parent | e09a04801ef1a4630bf4c69f279a5024299ef791 (diff) | |
download | sonarqube-31bd637bfc71b907dab84803d3845c3a243a1e11.tar.gz sonarqube-31bd637bfc71b907dab84803d3845c3a243a1e11.zip |
Write warning to log file, when a plugin can't be installed. Add URL to message.
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java | 31 |
1 files changed, 19 insertions, 12 deletions
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<String> getDownloads() { List<String> names = new ArrayList<String>(); - List<File> files = (List<File>)FileUtils.listFiles(downloadDir, new String[]{"jar"}, false); + List<File> files = (List<File>) 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); } } } |