From 7ee2cc6372f66afc24e0fd4f780bab8dfcdb4409 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Thu, 12 Oct 2017 13:38:17 +0200 Subject: [PATCH] SONAR-7734 Clarify message when one of several parameters is required --- .../sonar/server/ce/ws/ComponentAction.java | 5 ++-- .../server/component/ComponentFinder.java | 2 +- .../measure/custom/ws/CreateAction.java | 2 +- .../server/permission/ws/ProjectWsRef.java | 1 - .../project/ws/BulkUpdateKeyAction.java | 2 +- .../server/project/ws/UpdateKeyAction.java | 2 +- .../qualitygate/ws/ProjectStatusAction.java | 3 +-- .../server/qualitygate/ws/ShowAction.java | 25 ++++++++----------- .../sonar/server/setting/ws/SetAction.java | 4 +-- .../org/sonar/server/test/ws/ListAction.java | 2 +- .../webhook/ws/WebhookDeliveriesAction.java | 14 +++++------ .../server/component/ComponentFinderTest.java | 4 +-- .../server/component/ws/AppActionTest.java | 2 +- .../server/component/ws/TreeActionTest.java | 2 +- .../server/duplication/ws/ShowActionTest.java | 2 +- .../measure/custom/ws/CreateActionTest.java | 8 +++--- .../measure/custom/ws/SearchActionTest.java | 4 +-- .../ws/ProjectStatusActionTest.java | 4 +-- .../qualityprofile/ws/ExportActionTest.java | 2 +- .../server/setting/ws/SetActionTest.java | 4 +-- .../server/source/ws/LinesActionTest.java | 2 +- .../sonar/server/test/ws/ListActionTest.java | 2 +- .../ws/WebhookDeliveriesActionTest.java | 2 +- .../tests/duplication/DuplicationsTest.java | 2 +- 24 files changed, 48 insertions(+), 54 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ComponentAction.java b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ComponentAction.java index 0f109ec370a..289b0cd480e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ComponentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ComponentAction.java @@ -40,7 +40,6 @@ import org.sonarqube.ws.WsCe.ProjectResponse; import static org.sonar.db.Pagination.forPage; import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_COMPONENT; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.ce.CeWsParameters.DEPRECATED_PARAM_COMPONENT_KEY; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; @@ -63,8 +62,8 @@ public class ComponentAction implements CeWsAction { WebService.NewAction action = controller.createAction("component") .setDescription("Get the pending tasks, in-progress tasks and the last executed task of a given component (usually a project).
" + "Requires the following permission: 'Browse' on the specified component.
" + - "Either '%s' or '%s' must be provided, not both.", - PARAM_COMPONENT_ID, DEPRECATED_PARAM_COMPONENT_KEY) + "Either '%s' or '%s' must be provided.", + PARAM_COMPONENT_ID, PARAM_COMPONENT) .setSince("5.2") .setResponseExample(getClass().getResource("component-example.json")) .setChangelog( diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java index cb191f65287..384aa88a2e8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java @@ -40,7 +40,7 @@ import static org.sonar.server.ws.WsUtils.checkFoundWithOptional; import static org.sonar.server.ws.WsUtils.checkRequest; public class ComponentFinder { - private static final String MSG_COMPONENT_ID_OR_KEY_TEMPLATE = "Either '%s' or '%s' must be provided, not both"; + private static final String MSG_COMPONENT_ID_OR_KEY_TEMPLATE = "Either '%s' or '%s' must be provided"; private static final String MSG_PARAMETER_MUST_NOT_BE_EMPTY = "The '%s' parameter must not be empty"; private static final String LABEL_PROJECT = "Project"; private static final String LABEL_COMPONENT = "Component"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java index 568b92490af..0453dfcc850 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java @@ -147,7 +147,7 @@ public class CreateAction implements CustomMeasuresWsAction { private MetricDto searchMetric(DbSession dbSession, Request request) { Integer metricId = request.paramAsInt(PARAM_METRIC_ID); String metricKey = request.param(PARAM_METRIC_KEY); - checkArgument(metricId != null ^ metricKey != null, "The metric id or the metric key must be provided, not both."); + checkArgument(metricId != null ^ metricKey != null, "Either the metric id or the metric key must be provided"); if (metricId != null) { return dbClient.metricDao().selectOrFailById(dbSession, metricId); diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ProjectWsRef.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ProjectWsRef.java index 02bcb3d3025..5a3cad31e6a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ProjectWsRef.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ProjectWsRef.java @@ -51,7 +51,6 @@ public class ProjectWsRef { } public static ProjectWsRef newWsProjectRef(@Nullable String uuid, @Nullable String key) { - checkRequest(uuid == null ^ key == null, MSG_ID_OR_KEY_MUST_BE_PROVIDED); return new ProjectWsRef(uuid, key); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkUpdateKeyAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkUpdateKeyAction.java index 106a9db3a6c..017a6ec373b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkUpdateKeyAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkUpdateKeyAction.java @@ -80,7 +80,7 @@ public class BulkUpdateKeyAction implements ProjectsWsAction { "
  • %s: my_
  • " + "
  • %s: my_new_
  • " + "" + - "Either '%s' or '%s' must be provided, not both.
    " + + "Either '%s' or '%s' must be provided.
    " + "Requires one of the following permissions: " + "