summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-05-20 16:22:38 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-05-20 16:22:38 +0200
commit990fcb90cac56723923957a9a9601b27bf399eaa (patch)
tree9a0f7cf8fe58aa1d98646cd3a08086275494cdca
parent28d2cf2e08e4d8dd42904e8fc1db92e50905e54b (diff)
downloadsonarqube-990fcb90cac56723923957a9a9601b27bf399eaa.tar.gz
sonarqube-990fcb90cac56723923957a9a9601b27bf399eaa.zip
Add response example of /api/issue_filters/app WS
-rw-r--r--sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java50
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/filter/AppAction.java4
-rw-r--r--sonar-server/src/main/resources/org/sonar/server/issue/filter/app-example-show.json23
3 files changed, 53 insertions, 24 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java b/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java
index e632b6eef4b..49cb3bbde88 100644
--- a/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java
+++ b/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java
@@ -120,29 +120,9 @@ public class ComponentAppAction implements RequestHandler {
Long subProjectId = component.subProjectId();
// projectId and subProjectId can't be null here
if (projectId != null && subProjectId != null) {
- List<PropertyDto> propertyDtos = propertiesDao.selectByQuery(PropertyQuery.builder()
- .setKey("favourite")
- .setComponentId(component.getId())
- .setUserId(userSession.userId())
- .build(),
- session
- );
- boolean isFavourite = propertyDtos.size() == 1;
-
- json.prop("key", component.key());
- json.prop("path", component.path());
- json.prop("name", component.name());
- json.prop("q", component.qualifier());
-
- Component subProject = componentById(subProjectId, session);
- json.prop("subProjectName", subProject != null ? subProject.longName() : null);
-
- Component project = componentById(projectId, session);
- json.prop("projectName", project != null ? project.longName() : null);
-
- json.prop("fav", isFavourite);
+ appendComponent(json, component, projectId, subProjectId, userSession, session);
appendPeriods(json, projectId, session);
- appendRulesAggregation(json, component.key(), session);
+ appendIssuesAggregation(json, component.key(), session);
appendMeasures(json, fileKey, session);
}
} finally {
@@ -153,6 +133,30 @@ public class ComponentAppAction implements RequestHandler {
json.close();
}
+ private void appendComponent(JsonWriter json, ComponentDto component, Long projectId, Long subProjectId, UserSession userSession, DbSession session) {
+ List<PropertyDto> propertyDtos = propertiesDao.selectByQuery(PropertyQuery.builder()
+ .setKey("favourite")
+ .setComponentId(component.getId())
+ .setUserId(userSession.userId())
+ .build(),
+ session
+ );
+ boolean isFavourite = propertyDtos.size() == 1;
+
+ json.prop("key", component.key());
+ json.prop("path", component.path());
+ json.prop("name", component.name());
+ json.prop("q", component.qualifier());
+
+ Component subProject = componentById(subProjectId, session);
+ json.prop("subProjectName", subProject.longName());
+
+ Component project = componentById(projectId, session);
+ json.prop("projectName", project.longName());
+
+ json.prop("fav", isFavourite);
+ }
+
private void appendMeasures(JsonWriter json, String fileKey, DbSession session) {
json.name("measures").beginObject();
@@ -197,7 +201,7 @@ public class ComponentAppAction implements RequestHandler {
json.endArray();
}
- private void appendRulesAggregation(JsonWriter json, String componentKey, DbSession session) {
+ private void appendIssuesAggregation(JsonWriter json, String componentKey, DbSession session) {
json.name("severities").beginArray();
Multiset<String> severities = issueService.findSeveritiesByComponent(componentKey, session);
for (String severity : severities.elementSet()) {
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/filter/AppAction.java b/sonar-server/src/main/java/org/sonar/server/issue/filter/AppAction.java
index 84fb1dbe9ee..c480a9b2413 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/filter/AppAction.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/filter/AppAction.java
@@ -20,6 +20,7 @@
package org.sonar.server.issue.filter;
+import com.google.common.io.Resources;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.RequestHandler;
import org.sonar.api.server.ws.Response;
@@ -45,7 +46,8 @@ public class AppAction implements RequestHandler {
action
.setDescription("Data required for rendering the page 'Issues'")
.setInternal(true)
- .setHandler(this);
+ .setHandler(this)
+ .setResponseExample(Resources.getResource(this.getClass(), "app-example-show.json"));
action
.createParam("id")
.setDescription("Optionally, the ID of the current filter");
diff --git a/sonar-server/src/main/resources/org/sonar/server/issue/filter/app-example-show.json b/sonar-server/src/main/resources/org/sonar/server/issue/filter/app-example-show.json
new file mode 100644
index 00000000000..982d0ef6460
--- /dev/null
+++ b/sonar-server/src/main/resources/org/sonar/server/issue/filter/app-example-show.json
@@ -0,0 +1,23 @@
+{
+ "canManageFilters": true,
+ "canBulkChange": true,
+ "filter": {
+ "id": 8,
+ "name": "My Issues To Fix",
+ "description": "",
+ "user": "john.snow",
+ "shared": false,
+ "query": "asc=false|assignees=john.snow|statuses=OPEN,CONFIRMED,REOPENED",
+ "canModify": true
+ },
+ "favorites": [
+ {
+ "id": 8,
+ "name": "My Issues To Fix"
+ },
+ {
+ "id": 22,
+ "name": "SonarQube Issues"
+ }
+ ]
+}