diff options
16 files changed, 80 insertions, 125 deletions
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<PluginM private List<File> 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<PluginM return this; } - public String getGroup() { - return group != null ? group : key; - } - - public DefaultPluginMetadata setGroup(String group) { - this.group = group; - return this; - } - public String getName() { return name; } diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/PluginInstaller.java b/sonar-core/src/main/java/org/sonar/core/plugins/PluginInstaller.java index 4c988493080..117011a9a42 100644 --- a/sonar-core/src/main/java/org/sonar/core/plugins/PluginInstaller.java +++ b/sonar-core/src/main/java/org/sonar/core/plugins/PluginInstaller.java @@ -106,7 +106,6 @@ public class PluginInstaller { PluginManifest manifest = new PluginManifest(file); DefaultPluginMetadata metadata = DefaultPluginMetadata.create(file); metadata.setKey(manifest.getKey()); - metadata.setGroup(manifest.getGroup()); metadata.setName(manifest.getName()); metadata.setDescription(manifest.getDescription()); metadata.setLicense(manifest.getLicense()); diff --git a/sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java b/sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java index 0ddc9e37722..0714f5bdf23 100644 --- a/sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java +++ b/sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java @@ -35,7 +35,6 @@ public class DefaultPluginMetadataTest { public void testGettersAndSetters() { DefaultPluginMetadata metadata = DefaultPluginMetadata.create(new File("sonar-checkstyle-plugin.jar")); metadata.setKey("checkstyle") - .setGroup("java") .setLicense("LGPL") .setDescription("description") .setHomepage("http://home") @@ -49,7 +48,6 @@ public class DefaultPluginMetadataTest { .setImplementationBuild("abcdef"); assertThat(metadata.getKey()).isEqualTo("checkstyle"); - assertThat(metadata.getGroup()).isEqualTo("java"); assertThat(metadata.getLicense()).isEqualTo("LGPL"); assertThat(metadata.getDescription()).isEqualTo("description"); assertThat(metadata.getHomepage()).isEqualTo("http://home"); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginMetadata.java b/sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginMetadata.java index 46c58453046..71d70cf6dc5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginMetadata.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginMetadata.java @@ -32,8 +32,6 @@ public interface PluginMetadata { String getKey(); - String getGroup(); - String getName(); String getMainClass(); 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 38c2ecbc206..6a00e387275 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,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; @@ -148,15 +149,7 @@ public class PluginDeployer implements ServerComponent { } } - public void uninstall(String groupKey) { - for (PluginMetadata plugin : pluginByKeys.values()) { - if (plugin.getGroup().equals(groupKey)) { - uninstallPlugin(plugin.getKey()); - } - } - } - - private void uninstallPlugin(String pluginKey) { + public void uninstall(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 1e6f9c91730..6711a8f42bc 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,6 +19,12 @@ */ 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; @@ -27,16 +33,9 @@ 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; @@ -81,40 +80,37 @@ 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 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<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 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]<<update if update.isCompatible - @last_compatible[plugin.key]=update.release.version + @last_compatible[plugin.getKey()]=update.getRelease().getVersion() end end end @@ -81,12 +72,11 @@ class UpdatecenterController < ApplicationController load_matrix() if @matrix @center=@matrix.getCenter() - @matrix.findAvailableGroups().each do |update| - category = update.pluginsGroup.masterPlugin.category||'' + @matrix.findAvailablePlugins().each do |update| + category=update.getPlugin().getCategory()||'' @updates_by_category[category]||=[] @updates_by_category[category]<<update end - end end @@ -142,7 +132,6 @@ class UpdatecenterController < ApplicationController end private - def load_matrix @matrix=java_facade.getUpdateCenterMatrix(params[:reload]=='true') end @@ -154,7 +143,11 @@ class UpdatecenterController < ApplicationController end end - def installed_plugins + def user_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 10e3bf7d193..0f5defd15af 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,9 +31,8 @@ function installPlugin(key) { </tr> </thead> <tbody> - <% 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() %> <tr class="<%= cycle('even','odd', :name => category) -%>"> <td width="150" nowrap> @@ -42,15 +41,6 @@ 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 23f96068916..f483d55f8e3 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,11 +16,10 @@ </tr> </thead> <tbody> - <% if @plugins_groups.empty? %> + <% if @user_plugins.empty? %> <tr class="even"><td colspan="5">No plugins</td></tr> <% else - @plugins_groups.each do |group_key, plugins| - plugin = plugins.find {|plugin| plugin.key == group_key} + @user_plugins.each do |plugin| %> <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> @@ -29,16 +28,6 @@ <%= 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() %> @@ -70,5 +59,23 @@ </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 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() %> <tr class="<%= css -%>"> - <td width="1%" nowrap><% if index==0 %><b><%= h(plugin.getName()) -%></b> <%= @installed_plugins[plugin.getKey()] -%> -> <% end %></td> + <td width="1%" nowrap><% if index==0 %><b><%= h(plugin.getName()) -%></b> <%= @user_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 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(); } } |