aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java12
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/list-example.json (renamed from server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiods/ws/list-example.json)0
-rw-r--r--server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/show-example.json6
-rw-r--r--sonar-ws/src/main/protobuf/ws-newcodeperiods.proto7
5 files changed, 23 insertions, 8 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
index 3837853b3f4..0394cc27a70 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
@@ -20,9 +20,11 @@
package org.sonar.server.newcodeperiod.ws;
import com.google.common.base.Preconditions;
+import java.util.Arrays;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
@@ -93,7 +95,13 @@ public class SetAction implements NewCodePeriodsWsAction {
.setDescription("Branch key");
action.createParam(PARAM_TYPE)
.setRequired(true)
- .setDescription("Type");
+ .setDescription("Type<br/>" +
+ "Only new code periods of the following types are allowed:" +
+ "<ul>" +
+ Arrays.stream(NewCodePeriodType.values())
+ .map(newCodePeriodType -> "<li>" + newCodePeriodType.name() + "</li>")
+ .collect(Collectors.joining()) +
+ "</ul>");
action.createParam(PARAM_VALUE)
.setDescription("Value");
}
@@ -139,7 +147,7 @@ public class SetAction implements NewCodePeriodsWsAction {
}
private void setValue(DbSession dbSession, NewCodePeriodDto dto, NewCodePeriodType type, @Nullable ComponentDto projectBranch,
- @Nullable String branch, @Nullable String value) {
+ @Nullable String branch, @Nullable String value) {
switch (type) {
case PREVIOUS_VERSION:
Preconditions.checkArgument(value == null, "Unexpected value for type '%s'", type);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
index 86f95269dfe..c46343aca4b 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
@@ -42,7 +42,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.String.format;
import static org.sonar.server.component.ComponentFinder.ParamNames.PROJECT_ID_AND_KEY;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
-import static org.sonarqube.ws.NewCodePeriods.*;
+import static org.sonarqube.ws.NewCodePeriods.ShowWSResponse;
public class ShowAction implements NewCodePeriodsWsAction {
private static final String PARAM_BRANCH = "branch";
@@ -70,7 +70,7 @@ public class ShowAction implements NewCodePeriodsWsAction {
"<li>'Administer' rights on the specified component</li>" +
"</ul>")
.setSince("8.0")
- .setResponseExample(getClass().getResource("show_new_code_period-example.json"))
+ .setResponseExample(getClass().getResource("show-example.json"))
.setHandler(this);
action.createParam(PARAM_PROJECT)
@@ -90,7 +90,7 @@ public class ShowAction implements NewCodePeriodsWsAction {
try (DbSession dbSession = dbClient.openSession(false)) {
- ComponentDto projectBranch = null;
+ ComponentDto projectBranch;
String projectUuid = null;
String branchUuid = null;
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiods/ws/list-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/list-example.json
index 537c0ecebfd..537c0ecebfd 100644
--- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiods/ws/list-example.json
+++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/list-example.json
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/show-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/show-example.json
new file mode 100644
index 00000000000..59786307e94
--- /dev/null
+++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/newcodeperiod/ws/show-example.json
@@ -0,0 +1,6 @@
+{
+ "projectKey": "org.sonarsource.project:project",
+ "branchKey": "branch-1.1",
+ "type": "PREVIOUS_VERSION",
+ "inherited": true
+}
diff --git a/sonar-ws/src/main/protobuf/ws-newcodeperiods.proto b/sonar-ws/src/main/protobuf/ws-newcodeperiods.proto
index 7bf16771ac9..73b7fdc5350 100644
--- a/sonar-ws/src/main/protobuf/ws-newcodeperiods.proto
+++ b/sonar-ws/src/main/protobuf/ws-newcodeperiods.proto
@@ -40,7 +40,8 @@ message ListWSResponse {
}
enum NewCodePeriodType {
- PREVIOUS_VERSION = 0;
- NUMBER_OF_DAYS = 1;
- SPECIFIC_ANALYSIS = 2;
+ UNKNOWN = 0;
+ PREVIOUS_VERSION = 1;
+ NUMBER_OF_DAYS = 2;
+ SPECIFIC_ANALYSIS = 3;
}