diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-30 16:14:32 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-30 16:14:32 +0200 |
commit | 547e3117e69fefc314f8e395b29442fa5a324099 (patch) | |
tree | ce6baf18e6837ae00be63fe5910446a9471b7df6 | |
parent | 3d598f644c2afeb7b8bb34edc8ba6f53e523ee2e (diff) | |
download | sonarqube-547e3117e69fefc314f8e395b29442fa5a324099.tar.gz sonarqube-547e3117e69fefc314f8e395b29442fa5a324099.zip |
SONAR-4898 fix regression
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java index d9ea45f1b44..3884439e166 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java @@ -20,6 +20,7 @@ package org.sonar.server.plugins; import com.google.common.base.Joiner; +import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.io.FileUtils; @@ -52,7 +53,7 @@ public class ServerPluginJarsInstaller { private final ServerUpgradeStatus serverUpgradeStatus; public ServerPluginJarsInstaller(Server server, ServerUpgradeStatus serverUpgradeStatus, - DefaultServerFileSystem fs, ServerPluginJarInstaller installer) { + DefaultServerFileSystem fs, ServerPluginJarInstaller installer) { this.server = server; this.serverUpgradeStatus = serverUpgradeStatus; this.fs = fs; @@ -96,7 +97,7 @@ public class ServerPluginJarsInstaller { private void moveDownloadedPlugins() { if (fs.getDownloadedPluginsDir().exists()) { - Collection<File> sourceFiles = FileUtils.listFiles(fs.getDownloadedPluginsDir(), new String[] {"jar"}, false); + Collection<File> sourceFiles = FileUtils.listFiles(fs.getDownloadedPluginsDir(), new String[]{"jar"}, false); for (File sourceFile : sourceFiles) { overridePlugin(sourceFile, true); } @@ -116,6 +117,7 @@ public class ServerPluginJarsInstaller { } } + private void overridePlugin(File sourceFile, boolean deleteSource) { File destDir = fs.getUserPluginsDir(); File destFile = new File(destDir, sourceFile.getName()); @@ -179,7 +181,7 @@ public class ServerPluginJarsInstaller { public List<String> getUninstalls() { List<String> names = Lists.newArrayList(); if (fs.getTrashPluginsDir().exists()) { - List<File> files = (List<File>) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[] {"jar"}, false); + List<File> files = (List<File>) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[]{"jar"}, false); for (File file : files) { names.add(file.getName()); } @@ -189,7 +191,7 @@ public class ServerPluginJarsInstaller { public void cancelUninstalls() { if (fs.getTrashPluginsDir().exists()) { - List<File> files = (List<File>) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[] {"jar"}, false); + List<File> files = (List<File>) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[]{"jar"}, false); for (File file : files) { try { FileUtils.moveFileToDirectory(file, fs.getUserPluginsDir(), false); @@ -209,10 +211,9 @@ public class ServerPluginJarsInstaller { private void deploy(DefaultPluginMetadata plugin) { LOG.info("Deploy plugin {}", Joiner.on(" / ").skipNulls().join(plugin.getName(), plugin.getVersion(), plugin.getImplementationBuild())); - if (!plugin.isCompatibleWith(server.getVersion())) { - throw MessageException.of(String.format("Plugin %s needs a more recent version of SonarQube than %s. At least %s is expected", - plugin.getKey(), server.getVersion(), plugin.getSonarVersion())); - } + Preconditions.checkState(plugin.isCompatibleWith(server.getVersion()), + "Plugin %s needs a more recent version of SonarQube than %s. At least %s is expected", + plugin.getKey(), server.getVersion(), plugin.getSonarVersion()); try { File pluginDeployDir = new File(fs.getDeployedPluginsDir(), plugin.getKey()); |