diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2013-12-02 17:55:26 +0100 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2013-12-03 09:51:06 +0100 |
commit | 8389b135a1f331dfe90e3648dfa825402a78d502 (patch) | |
tree | 70fcd9fc8e26858e2864eaf37e92a069fbbd5fdb /sonar-server | |
parent | a81e6425d59ad1286a8c0fc1988f489ce23f9c3f (diff) | |
download | sonarqube-8389b135a1f331dfe90e3648dfa825402a78d502.tar.gz sonarqube-8389b135a1f331dfe90e3648dfa825402a78d502.zip |
SONAR-4688 Do not load i18n bundle twice (rules are already updated by RegisterRules)
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java | 22 | ||||
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java | 10 |
2 files changed, 10 insertions, 22 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java b/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java index fc9a5c7f748..5a20ad93b13 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java @@ -23,7 +23,6 @@ package org.sonar.server.rule; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; -import org.apache.commons.lang.StringUtils; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.common.collect.Maps; import org.elasticsearch.common.io.BytesStream; @@ -31,7 +30,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.sonar.api.rules.Rule; import org.sonar.api.utils.TimeProfiler; -import org.sonar.core.i18n.RuleI18nManager; import org.sonar.core.rule.RuleDao; import org.sonar.core.rule.RuleDto; import org.sonar.core.rule.RuleParamDto; @@ -39,7 +37,10 @@ import org.sonar.server.search.SearchIndex; import org.sonar.server.search.SearchQuery; import java.io.IOException; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; /** * Fill search index with rules @@ -54,12 +55,10 @@ public class RuleRegistry { private SearchIndex searchIndex; private RuleDao ruleDao; - private RuleI18nManager ruleI18nManager; - public RuleRegistry(SearchIndex searchIndex, RuleDao ruleDao, RuleI18nManager ruleI18nManager) { + public RuleRegistry(SearchIndex searchIndex, RuleDao ruleDao) { this.searchIndex = searchIndex; this.ruleDao = ruleDao; - this.ruleI18nManager = ruleI18nManager; } public void start() { @@ -164,20 +163,13 @@ public class RuleRegistry { } private XContentBuilder ruleDocument(RuleDto rule, Collection<RuleParamDto> params) throws IOException { - Locale locale = Locale.ENGLISH; XContentBuilder document = XContentFactory.jsonBuilder() .startObject() .field("id", rule.getId()) .field("key", rule.getRuleKey()) .field("language", rule.getLanguage()) - .field("name", - StringUtils.defaultIfEmpty( - ruleI18nManager.getName(rule.getRepositoryKey(), rule.getRuleKey(), locale), - rule.getName())) - .field("description", - StringUtils.defaultString( - ruleI18nManager.getDescription(rule.getRepositoryKey(), rule.getRuleKey(), locale), - rule.getDescription())) + .field("name", rule.getName()) + .field("description", rule.getDescription()) .field("parentKey", rule.getParentId() == null ? null : rule.getParentId()) .field("repositoryKey", rule.getRepositoryKey()) .field("severity", rule.getPriority()) diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java index ec3d11b9553..36308d9af0c 100644 --- a/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java +++ b/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java @@ -20,9 +20,6 @@ package org.sonar.server.rule; -import org.sonar.api.config.Settings; - -import org.sonar.core.profiling.Profiling; import com.github.tlrx.elasticsearch.test.EsSetup; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -30,7 +27,8 @@ import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.sonar.core.i18n.RuleI18nManager; +import org.sonar.api.config.Settings; +import org.sonar.core.profiling.Profiling; import org.sonar.core.rule.RuleDao; import org.sonar.core.rule.RuleDto; import org.sonar.core.rule.RuleParamDto; @@ -50,13 +48,11 @@ public class RuleRegistryTest { private EsSetup esSetup; private SearchIndex searchIndex; private RuleDao ruleDao; - private RuleI18nManager ruleI18nManager; RuleRegistry registry; @Before public void setUp() throws Exception { ruleDao = mock(RuleDao.class); - ruleI18nManager = mock(RuleI18nManager.class); esSetup = new EsSetup(); esSetup.execute(EsSetup.deleteAll()); @@ -69,7 +65,7 @@ public class RuleRegistryTest { searchIndex = new SearchIndex(node, profiling); searchIndex.start(); - registry = new RuleRegistry(searchIndex, ruleDao, ruleI18nManager); + registry = new RuleRegistry(searchIndex, ruleDao); registry.start(); String source1 = IOUtils.toString(TestUtils.getResource(getClass(), "rules/rule1.json").toURI()); |