From: Simon Brandhof Date: Fri, 3 Oct 2014 08:14:28 +0000 (+0200) Subject: Fix administration section in webapp X-Git-Tag: 4.5.1-RC1~119 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6db2ab62cedcbd6e203fd9c1e52744923bbff395;p=sonarqube.git Fix administration section in webapp --- diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/application_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/application_controller.rb index b01a0792d25..9ced766bb35 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/application_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/application_controller.rb @@ -324,10 +324,10 @@ class ApplicationController < ActionController::Base if params[:category].nil? # Select the 'general' category by default. If 'general' category is not found, then return the first one. - default_category = @categories.empty? ? nil : (@categories.find {|c| c == Java::OrgSonarApiConfigInternal::Category.new('general')} || @categories[0]) + default_category = @categories.empty? ? nil : (@categories.find {|c| c && c.key == 'general'} || @categories[0]) @category = default_category else - @category = @categories.find {|c| c == Java::OrgSonarApiConfigInternal::Category.new(params[:category])} + @category = @categories.find {|c| c && c.key == params[:category]} not_found('category') if @category.nil? end @@ -341,7 +341,7 @@ class ApplicationController < ActionController::Base ((@subcategories_per_categories[@category].include? @category) ? @category : @subcategories_per_categories[@category][0]) @subcategory = default_subcategory else - @subcategory = @subcategories_per_categories[@category].find {|s| s == Java::OrgSonarApiConfigInternal::SubCategory.new(params[:subcategory])} + @subcategory = @subcategories_per_categories[@category].find {|s| s && s.key == params[:subcategory]} not_found('subcategory') if @subcategory.nil? end diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java index e4008f2ecea..114abe3fd27 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java @@ -26,7 +26,7 @@ import java.util.Locale; /** * @since 3.7 */ -class Category { +public class Category { private final String originalKey; private final boolean special; @@ -40,15 +40,15 @@ class Category { this.special = special; } - String originalKey() { + public String originalKey() { return originalKey; } - String key() { + public String key() { return StringUtils.lowerCase(originalKey, Locale.ENGLISH); } - boolean isSpecial() { + public boolean isSpecial() { return special; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java index 5c20f786866..6a63144abf2 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java @@ -22,13 +22,20 @@ package org.sonar.api.config; import com.google.common.base.Strings; import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; -import org.sonar.api.*; +import org.sonar.api.BatchComponent; +import org.sonar.api.CoreProperties; import org.sonar.api.Properties; +import org.sonar.api.Property; +import org.sonar.api.ServerComponent; import org.sonar.api.utils.AnnotationUtils; import javax.annotation.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; /** * Metadata of all the properties declared by plugins diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java index 05c96078eca..4a1d884b3a7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java @@ -22,7 +22,7 @@ package org.sonar.api.config; /** * @since 3.7 */ -class SubCategory extends Category { +public class SubCategory extends Category { SubCategory(String originalKey) { super(originalKey); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java index 333b8e15c3e..127e7ea2796 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java @@ -128,12 +128,6 @@ public class PropertyDefinitionsTest { PropertyDefinition.builder("view").name("View").category("catView").onlyOnQualifiers(Qualifiers.VIEW).build() ); - assertThat(def.getPropertiesByCategory(null).keySet()).containsOnly("catGlobal1", "catGlobal2"); - assertThat(def.getPropertiesByCategory(Qualifiers.PROJECT).keySet()).containsOnly("catProject"); - assertThat(def.getPropertiesByCategory(Qualifiers.MODULE).keySet()).containsOnly("catModule"); - assertThat(def.getPropertiesByCategory(Qualifiers.VIEW).keySet()).containsOnly("catView"); - assertThat(def.getPropertiesByCategory("Unkown").keySet()).isEmpty(); - assertThat(def.propertiesByCategory(null).keySet()).contains(new Category("catGlobal1"), new Category("catGlobal2")); assertThat(def.propertiesByCategory(Qualifiers.PROJECT).keySet()).containsOnly(new Category("catProject")); assertThat(def.propertiesByCategory(Qualifiers.MODULE).keySet()).containsOnly(new Category("catModule")); @@ -150,9 +144,6 @@ public class PropertyDefinitionsTest { PropertyDefinition.builder("global4").name("Global4").category("catGlobal2").build() ); - assertThat(def.getPropertiesByCategory(null).get("catGlobal1").keySet()).containsOnly("catGlobal1", "sub1", "sub2"); - assertThat(def.getPropertiesByCategory(null).get("catGlobal2").keySet()).containsOnly("catGlobal2"); - assertThat(def.propertiesByCategory(null).get(new Category("catGlobal1")).keySet()).containsOnly(new SubCategory("catGlobal1"), new SubCategory("sub1"), new SubCategory("sub2")); assertThat(def.propertiesByCategory(null).get(new Category("catGlobal2")).keySet()).containsOnly(new SubCategory("catGlobal2")); @@ -162,10 +153,6 @@ public class PropertyDefinitionsTest { public void should_group_by_category_on_annotation_plugin() { PropertyDefinitions def = new PropertyDefinitions(ByCategory.class); - assertThat(def.getPropertiesByCategory().keySet()).containsOnly("catGlobal1", "catGlobal2"); - assertThat(def.getPropertiesByCategory(Qualifiers.PROJECT).keySet()).containsOnly("catProject"); - assertThat(def.getPropertiesByCategory(Qualifiers.MODULE).keySet()).containsOnly("catModule"); - assertThat(def.propertiesByCategory(null).keySet()).contains(new Category("catglobal1"), new Category("catglobal2")); assertThat(def.propertiesByCategory(Qualifiers.PROJECT).keySet()).containsOnly(new Category("catproject")); assertThat(def.propertiesByCategory(Qualifiers.MODULE).keySet()).containsOnly(new Category("catmodule"));