From: Julien Lancelot Date: Wed, 13 Feb 2013 17:38:07 +0000 (+0100) Subject: Revert "SONAR-3976 Introduce the concept of plugin group" X-Git-Tag: 3.5~161 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1ba490ba651f8339b4d8919a49a79b95a7c66c35;p=sonarqube.git Revert "SONAR-3976 Introduce the concept of plugin group" This reverts commit e1bccb1b2268d6b2bd809c6699e4e96f832c513d. --- diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java b/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java index bc08a0b8d63..f08e78de9a4 100644 --- a/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java +++ b/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java @@ -35,7 +35,6 @@ public class DefaultPluginMetadata implements PluginMetadata, Comparable deprecatedExtensions = Lists.newArrayList(); private String[] pathsToInternalDeps = new String[0]; private String key; - private String group; private String version; private String sonarVersion; private String name; @@ -107,15 +106,6 @@ public class DefaultPluginMetadata implements PluginMetadata, Comparable getDownloads() { List names = new ArrayList(); - List files = (List) FileUtils.listFiles(downloadDir, new String[]{"jar"}, false); + List files = (List) FileUtils.listFiles(downloadDir, new String[] { "jar" }, false); for (File file : files) { names.add(file.getName()); } return names; } - public void download(String groupKey, Version version) { - PluginsGroup group = center.getCenter().getGroup(groupKey); - if (group == null) { - String message = "This plugin does not exist: " + groupKey; + public void download(String pluginKey, Version version) { + Plugin plugin = center.getCenter().getPlugin(pluginKey); + if (plugin == null) { + String message = "This plugin does not exist: " + pluginKey; 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); - } + 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 ec3ed36077d..71ad6c7500d 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,7 +23,6 @@ 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 6b4ef69f904..ec2c02d767f 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,7 +25,6 @@ import org.sonar.updatecenter.common.Release; import java.util.ArrayList; import java.util.List; -@Deprecated public final class SonarUpdate implements Comparable { 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 d2c37342530..b7caf70ca76 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,18 +21,13 @@ package org.sonar.server.plugins; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -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 org.sonar.updatecenter.common.*; 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 c360a6c649d..fec82bd17d7 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,17 +43,15 @@ public final class UpdateCenterMatrixFactory implements ServerComponent { this.downloader = downloader; } - public org.sonar.updatecenter.common.UpdateCenterMatrix getMatrix(boolean refresh) { + public UpdateCenterMatrix getMatrix(boolean refresh) { UpdateCenter center = centerClient.getCenter(refresh); - org.sonar.updatecenter.common.UpdateCenterMatrix matrix = null; + UpdateCenterMatrix matrix = null; if (center != null) { - matrix = new org.sonar.updatecenter.common.UpdateCenterMatrix(center, sonarVersion); + matrix = new UpdateCenterMatrix(center, sonarVersion); matrix.setDate(centerClient.getLastRefreshDate()); for (PluginMetadata metadata : pluginRepository.getMetadata()) { - if (!metadata.isCore()) { - matrix.registerInstalledPlugin(metadata.getKey(), Version.create(metadata.getVersion())); - } + 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 d6eb9e3bfe5..d113ab03a37 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 8c311a0c6ad..2449acb4a9d 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,13 +29,8 @@ class UpdatecenterController < ApplicationController @uninstalls=java_facade.getPluginUninstalls() @downloads=java_facade.getPluginDownloads() - @plugins_groups = {} - installed_plugins.each do |plugin| - group_key = plugin.group - plugins = @plugins_groups[group_key] || [] - plugins << plugin - @plugins_groups[group_key] = plugins - end + @user_plugins=user_plugins() + @core_plugins=core_plugins() end def updates @@ -45,27 +40,23 @@ class UpdatecenterController < ApplicationController @center=nil @matrix=nil @updates_by_plugin={} - @installed_plugins={} + @user_plugins={} @last_compatible={} - installed_plugins.each do |plugin| - @installed_plugins[plugin.getKey()]=plugin.getVersion() + user_plugins.each do |plugin| + @user_plugins[plugin.getKey()]=plugin.getVersion() end load_matrix() if @matrix @center=@matrix.getCenter() - #@matrix.getInstalledGroups().each do |group| - # @installed_plugins[group.key()]=group.masterPlugin.getVersion() - #end - - @matrix.findGroupUpdates().each do |update| - plugin = update.pluginsGroup.masterPlugin + @matrix.findPluginUpdates().each do |update| + plugin=update.getPlugin() @updates_by_plugin[plugin]||=[] @updates_by_plugin[plugin]< - <% updates.sort_by{|c| c.pluginsGroup.key}.each do |update| - plugins_group = update.pluginsGroup - plugin = plugins_group.masterPlugin + <% updates.sort_by{|c| c.getPlugin().getName()}.each do |update| + plugin=update.getPlugin() %> @@ -42,15 +41,6 @@ function installPlugin(key) { <%= plugin.getDescription() %> 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 13ab1455fb4..d313e675353 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() %> - <% if index==0 %><%= h(plugin.getName()) -%> <%= @installed_plugins[plugin.getKey()] -%> -> <% end %> + <% if index==0 %><%= h(plugin.getName()) -%> <%= @user_plugins[plugin.getKey()] -%> -> <% end %> <%= release.getVersion() -%> <%= release_date(release.getDate()) if release.getDate() -%> <%= release.getDescription() -%> 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 2c70a5fc243..0078d749ffc 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 should_deploy_plugin() { + public void deployPlugin() { deployer.start(); // check that the plugin is registered @@ -82,7 +82,7 @@ public class PluginDeployerTest { } @Test - public void should_deploy_plugin_extensions() { + public void deployPluginExtensions() { deployer.start(); // check that the plugin is registered @@ -100,7 +100,7 @@ public class PluginDeployerTest { } @Test - public void should_ignore_jars_which_are_not_plugins() { + public void ignoreJarsWhichAreNotPlugins() { deployer.start(); assertThat(deployer.getMetadata()).isEmpty(); @@ -117,7 +117,7 @@ public class PluginDeployerTest { } @Test(expected = ServerStartException.class) - public void should_fail_if_two_plugins_with_same_key() { + public void failIfTwoPluginsWithSameKey() { deployer.start(); } }