aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentDoc.java13
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexDefinition.java2
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexer.java1
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java3
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentIndex.java2
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentQuery.java13
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java16
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java29
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchActionTest.java24
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsWsParameters.java1
10 files changed, 7 insertions, 97 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentDoc.java b/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentDoc.java
index 2d34902a550..e0469835334 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentDoc.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentDoc.java
@@ -21,13 +21,10 @@ package org.sonar.server.component.index;
import java.util.HashMap;
import java.util.Map;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
import org.sonar.server.es.BaseDoc;
import org.sonar.server.permission.index.AuthorizationDoc;
import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_KEY;
-import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_LANGUAGE;
import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_NAME;
import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_ORGANIZATION_UUID;
import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_PROJECT_UUID;
@@ -92,16 +89,6 @@ public class ComponentDoc extends BaseDoc {
return this;
}
- @CheckForNull
- public String getLanguage() {
- return getField(FIELD_LANGUAGE);
- }
-
- public ComponentDoc setLanguage(@Nullable String s) {
- setField(FIELD_LANGUAGE, s);
- return this;
- }
-
public String getOrganization() {
return getField(FIELD_ORGANIZATION_UUID);
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexDefinition.java b/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexDefinition.java
index 12ef3118426..635d0dc3a8a 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexDefinition.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexDefinition.java
@@ -46,7 +46,6 @@ public class ComponentIndexDefinition implements IndexDefinition {
public static final String FIELD_KEY = "key";
public static final String FIELD_NAME = "name";
public static final String FIELD_QUALIFIER = "qualifier";
- public static final String FIELD_LANGUAGE = "language";
private static final int DEFAULT_NUMBER_OF_SHARDS = 5;
@@ -95,7 +94,6 @@ public class ComponentIndexDefinition implements IndexDefinition {
.build();
mapping.keywordFieldBuilder(FIELD_QUALIFIER).build();
- mapping.keywordFieldBuilder(FIELD_LANGUAGE).disableNorms().build();
mapping.keywordFieldBuilder(FIELD_ORGANIZATION_UUID).disableNorms().build();
}
}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexer.java b/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexer.java
index 1b377567681..8e01790e79e 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexer.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/component/index/ComponentIndexer.java
@@ -183,7 +183,6 @@ public class ComponentIndexer implements ProjectIndexer, NeedAuthorizationIndexe
.setKey(component.getDbKey())
.setProjectUuid(component.projectUuid())
.setOrganization(component.getOrganizationUuid())
- .setLanguage(component.language())
.setQualifier(component.qualifier());
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java
index 896979d097e..1589043bd0b 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java
@@ -84,7 +84,7 @@ public class ComponentIndexerTest {
@Test
public void map_fields() {
OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertPrivateProject(organization, p -> p.setLanguage("java"));
+ ComponentDto project = db.components().insertPrivateProject(organization);
underTest.indexOnStartup(emptySet());
@@ -94,7 +94,6 @@ public class ComponentIndexerTest {
assertThat(doc.getKey()).isEqualTo(project.getDbKey());
assertThat(doc.getProjectUuid()).isEqualTo(project.projectUuid());
assertThat(doc.getName()).isEqualTo(project.name());
- assertThat(doc.getLanguage()).isEqualTo(project.language());
assertThat(doc.getOrganization()).isEqualTo(project.getOrganizationUuid());
}
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentIndex.java
index 021881cec66..ad80fe587e0 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentIndex.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentIndex.java
@@ -57,7 +57,6 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_KEY;
-import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_LANGUAGE;
import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_NAME;
import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_ORGANIZATION_UUID;
import static org.sonar.server.component.index.ComponentIndexDefinition.FIELD_QUALIFIER;
@@ -99,7 +98,6 @@ public class ComponentIndex {
esQuery.must(ComponentTextSearchQueryFactory.createQuery(componentTextSearchQuery, ComponentTextSearchFeatureRepertoire.values()));
});
setEmptiable(query.getQualifiers(), q -> esQuery.must(termsQuery(FIELD_QUALIFIER, q)));
- setNullable(query.getLanguage(), l -> esQuery.must(termQuery(FIELD_LANGUAGE, l)));
setNullable(query.getOrganizationUuid(), o -> esQuery.must(termQuery(FIELD_ORGANIZATION_UUID, o)));
requestBuilder.setQuery(esQuery);
requestBuilder.addSort(SORTABLE_ANALYZER.subField(FIELD_NAME), SortOrder.ASC);
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentQuery.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentQuery.java
index a524145f86a..a1460c2dcf4 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentQuery.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/component/index/ComponentQuery.java
@@ -30,13 +30,11 @@ public class ComponentQuery {
private final String organizationUuid;
private final String query;
private final Collection<String> qualifiers;
- private final String language;
private ComponentQuery(Builder builder) {
this.organizationUuid = builder.organizationUuid;
this.query = builder.query;
this.qualifiers = builder.qualifiers;
- this.language = builder.language;
}
@CheckForNull
@@ -53,11 +51,6 @@ public class ComponentQuery {
return qualifiers;
}
- @CheckForNull
- public String getLanguage() {
- return language;
- }
-
public static Builder builder() {
return new Builder();
}
@@ -66,7 +59,6 @@ public class ComponentQuery {
private String organizationUuid;
private String query;
private Collection<String> qualifiers = emptySet();
- private String language;
private Builder() {
// enforce static factory method
@@ -87,11 +79,6 @@ public class ComponentQuery {
return this;
}
- public Builder setLanguage(@Nullable String language) {
- this.language = language;
- return this;
- }
-
public ComponentQuery build() {
return new ComponentQuery(this);
}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
index ae98138c4e2..4c65a14116d 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
@@ -23,7 +23,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.resources.Qualifiers;
@@ -42,7 +41,6 @@ import org.sonar.server.tester.UserSessionRule;
import static java.util.Collections.emptySet;
import static java.util.Collections.singleton;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.ComponentTesting.newFileDto;
public class ComponentIndexSearchTest {
@Rule
@@ -60,20 +58,6 @@ public class ComponentIndexSearchTest {
private ComponentIndex underTest = new ComponentIndex(es.client(), new WebAuthorizationTypeSupport(userSession), System2.INSTANCE);
@Test
- @Ignore
- public void filter_by_language() {
- ComponentDto project = db.components().insertPrivateProject();
- db.components().insertComponent(newFileDto(project).setLanguage("java"));
- ComponentDto jsFile1 = db.components().insertComponent(newFileDto(project).setLanguage("js"));
- ComponentDto jsFile2 = db.components().insertComponent(newFileDto(project).setLanguage("js"));
- index(project);
-
- SearchIdResult<String> result = underTest.search(ComponentQuery.builder().setLanguage("js").build(), new SearchOptions());
-
- assertThat(result.getUuids()).containsExactlyInAnyOrder(jsFile1.uuid(), jsFile2.uuid());
- }
-
- @Test
public void filter_by_name() {
ComponentDto ignoredProject = db.components().insertPrivateProject(p -> p.setName("ignored project"));
ComponentDto project = db.components().insertPrivateProject(p -> p.setName("Project Shiny name"));
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java
index 54fdab08141..5fb58434a86 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SearchAction.java
@@ -26,7 +26,6 @@ import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import org.sonar.api.resources.Languages;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceTypes;
import org.sonar.api.server.ws.Change;
@@ -54,13 +53,10 @@ import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toMap;
import static org.sonar.core.util.stream.MoreCollectors.toHashSet;
import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
-import static org.sonar.server.language.LanguageParamUtils.getExampleValue;
-import static org.sonar.server.language.LanguageParamUtils.getOrderedLanguageKeys;
import static org.sonar.server.ws.WsParameterBuilder.createQualifiersParameter;
import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.ACTION_SEARCH;
-import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS;
@@ -69,16 +65,14 @@ public class SearchAction implements ComponentsWsAction {
private final DbClient dbClient;
private final ResourceTypes resourceTypes;
private final I18n i18n;
- private final Languages languages;
private final DefaultOrganizationProvider defaultOrganizationProvider;
- public SearchAction(ComponentIndex componentIndex, DbClient dbClient, ResourceTypes resourceTypes, I18n i18n, Languages languages,
+ public SearchAction(ComponentIndex componentIndex, DbClient dbClient, ResourceTypes resourceTypes, I18n i18n,
DefaultOrganizationProvider defaultOrganizationProvider) {
this.componentIndex = componentIndex;
this.dbClient = dbClient;
this.resourceTypes = resourceTypes;
this.i18n = i18n;
- this.languages = languages;
this.defaultOrganizationProvider = defaultOrganizationProvider;
}
@@ -89,10 +83,10 @@ public class SearchAction implements ComponentsWsAction {
.setDescription("Search for components")
.addPagingParams(100, MAX_LIMIT)
.setChangelog(
+ new Change("8.4", "Param 'language' has been removed"),
new Change("8.4", String.format("The use of 'DIR','FIL','UTS' as values for parameter '%s' is no longer supported", PARAM_QUALIFIERS)),
new Change("8.0", "Field 'id' from response has been removed"),
- new Change("7.6", String.format("The use of 'BRC' as value for parameter '%s' is deprecated", PARAM_QUALIFIERS))
- )
+ new Change("7.6", String.format("The use of 'BRC' as value for parameter '%s' is deprecated", PARAM_QUALIFIERS)))
.setResponseExample(getClass().getResource("search-components-example.json"))
.setHandler(this);
@@ -111,11 +105,6 @@ public class SearchAction implements ComponentsWsAction {
.setExampleValue("my-org")
.setSince("6.3");
- action
- .createParam(PARAM_LANGUAGE)
- .setDescription("Language key. If provided, only components for the given language are returned.")
- .setExampleValue(getExampleValue(languages))
- .setPossibleValues(getOrderedLanguageKeys(languages));
createQualifiersParameter(action, newQualifierParameterContext(i18n, resourceTypes))
.setRequired(true);
}
@@ -130,7 +119,6 @@ public class SearchAction implements ComponentsWsAction {
return new SearchRequest()
.setOrganization(request.param(PARAM_ORGANIZATION))
.setQualifiers(request.mandatoryParamAsStrings(PARAM_QUALIFIERS))
- .setLanguage(request.param(PARAM_LANGUAGE))
.setQuery(request.param(Param.TEXT_QUERY))
.setPage(request.mandatoryParamAsInt(Param.PAGE))
.setPageSize(request.mandatoryParamAsInt(Param.PAGE_SIZE));
@@ -174,7 +162,6 @@ public class SearchAction implements ComponentsWsAction {
return ComponentQuery.builder()
.setQuery(request.getQuery())
.setOrganization(organization.getUuid())
- .setLanguage(request.getLanguage())
.setQualifiers(request.getQualifiers())
.build();
}
@@ -266,16 +253,6 @@ public class SearchAction implements ComponentsWsAction {
this.query = query;
return this;
}
-
- @CheckForNull
- public String getLanguage() {
- return language;
- }
-
- public SearchRequest setLanguage(@Nullable String language) {
- this.language = language;
- return this;
- }
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
index 8692d26d4b3..535fd047165 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
@@ -28,7 +28,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Languages;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
@@ -59,8 +58,6 @@ import static java.util.Collections.singletonList;
import static java.util.Optional.ofNullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import static org.sonar.api.resources.Qualifiers.DIRECTORY;
import static org.sonar.api.resources.Qualifiers.FILE;
import static org.sonar.api.resources.Qualifiers.MODULE;
@@ -74,7 +71,6 @@ import static org.sonar.db.component.ComponentTesting.newModuleDto;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
import static org.sonar.db.component.ComponentTesting.newView;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_QUALIFIERS;
@@ -91,7 +87,6 @@ public class SearchActionTest {
private I18nRule i18n = new I18nRule();
private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
private ResourceTypesRule resourceTypes = new ResourceTypesRule();
- private Languages languages = mock(Languages.class);
private ComponentIndexer indexer = new ComponentIndexer(db.getDbClient(), es.client());
private PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, indexer);
private ComponentIndex index = new ComponentIndex(es.client(), new WebAuthorizationTypeSupport(userSession), System2.INSTANCE);
@@ -103,8 +98,7 @@ public class SearchActionTest {
@Before
public void setUp() {
resourceTypes.setAllQualifiers(PROJECT, MODULE, DIRECTORY, FILE);
- when(languages.all()).thenReturn(javaLanguage());
- ws = new WsActionTester(new SearchAction(index, db.getDbClient(), resourceTypes, i18n, languages, defaultOrganizationProvider));
+ ws = new WsActionTester(new SearchAction(index, db.getDbClient(), resourceTypes, i18n, defaultOrganizationProvider));
user = db.users().insertUser("john");
userSession.logIn(user);
@@ -120,12 +114,13 @@ public class SearchActionTest {
assertThat(action.changelog())
.extracting(Change::getVersion, Change::getDescription)
.containsExactlyInAnyOrder(
+ tuple("8.4", "Param 'language' has been removed"),
tuple("8.4", "The use of 'DIR','FIL','UTS' as values for parameter 'qualifiers' is no longer supported"),
tuple("8.0", "Field 'id' from response has been removed"),
tuple("7.6", "The use of 'BRC' as value for parameter 'qualifiers' is deprecated"));
assertThat(action.responseExampleAsString()).isNotEmpty();
- assertThat(action.params()).hasSize(6);
+ assertThat(action.params()).hasSize(5);
WebService.Param pageSize = action.param("ps");
assertThat(pageSize.isRequired()).isFalse();
@@ -183,18 +178,6 @@ public class SearchActionTest {
}
@Test
- public void search_with_language() {
- OrganizationDto organizationDto = db.organizations().insert();
- insertProjectsAuthorizedForUser(
- ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("java-project").setLanguage("java"),
- ComponentTesting.newPrivateProjectDto(organizationDto).setDbKey("cpp-project").setLanguage("cpp"));
-
- SearchWsResponse response = call(new SearchRequest().setOrganization(organizationDto.getKey()).setLanguage("java").setQualifiers(singletonList(PROJECT)));
-
- assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly("java-project");
- }
-
- @Test
public void return_only_projects_on_which_user_has_browse_permission() {
ComponentDto project1 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
ComponentDto project2 = ComponentTesting.newPrivateProjectDto(db.getDefaultOrganization());
@@ -287,7 +270,6 @@ public class SearchActionTest {
private SearchWsResponse call(SearchRequest wsRequest) {
TestRequest request = ws.newRequest();
ofNullable(wsRequest.getOrganization()).ifPresent(p3 -> request.setParam(PARAM_ORGANIZATION, p3));
- ofNullable(wsRequest.getLanguage()).ifPresent(p2 -> request.setParam(PARAM_LANGUAGE, p2));
ofNullable(wsRequest.getQualifiers()).ifPresent(p1 -> request.setParam(PARAM_QUALIFIERS, Joiner.on(",").join(p1)));
ofNullable(wsRequest.getQuery()).ifPresent(p -> request.setParam(TEXT_QUERY, p));
ofNullable(wsRequest.getPage()).ifPresent(page -> request.setParam(PAGE, String.valueOf(page)));
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsWsParameters.java
index 0072685f9cb..c8ec18c42a8 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsWsParameters.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsWsParameters.java
@@ -33,7 +33,6 @@ public class ComponentsWsParameters {
// parameters
public static final String PARAM_ORGANIZATION = "organization";
public static final String PARAM_QUALIFIERS = "qualifiers";
- public static final String PARAM_LANGUAGE = "language";
public static final String PARAM_STRATEGY = "strategy";
public static final String PARAM_FILTER = "filter";
public static final String PARAM_COMPONENT = "component";