]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5645 Blacklist SCM Activity plugin
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 25 Sep 2014 15:07:59 +0000 (17:07 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 2 Oct 2014 15:52:23 +0000 (17:52 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java
sonar-core/src/main/resources/org/sonar/l10n/core.properties
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java

index dbf7b8af7d1c71cf42d104a1ad32e8d863dec227..5caa64ee892ae216b6044c708498878c1f1aa212 100644 (file)
@@ -258,11 +258,12 @@ import java.util.List;
   @Property(
     key = CoreProperties.SCM_ENABLED_KEY,
     defaultValue = "true",
-    name = "Activation of the SCM Activity step",
-    description = "This property can be set to false in order to deactivate the SCM Activity step.",
+    name = "Activation of the SCM Sensor",
+    description = "This property can be set to false in order to deactivate the SCM Sensor.",
     module = false,
     project = true,
     global = true,
+    category = CoreProperties.CATEGORY_SCM,
     type = PropertyType.BOOLEAN
   ),
   @Property(
@@ -273,7 +274,7 @@ import java.util.List;
     module = false,
     project = true,
     global = false,
-    type = PropertyType.BOOLEAN
+    category = CoreProperties.CATEGORY_SCM
   )
 })
 public final class CorePlugin extends SonarPlugin {
index db2432439cb5326f28b9c3f81d7854b5fbaa78f9..5f02a203649cf6ab5a5ac5074284e8cbc1bcf4ca 100644 (file)
@@ -37,9 +37,12 @@ import org.sonar.updatecenter.common.PluginReferential;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 public class ServerPluginJarsInstaller {
 
@@ -50,9 +53,10 @@ public class ServerPluginJarsInstaller {
   private final ServerPluginJarInstaller installer;
   private final Map<String, PluginMetadata> pluginByKeys = Maps.newHashMap();
   private final ServerUpgradeStatus serverUpgradeStatus;
+  private final static Set<String> BLACKLISTED_PLUGINS = new HashSet<String>(Arrays.asList("scmactivity"));
 
   public ServerPluginJarsInstaller(Server server, ServerUpgradeStatus serverUpgradeStatus,
-                                   DefaultServerFileSystem fs, ServerPluginJarInstaller installer) {
+    DefaultServerFileSystem fs, ServerPluginJarInstaller installer) {
     this.server = server;
     this.serverUpgradeStatus = serverUpgradeStatus;
     this.fs = fs;
@@ -85,18 +89,26 @@ public class ServerPluginJarsInstaller {
     for (File file : fs.getUserPlugins()) {
       DefaultPluginMetadata metadata = installer.extractMetadata(file, false);
       if (StringUtils.isNotBlank(metadata.getKey())) {
-        PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata);
-        if (existing != null) {
-          throw MessageException.of(String.format("Found two files for the same plugin '%s': %s and %s",
-            metadata.getKey(), metadata.getFile().getName(), existing.getFile().getName()));
-        }
+        loadInstalledPlugin(metadata);
+      }
+    }
+  }
+
+  private void loadInstalledPlugin(DefaultPluginMetadata metadata) {
+    if (BLACKLISTED_PLUGINS.contains(metadata.getKey())) {
+      LOG.warn("Plugin {} is blacklisted. Please uninstall it.", metadata.getName());
+    } else {
+      PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata);
+      if (existing != null) {
+        throw MessageException.of(String.format("Found two files for the same plugin '%s': %s and %s",
+          metadata.getKey(), metadata.getFile().getName(), existing.getFile().getName()));
       }
     }
   }
 
   private void moveDownloadedPlugins() {
     if (fs.getDownloadedPluginsDir().exists()) {
-      Collection<File> sourceFiles = FileUtils.listFiles(fs.getDownloadedPluginsDir(), new String[]{"jar"}, false);
+      Collection<File> sourceFiles = FileUtils.listFiles(fs.getDownloadedPluginsDir(), new String[] {"jar"}, false);
       for (File sourceFile : sourceFiles) {
         overridePlugin(sourceFile, true);
       }
@@ -116,7 +128,6 @@ public class ServerPluginJarsInstaller {
     }
   }
 
-
   private void overridePlugin(File sourceFile, boolean deleteSource) {
     File destDir = fs.getUserPluginsDir();
     File destFile = new File(destDir, sourceFile.getName());
@@ -180,7 +191,7 @@ public class ServerPluginJarsInstaller {
   public List<String> getUninstalls() {
     List<String> names = Lists.newArrayList();
     if (fs.getTrashPluginsDir().exists()) {
-      List<File> files = (List<File>) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[]{"jar"}, false);
+      List<File> files = (List<File>) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[] {"jar"}, false);
       for (File file : files) {
         names.add(file.getName());
       }
@@ -190,7 +201,7 @@ public class ServerPluginJarsInstaller {
 
   public void cancelUninstalls() {
     if (fs.getTrashPluginsDir().exists()) {
-      List<File> files = (List<File>) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[]{"jar"}, false);
+      List<File> files = (List<File>) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[] {"jar"}, false);
       for (File file : files) {
         try {
           FileUtils.moveFileToDirectory(file, fs.getUserPluginsDir(), false);
index 891c4e034c40977b869fd336b7a2bc085ee193fc..a269b014eabd7c62ef5700d370bb671dad15f75c 100644 (file)
@@ -942,7 +942,7 @@ property.error.notBoolean=Valid options are "true" and "false"
 property.error.notInteger=Only digits are allowed
 property.error.notFloat=Not a floating point number
 property.error.notInOptions=Not a valid option
-
+property.category.scm=SCM
 
 
 #------------------------------------------------------------------------------
index c9b6c5e7b2067967298230c3a80610fc3f68b84d..e13f6c3581d923c8c8a7660f16c34d44c11c4bf6 100644 (file)
@@ -536,6 +536,11 @@ public interface CoreProperties {
    */
   String LANGUAGE_SPECIFIC_PARAMETERS_SIZE_METRIC_KEY = "size_metric";
 
+  /**
+   * @since 5.0
+   */
+  String CATEGORY_SCM = "scm";
+
   /**
    * @since 5.0
    */