aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-02-13 17:53:02 +0100
committerJulien Lancelot <julien.lancelot@gmail.com>2013-02-13 17:53:16 +0100
commite1bccb1b2268d6b2bd809c6699e4e96f832c513d (patch)
tree02a7a0aae2d8f0f894560f71dd7852501728e404 /sonar-server
parent5edf34024a334785a5f045fafebc20b10d46761f (diff)
downloadsonarqube-e1bccb1b2268d6b2bd809c6699e4e96f832c513d.tar.gz
sonarqube-e1bccb1b2268d6b2bd809c6699e4e96f832c513d.zip
SONAR-3976 Introduce the concept of plugin group
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java11
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java54
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/PluginUpdate.java1
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java1
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java7
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java10
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java12
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb37
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb14
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb33
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/plugins/PluginDeployerTest.java8
12 files changed, 110 insertions, 80 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 6a00e387275..38c2ecbc206 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
@@ -20,7 +20,6 @@
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;
@@ -149,7 +148,15 @@ public class PluginDeployer implements ServerComponent {
}
}
- public void uninstall(String pluginKey) {
+ public void uninstall(String groupKey) {
+ for (PluginMetadata plugin : pluginByKeys.values()) {
+ if (plugin.getGroup().equals(groupKey)) {
+ uninstallPlugin(plugin.getKey());
+ }
+ }
+ }
+
+ private void uninstallPlugin(String pluginKey) {
PluginMetadata metadata = pluginByKeys.get(pluginKey);
if ((metadata != null) && !metadata.isCore()) {
try {
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 6711a8f42bc..1e6f9c91730 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,12 +19,6 @@
*/
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;
@@ -33,9 +27,16 @@ 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.PluginsGroup;
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;
@@ -80,37 +81,40 @@ public class PluginDownloader implements ServerComponent {
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());
}
return names;
}
- public void download(String pluginKey, Version version) {
- Plugin plugin = center.getCenter().getPlugin(pluginKey);
- if (plugin == null) {
- String message = "This plugin does not exist: " + pluginKey;
+ public void download(String groupKey, Version version) {
+ PluginsGroup group = center.getCenter().getGroup(groupKey);
+ if (group == null) {
+ String message = "This plugin does not exist: " + groupKey;
Logs.INFO.warn(message);
throw new SonarException(message);
}
- Release release = plugin.getRelease(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);
- }
+ for (Plugin plugin : group.getPlugins()) {
+ String pluginKey = plugin.getKey();
+ Release release = plugin.getRelease(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 {
- URI uri = new URI(release.getDownloadUrl());
- String filename = StringUtils.substringAfterLast(uri.getPath(), "/");
- downloader.download(uri, new File(downloadDir, filename));
+ try {
+ URI uri = new URI(release.getDownloadUrl());
+ String filename = StringUtils.substringAfterLast(uri.getPath(), "/");
+ downloader.download(uri, new File(downloadDir, filename));
- } catch (Exception e) {
- String message = "Fail to download the plugin (" + pluginKey + ", version " + version + ") from " + release.getDownloadUrl();
- Logs.INFO.warn(message, e);
- throw new SonarException(message, e);
+ } catch (Exception e) {
+ String message = "Fail to download the plugin (" + pluginKey + ", version " + version + ") from " + release.getDownloadUrl();
+ Logs.INFO.warn(message, e);
+ throw new SonarException(message, e);
+ }
}
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/PluginUpdate.java b/sonar-server/src/main/java/org/sonar/server/plugins/PluginUpdate.java
index 71ad6c7500d..ec3ed36077d 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/PluginUpdate.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/PluginUpdate.java
@@ -23,6 +23,7 @@ import org.sonar.updatecenter.common.Plugin;
import org.sonar.updatecenter.common.Release;
import org.sonar.updatecenter.common.Version;
+@Deprecated
public final class PluginUpdate {
public enum Status {
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java b/sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java
index ec2c02d767f..6b4ef69f904 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java
@@ -25,6 +25,7 @@ import org.sonar.updatecenter.common.Release;
import java.util.ArrayList;
import java.util.List;
+@Deprecated
public final class SonarUpdate implements Comparable<SonarUpdate> {
private Release release;
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java
index b7caf70ca76..d2c37342530 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java
@@ -21,13 +21,18 @@ package org.sonar.server.plugins;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.sonar.updatecenter.common.*;
+import org.sonar.updatecenter.common.Artifact;
+import org.sonar.updatecenter.common.Plugin;
+import org.sonar.updatecenter.common.Release;
+import org.sonar.updatecenter.common.UpdateCenter;
+import org.sonar.updatecenter.common.Version;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
+@Deprecated
public final class UpdateCenterMatrix {
private UpdateCenter center;
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java
index fec82bd17d7..c360a6c649d 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java
@@ -43,15 +43,17 @@ public final class UpdateCenterMatrixFactory implements ServerComponent {
this.downloader = downloader;
}
- public UpdateCenterMatrix getMatrix(boolean refresh) {
+ public org.sonar.updatecenter.common.UpdateCenterMatrix getMatrix(boolean refresh) {
UpdateCenter center = centerClient.getCenter(refresh);
- UpdateCenterMatrix matrix = null;
+ org.sonar.updatecenter.common.UpdateCenterMatrix matrix = null;
if (center != null) {
- matrix = new UpdateCenterMatrix(center, sonarVersion);
+ matrix = new org.sonar.updatecenter.common.UpdateCenterMatrix(center, sonarVersion);
matrix.setDate(centerClient.getLastRefreshDate());
for (PluginMetadata metadata : pluginRepository.getMetadata()) {
- matrix.registerInstalledPlugin(metadata.getKey(), Version.create(metadata.getVersion()));
+ if (!metadata.isCore()) {
+ matrix.registerInstalledPlugin(metadata.getKey(), Version.create(metadata.getVersion()));
+ }
}
for (String filename : downloader.getDownloads()) {
matrix.registerPendingPluginsByFilename(filename);
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 d113ab03a37..d6eb9e3bfe5 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
@@ -74,10 +74,10 @@ import org.sonar.server.platform.SettingsChangeNotifier;
import org.sonar.server.plugins.DefaultServerPluginRepository;
import org.sonar.server.plugins.PluginDeployer;
import org.sonar.server.plugins.PluginDownloader;
-import org.sonar.server.plugins.UpdateCenterMatrix;
import org.sonar.server.plugins.UpdateCenterMatrixFactory;
import org.sonar.server.rules.ProfilesConsole;
import org.sonar.server.rules.RulesConsole;
+import org.sonar.updatecenter.common.UpdateCenterMatrix;
import org.sonar.updatecenter.common.Version;
import javax.annotation.Nullable;
@@ -325,7 +325,7 @@ public final class JRubyFacade {
public void ruleSeverityChanged(int parentProfileId, int activeRuleId, int oldSeverityId, int newSeverityId, String userName) {
getProfilesManager().ruleSeverityChanged(parentProfileId, activeRuleId, RulePriority.values()[oldSeverityId],
- RulePriority.values()[newSeverityId], userName);
+ RulePriority.values()[newSeverityId], userName);
}
public void ruleDeactivated(int parentProfileId, int deactivatedRuleId, String userName) {
@@ -521,10 +521,10 @@ public final class JRubyFacade {
// notifier is null when creating the administrator in the migration script 011.
if (notifier != null) {
notifier.onNewUser(NewUserHandler.Context.builder()
- .setLogin(fields.get("login"))
- .setName(fields.get("name"))
- .setEmail(fields.get("email"))
- .build());
+ .setLogin(fields.get("login"))
+ .setName(fields.get("name"))
+ .setEmail(fields.get("email"))
+ .build());
}
}
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 2449acb4a9d..8c311a0c6ad 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
@@ -29,8 +29,13 @@ class UpdatecenterController < ApplicationController
@uninstalls=java_facade.getPluginUninstalls()
@downloads=java_facade.getPluginDownloads()
- @user_plugins=user_plugins()
- @core_plugins=core_plugins()
+ @plugins_groups = {}
+ installed_plugins.each do |plugin|
+ group_key = plugin.group
+ plugins = @plugins_groups[group_key] || []
+ plugins << plugin
+ @plugins_groups[group_key] = plugins
+ end
end
def updates
@@ -40,23 +45,27 @@ class UpdatecenterController < ApplicationController
@center=nil
@matrix=nil
@updates_by_plugin={}
- @user_plugins={}
+ @installed_plugins={}
@last_compatible={}
- user_plugins.each do |plugin|
- @user_plugins[plugin.getKey()]=plugin.getVersion()
+ installed_plugins.each do |plugin|
+ @installed_plugins[plugin.getKey()]=plugin.getVersion()
end
load_matrix()
if @matrix
@center=@matrix.getCenter()
- @matrix.findPluginUpdates().each do |update|
- plugin=update.getPlugin()
+ #@matrix.getInstalledGroups().each do |group|
+ # @installed_plugins[group.key()]=group.masterPlugin.getVersion()
+ #end
+
+ @matrix.findGroupUpdates().each do |update|
+ plugin = update.pluginsGroup.masterPlugin
@updates_by_plugin[plugin]||=[]
@updates_by_plugin[plugin]<<update
if update.isCompatible
- @last_compatible[plugin.getKey()]=update.getRelease().getVersion()
+ @last_compatible[plugin.key]=update.release.version
end
end
end
@@ -72,11 +81,12 @@ class UpdatecenterController < ApplicationController
load_matrix()
if @matrix
@center=@matrix.getCenter()
- @matrix.findAvailablePlugins().each do |update|
- category=update.getPlugin().getCategory()||''
+ @matrix.findAvailableGroups().each do |update|
+ category = update.pluginsGroup.masterPlugin.category||''
@updates_by_category[category]||=[]
@updates_by_category[category]<<update
end
+
end
end
@@ -132,6 +142,7 @@ class UpdatecenterController < ApplicationController
end
private
+
def load_matrix
@matrix=java_facade.getUpdateCenterMatrix(params[:reload]=='true')
end
@@ -143,11 +154,7 @@ class UpdatecenterController < ApplicationController
end
end
- def user_plugins
+ def installed_plugins
java_facade.getPluginsMetadata().select{|plugin| !plugin.isCore()}.sort
end
-
- def core_plugins
- java_facade.getPluginsMetadata().select{|plugin| plugin.isCore()}.sort
- end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb
index 0f5defd15af..10e3bf7d193 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb
@@ -31,8 +31,9 @@ function installPlugin(key) {
</tr>
</thead>
<tbody>
- <% updates.sort_by{|c| c.getPlugin().getName()}.each do |update|
- plugin=update.getPlugin()
+ <% updates.sort_by{|c| c.pluginsGroup.key}.each do |update|
+ plugins_group = update.pluginsGroup
+ plugin = plugins_group.masterPlugin
%>
<tr class="<%= cycle('even','odd', :name => category) -%>">
<td width="150" nowrap>
@@ -41,6 +42,15 @@ function installPlugin(key) {
<td>
<%= plugin.getDescription() %>
<div id="detail-<%= plugin.getKey() -%>" style="display:none">
+
+ <% plugins_group.plugins.each do |sub_plugin| %>
+ <% if sub_plugin.key != plugin.key %>
+ <div>
+ <span><%= sub_plugin.name -%></span> : <span><%= sub_plugin.description -%></span>
+ </div>
+ <% end %>
+ <% end %>
+
<table class="spaced width100">
<% if plugin.getLicense() %>
<tr>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb
index f483d55f8e3..23f96068916 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb
@@ -16,10 +16,11 @@
</tr>
</thead>
<tbody>
- <% if @user_plugins.empty? %>
+ <% if @plugins_groups.empty? %>
<tr class="even"><td colspan="5">No plugins</td></tr>
<% else
- @user_plugins.each do |plugin|
+ @plugins_groups.each do |group_key, plugins|
+ plugin = plugins.find {|plugin| plugin.key == group_key}
%>
<tr class="select <%= cycle('even', 'odd', :name => 'user') -%>" id="select_<%= plugin.getKey() -%>">
<td width="1%" nowrap><b><a href="#plugin" onclick="showPlugin('<%= plugin.getKey() -%>')"><%= h(plugin.getName()) -%></a></b> <span class="note">[<%= h plugin.getKey() -%>]</span></td>
@@ -28,6 +29,16 @@
<%= plugin.getDescription() -%>
<div id="detail-<%= plugin.getKey() -%>" style="display:none">
+
+
+ <% plugins.each do |sub_plugin| %>
+ <% if sub_plugin.key != plugin.key %>
+ <div>
+ <span><%= sub_plugin.name -%></span> : <span><%= sub_plugin.description -%></span>
+ </div>
+ <% end %>
+ <% end %>
+
<table class="spaced width100">
<% if plugin.getLicense() %><tr><td class="thin nowrap"><b>License:</b> </td><td><%= plugin.getLicense() -%></td></tr><% end %>
<% if plugin.getOrganization() %>
@@ -59,23 +70,5 @@
</tbody>
</table>
- <div class="break30"> </div>
-
- <table class="data width100" id="system-plugins">
- <thead>
- <tr><th colspan="3"><h2>System plugins</h2></th></tr>
- </thead>
- <tbody>
- <%
- @core_plugins.each do |plugin|
- %>
- <tr class="<%= cycle('even','odd', :name => 'core') -%>" id="<%= u plugin.getKey() -%>">
- <td width="1%" nowrap><b><%= plugin.getName() -%></b> <span class="note">[<%= h plugin.getKey() -%>]</span></td>
- <td><%= plugin.getDescription() -%></td>
- </tr>
- <% end %>
- </tbody>
- </table>
-
</div>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb
index d313e675353..13ab1455fb4 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb
@@ -32,7 +32,7 @@ function upgradePlugin(key) {
release=update.getRelease()
%>
<tr class="<%= css -%>">
- <td width="1%" nowrap><% if index==0 %><b><%= h(plugin.getName()) -%></b> <%= @user_plugins[plugin.getKey()] -%> -> <% end %></td>
+ <td width="1%" nowrap><% if index==0 %><b><%= h(plugin.getName()) -%></b> <%= @installed_plugins[plugin.getKey()] -%> -> <% end %></td>
<td width="1%" nowrap><b><%= release.getVersion() -%></b></td>
<td width="1%" nowrap><%= release_date(release.getDate()) if release.getDate() -%></td>
<td><%= release.getDescription() -%></td>
diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/PluginDeployerTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/PluginDeployerTest.java
index 0078d749ffc..2c70a5fc243 100644
--- a/sonar-server/src/test/java/org/sonar/server/plugins/PluginDeployerTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/plugins/PluginDeployerTest.java
@@ -63,7 +63,7 @@ public class PluginDeployerTest {
}
@Test
- public void deployPlugin() {
+ public void should_deploy_plugin() {
deployer.start();
// check that the plugin is registered
@@ -82,7 +82,7 @@ public class PluginDeployerTest {
}
@Test
- public void deployPluginExtensions() {
+ public void should_deploy_plugin_extensions() {
deployer.start();
// check that the plugin is registered
@@ -100,7 +100,7 @@ public class PluginDeployerTest {
}
@Test
- public void ignoreJarsWhichAreNotPlugins() {
+ public void should_ignore_jars_which_are_not_plugins() {
deployer.start();
assertThat(deployer.getMetadata()).isEmpty();
@@ -117,7 +117,7 @@ public class PluginDeployerTest {
}
@Test(expected = ServerStartException.class)
- public void failIfTwoPluginsWithSameKey() {
+ public void should_fail_if_two_plugins_with_same_key() {
deployer.start();
}
}