summaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2012-03-15 12:19:32 +0100
committerFabrice Bellingard <bellingard@gmail.com>2012-03-15 15:44:23 +0100
commitda854ba498a3c6ecad5bea7756067f0e703ec792 (patch)
treef507c0210422a3a9222aed9bb355ba234b577d2e /sonar-core
parent0065d6255ea326e298e57e8de2d3fe6fca4a0597 (diff)
downloadsonarqube-da854ba498a3c6ecad5bea7756067f0e703ec792.tar.gz
sonarqube-da854ba498a3c6ecad5bea7756067f0e703ec792.zip
SONAR-3319 Extract code used for backward compatibility into a method
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java b/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java
index 4ff61bdc04b..c19d9475a55 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/RuleI18nManager.java
@@ -55,12 +55,12 @@ public class RuleI18nManager implements ServerComponent {
public String getDescription(String repositoryKey, String ruleKey, Locale locale) {
String relatedProperty = new StringBuilder().append(RULE_PREFIX).append(repositoryKey).append(".").append(ruleKey).append(NAME_SUFFIX).toString();
- Locale localeWithoutCountry = (locale.getCountry()==null ? locale : new Locale(locale.getLanguage()));
+ Locale localeWithoutCountry = (locale.getCountry() == null ? locale : new Locale(locale.getLanguage()));
String ruleDescriptionFilePath = "rules/" + repositoryKey + "/" + ruleKey + ".html";
String description = i18nManager.messageFromFile(localeWithoutCountry, ruleDescriptionFilePath, relatedProperty, true);
if (description == null) {
- // For backward compatibility, let's search at the root folder as it used to be before Sonar 2.15
- description = i18nManager.messageFromFile(localeWithoutCountry, ruleKey + ".html", relatedProperty, true);
+ // Following line is to ensure backward compatibility (SONAR-3319)
+ description = lookUpDescriptionInFormerLocation(ruleKey, relatedProperty, localeWithoutCountry);
if (description == null && !"en".equals(localeWithoutCountry.getLanguage())) {
// nothing was found, let's get the value of the default bundle
description = i18nManager.messageFromFile(Locale.ENGLISH, ruleDescriptionFilePath, relatedProperty, true);
@@ -69,6 +69,16 @@ public class RuleI18nManager implements ServerComponent {
return description;
}
+ /*
+ * Method used to ensure backward compatibility for language plugins that store HTML rule description files in the former
+ * location (which was used prior to Sonar 2.15).
+ *
+ * See http://jira.codehaus.org/browse/SONAR-3319
+ */
+ private String lookUpDescriptionInFormerLocation(String ruleKey, String relatedProperty, Locale localeWithoutCountry) {
+ return i18nManager.messageFromFile(localeWithoutCountry, ruleKey + ".html", relatedProperty, true);
+ }
+
public String getParamDescription(String repositoryKey, String ruleKey, String paramKey, Locale locale) {
return message(repositoryKey, ruleKey, locale, ".param." + paramKey);
}