diff options
author | Godin <mandrikov@gmail.com> | 2010-10-27 18:50:45 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-10-27 18:50:45 +0000 |
commit | 6e0bd0e0c8a4bfb145131a266d6bb4d1c3be2b52 (patch) | |
tree | 13b98676f93400074e1f903179f850542dc30999 | |
parent | 62346ef1b5ab79e61842f605db1d00224f4ab698 (diff) | |
download | sonarqube-6e0bd0e0c8a4bfb145131a266d6bb4d1c3be2b52.tar.gz sonarqube-6e0bd0e0c8a4bfb145131a266d6bb4d1c3be2b52.zip |
SONAR-1886: Uninstall a plugin
4 files changed, 28 insertions, 4 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java b/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java index a7df673ab6b..b9bde56556c 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java @@ -68,7 +68,7 @@ public final class PluginDeployer implements ServerComponent { public void start() throws IOException { TimeProfiler profiler = new TimeProfiler().start("Install plugins"); - deleteRemovedPlugins(); + deleteUninstalledPlugins(); loadUserPlugins(); moveAndLoadDownloadedPlugins(); @@ -81,7 +81,7 @@ public final class PluginDeployer implements ServerComponent { profiler.stop(); } - private void deleteRemovedPlugins() { + private void deleteUninstalledPlugins() { File trashDir = fileSystem.getRemovedPluginsDir(); try { if (trashDir.exists()) { @@ -112,6 +112,19 @@ public final class PluginDeployer implements ServerComponent { return names; } + public void cancelUninstalls() { + if (fileSystem.getRemovedPluginsDir().exists()) { + List<File> files = (List<File>) FileUtils.listFiles(fileSystem.getRemovedPluginsDir(), new String[] { "jar" }, false); + for (File file : files) { + try { + FileUtils.moveFileToDirectory(file, fileSystem.getUserPluginsDir(), false); + } catch (IOException e) { + throw new SonarException("Fail to cancel plugin uninstalls", e); + } + } + } + } + private void persistPlugins() { List<JpaPlugin> previousPlugins = dao.getPlugins(); List<JpaPlugin> installedPlugins = new ArrayList<JpaPlugin>(); diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 8a68e00ccb3..e9b556c55d8 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -82,6 +82,10 @@ public final class JRubyFacade implements ServerComponent { getContainer().getComponent(PluginDeployer.class).uninstall(pluginKey); } + public void cancelPluginUninstalls() { + getContainer().getComponent(PluginDeployer.class).cancelUninstalls(); + } + public List<String> getPluginUninstalls() { return getContainer().getComponent(PluginDeployer.class).getUninstalls(); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb index b330dcebdde..a3014ae14ff 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb @@ -66,7 +66,7 @@ class UpdatecenterController < ApplicationController end end - def cancel + def cancel_downloads java_facade.cancelPluginDownloads() flash[:notice]="Plugin downloads are canceled." redirect_to :action => 'index' @@ -97,6 +97,12 @@ class UpdatecenterController < ApplicationController redirect_to :action => 'index' end + def cancel_uninstalls + java_facade.cancelPluginUninstalls() + flash[:notice]="Plugin uninstalls are canceled." + redirect_to :action => 'index' + end + private def load_update_finder @finder=java_facade.getUpdateFinder(params[:reload]=='true') diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb index 58772dbcec9..2a72d44f3f7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb @@ -25,12 +25,13 @@ <li><%= uninstall -%></li> <% end %> </ul> + <input type="submit" value="Cancel unistalls"></input> </p> </form> <% end %> <% if @downloads.size > 0 %> -<form action="<%= ApplicationController.root_context -%>/updatecenter/cancel" method="post" class="warning"> +<form action="<%= ApplicationController.root_context -%>/updatecenter/cancel_downloads" method="post" class="warning"> <p>Sonar needs to be restarted in order to install the following plugins: <ul> <% @downloads.each do |download| %> <li><%= download -%></li> |