From 6e0bd0e0c8a4bfb145131a266d6bb4d1c3be2b52 Mon Sep 17 00:00:00 2001 From: Godin Date: Wed, 27 Oct 2010 18:50:45 +0000 Subject: SONAR-1886: Uninstall a plugin --- .../java/org/sonar/server/plugins/PluginDeployer.java | 17 +++++++++++++++-- .../src/main/java/org/sonar/server/ui/JRubyFacade.java | 4 ++++ .../WEB-INF/app/controllers/updatecenter_controller.rb | 8 +++++++- .../WEB-INF/app/views/updatecenter/_operations.html.erb | 3 ++- 4 files changed, 28 insertions(+), 4 deletions(-) (limited to 'sonar-server') 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 files = (List) 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 previousPlugins = dao.getPlugins(); List installedPlugins = new ArrayList(); 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 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 @@
  • <%= uninstall -%>
  • <% end %> +

    <% end %> <% if @downloads.size > 0 %> -
    +

    Sonar needs to be restarted in order to install the following plugins:

      <% @downloads.each do |download| %>
    • <%= download -%>
    • -- cgit v1.2.3