]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19934 Rename ws param componentKeys to components
authorEric Giffon <eric.giffon@sonarsource.com>
Tue, 18 Jul 2023 13:16:44 +0000 (15:16 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 19 Jul 2023 20:03:05 +0000 (20:03 +0000)
server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java
server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionComponentsIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionFacetsIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/SearchAction.java
sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java
sonar-ws/src/main/java/org/sonarqube/ws/client/issues/IssuesService.java

index 76cc62d76c7dd350b0bb642eee695765ac43a98e..fb2ce21a14ac1fbdbdb22f1d564338df45923a98 100644 (file)
@@ -73,7 +73,7 @@ import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime;
 import static org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH;
-import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
+import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_UUIDS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AFTER;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_IN_LAST;
@@ -251,7 +251,7 @@ public class IssueQueryFactory {
     boolean effectiveOnComponentOnly = false;
 
     checkArgument(atMostOneNonNullElement(componentKeys, componentUuids),
-      "At most one of the following parameters can be provided: %s and %s", PARAM_COMPONENT_KEYS, PARAM_COMPONENT_UUIDS);
+      "At most one of the following parameters can be provided: %s and %s", PARAM_COMPONENTS, PARAM_COMPONENT_UUIDS);
 
     if (componentKeys != null) {
       allComponents.addAll(getComponentsFromKeys(session, componentKeys, branch, pullRequest));
index a7d8ddbeb8293ed070b3840a15eb9a05e311db48..e8a560d08aff1ca8024c14ad164afb42e4603907 100644 (file)
@@ -284,7 +284,7 @@ public class IssueQueryFactoryTest {
 
     assertThatThrownBy(() -> underTest.create(request))
       .isInstanceOf(IllegalArgumentException.class)
-      .hasMessageContaining("At most one of the following parameters can be provided: componentKeys and componentUuids");
+      .hasMessageContaining("At most one of the following parameters can be provided: components and componentUuids");
   }
 
   @Test
index 6b5e9e066a38002ca366f9596850f5ee683c6afe..0354b324d4c799a9b6db2a3f8d97e5a5ae252e9d 100644 (file)
@@ -75,7 +75,7 @@ import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
 import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_BRANCH;
-import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
+import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_DIRECTORIES;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD;
@@ -169,7 +169,7 @@ public class SearchActionComponentsIT {
     indexIssues();
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
+      .setParam(PARAM_COMPONENTS, project.getKey())
       .setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
       .execute()
       .assertJson(this.getClass(), "search_since_leak_period.json");
@@ -209,12 +209,12 @@ public class SearchActionComponentsIT {
     indexIssues();
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, file.getKey())
+      .setParam(PARAM_COMPONENTS, file.getKey())
       .execute()
       .assertJson(this.getClass(), "search_by_file_key.json");
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, unitTest.getKey())
+      .setParam(PARAM_COMPONENTS, unitTest.getKey())
       .execute()
       .assertJson(this.getClass(), "search_by_test_key.json");
   }
@@ -231,7 +231,7 @@ public class SearchActionComponentsIT {
     indexIssues();
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, directory.getKey())
+      .setParam(PARAM_COMPONENTS, directory.getKey())
       .execute()
       .assertJson(this.getClass(), "search_by_file_uuid.json");
 
@@ -266,7 +266,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, view.getKey())
+      .setParam(PARAM_COMPONENTS, view.getKey())
       .execute()
       .assertJson(this.getClass(), "search_by_view_uuid.json");
   }
@@ -286,7 +286,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, subView.getKey())
+      .setParam(PARAM_COMPONENTS, subView.getKey())
       .execute()
       .assertJson(this.getClass(), "search_by_view_uuid.json");
   }
@@ -306,7 +306,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, subView.getKey())
+      .setParam(PARAM_COMPONENTS, subView.getKey())
       .execute()
       .assertJson(this.getClass(), "no_issue.json");
   }
@@ -330,7 +330,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+      .setParam(PARAM_COMPONENTS, application.getKey())
       .executeProtobuf(SearchWsResponse.class);
 
     assertThat(result.getIssuesList()).extracting(Issue::getKey)
