]> source.dussan.org Git - sonarqube.git/commitdiff
Revert "SONAR-3976 Introduce the concept of plugin group"
authorJulien Lancelot <julien.lancelot@gmail.com>
Wed, 13 Feb 2013 17:38:07 +0000 (18:38 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 14 Feb 2013 07:43:40 +0000 (08:43 +0100)
This reverts commit e1bccb1b2268d6b2bd809c6699e4e96f832c513d.

16 files changed:
sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java
sonar-core/src/main/java/org/sonar/core/plugins/PluginInstaller.java
sonar-core/src/test/java/org/sonar/core/plugins/DefaultPluginMetadataTest.java
sonar-plugin-api/src/main/java/org/sonar/api/platform/PluginMetadata.java
sonar-server/src/main/java/org/sonar/server/plugins/PluginDeployer.java
sonar-server/src/main/java/org/sonar/server/plugins/PluginDownloader.java
sonar-server/src/main/java/org/sonar/server/plugins/PluginUpdate.java
sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java
sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java
sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java
sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb
sonar-server/src/test/java/org/sonar/server/plugins/PluginDeployerTest.java

index bc08a0b8d63a9ae086db53d511382b9d82c5e97d..f08e78de9a40a0b070553fd7b791003e8279d997 100644 (file)
@@ -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;
   }
index 4c988493080ca10381ea6d0ebcaa27d2acc9364a..117011a9a42dc11c80421a6d68cf04eb208d549b 100644 (file)
@@ -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());
index 0ddc9e377227c2f9bbe907f4854fda1ccdaefaa1..0714f5bdf23139abd8b624d3a93c6d2ac72dbcf7 100644 (file)
@@ -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");
index 46c58453046c90778c43b6f7689a4261ae1e28d0..71d70cf6dc599d6735fc4af9355dab49666668d6 100644 (file)
@@ -32,8 +32,6 @@ public interface PluginMetadata {
 
   String getKey();
 
-  String getGroup();
-
   String getName();
 
   String getMainClass();
index 38c2ecbc206e00c88a5a8985d6f7c61669c91c56..6a00e387275ae5c15f636af93109479cf6d3f22c 100644 (file)
@@ -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 {
index 1e6f9c917309430fc755e8d5f0da8ae67ac35249..6711a8f42bcfdb324bc231508105097689e6a06e 100644 (file)
  */
 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);
     }
   }
 }
index ec3ed36077db41a6d1892c87d6b8b0cdec1fdbb6..71ad6c7500da68f27b0ecd18989df3af02e0a391 100644 (file)
@@ -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 {
index 6b4ef69f904a5fa02608d8e2f4a77e1b24f43b3d..ec2c02d767f3d133e506692da60f9f57dc075784 100644 (file)
@@ -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;
index d2c373425302e241276e8cca6bdadd5c6dabf772..b7caf70ca76215494c8503d45c8684700ef0e902 100644 (file)
@@ -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;
index c360a6c649dea7463aacbafb23f37ce1f1b57af1..fec82bd17d7d0a03fc7bc42f7c83fbfcdf129ffa 100644 (file)
@@ -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);
index d6eb9e3bfe5849d99d889b349ce21fd324f6803e..d113ab03a37a89de2c05723aa9099615b8ec393b 100644 (file)
@@ -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());
     }
   }
 
index 8c311a0c6adda7cedeed2d43c501c491edac6d84..2449acb4a9d3359acf8adb3f07a34c4e07398cdf 100644 (file)
@@ -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
index 10e3bf7d1933a6e69323a835fc885898659e7776..0f5defd15afaa4d998ba18214c9b235870191ac4 100644 (file)
@@ -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>
index 23f9606891685a98fe9293c5ff2adba7a4b178c3..f483d55f8e35ee90ebe946553012af249f995a7b 100644 (file)
      </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>
          <%= 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() %>
    </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>
 
index 13ab1455fb45fc315da479cdbb8eece3f038e84d..d313e67535331fa23e20d3625a83b063585857f1 100644 (file)
@@ -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>
index 2c70a5fc243f017d984bdbd5bda8befddaf28146..0078d749ffcae33afa1fed18436756da6faf8af0 100644 (file)
@@ -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();
   }
 }