From: Jean-Baptiste Lievremont Date: Tue, 14 Jan 2014 10:05:52 +0000 (+0100) Subject: SONAR-4923 Move mappings to correct package X-Git-Tag: 4.2~710 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5b3238b799cf2619c72f8fd42c1a918fa001d562;p=sonarqube.git SONAR-4923 Move mappings to correct package --- diff --git a/sonar-server/src/main/java/org/sonar/server/es/SearchNode.java b/sonar-server/src/main/java/org/sonar/server/es/SearchNode.java index c91d73f2cec..d9c8dbe3745 100644 --- a/sonar-server/src/main/java/org/sonar/server/es/SearchNode.java +++ b/sonar-server/src/main/java/org/sonar/server/es/SearchNode.java @@ -48,7 +48,6 @@ public class SearchNode implements Startable { private static final Logger LOG = LoggerFactory.getLogger(SearchIndex.class); private static final String HTTP_ENABLED = "http.enabled"; - private static final String INSTANCE_NAME = "sonarqube"; static final String DATA_DIR = "data/es"; private static final String DEFAULT_HEALTH_TIMEOUT = "30s"; 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 e5529a7e407..a23d406e7ce 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 @@ -20,9 +20,6 @@ package org.sonar.server.rule; -import org.sonar.server.es.SearchIndex; -import org.sonar.server.es.SearchQuery; - import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import org.apache.ibatis.session.SqlSession; @@ -40,6 +37,8 @@ import org.sonar.core.qualityprofile.db.ActiveRuleDao; import org.sonar.core.qualityprofile.db.ActiveRuleDto; import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; import org.sonar.core.rule.*; +import org.sonar.server.es.SearchIndex; +import org.sonar.server.es.SearchQuery; import java.io.IOException; import java.util.Arrays; @@ -76,8 +75,8 @@ public class RuleRegistry { } public void start() { - searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_RULE, "/com/sonar/search/rule_mapping.json"); - searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_ACTIVE_RULE, "/com/sonar/search/active_rule_mapping.json"); + searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_RULE, "/org/sonar/server/es/config/mappings/rule_mapping.json"); + searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_ACTIVE_RULE, "/org/sonar/server/es/config/mappings/active_rule_mapping.json"); } public void bulkRegisterRules(Collection rules, Multimap paramsByRule, Multimap tagsByRule) { diff --git a/sonar-server/src/main/resources/com/sonar/search/active_rule_mapping.json b/sonar-server/src/main/resources/com/sonar/search/active_rule_mapping.json deleted file mode 100644 index 8fef621f2e6..00000000000 --- a/sonar-server/src/main/resources/com/sonar/search/active_rule_mapping.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "active_rule": { - "_id": { - "path": "id" - }, - "_parent": { - "type": "rule" - }, - "properties": { - "id": { - "type": "integer", - "index": "not_analyzed" - }, - "severity": { - "type": "string", - "index": "not_analyzed" - }, - "profileId": { - "type": "integer", - "index": "not_analyzed" - }, - "parentId": { - "type": "integer", - "index": "not_analyzed" - }, - "inheritance": { - "type": "string", - "index": "not_analyzed" - }, - "note": { - "properties": { - "data": { - "type": "string", - "index": "no" - }, - "userLogin": { - "type": "string", - "index": "no" - }, - "createdAt": { - "type": "date", - "format": "date_optional_time" - }, - "updatedAt": { - "type": "date", - "format": "date_optional_time" - } - } - }, - "params": { - "properties": { - "key": { - "type": "string", - "index": "no" - }, - "value": { - "type": "string", - "index": "no" - } - } - } - } - } -} diff --git a/sonar-server/src/main/resources/com/sonar/search/rule_mapping.json b/sonar-server/src/main/resources/com/sonar/search/rule_mapping.json deleted file mode 100644 index 7c39f03980e..00000000000 --- a/sonar-server/src/main/resources/com/sonar/search/rule_mapping.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "rule": { - "_id": { - "path": "id" - }, - "properties": { - "id": { - "type": "integer", - "index": "not_analyzed" - }, - "key": { - "type": "string", - "index": "not_analyzed" - }, - "language": { - "type": "string", - "index": "not_analyzed" - }, - "name": { - "type": "multi_field", - "fields": { - "name": { "type": "string", "index": "analyzed" }, - "raw": { "type": "string", "index": "not_analyzed"} - } - }, - "description": { - "type": "string", - "index": "no" - }, - "parentKey": { - "type": "string", - "index": "not_analyzed" - }, - "repositoryKey": { - "type": "string", - "index": "not_analyzed" - }, - "severity": { - "type": "string", - "index": "not_analyzed" - }, - "status": { - "type": "string", - "index": "not_analyzed" - }, - "cardinality": { - "type": "string", - "index": "no" - }, - "createdAt": { - "type": "date", - "format": "date_optional_time" - }, - "updatedAt": { - "type": "date", - "format": "date_optional_time" - }, - "note": { - "properties": { - "data": { - "type": "string", - "index": "no" - }, - "userLogin": { - "type": "string", - "index": "no" - }, - "createdAt": { - "type": "date", - "format": "date_optional_time" - }, - "updatedAt": { - "type": "date", - "format": "date_optional_time" - } - } - }, - "params": { - "properties": { - "key": { - "type": "string", - "index": "no" - }, - "type": { - "type": "string", - "index": "no" - }, - "defaultValue": { - "type": "string", - "index": "no" - }, - "description": { - "type": "string", - "index": "no" - } - } - }, - "systemTags": { - "type": "string", - "index": "not_analyzed" - }, - "adminTags": { - "type": "string", - "index": "not_analyzed" - } - } - } -} diff --git a/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/active_rule_mapping.json b/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/active_rule_mapping.json new file mode 100644 index 00000000000..8fef621f2e6 --- /dev/null +++ b/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/active_rule_mapping.json @@ -0,0 +1,64 @@ +{ + "active_rule": { + "_id": { + "path": "id" + }, + "_parent": { + "type": "rule" + }, + "properties": { + "id": { + "type": "integer", + "index": "not_analyzed" + }, + "severity": { + "type": "string", + "index": "not_analyzed" + }, + "profileId": { + "type": "integer", + "index": "not_analyzed" + }, + "parentId": { + "type": "integer", + "index": "not_analyzed" + }, + "inheritance": { + "type": "string", + "index": "not_analyzed" + }, + "note": { + "properties": { + "data": { + "type": "string", + "index": "no" + }, + "userLogin": { + "type": "string", + "index": "no" + }, + "createdAt": { + "type": "date", + "format": "date_optional_time" + }, + "updatedAt": { + "type": "date", + "format": "date_optional_time" + } + } + }, + "params": { + "properties": { + "key": { + "type": "string", + "index": "no" + }, + "value": { + "type": "string", + "index": "no" + } + } + } + } + } +} diff --git a/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/rule_mapping.json b/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/rule_mapping.json new file mode 100644 index 00000000000..7c39f03980e --- /dev/null +++ b/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/rule_mapping.json @@ -0,0 +1,108 @@ +{ + "rule": { + "_id": { + "path": "id" + }, + "properties": { + "id": { + "type": "integer", + "index": "not_analyzed" + }, + "key": { + "type": "string", + "index": "not_analyzed" + }, + "language": { + "type": "string", + "index": "not_analyzed" + }, + "name": { + "type": "multi_field", + "fields": { + "name": { "type": "string", "index": "analyzed" }, + "raw": { "type": "string", "index": "not_analyzed"} + } + }, + "description": { + "type": "string", + "index": "no" + }, + "parentKey": { + "type": "string", + "index": "not_analyzed" + }, + "repositoryKey": { + "type": "string", + "index": "not_analyzed" + }, + "severity": { + "type": "string", + "index": "not_analyzed" + }, + "status": { + "type": "string", + "index": "not_analyzed" + }, + "cardinality": { + "type": "string", + "index": "no" + }, + "createdAt": { + "type": "date", + "format": "date_optional_time" + }, + "updatedAt": { + "type": "date", + "format": "date_optional_time" + }, + "note": { + "properties": { + "data": { + "type": "string", + "index": "no" + }, + "userLogin": { + "type": "string", + "index": "no" + }, + "createdAt": { + "type": "date", + "format": "date_optional_time" + }, + "updatedAt": { + "type": "date", + "format": "date_optional_time" + } + } + }, + "params": { + "properties": { + "key": { + "type": "string", + "index": "no" + }, + "type": { + "type": "string", + "index": "no" + }, + "defaultValue": { + "type": "string", + "index": "no" + }, + "description": { + "type": "string", + "index": "no" + } + } + }, + "systemTags": { + "type": "string", + "index": "not_analyzed" + }, + "adminTags": { + "type": "string", + "index": "not_analyzed" + } + } + } +} diff --git a/sonar-server/src/test/java/org/sonar/server/rule/ProfileRulesTest.java b/sonar-server/src/test/java/org/sonar/server/rule/ProfileRulesTest.java index 8f0554a05b3..3f688690871 100644 --- a/sonar-server/src/test/java/org/sonar/server/rule/ProfileRulesTest.java +++ b/sonar-server/src/test/java/org/sonar/server/rule/ProfileRulesTest.java @@ -19,18 +19,18 @@ */ package org.sonar.server.rule; -import org.sonar.server.es.SearchIndex; -import org.sonar.server.es.SearchNode; - import com.github.tlrx.elasticsearch.test.EsSetup; import org.apache.commons.io.IOUtils; import org.elasticsearch.client.Requests; +import org.elasticsearch.common.settings.ImmutableSettings; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.sonar.api.config.Settings; import org.sonar.api.rule.Severity; import org.sonar.core.profiling.Profiling; +import org.sonar.server.es.SearchIndex; +import org.sonar.server.es.SearchNode; import org.sonar.server.qualityprofile.Paging; import org.sonar.server.qualityprofile.QProfileRule; import org.sonar.test.TestUtils; @@ -48,7 +48,10 @@ public class ProfileRulesTest { @Before public void setUp() throws Exception { - esSetup = new EsSetup(); + esSetup = new EsSetup(ImmutableSettings.builder() + .loadFromUrl(SearchNode.class.getResource("config/elasticsearch.json")) + .build() + ); esSetup.execute(EsSetup.deleteAll()); SearchNode searchNode = mock(SearchNode.class); 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 6a560e82a00..a4f431826c1 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.server.es.SearchIndex; -import org.sonar.server.es.SearchNode; - import com.github.tlrx.elasticsearch.test.EsSetup; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableList; @@ -31,6 +28,7 @@ import com.google.common.collect.Multimap; import org.apache.commons.io.IOUtils; import org.apache.ibatis.session.SqlSession; import org.elasticsearch.common.collect.Lists; +import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.search.SearchHit; import org.junit.After; import org.junit.Before; @@ -45,6 +43,8 @@ import org.sonar.core.qualityprofile.db.ActiveRuleDao; import org.sonar.core.qualityprofile.db.ActiveRuleDto; import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; import org.sonar.core.rule.*; +import org.sonar.server.es.SearchIndex; +import org.sonar.server.es.SearchNode; import org.sonar.test.TestUtils; import java.io.IOException; @@ -86,7 +86,7 @@ public class RuleRegistryTest { public void setUp() throws Exception { when(myBatis.openSession()).thenReturn(session); - esSetup = new EsSetup(); + esSetup = new EsSetup(ImmutableSettings.builder().loadFromUrl(SearchNode.class.getResource("config/elasticsearch.json")).build()); esSetup.execute(EsSetup.deleteAll()); SearchNode node = mock(SearchNode.class);