@@ -373,7 +373,7 @@ public class SearchActionComponentsIT {
 
     // All issues on applicationBranch1
     assertThat(ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, applicationBranch1.getKey())
+      .setParam(PARAM_COMPONENTS, applicationBranch1.getKey())
       .setParam(PARAM_BRANCH, appBranch1)
       .executeProtobuf(SearchWsResponse.class).getIssuesList())
         .extracting(Issue::getKey, Issue::getComponent, Issue::getProject, Issue::getBranch, Issue::hasBranch)
@@ -384,7 +384,7 @@ public class SearchActionComponentsIT {
 
     // Issues on project1Branch1
     assertThat(ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, applicationBranch1.getKey())
+      .setParam(PARAM_COMPONENTS, applicationBranch1.getKey())
       .setParam(PARAM_PROJECTS, project1.getKey())
       .setParam(PARAM_BRANCH, appBranch1)
       .executeProtobuf(SearchWsResponse.class).getIssuesList())
@@ -406,7 +406,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+      .setParam(PARAM_COMPONENTS, application.getKey())
       .executeProtobuf(SearchWsResponse.class);
 
     assertThat(result.getIssuesList()).isEmpty();
@@ -424,7 +424,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+      .setParam(PARAM_COMPONENTS, application.getKey())
       .executeProtobuf(SearchWsResponse.class);
 
     assertThat(result.getIssuesList()).isEmpty();
@@ -456,7 +456,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+      .setParam(PARAM_COMPONENTS, application.getKey())
       .setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
       .executeProtobuf(SearchWsResponse.class);
 
@@ -483,7 +483,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+      .setParam(PARAM_COMPONENTS, application.getKey())
       .setParam(PARAM_PROJECTS, project1.getKey())
       .executeProtobuf(SearchWsResponse.class);
 
@@ -518,7 +518,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+      .setParam(PARAM_COMPONENTS, application.getKey())
       .setParam(PARAM_PROJECTS, project1.getKey())
       .setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
       .executeProtobuf(SearchWsResponse.class);
@@ -554,7 +554,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, application.getKey())
+      .setParam(PARAM_COMPONENTS, application.getKey())
       .setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
       .executeProtobuf(SearchWsResponse.class);
 
@@ -580,7 +580,7 @@ public class SearchActionComponentsIT {
 
     // On component key + branch
     assertThat(ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
+      .setParam(PARAM_COMPONENTS, project.getKey())
       .setParam(PARAM_BRANCH, branchName)
       .executeProtobuf(SearchWsResponse.class).getIssuesList())
         .extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
@@ -595,7 +595,7 @@ public class SearchActionComponentsIT {
         .containsExactlyInAnyOrder(tuple(branchIssue.getKey(), branchFile.getKey(), branchName));
     // On file key + branch
     assertThat(ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, branchFile.getKey())
+      .setParam(PARAM_COMPONENTS, branchFile.getKey())
       .setParam(PARAM_BRANCH, branchName)
       .executeProtobuf(SearchWsResponse.class).getIssuesList())
         .extracting(Issue::getKey, Issue::getComponent, Issue::getBranch)
@@ -617,7 +617,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, branch.getKey())
+      .setParam(PARAM_COMPONENTS, branch.getKey())
       .setParam(PARAM_BRANCH, branchName)
       .executeProtobuf(SearchWsResponse.class);
 
@@ -644,7 +644,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, pullRequest.getKey())
+      .setParam(PARAM_COMPONENTS, pullRequest.getKey())
       .setParam(PARAM_PULL_REQUEST, pullRequestKey)
       .executeProtobuf(SearchWsResponse.class);
 
