diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-09-28 16:40:42 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-09-29 11:38:18 +0200 |
commit | 8d61942d055140fc5b43273e10960fb023e899ed (patch) | |
tree | 8e8d4d791f5281d3046276d015792d566ff14ce1 /server | |
parent | 96ab2f7679e5c904a942f5256969ddff07ca788d (diff) | |
download | sonarqube-8d61942d055140fc5b43273e10960fb023e899ed.tar.gz sonarqube-8d61942d055140fc5b43273e10960fb023e899ed.zip |
SONAR-5770 Improve api/ce/component
- renamed from api/ce/project
- parameter componentId supports non-projects -> returns empty results instead of raising 403
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeWsModule.java | 2 | ||||
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/computation/ws/ComponentWsAction.java (renamed from server/sonar-server/src/main/java/org/sonar/server/computation/ws/ProjectWsAction.java) | 12 | ||||
-rw-r--r-- | server/sonar-server/src/main/resources/org/sonar/server/computation/ws/component-example.json (renamed from server/sonar-server/src/main/resources/org/sonar/server/computation/ws/project-example.json) | 0 | ||||
-rw-r--r-- | server/sonar-server/src/test/java/org/sonar/server/computation/ws/ComponentWsActionTest.java (renamed from server/sonar-server/src/test/java/org/sonar/server/computation/ws/ProjectWsActionTest.java) | 8 | ||||
-rw-r--r-- | server/sonar-web/src/main/js/api/ce.js | 2 |
5 files changed, 12 insertions, 12 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeWsModule.java index 2092778ad26..7c604823128 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeWsModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeWsModule.java @@ -32,7 +32,7 @@ public class CeWsModule extends Module { CeWs.class, IsQueueEmptyWs.class, LogsWsAction.class, - ProjectWsAction.class, + ComponentWsAction.class, SubmitWsAction.class, TaskFormatter.class, TaskWsAction.class); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ProjectWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ComponentWsAction.java index 3af33043327..f84a9b541a5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ProjectWsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ComponentWsAction.java @@ -36,7 +36,7 @@ import org.sonar.server.ws.WsUtils; import static org.sonarqube.ws.WsCe.ProjectResponse; -public class ProjectWsAction implements CeWsAction { +public class ComponentWsAction implements CeWsAction { public static final String PARAM_COMPONENT_UUID = "componentId"; @@ -44,7 +44,7 @@ public class ProjectWsAction implements CeWsAction { private final DbClient dbClient; private final TaskFormatter formatter; - public ProjectWsAction(UserSession userSession, DbClient dbClient, TaskFormatter formatter) { + public ComponentWsAction(UserSession userSession, DbClient dbClient, TaskFormatter formatter) { this.userSession = userSession; this.dbClient = dbClient; this.formatter = formatter; @@ -52,10 +52,10 @@ public class ProjectWsAction implements CeWsAction { @Override public void define(WebService.NewController controller) { - WebService.NewAction action = controller.createAction("project") - .setDescription("Get the pending and last executed tasks of a given project") + WebService.NewAction action = controller.createAction("component") + .setDescription("Get the pending and last executed tasks of a given component (usually a project)") .setInternal(true) - .setResponseExample(getClass().getResource("project-example.json")) + .setResponseExample(getClass().getResource("component-example.json")) .setHandler(this); action.createParam(PARAM_COMPONENT_UUID) @@ -66,7 +66,7 @@ public class ProjectWsAction implements CeWsAction { @Override public void handle(Request wsRequest, Response wsResponse) throws Exception { String componentUuid = wsRequest.mandatoryParam(PARAM_COMPONENT_UUID); - userSession.checkProjectUuidPermission(UserRole.USER, componentUuid); + userSession.checkComponentUuidPermission(UserRole.USER, componentUuid); DbSession dbSession = dbClient.openSession(false); try { diff --git a/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/project-example.json b/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/component-example.json index 747ca57fe00..747ca57fe00 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/project-example.json +++ b/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/component-example.json diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/ProjectWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/ComponentWsActionTest.java index d6a187a8e5e..025c03ba1a8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/ProjectWsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/ComponentWsActionTest.java @@ -44,7 +44,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class ProjectWsActionTest { +public class ComponentWsActionTest { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); @@ -54,7 +54,7 @@ public class ProjectWsActionTest { CeLogging ceLogging = mock(CeLogging.class); TaskFormatter formatter = new TaskFormatter(dbTester.getDbClient(), ceLogging); - ProjectWsAction underTest = new ProjectWsAction(userSession, dbTester.getDbClient(), formatter); + ComponentWsAction underTest = new ComponentWsAction(userSession, dbTester.getDbClient(), formatter); WsActionTester tester = new WsActionTester(underTest); @Before @@ -64,7 +64,7 @@ public class ProjectWsActionTest { @Test public void empty_queue_and_empty_activity() { - userSession.addProjectUuidPermissions(UserRole.USER, "PROJECT_1"); + userSession.addComponentUuidPermission(UserRole.USER, "PROJECT_1", "PROJECT_1"); TestResponse wsResponse = tester.newRequest() .setParam("componentId", "PROJECT_1") @@ -78,7 +78,7 @@ public class ProjectWsActionTest { @Test public void project_tasks() { - userSession.addProjectUuidPermissions(UserRole.USER, "PROJECT_1"); + userSession.addComponentUuidPermission(UserRole.USER, "PROJECT_1", "PROJECT_1"); insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS); insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED); insertActivity("T3", "PROJECT_1", CeActivityDto.Status.FAILED); diff --git a/server/sonar-web/src/main/js/api/ce.js b/server/sonar-web/src/main/js/api/ce.js index d2bed547a4a..f14185b7882 100644 --- a/server/sonar-web/src/main/js/api/ce.js +++ b/server/sonar-web/src/main/js/api/ce.js @@ -26,6 +26,6 @@ export function cancelAllTasks () { } export function getTasksForComponent(componentId) { - let url = baseUrl + '/api/ce/project'; + let url = baseUrl + '/api/ce/component'; return $.get(url, { componentId }); } |