summaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/java
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-07 13:09:36 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-07 13:09:58 +0200
commitc5f3ff40749fb8eeb1d953571420b62f04d2aee5 (patch)
tree66dd934962595ea23f3c4c7295299e1910257060 /sonar-server/src/main/java
parent97cf6b73ad96ecff1aa56136d45803994698c8bb (diff)
downloadsonarqube-c5f3ff40749fb8eeb1d953571420b62f04d2aee5.tar.gz
sonarqube-c5f3ff40749fb8eeb1d953571420b62f04d2aee5.zip
SONAR-5007 fix removal of param value
Diffstat (limited to 'sonar-server/src/main/java')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java16
-rw-r--r--sonar-server/src/main/java/org/sonar/server/search/ESNode.java30
2 files changed, 21 insertions, 25 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
index 9c6e935c196..2fb2b565d6d 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
@@ -164,25 +164,25 @@ public class RuleActivator implements ServerComponent {
private void applySeverityAndParamToChange(RuleActivation request, RuleActivatorContext context, ActiveRuleChange change) {
if (request.isReset()) {
// load severity and params from parent profile, else from default values
- change.setSeverity(firstNonEmpty(
+ change.setSeverity(firstNonNull(
context.parentSeverity(), context.defaultSeverity()));
for (RuleParamDto ruleParamDto : context.ruleParams()) {
String paramKey = ruleParamDto.getName();
- change.setParameter(paramKey, validateParam(ruleParamDto, firstNonEmpty(
+ change.setParameter(paramKey, validateParam(ruleParamDto, firstNonNull(
context.parentParamValue(paramKey), context.defaultParamValue(paramKey))));
}
} else if (context.activeRule() != null) {
// already activated -> load severity and parameters from request, else keep existing ones, else from parent,
// else from default
- change.setSeverity(firstNonEmpty(
+ change.setSeverity(firstNonNull(
request.getSeverity(),
context.currentSeverity(),
context.parentSeverity(),
context.defaultSeverity()));
for (RuleParamDto ruleParamDto : context.ruleParams()) {
String paramKey = ruleParamDto.getName();
- change.setParameter(paramKey, validateParam(ruleParamDto, firstNonEmpty(
+ change.setParameter(paramKey, validateParam(ruleParamDto, firstNonNull(
context.requestParamValue(request, paramKey),
context.currentParamValue(paramKey),
context.parentParamValue(paramKey),
@@ -191,13 +191,13 @@ public class RuleActivator implements ServerComponent {
} else if (context.activeRule() == null) {
// not activated -> load severity and parameters from request, else from parent, else from defaults
- change.setSeverity(firstNonEmpty(
+ change.setSeverity(firstNonNull(
request.getSeverity(),
context.parentSeverity(),
context.defaultSeverity()));
for (RuleParamDto ruleParamDto : context.ruleParams()) {
String paramKey = ruleParamDto.getName();
- change.setParameter(paramKey, validateParam(ruleParamDto, firstNonEmpty(
+ change.setParameter(paramKey, validateParam(ruleParamDto, firstNonNull(
context.requestParamValue(request, paramKey),
context.parentParamValue(paramKey),
context.defaultParamValue(paramKey))));
@@ -206,9 +206,9 @@ public class RuleActivator implements ServerComponent {
}
@CheckForNull
- String firstNonEmpty(String... strings) {
+ String firstNonNull(String... strings) {
for (String s : strings) {
- if (StringUtils.isNotEmpty(s)) {
+ if (s!=null) {
return s;
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/search/ESNode.java b/sonar-server/src/main/java/org/sonar/server/search/ESNode.java
index 0bf101085f8..f568a09c97e 100644
--- a/sonar-server/src/main/java/org/sonar/server/search/ESNode.java
+++ b/sonar-server/src/main/java/org/sonar/server/search/ESNode.java
@@ -23,7 +23,6 @@ package org.sonar.server.search;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.io.FileUtils;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
-import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.logging.slf4j.Slf4jESLoggerFactory;
@@ -112,13 +111,11 @@ public class ESNode implements Startable {
.node();
node.start();
-
- if (
- node.client().admin().cluster().prepareHealth()
- .setWaitForYellowStatus()
- .setTimeout(healthTimeout)
- .get()
- .getStatus() == ClusterHealthStatus.RED) {
+ if (node.client().admin().cluster().prepareHealth()
+ .setWaitForYellowStatus()
+ .setTimeout(healthTimeout)
+ .get()
+ .getStatus() == ClusterHealthStatus.RED) {
throw new IllegalStateException(
String.format("Elasticsearch index is corrupt, please delete directory '%s/%s' and relaunch the SonarQube server.", fileSystem.getHomeDir().getAbsolutePath(), DATA_DIR));
}
@@ -174,41 +171,40 @@ public class ESNode implements Startable {
esSettings
.put("index.mapper.dynamic", false)
- // Sortable text analyzer
+ // Sortable text analyzer
.put("index.analysis.analyzer.sortable.type", "custom")
.put("index.analysis.analyzer.sortable.tokenizer", "keyword")
.putArray("index.analysis.analyzer.sortable.filter", "trim", "lowercase", "truncate")
- // Edge NGram index-analyzer
+ // Edge NGram index-analyzer
.put("index.analysis.analyzer.index_grams.type", "custom")
.put("index.analysis.analyzer.index_grams.tokenizer", "whitespace")
.putArray("index.analysis.analyzer.index_grams.filter", "trim", "lowercase", "gram_filter")
- // Edge NGram search-analyzer
+ // Edge NGram search-analyzer
.put("index.analysis.analyzer.search_grams.type", "custom")
.put("index.analysis.analyzer.search_grams.tokenizer", "whitespace")
.putArray("index.analysis.analyzer.search_grams.filter", "trim", "lowercase")
- // Word index-analyzer
+ // Word index-analyzer
.put("index.analysis.analyzer.index_words.type", "custom")
.put("index.analysis.analyzer.index_words.tokenizer", "standard")
.putArray("index.analysis.analyzer.index_words.filter",
"standard", "word_filter", "lowercase", "stop", "asciifolding", "porter_stem")
- // Word search-analyzer
+ // Word search-analyzer
.put("index.analysis.analyzer.search_words.type", "custom")
.put("index.analysis.analyzer.search_words.tokenizer", "standard")
.putArray("index.analysis.analyzer.search_words.filter",
"standard", "lowercase", "stop", "asciifolding", "porter_stem")
-
- // Edge NGram filter
+ // Edge NGram filter
.put("index.analysis.filter.gram_filter.type", "edgeNGram")
.put("index.analysis.filter.gram_filter.min_gram", 2)
.put("index.analysis.filter.gram_filter.max_gram", 15)
.putArray("index.analysis.filter.gram_filter.token_chars", "letter", "digit", "punctuation", "symbol")
- // Word filter
+ // Word filter
.put("index.analysis.filter.word_filter.type", "word_delimiter")
.put("index.analysis.filter.word_filter.generate_word_parts", true)
.put("index.analysis.filter.word_filter.catenate_words", true)
@@ -219,7 +215,7 @@ public class ESNode implements Startable {
.put("index.analysis.filter.word_filter.split_on_numerics", true)
.put("index.analysis.filter.word_filter.stem_english_possessive", true)
- // Path Analyzer
+ // Path Analyzer
.put("index.analysis.analyzer.path_analyzer.type", "custom")
.put("index.analysis.analyzer.path_analyzer.tokenizer", "path_hierarchy");