@@ -669,7 +669,7 @@ public class SearchActionComponentsIT {
     indexIssuesAndViews();
 
     SearchWsResponse result = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
+      .setParam(PARAM_COMPONENTS, project.getKey())
       .setParam(PARAM_BRANCH, DEFAULT_MAIN_BRANCH_NAME)
       .executeProtobuf(SearchWsResponse.class);
 
index d975f360a1a8a100de471b6e61120864468f5c21..e7dc989e17bf2e5540eff6fbd0686051a29061f4 100644 (file)
@@ -62,7 +62,7 @@ import static org.sonar.api.server.ws.WebService.Param.FACETS;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.server.tester.UserSessionRule.standalone;
-import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
+import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_FILES;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_PROJECTS;
 
@@ -106,7 +106,7 @@ public class SearchActionFacetsIT {
     indexIssues();
 
     SearchWsResponse response = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
+      .setParam(PARAM_COMPONENTS, project.getKey())
       .setParam(FACETS, "severities,statuses,resolutions,rules,types,languages,projects,files,assignees")
       .executeProtobuf(SearchWsResponse.class);
 
@@ -183,7 +183,7 @@ public class SearchActionFacetsIT {
 
     SearchWsResponse response = ws.newRequest()
       .setParam("resolved", "false")
-      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
+      .setParam(PARAM_COMPONENTS, project.getKey())
       .setParam(WebService.Param.FACETS, "directories")
       .executeProtobuf(SearchWsResponse.class);
 
@@ -224,7 +224,7 @@ public class SearchActionFacetsIT {
     indexIssues();
 
     SearchWsResponse response = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
+      .setParam(PARAM_COMPONENTS, project.getKey())
       .setParam(PARAM_FILES, file1.path())
       .setParam(WebService.Param.FACETS, "files")
       .executeProtobuf(SearchWsResponse.class);
@@ -284,7 +284,7 @@ public class SearchActionFacetsIT {
     indexIssues();
 
     SearchWsResponse response = ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, project.getKey())
+      .setParam(PARAM_COMPONENTS, project.getKey())
       .setParam(FACETS, "files,directories,statuses,resolutions,severities,types,rules,languages,assignees")
       .executeProtobuf(SearchWsResponse.class);
 
index e36646a0b6b8c0b0121eaef334f1cbcbd4b1ac15..17e7a9a1343326757b1eddef094aa3d4ff4f7be9 100644 (file)
@@ -120,7 +120,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_SET_TAGS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ADDITIONAL_FIELDS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEES;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CODE_VARIANTS;
-import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
+import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AFTER;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_HIDE_COMMENTS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_IN_NEW_CODE_PERIOD;
@@ -620,7 +620,7 @@ public class SearchActionIT {
     session.commit();
     indexIssues();
 
-    ws.newRequest().setParam(PARAM_COMPONENT_KEYS, file.getKey()).execute()
+    ws.newRequest().setParam(PARAM_COMPONENTS, file.getKey()).execute()
       .assertJson(this.getClass(), "apply_paging_with_one_component.json");
   }
 
@@ -711,7 +711,7 @@ public class SearchActionIT {
 
     ws.newRequest()
       .setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
-      .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY")
+      .setParam(PARAM_COMPONENTS, "PROJECT_KEY")
       .execute()
       .assertJson(this.getClass(), "filter_by_leak_period.json");
 
@@ -759,7 +759,7 @@ public class SearchActionIT {
     userSession.logIn(john);
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY")
+      .setParam(PARAM_COMPONENTS, "PROJECT_KEY")
       .setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
       .execute()
       .assertJson(this.getClass(), "empty_result.json");
@@ -804,7 +804,7 @@ public class SearchActionIT {
     userSession.logIn(john);
 
     ws.newRequest()
-      .setParam(PARAM_COMPONENT_KEYS, "PROJECT_KEY")
+      .setParam(PARAM_COMPONENTS, "PROJECT_KEY")
       .setParam(PARAM_PULL_REQUEST, "pr")
       .setParam(PARAM_IN_NEW_CODE_PERIOD, "true")
       .execute()
@@ -1749,7 +1749,7 @@ public class SearchActionIT {
   public void empty_search_with_unknown_branch() {
     SearchWsResponse response = ws.newRequest()
       .setParam("onComponentOnly", "true")
-      .setParam("componentKeys", "foo")
+      .setParam("components", "foo")
       .setParam("branch", "bar")
       .executeProtobuf(SearchWsResponse.class);
 
@@ -1787,7 +1787,7 @@ public class SearchActionIT {
     assertThat(def.responseExampleAsString()).isNotEmpty();
 
     assertThat(def.params()).extracting("key").containsExactlyInAnyOrder(
-      "additionalFields", "asc", "assigned", "assignees", "author", "componentKeys", "branch", "pullRequest", "createdAfter", "createdAt",
+      "additionalFields", "asc", "assigned", "assignees", "author", "components", "branch", "pullRequest", "createdAfter", "createdAt",
       "createdBefore", "createdInLast", "directories", "facets", "files", "issues", "scopes", "languages", "onComponentOnly",
       "p", "projects", "ps", "resolutions", "resolved", "rules", "s", "severities", "statuses", "tags", "types", "pciDss-3.2", "pciDss-4.0", "owaspAsvs-4.0",
       "owaspAsvsLevel", "owaspTop10",
index a113b2cd52177c5eaa6874274763cf09f8cbbd8b..674c74cca2e549fac635434621a562572c92c499 100644 (file)
@@ -95,6 +95,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEES;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_AUTHOR;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_BRANCH;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CODE_VARIANTS;
+import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AFTER;
 import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_CREATED_AT;
@@ -193,6 +194,7 @@ public class SearchAction implements IssuesWsAction {
         + "<br/>When issue indexation is in progress returns 503 service unavailable HTTP code.")
       .setSince("3.6")
       .setChangelog(
+        new Change("10.2", format("Parameter '%s' renamed to '%s'", PARAM_COMPONENT_KEYS, PARAM_COMPONENTS)),
         new Change("10.1", "Add the 'codeVariants' parameter, facet and response field"),
         new Change("10.0", "Parameter 'sansTop25' is deprecated"),
         new Change("10.0", "The value 'sansTop25' for the parameter 'facets' has been deprecated"),
@@ -370,7 +372,8 @@ public class SearchAction implements IssuesWsAction {
       .setBooleanPossibleValues()
       .setDefaultValue("false");
 
-    action.createParam(PARAM_COMPONENT_KEYS)
+    action.createParam(PARAM_COMPONENTS)
+      .setDeprecatedKey(PARAM_COMPONENT_KEYS, "10.2")
       .setDescription("Comma-separated list of component keys. Retrieve issues associated to a specific list of components (and all its descendants). " +
         "A component can be a portfolio, project, module, directory or file.")
       .setExampleValue(KEY_PROJECT_EXAMPLE_001);
@@ -549,7 +552,7 @@ public class SearchAction implements IssuesWsAction {
       .setAssigned(request.paramAsBoolean(PARAM_ASSIGNED))
       .setAssigneesUuid(getLogins(dbSession, request.paramAsStrings(PARAM_ASSIGNEES)))
       .setAuthors(request.multiParam(PARAM_AUTHOR))
-      .setComponentKeys(request.paramAsStrings(PARAM_COMPONENT_KEYS))
+      .setComponentKeys(request.paramAsStrings(PARAM_COMPONENTS))
       .setCreatedAfter(request.param(PARAM_CREATED_AFTER))
       .setCreatedAt(request.param(PARAM_CREATED_AT))
       .setCreatedBefore(request.param(PARAM_CREATED_BEFORE))
index 634b5962bccfe35a7e035b5e43f405d4de723cf1..be7928515eefb32af7e7da1493b03cd5bedf5e2a 100644 (file)
@@ -56,6 +56,7 @@ public class IssuesWsParameters {
   public static final String PARAM_STATUSES = "statuses";
   public static final String PARAM_RESOLUTIONS = "resolutions";
   public static final String PARAM_RESOLVED = "resolved";
+  public static final String PARAM_COMPONENTS = "components";
   public static final String PARAM_COMPONENT_KEYS = "componentKeys";
   public static final String PARAM_COMPONENT_UUIDS = "componentUuids";
   public static final String PARAM_PROJECTS = "projects";
index 09b293798d40e1ce448394d44984f512a05c8b68..fe2299220d7db424e330a6824ae84164452dffe8 100644 (file)
@@ -221,7 +221,7 @@ public class IssuesService extends BaseService {
         .setParam("assignees", request.getAssignees() == null ? null : request.getAssignees().stream().collect(Collectors.joining(",")))
         .setParam("author", request.getAuthor())
         .setParam("branch", request.getBranch())
-        .setParam("componentKeys", request.getComponentKeys() == null ? null : request.getComponentKeys().stream().collect(Collectors.joining(",")))
+        .setParam("components", request.getComponentKeys() == null ? null : request.getComponentKeys().stream().collect(Collectors.joining(",")))
         .setParam("createdAfter", request.getCreatedAfter())
         .setParam("createdAt", request.getCreatedAt())
         .setParam("createdBefore", request.getCreatedBefore())