]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5770 add WS api/ce/project
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 21 Sep 2015 17:46:09 +0000 (19:46 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 22 Sep 2015 15:12:52 +0000 (17:12 +0200)
38 files changed:
server/sonar-server/src/main/java/org/sonar/server/computation/ws/ActivityWsAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/CancelWsAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeActivityWsAction.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeCancelWsAction.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeQueueWsAction.java
server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeSubmitWsAction.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeTaskWsAction.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeWsModule.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeWsTaskFormatter.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/ProjectWsAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/SubmitWsAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/TaskFormatter.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/ws/TaskWsAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/main/resources/org/sonar/server/computation/ws/CeActivityWsAction/example.json [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/computation/ws/CeQueueWsAction/example.json [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/computation/ws/CeSubmitWsAction/example.json [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/computation/ws/activity-example.json [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/computation/ws/project-example.json [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/computation/ws/queue-example.json [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/computation/ws/submit-example.json [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/ActivityWsActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/CancelWsActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeActivityWsActionTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeCancelWsActionTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeQueueWsActionTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeSubmitWsActionTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeTaskWsActionTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeWsModuleTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeWsTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/ws/ProjectWsActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/QueueWsActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/SubmitWsActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/ws/TaskWsActionTest.java [new file with mode: 0644]
sonar-db/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml
sonar-db/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java
sonar-ws/src/main/gen-java/org/sonarqube/ws/WsCe.java
sonar-ws/src/main/protobuf/ws-ce.proto

diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ActivityWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/ActivityWsAction.java
new file mode 100644 (file)
index 0000000..99aecc4
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import java.util.List;
+import org.apache.ibatis.session.RowBounds;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.web.UserRole;
+import org.sonar.core.util.Uuids;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.ce.CeActivityDto;
+import org.sonar.db.ce.CeActivityQuery;
+import org.sonar.db.ce.CeTaskTypes;
+import org.sonar.server.user.UserSession;
+import org.sonar.server.ws.WsUtils;
+import org.sonarqube.ws.Common;
+import org.sonarqube.ws.WsCe;
+
+public class ActivityWsAction implements CeWsAction {
+
+  private static final String PARAM_COMPONENT_UUID = "componentId";
+  private static final String PARAM_TYPE = "type";
+  private static final String PARAM_STATUS = "status";
+  private static final String PARAM_ONLY_CURRENTS = "onlyCurrents";
+
+  private final UserSession userSession;
+  private final DbClient dbClient;
+  private final TaskFormatter formatter;
+
+  public ActivityWsAction(UserSession userSession, DbClient dbClient, TaskFormatter formatter) {
+    this.userSession = userSession;
+    this.dbClient = dbClient;
+    this.formatter = formatter;
+  }
+
+  @Override
+  public void define(WebService.NewController controller) {
+    WebService.NewAction action = controller.createAction("activity")
+      .setInternal(true)
+      .setResponseExample(getClass().getResource("activity-example.json"))
+      .setHandler(this);
+    action.createParam(PARAM_COMPONENT_UUID)
+      .setDescription("Optional id of the component (project) to filter on")
+      .setExampleValue(Uuids.UUID_EXAMPLE_03);
+    action.createParam(PARAM_STATUS)
+      .setDescription("Optional filter on task status")
+      .setPossibleValues(CeActivityDto.Status.values());
+    action.createParam(PARAM_ONLY_CURRENTS)
+      .setDescription("Optional filter on the current activities (only the most recent task by project)")
+      .setBooleanPossibleValues()
+      .setDefaultValue("false");
+    action.createParam(PARAM_TYPE)
+      .setDescription("Optional filter on task type")
+      .setExampleValue(CeTaskTypes.REPORT);
+    action.addPagingParams(10);
+  }
+
+  @Override
+  public void handle(Request wsRequest, Response wsResponse) throws Exception {
+    DbSession dbSession = dbClient.openSession(false);
+    try {
+      CeActivityQuery query = readQuery(wsRequest);
+      RowBounds rowBounds = readMyBatisRowBounds(wsRequest);
+      List<CeActivityDto> dtos = dbClient.ceActivityDao().selectByQuery(dbSession, query, rowBounds);
+      int total = dbClient.ceActivityDao().countByQuery(dbSession, query);
+
+      WsCe.ActivityResponse.Builder wsResponseBuilder = WsCe.ActivityResponse.newBuilder();
+      wsResponseBuilder.addAllTasks(formatter.formatActivity(dbSession, dtos));
+      wsResponseBuilder.setPaging(Common.Paging.newBuilder()
+        .setPageIndex(wsRequest.mandatoryParamAsInt(WebService.Param.PAGE))
+        .setPageSize(wsRequest.mandatoryParamAsInt(WebService.Param.PAGE_SIZE))
+        .setTotal(total));
+      WsUtils.writeProtobuf(wsResponseBuilder.build(), wsRequest, wsResponse);
+
+    } finally {
+      dbClient.closeSession(dbSession);
+    }
+  }
+
+  private CeActivityQuery readQuery(Request wsRequest) {
+    CeActivityQuery query = new CeActivityQuery();
+    query.setType(wsRequest.param(PARAM_TYPE));
+    query.setOnlyCurrents(wsRequest.mandatoryParamAsBoolean(PARAM_ONLY_CURRENTS));
+      
+    String status = wsRequest.param(PARAM_STATUS);
+    if (status != null) {
+      query.setStatus(CeActivityDto.Status.valueOf(status));
+    }
+    
+    String componentUuid = wsRequest.param(PARAM_COMPONENT_UUID);
+    if (componentUuid == null) {
+      userSession.checkGlobalPermission(UserRole.ADMIN);
+    } else {
+      userSession.checkProjectUuidPermission(UserRole.USER, componentUuid);
+      query.setComponentUuid(componentUuid);
+    }
+    return query;
+  }
+
+  private static RowBounds readMyBatisRowBounds(Request wsRequest) {
+    int pageIndex = wsRequest.mandatoryParamAsInt(WebService.Param.PAGE);
+    int pageSize = wsRequest.mandatoryParamAsInt(WebService.Param.PAGE_SIZE);
+    return new RowBounds((pageIndex - 1) * pageSize, pageSize);
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CancelWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CancelWsAction.java
new file mode 100644 (file)
index 0000000..7588beb
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.web.UserRole;
+import org.sonar.core.util.Uuids;
+import org.sonar.server.computation.CeQueue;
+import org.sonar.server.exceptions.BadRequestException;
+import org.sonar.server.user.UserSession;
+
+public class CancelWsAction implements CeWsAction {
+
+  public static final String PARAM_TASK_ID = "id";
+  public static final String PARAM_ALL = "all";
+
+  private final UserSession userSession;
+  private final CeQueue queue;
+
+  public CancelWsAction(UserSession userSession, CeQueue queue) {
+    this.userSession = userSession;
+    this.queue = queue;
+  }
+
+  @Override
+  public void define(WebService.NewController controller) {
+    WebService.NewAction action = controller.createAction("cancel")
+      .setDescription("Cancels a pending task. Requires system administration permission.")
+      .setInternal(true)
+      .setPost(true)
+      .setHandler(this);
+
+    action
+      .createParam(PARAM_TASK_ID)
+      .setDescription("Optional id of the task to cancel.")
+      .setExampleValue(Uuids.UUID_EXAMPLE_01);
+
+    action
+      .createParam(PARAM_ALL)
+      .setDescription("Cancels all pending tasks if this parameter is set. Ignored if the parameter " + PARAM_TASK_ID + " is set.")
+      .setBooleanPossibleValues()
+      .setDefaultValue("false");
+  }
+
+  @Override
+  public void handle(Request wsRequest, Response wsResponse) throws Exception {
+    userSession.checkGlobalPermission(UserRole.ADMIN);
+    String taskId = wsRequest.param(PARAM_TASK_ID);
+    if (taskId != null) {
+      queue.cancel(taskId);
+    } else if (wsRequest.paramAsBoolean(PARAM_ALL)) {
+      queue.cancelAll();
+    } else {
+      throw new BadRequestException("Missing parameters");
+    }
+    wsResponse.noContent();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeActivityWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeActivityWsAction.java
deleted file mode 100644 (file)
index f10d7b4..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import java.util.List;
-import org.apache.ibatis.session.RowBounds;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.web.UserRole;
-import org.sonar.core.util.Uuids;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.ce.CeActivityDto;
-import org.sonar.db.ce.CeActivityQuery;
-import org.sonar.db.ce.CeTaskTypes;
-import org.sonar.server.user.UserSession;
-import org.sonar.server.ws.WsUtils;
-import org.sonarqube.ws.Common;
-import org.sonarqube.ws.WsCe;
-
-/**
- * GET api/ce/activity
- * <p>Get the past executed tasks</p>
- */
-public class CeActivityWsAction implements CeWsAction {
-
-  private static final String PARAM_COMPONENT_ID = "componentId";
-  private static final String PARAM_TYPE = "type";
-  private static final String PARAM_STATUS = "status";
-  private static final String PARAM_ONLY_CURRENTS = "onlyCurrents";
-
-  private final UserSession userSession;
-  private final DbClient dbClient;
-  private final CeWsTaskFormatter formatter;
-
-  public CeActivityWsAction(UserSession userSession, DbClient dbClient, CeWsTaskFormatter formatter) {
-    this.userSession = userSession;
-    this.dbClient = dbClient;
-    this.formatter = formatter;
-  }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    WebService.NewAction action = controller.createAction("activity")
-      .setInternal(true)
-      .setResponseExample(getClass().getResource("CeActivityWsAction/example.json"))
-      .setHandler(this);
-    action.createParam(PARAM_COMPONENT_ID)
-      .setDescription("Optional id of the component (project) to filter on")
-      .setExampleValue(Uuids.UUID_EXAMPLE_03);
-    action.createParam(PARAM_STATUS)
-      .setDescription("Optional filter on task status")
-      .setPossibleValues(CeActivityDto.Status.values());
-    action.createParam(PARAM_ONLY_CURRENTS)
-      .setDescription("Optional filter on the current activities (only the most recent task by project)")
-      .setBooleanPossibleValues()
-      .setDefaultValue("false");
-    action.createParam(PARAM_TYPE)
-      .setDescription("Optional filter on task type")
-      .setExampleValue(CeTaskTypes.REPORT);
-    action.addPagingParams(10);
-  }
-
-  @Override
-  public void handle(Request wsRequest, Response wsResponse) throws Exception {
-    DbSession dbSession = dbClient.openSession(false);
-    try {
-      CeActivityQuery query = readQuery(wsRequest);
-      RowBounds rowBounds = readMyBatisRowBounds(wsRequest);
-      List<CeActivityDto> dtos = dbClient.ceActivityDao().selectByQuery(dbSession, query, rowBounds);
-      int total = dbClient.ceActivityDao().countByQuery(dbSession, query);
-
-      WsCe.ActivityResponse.Builder wsResponseBuilder = WsCe.ActivityResponse.newBuilder();
-      wsResponseBuilder.addAllTasks(formatter.formatActivity(dbSession, dtos));
-      wsResponseBuilder.setPaging(Common.Paging.newBuilder()
-        .setPageIndex(wsRequest.mandatoryParamAsInt(WebService.Param.PAGE))
-        .setPageSize(wsRequest.mandatoryParamAsInt(WebService.Param.PAGE_SIZE))
-        .setTotal(total));
-      WsUtils.writeProtobuf(wsResponseBuilder.build(), wsRequest, wsResponse);
-
-    } finally {
-      dbClient.closeSession(dbSession);
-    }
-  }
-
-  private CeActivityQuery readQuery(Request wsRequest) {
-    CeActivityQuery query = new CeActivityQuery();
-    query.setType(wsRequest.param(PARAM_TYPE));
-    query.setOnlyCurrents(wsRequest.mandatoryParamAsBoolean(PARAM_ONLY_CURRENTS));
-      
-    String status = wsRequest.param(PARAM_STATUS);
-    if (status != null) {
-      query.setStatus(CeActivityDto.Status.valueOf(status));
-    }
-    
-    String componentId = wsRequest.param(PARAM_COMPONENT_ID);
-    if (componentId == null) {
-      userSession.checkGlobalPermission(UserRole.ADMIN);
-    } else {
-      userSession.checkProjectUuidPermission(UserRole.ADMIN, componentId);
-      query.setComponentUuid(componentId);
-    }
-    return query;
-  }
-
-  private static RowBounds readMyBatisRowBounds(Request wsRequest) {
-    int pageIndex = wsRequest.mandatoryParamAsInt(WebService.Param.PAGE);
-    int pageSize = wsRequest.mandatoryParamAsInt(WebService.Param.PAGE_SIZE);
-    return new RowBounds((pageIndex - 1) * pageSize, pageSize);
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeCancelWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeCancelWsAction.java
deleted file mode 100644 (file)
index 89031c1..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.web.UserRole;
-import org.sonar.core.util.Uuids;
-import org.sonar.server.computation.CeQueue;
-import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.user.UserSession;
-
-public class CeCancelWsAction implements CeWsAction {
-
-  public static final String PARAM_TASK_ID = "id";
-  public static final String PARAM_ALL = "all";
-
-  private final UserSession userSession;
-  private final CeQueue queue;
-
-  public CeCancelWsAction(UserSession userSession, CeQueue queue) {
-    this.userSession = userSession;
-    this.queue = queue;
-  }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    WebService.NewAction action = controller.createAction("cancel")
-      .setDescription("Cancels a pending task. Requires system administration permission.")
-      .setInternal(true)
-      .setPost(true)
-      .setHandler(this);
-
-    action
-      .createParam(PARAM_TASK_ID)
-      .setDescription("Optional id of the task to cancel.")
-      .setExampleValue(Uuids.UUID_EXAMPLE_01);
-
-    action
-      .createParam(PARAM_ALL)
-      .setDescription("Cancels all pending tasks if this parameter is set. Ignored if the parameter " + PARAM_TASK_ID + " is set.")
-      .setBooleanPossibleValues()
-      .setDefaultValue("false");
-  }
-
-  @Override
-  public void handle(Request wsRequest, Response wsResponse) throws Exception {
-    userSession.checkGlobalPermission(UserRole.ADMIN);
-    String taskId = wsRequest.param(PARAM_TASK_ID);
-    if (taskId != null) {
-      queue.cancel(taskId);
-    } else if (wsRequest.paramAsBoolean(PARAM_ALL)) {
-      queue.cancelAll();
-    } else {
-      throw new BadRequestException("Missing parameters");
-    }
-    wsResponse.noContent();
-  }
-}
index 6ffa6fc514eff2ecb9a3b5151c74496366268dbb..1a0cc7110220e8716a6a12b50614e06c9b62ee7b 100644 (file)
@@ -31,19 +31,15 @@ import org.sonar.server.user.UserSession;
 import org.sonar.server.ws.WsUtils;
 import org.sonarqube.ws.WsCe;
 
-/**
- * GET api/ce/queue
- * <p>Get the status of the queue</p>
- */
 public class CeQueueWsAction implements CeWsAction {
 
-  public static final String PARAM_COMPONENT_ID = "componentId";
+  public static final String PARAM_COMPONENT_UUID = "componentId";
 
   private final UserSession userSession;
   private final DbClient dbClient;
-  private final CeWsTaskFormatter formatter;
+  private final TaskFormatter formatter;
 
-  public CeQueueWsAction(UserSession userSession, DbClient dbClient, CeWsTaskFormatter formatter) {
+  public CeQueueWsAction(UserSession userSession, DbClient dbClient, TaskFormatter formatter) {
     this.userSession = userSession;
     this.dbClient = dbClient;
     this.formatter = formatter;
@@ -54,15 +50,15 @@ public class CeQueueWsAction implements CeWsAction {
     WebService.NewAction action = controller.createAction("queue")
       .setDescription("Gets the tasks of the Compute Engine queue")
       .setInternal(true)
-      .setResponseExample(getClass().getResource("CeQueueWsAction/example.json"))
+      .setResponseExample(getClass().getResource("queue-example.json"))
       .setHandler(this);
 
-    action.createParam(PARAM_COMPONENT_ID);
+    action.createParam(PARAM_COMPONENT_UUID);
   }
 
   @Override
   public void handle(Request wsRequest, Response wsResponse) throws Exception {
-    String componentUuid = wsRequest.param(PARAM_COMPONENT_ID);
+    String componentUuid = wsRequest.param(PARAM_COMPONENT_UUID);
 
     DbSession dbSession = dbClient.openSession(false);
     try {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeSubmitWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeSubmitWsAction.java
deleted file mode 100644 (file)
index 2c26dd9..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import java.io.InputStream;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.server.computation.CeTask;
-import org.sonar.server.computation.ReportSubmitter;
-import org.sonar.server.ws.WsUtils;
-import org.sonarqube.ws.WsCe;
-
-/**
- * POST api/ce/submit
- * <p>Submits an analysis report to the queue of Compute Engine</p>
- */
-public class CeSubmitWsAction implements CeWsAction {
-
-  public static final String PARAM_PROJECT_KEY = "projectKey";
-  public static final String PARAM_PROJECT_BRANCH = "projectBranch";
-  public static final String PARAM_PROJECT_NAME = "projectName";
-  public static final String PARAM_REPORT_DATA = "report";
-
-  private final ReportSubmitter reportSubmitter;
-
-  public CeSubmitWsAction(ReportSubmitter reportSubmitter) {
-    this.reportSubmitter = reportSubmitter;
-  }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    WebService.NewAction action = controller.createAction("submit")
-      .setDescription("Submit an analysis report to the queue of Compute Engine. Report is processed asynchronously.")
-      .setPost(true)
-      .setInternal(true)
-      .setHandler(this)
-      .setResponseExample(getClass().getResource("CeSubmitWsAction/example.json"));
-
-    action
-      .createParam(PARAM_PROJECT_KEY)
-      .setRequired(true)
-      .setDescription("Key of project")
-      .setExampleValue("my_project");
-
-    action
-      .createParam(PARAM_PROJECT_BRANCH)
-      .setDescription("Optional branch of project")
-      .setExampleValue("branch-1.x");
-
-    action
-      .createParam(PARAM_PROJECT_NAME)
-      .setRequired(false)
-      .setDescription("Optional name of the project, used only if the project does not exist yet.")
-      .setExampleValue("My Project");
-
-    action
-      .createParam(PARAM_REPORT_DATA)
-      .setRequired(true)
-      .setDescription("Report file. Format is not an API, it changes among SonarQube versions.");
-  }
-
-  @Override
-  public void handle(Request wsRequest, Response wsResponse) throws Exception {
-    String projectKey = wsRequest.mandatoryParam(PARAM_PROJECT_KEY);
-    String projectBranch = wsRequest.param(PARAM_PROJECT_BRANCH);
-    String projectName = StringUtils.defaultIfBlank(wsRequest.param(PARAM_PROJECT_NAME), projectKey);
-    InputStream reportInput = wsRequest.paramAsInputStream(PARAM_REPORT_DATA);
-
-    CeTask task = reportSubmitter.submit(projectKey, projectBranch, projectName, reportInput);
-
-    WsCe.SubmitResponse submitResponse = WsCe.SubmitResponse.newBuilder()
-      .setTaskId(task.getUuid())
-      .setProjectId(task.getComponentUuid())
-      .build();
-    WsUtils.writeProtobuf(submitResponse, wsRequest, wsResponse);
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeTaskWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeTaskWsAction.java
deleted file mode 100644 (file)
index 6f4ded4..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import com.google.common.base.Optional;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.web.UserRole;
-import org.sonar.core.util.Uuids;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.ce.CeActivityDto;
-import org.sonar.db.ce.CeQueueDto;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.user.UserSession;
-import org.sonar.server.ws.WsUtils;
-import org.sonarqube.ws.WsCe;
-
-public class CeTaskWsAction implements CeWsAction {
-
-  public static final String ACTION = "task";
-  public static final String PARAM_TASK_ID = "id";
-
-  private final DbClient dbClient;
-  private final CeWsTaskFormatter wsTaskFormatter;
-  private final UserSession userSession;
-
-  public CeTaskWsAction(DbClient dbClient, CeWsTaskFormatter wsTaskFormatter, UserSession userSession) {
-    this.dbClient = dbClient;
-    this.wsTaskFormatter = wsTaskFormatter;
-    this.userSession = userSession;
-  }
-
-  @Override
-  public void define(WebService.NewController controller) {
-    WebService.NewAction action = controller.createAction(ACTION)
-      .setDescription("Task information")
-      .setInternal(true)
-      .setHandler(this);
-
-    action
-      .createParam(PARAM_TASK_ID)
-      .setRequired(true)
-      .setDescription("Id of task")
-      .setExampleValue(Uuids.UUID_EXAMPLE_01);
-  }
-
-  @Override
-  public void handle(Request wsRequest, Response wsResponse) throws Exception {
-    userSession.checkGlobalPermission(UserRole.ADMIN);
-
-    String taskId = wsRequest.mandatoryParam(PARAM_TASK_ID);
-    DbSession dbSession = dbClient.openSession(false);
-    try {
-      WsCe.TaskResponse.Builder wsTaskResponse = WsCe.TaskResponse.newBuilder();
-      Optional<CeQueueDto> queueDto = dbClient.ceQueueDao().selectByUuid(dbSession, taskId);
-      if (queueDto.isPresent()) {
-        wsTaskResponse.setTask(wsTaskFormatter.formatQueue(dbSession, queueDto.get()));
-      } else {
-        Optional<CeActivityDto> activityDto = dbClient.ceActivityDao().selectByUuid(dbSession, taskId);
-        if (activityDto.isPresent()) {
-          wsTaskResponse.setTask(wsTaskFormatter.formatActivity(dbSession, activityDto.get()));
-        } else {
-          throw new NotFoundException();
-        }
-      }
-      WsUtils.writeProtobuf(wsTaskResponse.build(), wsRequest, wsResponse);
-
-    } finally {
-      dbClient.closeSession(dbSession);
-    }
-
-  }
-}
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
new file mode 100644 (file)
index 0000000..202c5e0
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import org.sonar.core.platform.Module;
+
+public class CeWsModule extends Module {
+  @Override
+  protected void configureModule() {
+    add(
+      ActivityWsAction.class,
+      CancelWsAction.class,
+      CeQueueWsAction.class,
+      CeWs.class,
+      IsQueueEmptyWs.class,
+      ProjectWsAction.class,
+      SubmitWsAction.class,
+      TaskFormatter.class,
+      TaskWsAction.class);
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeWsTaskFormatter.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/CeWsTaskFormatter.java
deleted file mode 100644 (file)
index 89a03a0..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import com.google.common.base.Optional;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import org.sonar.api.utils.DateUtils;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.ce.CeActivityDto;
-import org.sonar.db.ce.CeQueueDto;
-import org.sonar.db.component.ComponentDto;
-import org.sonarqube.ws.WsCe;
-
-public class CeWsTaskFormatter {
-
-  private final DbClient dbClient;
-
-  public CeWsTaskFormatter(DbClient dbClient) {
-    this.dbClient = dbClient;
-  }
-
-  public List<WsCe.Task> formatQueue(DbSession dbSession, List<CeQueueDto> dtos) {
-    ComponentCache cache = new ComponentCache(dbSession);
-    List<WsCe.Task> result = new ArrayList<>();
-    for (CeQueueDto dto : dtos) {
-      result.add(formatQueue(dto, cache));
-    }
-    return result;
-  }
-
-  public WsCe.Task formatQueue(DbSession dbSession, CeQueueDto dto) {
-    return formatQueue(dto, new ComponentCache(dbSession));
-  }
-
-  private WsCe.Task formatQueue(CeQueueDto dto, ComponentCache componentCache) {
-    WsCe.Task.Builder builder = WsCe.Task.newBuilder();
-    builder.setId(dto.getUuid());
-    builder.setStatus(WsCe.TaskStatus.valueOf(dto.getStatus().name()));
-    builder.setType(dto.getTaskType());
-    if (dto.getComponentUuid() != null) {
-      builder.setComponentId(dto.getComponentUuid());
-      buildComponent(builder, componentCache.get(dto.getComponentUuid()));
-    }
-    if (dto.getSubmitterLogin() != null) {
-      builder.setSubmitterLogin(dto.getSubmitterLogin());
-    }
-    builder.setSubmittedAt(DateUtils.formatDateTime(new Date(dto.getCreatedAt())));
-    if (dto.getStartedAt() != null) {
-      builder.setStartedAt(DateUtils.formatDateTime(new Date(dto.getStartedAt())));
-    }
-    return builder.build();
-  }
-
-  public WsCe.Task formatActivity(DbSession dbSession, CeActivityDto dto) {
-    return formatActivity(dto, new ComponentCache(dbSession));
-  }
-
-  public List<WsCe.Task> formatActivity(DbSession dbSession, List<CeActivityDto> dtos) {
-    ComponentCache cache = new ComponentCache(dbSession);
-    List<WsCe.Task> result = new ArrayList<>();
-    for (CeActivityDto dto : dtos) {
-      result.add(formatActivity(dto, cache));
-    }
-    return result;
-  }
-
-  private WsCe.Task formatActivity(CeActivityDto dto, ComponentCache componentCache) {
-    WsCe.Task.Builder builder = WsCe.Task.newBuilder();
-    builder.setId(dto.getUuid());
-    builder.setStatus(WsCe.TaskStatus.valueOf(dto.getStatus().name()));
-    builder.setType(dto.getTaskType());
-    if (dto.getComponentUuid() != null) {
-      builder.setComponentId(dto.getComponentUuid());
-      buildComponent(builder, componentCache.get(dto.getComponentUuid()));
-    }
-    if (dto.getSubmitterLogin() != null) {
-      builder.setSubmitterLogin(dto.getSubmitterLogin());
-    }
-    builder.setSubmittedAt(DateUtils.formatDateTime(new Date(dto.getCreatedAt())));
-    if (dto.getStartedAt() != null) {
-      builder.setStartedAt(DateUtils.formatDateTime(new Date(dto.getStartedAt())));
-    }
-    if (dto.getFinishedAt() != null) {
-      builder.setFinishedAt(DateUtils.formatDateTime(new Date(dto.getFinishedAt())));
-    }
-    if (dto.getExecutionTimeMs() != null) {
-      builder.setExecutionTimeMs(dto.getExecutionTimeMs());
-    }
-    return builder.build();
-  }
-
-  private void buildComponent(WsCe.Task.Builder builder, @Nullable ComponentDto componentDto) {
-    if (componentDto != null) {
-      builder.setComponentKey(componentDto.getKey());
-      builder.setComponentName(componentDto.name());
-    }
-  }
-
-  private class ComponentCache {
-    private final DbSession dbSession;
-    private final Map<String, ComponentDto> componentsByUuid = new HashMap<>();
-
-    ComponentCache(DbSession dbSession) {
-      this.dbSession = dbSession;
-    }
-
-    @CheckForNull
-    ComponentDto get(String uuid) {
-      ComponentDto dto = componentsByUuid.get(uuid);
-      if (dto == null) {
-        Optional<ComponentDto> opt = dbClient.componentDao().selectByUuid(dbSession, uuid);
-        if (opt.isPresent()) {
-          dto = opt.get();
-          componentsByUuid.put(uuid, dto);
-        }
-      }
-      return dto;
-    }
-  }
-}
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/ProjectWsAction.java
new file mode 100644 (file)
index 0000000..3af3304
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import java.util.List;
+import org.apache.ibatis.session.RowBounds;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.web.UserRole;
+import org.sonar.core.util.Uuids;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.ce.CeActivityDto;
+import org.sonar.db.ce.CeActivityQuery;
+import org.sonar.db.ce.CeQueueDto;
+import org.sonar.server.user.UserSession;
+import org.sonar.server.ws.WsUtils;
+
+import static org.sonarqube.ws.WsCe.ProjectResponse;
+
+public class ProjectWsAction implements CeWsAction {
+
+  public static final String PARAM_COMPONENT_UUID = "componentId";
+
+  private final UserSession userSession;
+  private final DbClient dbClient;
+  private final TaskFormatter formatter;
+
+  public ProjectWsAction(UserSession userSession, DbClient dbClient, TaskFormatter formatter) {
+    this.userSession = userSession;
+    this.dbClient = dbClient;
+    this.formatter = formatter;
+  }
+
+  @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")
+      .setInternal(true)
+      .setResponseExample(getClass().getResource("project-example.json"))
+      .setHandler(this);
+
+    action.createParam(PARAM_COMPONENT_UUID)
+      .setRequired(true)
+      .setExampleValue(Uuids.UUID_EXAMPLE_01);
+  }
+
+  @Override
+  public void handle(Request wsRequest, Response wsResponse) throws Exception {
+    String componentUuid = wsRequest.mandatoryParam(PARAM_COMPONENT_UUID);
+    userSession.checkProjectUuidPermission(UserRole.USER, componentUuid);
+
+    DbSession dbSession = dbClient.openSession(false);
+    try {
+      List<CeQueueDto> queueDtos = dbClient.ceQueueDao().selectByComponentUuid(dbSession, componentUuid);
+      CeActivityQuery activityQuery = new CeActivityQuery()
+        .setComponentUuid(componentUuid)
+        .setOnlyCurrents(true);
+      List<CeActivityDto> activityDtos = dbClient.ceActivityDao().selectByQuery(dbSession, activityQuery, new RowBounds(0, 1));
+
+      ProjectResponse.Builder wsResponseBuilder = ProjectResponse.newBuilder();
+      wsResponseBuilder.addAllQueue(formatter.formatQueue(dbSession, queueDtos));
+      if (activityDtos.size() == 1) {
+        wsResponseBuilder.setCurrent(formatter.formatActivity(dbSession, activityDtos.get(0)));
+      }
+      WsUtils.writeProtobuf(wsResponseBuilder.build(), wsRequest, wsResponse);
+
+    } finally {
+      dbClient.closeSession(dbSession);
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/SubmitWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/SubmitWsAction.java
new file mode 100644 (file)
index 0000000..2ea8ce2
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import java.io.InputStream;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.server.computation.CeTask;
+import org.sonar.server.computation.ReportSubmitter;
+import org.sonar.server.ws.WsUtils;
+import org.sonarqube.ws.WsCe;
+
+public class SubmitWsAction implements CeWsAction {
+
+  public static final String PARAM_PROJECT_KEY = "projectKey";
+  public static final String PARAM_PROJECT_BRANCH = "projectBranch";
+  public static final String PARAM_PROJECT_NAME = "projectName";
+  public static final String PARAM_REPORT_DATA = "report";
+
+  private final ReportSubmitter reportSubmitter;
+
+  public SubmitWsAction(ReportSubmitter reportSubmitter) {
+    this.reportSubmitter = reportSubmitter;
+  }
+
+  @Override
+  public void define(WebService.NewController controller) {
+    WebService.NewAction action = controller.createAction("submit")
+      .setDescription("Submit an analysis report to the queue of Compute Engine. Report is processed asynchronously.")
+      .setPost(true)
+      .setInternal(true)
+      .setHandler(this)
+      .setResponseExample(getClass().getResource("submit-example.json"));
+
+    action
+      .createParam(PARAM_PROJECT_KEY)
+      .setRequired(true)
+      .setDescription("Key of project")
+      .setExampleValue("my_project");
+
+    action
+      .createParam(PARAM_PROJECT_BRANCH)
+      .setDescription("Optional branch of project")
+      .setExampleValue("branch-1.x");
+
+    action
+      .createParam(PARAM_PROJECT_NAME)
+      .setRequired(false)
+      .setDescription("Optional name of the project, used only if the project does not exist yet.")
+      .setExampleValue("My Project");
+
+    action
+      .createParam(PARAM_REPORT_DATA)
+      .setRequired(true)
+      .setDescription("Report file. Format is not an API, it changes among SonarQube versions.");
+  }
+
+  @Override
+  public void handle(Request wsRequest, Response wsResponse) throws Exception {
+    String projectKey = wsRequest.mandatoryParam(PARAM_PROJECT_KEY);
+    String projectBranch = wsRequest.param(PARAM_PROJECT_BRANCH);
+    String projectName = StringUtils.defaultIfBlank(wsRequest.param(PARAM_PROJECT_NAME), projectKey);
+    InputStream reportInput = wsRequest.paramAsInputStream(PARAM_REPORT_DATA);
+
+    CeTask task = reportSubmitter.submit(projectKey, projectBranch, projectName, reportInput);
+
+    WsCe.SubmitResponse submitResponse = WsCe.SubmitResponse.newBuilder()
+      .setTaskId(task.getUuid())
+      .setProjectId(task.getComponentUuid())
+      .build();
+    WsUtils.writeProtobuf(submitResponse, wsRequest, wsResponse);
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/TaskFormatter.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/TaskFormatter.java
new file mode 100644 (file)
index 0000000..75519ea
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import com.google.common.base.Optional;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import org.sonar.api.utils.DateUtils;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.ce.CeActivityDto;
+import org.sonar.db.ce.CeQueueDto;
+import org.sonar.db.component.ComponentDto;
+import org.sonarqube.ws.WsCe;
+
+public class TaskFormatter {
+
+  private final DbClient dbClient;
+
+  public TaskFormatter(DbClient dbClient) {
+    this.dbClient = dbClient;
+  }
+
+  public List<WsCe.Task> formatQueue(DbSession dbSession, List<CeQueueDto> dtos) {
+    ComponentCache cache = new ComponentCache(dbSession);
+    List<WsCe.Task> result = new ArrayList<>();
+    for (CeQueueDto dto : dtos) {
+      result.add(formatQueue(dto, cache));
+    }
+    return result;
+  }
+
+  public WsCe.Task formatQueue(DbSession dbSession, CeQueueDto dto) {
+    return formatQueue(dto, new ComponentCache(dbSession));
+  }
+
+  private WsCe.Task formatQueue(CeQueueDto dto, ComponentCache componentCache) {
+    WsCe.Task.Builder builder = WsCe.Task.newBuilder();
+    builder.setId(dto.getUuid());
+    builder.setStatus(WsCe.TaskStatus.valueOf(dto.getStatus().name()));
+    builder.setType(dto.getTaskType());
+    if (dto.getComponentUuid() != null) {
+      builder.setComponentId(dto.getComponentUuid());
+      buildComponent(builder, componentCache.get(dto.getComponentUuid()));
+    }
+    if (dto.getSubmitterLogin() != null) {
+      builder.setSubmitterLogin(dto.getSubmitterLogin());
+    }
+    builder.setSubmittedAt(DateUtils.formatDateTime(new Date(dto.getCreatedAt())));
+    if (dto.getStartedAt() != null) {
+      builder.setStartedAt(DateUtils.formatDateTime(new Date(dto.getStartedAt())));
+    }
+    return builder.build();
+  }
+
+  public WsCe.Task formatActivity(DbSession dbSession, CeActivityDto dto) {
+    return formatActivity(dto, new ComponentCache(dbSession));
+  }
+
+  public List<WsCe.Task> formatActivity(DbSession dbSession, List<CeActivityDto> dtos) {
+    ComponentCache cache = new ComponentCache(dbSession);
+    List<WsCe.Task> result = new ArrayList<>();
+    for (CeActivityDto dto : dtos) {
+      result.add(formatActivity(dto, cache));
+    }
+    return result;
+  }
+
+  private WsCe.Task formatActivity(CeActivityDto dto, ComponentCache componentCache) {
+    WsCe.Task.Builder builder = WsCe.Task.newBuilder();
+    builder.setId(dto.getUuid());
+    builder.setStatus(WsCe.TaskStatus.valueOf(dto.getStatus().name()));
+    builder.setType(dto.getTaskType());
+    if (dto.getComponentUuid() != null) {
+      builder.setComponentId(dto.getComponentUuid());
+      buildComponent(builder, componentCache.get(dto.getComponentUuid()));
+    }
+    if (dto.getSubmitterLogin() != null) {
+      builder.setSubmitterLogin(dto.getSubmitterLogin());
+    }
+    builder.setSubmittedAt(DateUtils.formatDateTime(new Date(dto.getSubmittedAt())));
+    if (dto.getStartedAt() != null) {
+      builder.setStartedAt(DateUtils.formatDateTime(new Date(dto.getStartedAt())));
+    }
+    if (dto.getFinishedAt() != null) {
+      builder.setFinishedAt(DateUtils.formatDateTime(new Date(dto.getFinishedAt())));
+    }
+    if (dto.getExecutionTimeMs() != null) {
+      builder.setExecutionTimeMs(dto.getExecutionTimeMs());
+    }
+    return builder.build();
+  }
+
+  private static void buildComponent(WsCe.Task.Builder builder, @Nullable ComponentDto componentDto) {
+    if (componentDto != null) {
+      builder.setComponentKey(componentDto.getKey());
+      builder.setComponentName(componentDto.name());
+    }
+  }
+
+  private class ComponentCache {
+    private final DbSession dbSession;
+    private final Map<String, ComponentDto> componentsByUuid = new HashMap<>();
+
+    ComponentCache(DbSession dbSession) {
+      this.dbSession = dbSession;
+    }
+
+    @CheckForNull
+    ComponentDto get(String uuid) {
+      ComponentDto dto = componentsByUuid.get(uuid);
+      if (dto == null) {
+        Optional<ComponentDto> opt = dbClient.componentDao().selectByUuid(dbSession, uuid);
+        if (opt.isPresent()) {
+          dto = opt.get();
+          componentsByUuid.put(uuid, dto);
+        }
+      }
+      return dto;
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ws/TaskWsAction.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ws/TaskWsAction.java
new file mode 100644 (file)
index 0000000..a1305a4
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import com.google.common.base.Optional;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.web.UserRole;
+import org.sonar.core.util.Uuids;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.ce.CeActivityDto;
+import org.sonar.db.ce.CeQueueDto;
+import org.sonar.server.exceptions.NotFoundException;
+import org.sonar.server.user.UserSession;
+import org.sonar.server.ws.WsUtils;
+import org.sonarqube.ws.WsCe;
+
+public class TaskWsAction implements CeWsAction {
+
+  public static final String ACTION = "task";
+  public static final String PARAM_TASK_UUID = "id";
+
+  private final DbClient dbClient;
+  private final TaskFormatter wsTaskFormatter;
+  private final UserSession userSession;
+
+  public TaskWsAction(DbClient dbClient, TaskFormatter wsTaskFormatter, UserSession userSession) {
+    this.dbClient = dbClient;
+    this.wsTaskFormatter = wsTaskFormatter;
+    this.userSession = userSession;
+  }
+
+  @Override
+  public void define(WebService.NewController controller) {
+    WebService.NewAction action = controller.createAction(ACTION)
+      .setDescription("Task information")
+      .setInternal(true)
+      .setHandler(this);
+
+    action
+      .createParam(PARAM_TASK_UUID)
+      .setRequired(true)
+      .setDescription("Id of task")
+      .setExampleValue(Uuids.UUID_EXAMPLE_01);
+  }
+
+  @Override
+  public void handle(Request wsRequest, Response wsResponse) throws Exception {
+    userSession.checkGlobalPermission(UserRole.ADMIN);
+
+    String taskUuid = wsRequest.mandatoryParam(PARAM_TASK_UUID);
+    DbSession dbSession = dbClient.openSession(false);
+    try {
+      WsCe.TaskResponse.Builder wsTaskResponse = WsCe.TaskResponse.newBuilder();
+      Optional<CeQueueDto> queueDto = dbClient.ceQueueDao().selectByUuid(dbSession, taskUuid);
+      if (queueDto.isPresent()) {
+        wsTaskResponse.setTask(wsTaskFormatter.formatQueue(dbSession, queueDto.get()));
+      } else {
+        Optional<CeActivityDto> activityDto = dbClient.ceActivityDao().selectByUuid(dbSession, taskUuid);
+        if (activityDto.isPresent()) {
+          wsTaskResponse.setTask(wsTaskFormatter.formatActivity(dbSession, activityDto.get()));
+        } else {
+          throw new NotFoundException();
+        }
+      }
+      WsUtils.writeProtobuf(wsTaskResponse.build(), wsRequest, wsResponse);
+
+    } finally {
+      dbClient.closeSession(dbSession);
+    }
+
+  }
+}
index 85ca5601521331317e2fc736f343476fe1870938..2eb8e2e84c82e76d2c53ce6fed94a93ae6b5a131 100644 (file)
@@ -64,8 +64,8 @@ import org.sonar.server.component.DefaultRubyComponentService;
 import org.sonar.server.component.ws.ComponentsWs;
 import org.sonar.server.component.ws.EventsWs;
 import org.sonar.server.component.ws.ResourcesWs;
-import org.sonar.server.computation.CeQueueImpl;
 import org.sonar.server.computation.CeQueueCleaner;
+import org.sonar.server.computation.CeQueueImpl;
 import org.sonar.server.computation.CeQueueInitializer;
 import org.sonar.server.computation.CleanReportQueueListener;
 import org.sonar.server.computation.ComputeEngineProcessingModule;
@@ -73,14 +73,7 @@ import org.sonar.server.computation.ReportFiles;
 import org.sonar.server.computation.ReportSubmitter;
 import org.sonar.server.computation.monitoring.CEQueueStatusImpl;
 import org.sonar.server.computation.monitoring.ComputeEngineQueueMonitor;
-import org.sonar.server.computation.ws.CeActivityWsAction;
-import org.sonar.server.computation.ws.CeCancelWsAction;
-import org.sonar.server.computation.ws.CeQueueWsAction;
-import org.sonar.server.computation.ws.CeSubmitWsAction;
-import org.sonar.server.computation.ws.CeTaskWsAction;
-import org.sonar.server.computation.ws.CeWs;
-import org.sonar.server.computation.ws.CeWsTaskFormatter;
-import org.sonar.server.computation.ws.IsQueueEmptyWs;
+import org.sonar.server.computation.ws.CeWsModule;
 import org.sonar.server.config.ws.PropertiesWs;
 import org.sonar.server.dashboard.template.GlobalDefaultDashboard;
 import org.sonar.server.dashboard.template.ProjectDefaultDashboard;
@@ -724,14 +717,7 @@ public class PlatformLevel4 extends PlatformLevel {
       CleanReportQueueListener.class,
       ReportFiles.class,
       ComputeEngineProcessingModule.class,
-      CeWs.class,
-      CeWsTaskFormatter.class,
-      CeTaskWsAction.class,
-      CeSubmitWsAction.class,
-      CeActivityWsAction.class,
-      CeCancelWsAction.class,
-      CeQueueWsAction.class,
-      IsQueueEmptyWs.class,
+      CeWsModule.class,
       DefaultPeriodCleaner.class,
       ProjectCleaner.class,
       ProjectSettingsFactory.class,
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/CeActivityWsAction/example.json b/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/CeActivityWsAction/example.json
deleted file mode 100644 (file)
index b7b3b27..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-{
-  "paging": {
-    "pageIndex": 1,
-    "pageSize": 10,
-    "total": 233
-  },
-  "tasks": [
-    {
-      "id": "BU_dO1vsORa8_beWCwsP",
-      "type": "REPORT",
-      "componentId": "AU-Tpxb--iU5OvuD2FLy",
-      "componentKey": "project_1",
-      "componentName": "Project One",
-      "status": "SUCCESS",
-      "submittedAt": "2015-08-13T23:34:59+0200",
-      "submitterLogin": "john",
-      "startedAt": "2015-08-13T23:35:00+0200",
-      "finishedAt": "2015-08-13T23:35:10+0200",
-      "executionTimeMs": 10000
-    },
-    {
-      "id": "AU_dO1vsORa8_beWCwmP",
-      "taskType": "REPORT",
-      "componentId": "AU_dO1vlORa8_beWCwmO",
-      "componentKey": "project_2",
-      "componentName": "Project Two",
-      "status": "FAILED",
-      "submittedAt": "2015-09-17T23:34:59+0200",
-      "startedAt": "2015-09-17T23:35:00+0200",
-      "finishedAt": "2015-08-13T23:37:00+0200",
-      "executionTimeMs": 120000
-    }
-  ]
-}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/CeQueueWsAction/example.json b/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/CeQueueWsAction/example.json
deleted file mode 100644 (file)
index 12ff5cc..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "tasks": [
-    {
-      "id": "BU_dO1vsORa8_beWCwsP",
-      "type": "REPORT",
-      "componentId": "AU-Tpxb--iU5OvuD2FLy",
-      "componentKey": "project_1",
-      "componentName": "Project One",
-      "status": "IN_PROGRESS",
-      "submittedAt": "2015-08-13T23:34:59+0200",
-      "submitterLogin": "john"
-    },
-    {
-      "id": "AU_dO1vsORa8_beWCwmP",
-      "taskType": "REPORT",
-      "componentId": "AU_dO1vlORa8_beWCwmO",
-      "componentKey": "project_2",
-      "componentName": "Project Two",
-      "status": "PENDING",
-      "submittedAt": "2015-09-17T23:34:59+0200",
-      "startedAt": "2015-09-17T23:35:00+0200"
-    }
-  ]
-}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/CeSubmitWsAction/example.json b/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/CeSubmitWsAction/example.json
deleted file mode 100644 (file)
index 7cee04f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-{
-  "taskId": "TASK_1",
-  "projectId": "PROJECT_1"
-}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/activity-example.json b/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/activity-example.json
new file mode 100644 (file)
index 0000000..b7b3b27
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "paging": {
+    "pageIndex": 1,
+    "pageSize": 10,
+    "total": 233
+  },
+  "tasks": [
+    {
+      "id": "BU_dO1vsORa8_beWCwsP",
+      "type": "REPORT",
+      "componentId": "AU-Tpxb--iU5OvuD2FLy",
+      "componentKey": "project_1",
+      "componentName": "Project One",
+      "status": "SUCCESS",
+      "submittedAt": "2015-08-13T23:34:59+0200",
+      "submitterLogin": "john",
+      "startedAt": "2015-08-13T23:35:00+0200",
+      "finishedAt": "2015-08-13T23:35:10+0200",
+      "executionTimeMs": 10000
+    },
+    {
+      "id": "AU_dO1vsORa8_beWCwmP",
+      "taskType": "REPORT",
+      "componentId": "AU_dO1vlORa8_beWCwmO",
+      "componentKey": "project_2",
+      "componentName": "Project Two",
+      "status": "FAILED",
+      "submittedAt": "2015-09-17T23:34:59+0200",
+      "startedAt": "2015-09-17T23:35:00+0200",
+      "finishedAt": "2015-08-13T23:37:00+0200",
+      "executionTimeMs": 120000
+    }
+  ]
+}
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/project-example.json
new file mode 100644 (file)
index 0000000..3bdd494
--- /dev/null
@@ -0,0 +1,25 @@
+{
+  "queue": [
+    {
+      "id": "AU_w84A6gAS1Hm6h4_ih",
+      "type": "REPORT",
+      "componentId": "AU_w74XMgAS1Hm6h4-Y-",
+      "componentKey": "com.github.kevinsawicki:http-request-parent",
+      "componentName": "HttpRequest",
+      "status": "PENDING",
+      "submittedAt": "2015-09-21T19:28:54+0200"
+    }
+  ],
+  "current": {
+    "id": "AU_w8LDjgAS1Hm6h4-aY",
+    "type": "REPORT",
+    "componentId": "AU_w74XMgAS1Hm6h4-Y-",
+    "componentKey": "com.github.kevinsawicki:http-request-parent",
+    "componentName": "HttpRequest",
+    "status": "SUCCESS",
+    "submittedAt": "2015-09-21T19:25:49+0200",
+    "startedAt": "2015-09-21T19:25:57+0200",
+    "finishedAt": "2015-09-21T19:25:58+0200",
+    "executionTimeMs": 1371
+  }
+}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/queue-example.json b/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/queue-example.json
new file mode 100644 (file)
index 0000000..12ff5cc
--- /dev/null
@@ -0,0 +1,24 @@
+{
+  "tasks": [
+    {
+      "id": "BU_dO1vsORa8_beWCwsP",
+      "type": "REPORT",
+      "componentId": "AU-Tpxb--iU5OvuD2FLy",
+      "componentKey": "project_1",
+      "componentName": "Project One",
+      "status": "IN_PROGRESS",
+      "submittedAt": "2015-08-13T23:34:59+0200",
+      "submitterLogin": "john"
+    },
+    {
+      "id": "AU_dO1vsORa8_beWCwmP",
+      "taskType": "REPORT",
+      "componentId": "AU_dO1vlORa8_beWCwmO",
+      "componentKey": "project_2",
+      "componentName": "Project Two",
+      "status": "PENDING",
+      "submittedAt": "2015-09-17T23:34:59+0200",
+      "startedAt": "2015-09-17T23:35:00+0200"
+    }
+  ]
+}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/submit-example.json b/server/sonar-server/src/main/resources/org/sonar/server/computation/ws/submit-example.json
new file mode 100644 (file)
index 0000000..7cee04f
--- /dev/null
@@ -0,0 +1,4 @@
+{
+  "taskId": "TASK_1",
+  "projectId": "PROJECT_1"
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/ActivityWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/ActivityWsActionTest.java
new file mode 100644 (file)
index 0000000..8f4e958
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import java.util.Collections;
+import java.util.List;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.System2;
+import org.sonar.api.web.UserRole;
+import org.sonar.core.util.Protobuf;
+import org.sonar.db.DbTester;
+import org.sonar.db.ce.CeActivityDto;
+import org.sonar.db.ce.CeQueueDto;
+import org.sonar.db.ce.CeTaskTypes;
+import org.sonar.server.plugins.MimeTypes;
+import org.sonar.server.tester.UserSessionRule;
+import org.sonar.server.ws.TestResponse;
+import org.sonar.server.ws.WsActionTester;
+import org.sonarqube.ws.WsCe;
+
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ActivityWsActionTest {
+
+  @Rule
+  public UserSessionRule userSession = UserSessionRule.standalone();
+
+  @Rule
+  public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+  TaskFormatter formatter = new TaskFormatter(dbTester.getDbClient());
+  ActivityWsAction underTest = new ActivityWsAction(userSession, dbTester.getDbClient(), formatter);
+  WsActionTester tester = new WsActionTester(underTest);
+
+  @Test
+  public void get_all_past_activity() {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
+    insert("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
+
+    TestResponse wsResponse = tester.newRequest()
+      .setMediaType(MimeTypes.PROTOBUF)
+      .execute();
+
+    // verify the protobuf response
+    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
+    assertThat(activityResponse.getTasksCount()).isEqualTo(2);
+
+    // chronological order, from newest to oldest
+    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T2");
+    assertThat(activityResponse.getTasks(0).getStatus()).isEqualTo(WsCe.TaskStatus.FAILED);
+    assertThat(activityResponse.getTasks(0).getComponentId()).isEqualTo("PROJECT_2");
+    assertThat(activityResponse.getTasks(0).getExecutionTimeMs()).isEqualTo(500L);
+    assertThat(activityResponse.getTasks(1).getId()).isEqualTo("T1");
+    assertThat(activityResponse.getTasks(1).getStatus()).isEqualTo(WsCe.TaskStatus.SUCCESS);
+    assertThat(activityResponse.getTasks(1).getComponentId()).isEqualTo("PROJECT_1");
+  }
+
+  @Test
+   public void filter_by_status() {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
+    insert("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
+
+    TestResponse wsResponse = tester.newRequest()
+      .setParam("status", "FAILED")
+      .setMediaType(MimeTypes.PROTOBUF)
+      .execute();
+
+    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
+    assertThat(activityResponse.getTasksCount()).isEqualTo(1);
+    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T2");
+  }
+
+  @Test
+  public void filter_on_current_activities() {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+    // T2 is the current activity (the most recent one)
+    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
+    insert("T2", "PROJECT_1", CeActivityDto.Status.FAILED);
+
+    TestResponse wsResponse = tester.newRequest()
+      .setParam("onlyCurrents", "true")
+      .setMediaType(MimeTypes.PROTOBUF)
+      .execute();
+
+    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
+    assertThat(activityResponse.getTasksCount()).isEqualTo(1);
+    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T2");
+  }
+
+  @Test
+  public void paginate_results() {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
+    insert("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
+
+    assertPage(1, 1, 2, asList("T2"));
+    assertPage(2, 1, 2, asList("T1"));
+    assertPage(1, 10, 2, asList("T2", "T1"));
+    assertPage(2, 10, 2, Collections.<String>emptyList());
+  }
+
+  private void assertPage(int pageIndex, int pageSize, int expectedTotal, List<String> expectedOrderedTaskIds) {
+    TestResponse wsResponse = tester.newRequest()
+      .setMediaType(MimeTypes.PROTOBUF)
+      .setParam(WebService.Param.PAGE, Integer.toString(pageIndex))
+      .setParam(WebService.Param.PAGE_SIZE, Integer.toString(pageSize))
+      .execute();
+
+    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
+    assertThat(activityResponse.getPaging().getPageIndex()).isEqualTo(pageIndex);
+    assertThat(activityResponse.getPaging().getPageSize()).isEqualTo(pageSize);
+    assertThat(activityResponse.getPaging().getTotal()).isEqualTo(expectedTotal);
+
+    assertThat(activityResponse.getTasksCount()).isEqualTo(expectedOrderedTaskIds.size());
+    for (int i = 0; i < expectedOrderedTaskIds.size(); i++) {
+      String expectedTaskId = expectedOrderedTaskIds.get(i);
+      assertThat(activityResponse.getTasks(i).getId()).isEqualTo(expectedTaskId);
+    }
+  }
+
+  @Test
+  public void get_project_activity() {
+    userSession.addProjectUuidPermissions(UserRole.USER, "PROJECT_1");
+    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
+    insert("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
+
+    TestResponse wsResponse = tester.newRequest()
+      .setParam("componentId", "PROJECT_1")
+      .setMediaType(MimeTypes.PROTOBUF)
+      .execute();
+
+    // verify the protobuf response
+    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
+    assertThat(activityResponse.getTasksCount()).isEqualTo(1);
+    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T1");
+    assertThat(activityResponse.getTasks(0).getStatus()).isEqualTo(WsCe.TaskStatus.SUCCESS);
+    assertThat(activityResponse.getTasks(0).getComponentId()).isEqualTo("PROJECT_1");
+  }
+
+  private CeActivityDto insert(String taskUuid, String componentUuid, CeActivityDto.Status status) {
+    CeQueueDto queueDto = new CeQueueDto();
+    queueDto.setTaskType(CeTaskTypes.REPORT);
+    queueDto.setComponentUuid(componentUuid);
+    queueDto.setUuid(taskUuid);
+    CeActivityDto activityDto = new CeActivityDto(queueDto);
+    activityDto.setStatus(status);
+    activityDto.setExecutionTimeMs(500L);
+    dbTester.getDbClient().ceActivityDao().insert(dbTester.getSession(), activityDto);
+    dbTester.getSession().commit();
+    return activityDto;
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CancelWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CancelWsActionTest.java
new file mode 100644 (file)
index 0000000..3374424
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.api.web.UserRole;
+import org.sonar.db.DbTester;
+import org.sonar.server.computation.CeQueue;
+import org.sonar.server.exceptions.BadRequestException;
+import org.sonar.server.exceptions.ForbiddenException;
+import org.sonar.server.tester.UserSessionRule;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
+public class CancelWsActionTest {
+
+  @Rule
+  public UserSessionRule userSession = UserSessionRule.standalone();
+
+  @Rule
+  public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+  CeQueue queue = mock(CeQueue.class);
+  CancelWsAction underTest = new CancelWsAction(userSession, queue);
+  WsActionTester tester = new WsActionTester(underTest);
+
+  @Test
+  public void cancel_all_pending_tasks() {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+
+    tester.newRequest()
+      .setParam("all", "true")
+      .execute();
+
+    verify(queue).cancelAll();
+  }
+
+  @Test
+  public void cancel_pending_task() {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+
+    tester.newRequest()
+      .setParam("id", "T1")
+      .execute();
+
+    verify(queue).cancel("T1");
+  }
+
+  @Test(expected = BadRequestException.class)
+  public void missing_parameters() {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+
+    tester.newRequest().execute();
+
+    verifyZeroInteractions(queue);
+  }
+
+  @Test(expected = ForbiddenException.class)
+  public void not_authorized() {
+    tester.newRequest()
+      .setParam("id", "T1")
+      .execute();
+
+    verifyZeroInteractions(queue);
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeActivityWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeActivityWsActionTest.java
deleted file mode 100644 (file)
index 4835be6..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import java.util.Collections;
-import java.util.List;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.System2;
-import org.sonar.api.web.UserRole;
-import org.sonar.core.util.Protobuf;
-import org.sonar.db.DbTester;
-import org.sonar.db.ce.CeActivityDto;
-import org.sonar.db.ce.CeQueueDto;
-import org.sonar.db.ce.CeTaskTypes;
-import org.sonar.server.plugins.MimeTypes;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestResponse;
-import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.WsCe;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CeActivityWsActionTest {
-
-  @Rule
-  public UserSessionRule userSession = UserSessionRule.standalone();
-
-  @Rule
-  public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
-  CeWsTaskFormatter formatter = new CeWsTaskFormatter(dbTester.getDbClient());
-  CeActivityWsAction underTest = new CeActivityWsAction(userSession, dbTester.getDbClient(), formatter);
-  WsActionTester tester = new WsActionTester(underTest);
-
-  @Test
-  public void get_all_past_activity() {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
-    insert("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
-
-    TestResponse wsResponse = tester.newRequest()
-      .setMediaType(MimeTypes.PROTOBUF)
-      .execute();
-
-    // verify the protobuf response
-    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
-    assertThat(activityResponse.getTasksCount()).isEqualTo(2);
-
-    // chronological order, from newest to oldest
-    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T2");
-    assertThat(activityResponse.getTasks(0).getStatus()).isEqualTo(WsCe.TaskStatus.FAILED);
-    assertThat(activityResponse.getTasks(0).getComponentId()).isEqualTo("PROJECT_2");
-    assertThat(activityResponse.getTasks(0).getExecutionTimeMs()).isEqualTo(500L);
-    assertThat(activityResponse.getTasks(1).getId()).isEqualTo("T1");
-    assertThat(activityResponse.getTasks(1).getStatus()).isEqualTo(WsCe.TaskStatus.SUCCESS);
-    assertThat(activityResponse.getTasks(1).getComponentId()).isEqualTo("PROJECT_1");
-  }
-
-  @Test
-   public void filter_by_status() {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
-    insert("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
-
-    TestResponse wsResponse = tester.newRequest()
-      .setParam("status", "FAILED")
-      .setMediaType(MimeTypes.PROTOBUF)
-      .execute();
-
-    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
-    assertThat(activityResponse.getTasksCount()).isEqualTo(1);
-    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T2");
-  }
-
-  @Test
-  public void filter_on_current_activities() {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-    // T2 is the current activity (the most recent one)
-    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
-    insert("T2", "PROJECT_1", CeActivityDto.Status.FAILED);
-
-    TestResponse wsResponse = tester.newRequest()
-      .setParam("onlyCurrents", "true")
-      .setMediaType(MimeTypes.PROTOBUF)
-      .execute();
-
-    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
-    assertThat(activityResponse.getTasksCount()).isEqualTo(1);
-    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T2");
-  }
-
-  @Test
-  public void paginate_results() {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
-    insert("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
-
-    assertPage(1, 1, 2, asList("T2"));
-    assertPage(2, 1, 2, asList("T1"));
-    assertPage(1, 10, 2, asList("T2", "T1"));
-    assertPage(2, 10, 2, Collections.<String>emptyList());
-  }
-
-  private void assertPage(int pageIndex, int pageSize, int expectedTotal, List<String> expectedOrderedTaskIds) {
-    TestResponse wsResponse = tester.newRequest()
-      .setMediaType(MimeTypes.PROTOBUF)
-      .setParam(WebService.Param.PAGE, Integer.toString(pageIndex))
-      .setParam(WebService.Param.PAGE_SIZE, Integer.toString(pageSize))
-      .execute();
-
-    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
-    assertThat(activityResponse.getPaging().getPageIndex()).isEqualTo(pageIndex);
-    assertThat(activityResponse.getPaging().getPageSize()).isEqualTo(pageSize);
-    assertThat(activityResponse.getPaging().getTotal()).isEqualTo(expectedTotal);
-
-    assertThat(activityResponse.getTasksCount()).isEqualTo(expectedOrderedTaskIds.size());
-    for (int i = 0; i < expectedOrderedTaskIds.size(); i++) {
-      String expectedTaskId = expectedOrderedTaskIds.get(i);
-      assertThat(activityResponse.getTasks(i).getId()).isEqualTo(expectedTaskId);
-    }
-  }
-
-  @Test
-  public void get_project_activity() {
-    userSession.addProjectUuidPermissions(UserRole.ADMIN, "PROJECT_1");
-    insert("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
-    insert("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
-
-    TestResponse wsResponse = tester.newRequest()
-      .setParam("componentId", "PROJECT_1")
-      .setMediaType(MimeTypes.PROTOBUF)
-      .execute();
-
-    // verify the protobuf response
-    WsCe.ActivityResponse activityResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.ActivityResponse.PARSER);
-    assertThat(activityResponse.getTasksCount()).isEqualTo(1);
-    assertThat(activityResponse.getTasks(0).getId()).isEqualTo("T1");
-    assertThat(activityResponse.getTasks(0).getStatus()).isEqualTo(WsCe.TaskStatus.SUCCESS);
-    assertThat(activityResponse.getTasks(0).getComponentId()).isEqualTo("PROJECT_1");
-  }
-
-  private CeActivityDto insert(String taskUuid, String componentUuid, CeActivityDto.Status status) {
-    CeQueueDto queueDto = new CeQueueDto();
-    queueDto.setTaskType(CeTaskTypes.REPORT);
-    queueDto.setComponentUuid(componentUuid);
-    queueDto.setUuid(taskUuid);
-    CeActivityDto activityDto = new CeActivityDto(queueDto);
-    activityDto.setStatus(status);
-    activityDto.setExecutionTimeMs(500L);
-    dbTester.getDbClient().ceActivityDao().insert(dbTester.getSession(), activityDto);
-    dbTester.getSession().commit();
-    return activityDto;
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeCancelWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeCancelWsActionTest.java
deleted file mode 100644 (file)
index 8102b93..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.api.web.UserRole;
-import org.sonar.db.DbTester;
-import org.sonar.server.computation.CeQueue;
-import org.sonar.server.exceptions.BadRequestException;
-import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.WsActionTester;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-
-public class CeCancelWsActionTest {
-
-  @Rule
-  public UserSessionRule userSession = UserSessionRule.standalone();
-
-  @Rule
-  public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
-  CeQueue queue = mock(CeQueue.class);
-  CeCancelWsAction underTest = new CeCancelWsAction(userSession, queue);
-  WsActionTester tester = new WsActionTester(underTest);
-
-  @Test
-  public void cancel_all_pending_tasks() {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-
-    tester.newRequest()
-      .setParam("all", "true")
-      .execute();
-
-    verify(queue).cancelAll();
-  }
-
-  @Test
-  public void cancel_pending_task() {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-
-    tester.newRequest()
-      .setParam("id", "T1")
-      .execute();
-
-    verify(queue).cancel("T1");
-  }
-
-  @Test(expected = BadRequestException.class)
-  public void missing_parameters() {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-
-    tester.newRequest().execute();
-
-    verifyZeroInteractions(queue);
-  }
-
-  @Test(expected = ForbiddenException.class)
-  public void not_authorized() {
-    tester.newRequest()
-      .setParam("id", "T1")
-      .execute();
-
-    verifyZeroInteractions(queue);
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeQueueWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeQueueWsActionTest.java
deleted file mode 100644 (file)
index 5cc9b70..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.api.web.UserRole;
-import org.sonar.core.util.Protobuf;
-import org.sonar.db.DbTester;
-import org.sonar.db.ce.CeQueueDto;
-import org.sonar.db.ce.CeTaskTypes;
-import org.sonar.server.plugins.MimeTypes;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestResponse;
-import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.WsCe;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CeQueueWsActionTest {
-
-  @Rule
-  public UserSessionRule userSession = UserSessionRule.standalone();
-
-  @Rule
-  public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
-  CeWsTaskFormatter formatter = new CeWsTaskFormatter(dbTester.getDbClient());
-  CeQueueWsAction underTest = new CeQueueWsAction(userSession, dbTester.getDbClient(), formatter);
-  WsActionTester tester = new WsActionTester(underTest);
-
-  @Test
-  public void get_all_queue() {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-    insert("T1", "PROJECT_1", CeQueueDto.Status.PENDING);
-    insert("T2", "PROJECT_2", CeQueueDto.Status.IN_PROGRESS);
-
-    TestResponse wsResponse = tester.newRequest()
-      .setMediaType(MimeTypes.PROTOBUF)
-      .execute();
-
-    // verify the protobuf response
-    WsCe.QueueResponse queueResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.QueueResponse.PARSER);
-    assertThat(queueResponse.getTasksCount()).isEqualTo(2);
-    assertThat(queueResponse.getTasks(0).getId()).isEqualTo("T1");
-    assertThat(queueResponse.getTasks(0).getStatus()).isEqualTo(WsCe.TaskStatus.PENDING);
-    assertThat(queueResponse.getTasks(0).getComponentId()).isEqualTo("PROJECT_1");
-    assertThat(queueResponse.getTasks(1).getId()).isEqualTo("T2");
-    assertThat(queueResponse.getTasks(1).getStatus()).isEqualTo(WsCe.TaskStatus.IN_PROGRESS);
-    assertThat(queueResponse.getTasks(1).getComponentId()).isEqualTo("PROJECT_2");
-  }
-
-  @Test
-  public void get_queue_of_project() {
-    userSession.addProjectUuidPermissions(UserRole.USER, "PROJECT_1");
-    insert("T1", "PROJECT_1", CeQueueDto.Status.PENDING);
-    insert("T2", "PROJECT_2", CeQueueDto.Status.PENDING);
-    insert("T3", "PROJECT_2", CeQueueDto.Status.IN_PROGRESS);
-
-    TestResponse wsResponse = tester.newRequest()
-      .setParam("componentId", "PROJECT_1")
-      .setMediaType(MimeTypes.PROTOBUF)
-      .execute();
-
-    // verify the protobuf response
-    WsCe.QueueResponse queueResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.QueueResponse.PARSER);
-    assertThat(queueResponse.getTasksCount()).isEqualTo(1);
-    assertThat(queueResponse.getTasks(0).getId()).isEqualTo("T1");
-  }
-
-  private CeQueueDto insert(String taskUuid, String componentUuid, CeQueueDto.Status status) {
-    CeQueueDto queueDto = new CeQueueDto();
-    queueDto.setTaskType(CeTaskTypes.REPORT);
-    queueDto.setComponentUuid(componentUuid);
-    queueDto.setUuid(taskUuid);
-    queueDto.setStatus(status);
-    dbTester.getDbClient().ceQueueDao().insert(dbTester.getSession(), queueDto);
-    dbTester.getSession().commit();
-    return queueDto;
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeSubmitWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeSubmitWsActionTest.java
deleted file mode 100644 (file)
index cfbb12b..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import java.io.InputStream;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.sonar.core.util.Protobuf;
-import org.sonar.db.ce.CeTaskTypes;
-import org.sonar.server.computation.CeTask;
-import org.sonar.server.computation.ReportSubmitter;
-import org.sonar.server.plugins.MimeTypes;
-import org.sonar.server.ws.TestResponse;
-import org.sonar.server.ws.WsActionTester;
-import org.sonar.test.JsonAssert;
-import org.sonarqube.ws.WsCe;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class CeSubmitWsActionTest {
-
-  ReportSubmitter reportSubmitter = mock(ReportSubmitter.class);
-  CeSubmitWsAction underTest = new CeSubmitWsAction(reportSubmitter);
-  WsActionTester tester = new WsActionTester(underTest);
-
-  @Test
-  public void submit_task_to_the_queue_and_ask_for_immediate_processing() {
-    CeTask task = new CeTask.Builder().setUuid("TASK_1").setType(CeTaskTypes.REPORT).setComponentUuid("PROJECT_1").setSubmitterLogin("robert").build();
-    when(reportSubmitter.submit(eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class))).thenReturn(task);
-
-    TestResponse wsResponse = tester.newRequest()
-      .setParam("projectKey", "my_project")
-      .setParam("projectName", "My Project")
-      .setParam("report", "{binary}")
-      .setMediaType(MimeTypes.PROTOBUF)
-      .setMethod("POST")
-      .execute();
-
-    verify(reportSubmitter).submit(eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class));
-
-    WsCe.SubmitResponse submitResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.SubmitResponse.PARSER);
-    assertThat(submitResponse.getTaskId()).isEqualTo("TASK_1");
-    assertThat(submitResponse.getProjectId()).isEqualTo("PROJECT_1");
-  }
-
-  @Test
-  public void test_example_json_response() {
-    CeTask task = new CeTask.Builder().setUuid("TASK_1").setType(CeTaskTypes.REPORT).setComponentUuid("PROJECT_1").setSubmitterLogin("robert").build();
-    when(reportSubmitter.submit(eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class))).thenReturn(task);
-
-    TestResponse wsResponse = tester.newRequest()
-      .setParam("projectKey", "my_project")
-      .setParam("projectName", "My Project")
-      .setParam("report", "{binary}")
-      .setMediaType(MimeTypes.JSON)
-      .setMethod("POST")
-      .execute();
-
-    JsonAssert.assertJson(tester.getDef().responseExampleAsString()).isSimilarTo(wsResponse.getInput());
-  }
-
-  /**
-   * If project name is not specified, then name is the project key
-   */
-  @Test
-  public void project_name_is_optional() {
-    CeTask task = new CeTask.Builder().setUuid("TASK_1").setType(CeTaskTypes.REPORT).setComponentUuid("PROJECT_1").setSubmitterLogin("robert").build();
-    when(reportSubmitter.submit(eq("my_project"), Matchers.isNull(String.class), eq("my_project"), any(InputStream.class))).thenReturn(task);
-
-    tester.newRequest()
-      .setParam("projectKey", "my_project")
-      .setParam("report", "{binary}")
-      .setMediaType(MimeTypes.PROTOBUF)
-      .setMethod("POST")
-      .execute();
-
-    verify(reportSubmitter).submit(eq("my_project"), Matchers.isNull(String.class), eq("my_project"), any(InputStream.class));
-
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeTaskWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeTaskWsActionTest.java
deleted file mode 100644 (file)
index d01092a..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.computation.ws;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.api.web.UserRole;
-import org.sonar.core.util.Protobuf;
-import org.sonar.db.DbTester;
-import org.sonar.db.ce.CeActivityDto;
-import org.sonar.db.ce.CeQueueDto;
-import org.sonar.db.ce.CeTaskTypes;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.plugins.MimeTypes;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestResponse;
-import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.WsCe;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CeTaskWsActionTest {
-
-  @Rule
-  public UserSessionRule userSession = UserSessionRule.standalone();
-
-  @Rule
-  public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
-  CeWsTaskFormatter formatter = new CeWsTaskFormatter(dbTester.getDbClient());
-  CeTaskWsAction underTest = new CeTaskWsAction(dbTester.getDbClient(), formatter, userSession);
-  WsActionTester tester = new WsActionTester(underTest);
-
-  @Test
-  public void task_is_in_queue() throws Exception {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-
-    ComponentDto project = new ComponentDto().setUuid("PROJECT_1").setName("Project One").setKey("P1");
-    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project);
-
-    CeQueueDto queueDto = new CeQueueDto();
-    queueDto.setTaskType(CeTaskTypes.REPORT);
-    queueDto.setUuid("TASK_1");
-    queueDto.setComponentUuid(project.uuid());
-    queueDto.setStatus(CeQueueDto.Status.PENDING);
-    queueDto.setSubmitterLogin("john");
-    dbTester.getDbClient().ceQueueDao().insert(dbTester.getSession(), queueDto);
-    dbTester.getSession().commit();
-
-    TestResponse wsResponse = tester.newRequest()
-      .setMediaType(MimeTypes.PROTOBUF)
-      .setParam("id", "TASK_1")
-      .execute();
-
-    // verify the protobuf response
-    WsCe.TaskResponse taskResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.TaskResponse.PARSER);
-    assertThat(taskResponse.getTask().getId()).isEqualTo("TASK_1");
-    assertThat(taskResponse.getTask().getStatus()).isEqualTo(WsCe.TaskStatus.PENDING);
-    assertThat(taskResponse.getTask().getSubmitterLogin()).isEqualTo("john");
-    assertThat(taskResponse.getTask().getComponentId()).isEqualTo(project.uuid());
-    assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(project.key());
-    assertThat(taskResponse.getTask().getComponentName()).isEqualTo(project.name());
-    assertThat(taskResponse.getTask().hasExecutionTimeMs()).isFalse();
-  }
-
-  @Test
-  public void task_is_archived() throws Exception {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-
-    ComponentDto project = new ComponentDto().setUuid("PROJECT_1").setName("Project One").setKey("P1");
-    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project);
-
-    CeQueueDto queueDto = new CeQueueDto();
-    queueDto.setTaskType(CeTaskTypes.REPORT);
-    queueDto.setUuid("TASK_1");
-    queueDto.setComponentUuid(project.uuid());
-    CeActivityDto activityDto = new CeActivityDto(queueDto);
-    activityDto.setStatus(CeActivityDto.Status.FAILED);
-    activityDto.setExecutionTimeMs(500L);
-    dbTester.getDbClient().ceActivityDao().insert(dbTester.getSession(), activityDto);
-    dbTester.getSession().commit();
-
-    TestResponse wsResponse = tester.newRequest()
-      .setMediaType(MimeTypes.PROTOBUF)
-      .setParam("id", "TASK_1")
-      .execute();
-
-    // verify the protobuf response
-    WsCe.TaskResponse taskResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.TaskResponse.PARSER);
-    assertThat(taskResponse.getTask().getId()).isEqualTo("TASK_1");
-    assertThat(taskResponse.getTask().getStatus()).isEqualTo(WsCe.TaskStatus.FAILED);
-    assertThat(taskResponse.getTask().getComponentId()).isEqualTo(project.uuid());
-    assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(project.key());
-    assertThat(taskResponse.getTask().getComponentName()).isEqualTo(project.name());
-    assertThat(taskResponse.getTask().getExecutionTimeMs()).isEqualTo(500L);
-  }
-
-  @Test(expected = NotFoundException.class)
-  public void task_not_found() throws Exception {
-    userSession.setGlobalPermissions(UserRole.ADMIN);
-
-    tester.newRequest()
-      .setParam("id", "DOES_NOT_EXIST")
-      .execute();
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeWsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/CeWsModuleTest.java
new file mode 100644 (file)
index 0000000..f9c9c7b
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CeWsModuleTest {
+
+  @Test
+  public void verify_count_of_added_components() {
+    ComponentContainer container = new ComponentContainer();
+    new CeWsModule().configure(container);
+    assertThat(container.size()).isEqualTo(9 + 2 /* injected by ComponentContainer */);
+  }
+}
index 6b7574c8ed1602db3dbd89ed81d25862ada06789..c88e206cff9e7d5a6b5d19978812b8ced4f9dd56 100644 (file)
@@ -31,7 +31,7 @@ public class CeWsTest {
 
   @Test
   public void define() throws Exception {
-    CeWsAction wsAction = new CeSubmitWsAction(mock(ReportSubmitter.class));
+    CeWsAction wsAction = new SubmitWsAction(mock(ReportSubmitter.class));
 
     CeWs ws = new CeWs(wsAction);
     WebService.Context context = mock(WebService.Context.class, Mockito.RETURNS_DEEP_STUBS);
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/ProjectWsActionTest.java
new file mode 100644 (file)
index 0000000..a088f19
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.api.web.UserRole;
+import org.sonar.core.util.Protobuf;
+import org.sonar.db.DbTester;
+import org.sonar.db.ce.CeActivityDto;
+import org.sonar.db.ce.CeQueueDto;
+import org.sonar.db.ce.CeTaskTypes;
+import org.sonar.server.plugins.MimeTypes;
+import org.sonar.server.tester.UserSessionRule;
+import org.sonar.server.ws.TestResponse;
+import org.sonar.server.ws.WsActionTester;
+import org.sonarqube.ws.WsCe;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ProjectWsActionTest {
+
+  @Rule
+  public UserSessionRule userSession = UserSessionRule.standalone();
+
+  @Rule
+  public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+  TaskFormatter formatter = new TaskFormatter(dbTester.getDbClient());
+  ProjectWsAction underTest = new ProjectWsAction(userSession, dbTester.getDbClient(), formatter);
+  WsActionTester tester = new WsActionTester(underTest);
+
+  @Test
+  public void empty_queue_and_empty_activity() {
+    userSession.addProjectUuidPermissions(UserRole.USER, "PROJECT_1");
+
+    TestResponse wsResponse = tester.newRequest()
+      .setParam("componentId", "PROJECT_1")
+      .setMediaType(MimeTypes.PROTOBUF)
+      .execute();
+
+    WsCe.ProjectResponse response = Protobuf.read(wsResponse.getInputStream(), WsCe.ProjectResponse.PARSER);
+    assertThat(response.getQueueCount()).isEqualTo(0);
+    assertThat(response.hasCurrent()).isFalse();
+  }
+
+  @Test
+  public void project_tasks() {
+    userSession.addProjectUuidPermissions(UserRole.USER, "PROJECT_1");
+    insertActivity("T1", "PROJECT_1", CeActivityDto.Status.SUCCESS);
+    insertActivity("T2", "PROJECT_2", CeActivityDto.Status.FAILED);
+    insertActivity("T3", "PROJECT_1", CeActivityDto.Status.FAILED);
+    insertQueue("T4", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS);
+    insertQueue("T5", "PROJECT_1", CeQueueDto.Status.PENDING);
+
+    TestResponse wsResponse = tester.newRequest()
+      .setParam("componentId", "PROJECT_1")
+      .setMediaType(MimeTypes.PROTOBUF)
+      .execute();
+
+    WsCe.ProjectResponse response = Protobuf.read(wsResponse.getInputStream(), WsCe.ProjectResponse.PARSER);
+    assertThat(response.getQueueCount()).isEqualTo(2);
+    assertThat(response.getQueue(0).getId()).isEqualTo("T4");
+    assertThat(response.getQueue(1).getId()).isEqualTo("T5");
+    // T3 is the latest task executed on PROJECT_1
+    assertThat(response.hasCurrent()).isTrue();
+    assertThat(response.getCurrent().getId()).isEqualTo("T3");
+  }
+
+  private CeQueueDto insertQueue(String taskUuid, String componentUuid, CeQueueDto.Status status) {
+    CeQueueDto queueDto = new CeQueueDto();
+    queueDto.setTaskType(CeTaskTypes.REPORT);
+    queueDto.setComponentUuid(componentUuid);
+    queueDto.setUuid(taskUuid);
+    queueDto.setStatus(status);
+    dbTester.getDbClient().ceQueueDao().insert(dbTester.getSession(), queueDto);
+    dbTester.getSession().commit();
+    return queueDto;
+  }
+
+  private CeActivityDto insertActivity(String taskUuid, String componentUuid, CeActivityDto.Status status) {
+    CeQueueDto queueDto = new CeQueueDto();
+    queueDto.setTaskType(CeTaskTypes.REPORT);
+    queueDto.setComponentUuid(componentUuid);
+    queueDto.setUuid(taskUuid);
+    CeActivityDto activityDto = new CeActivityDto(queueDto);
+    activityDto.setStatus(status);
+    activityDto.setExecutionTimeMs(500L);
+    dbTester.getDbClient().ceActivityDao().insert(dbTester.getSession(), activityDto);
+    dbTester.getSession().commit();
+    return activityDto;
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/QueueWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/QueueWsActionTest.java
new file mode 100644 (file)
index 0000000..6f465f8
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.api.web.UserRole;
+import org.sonar.core.util.Protobuf;
+import org.sonar.db.DbTester;
+import org.sonar.db.ce.CeQueueDto;
+import org.sonar.db.ce.CeTaskTypes;
+import org.sonar.server.plugins.MimeTypes;
+import org.sonar.server.tester.UserSessionRule;
+import org.sonar.server.ws.TestResponse;
+import org.sonar.server.ws.WsActionTester;
+import org.sonarqube.ws.WsCe;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class QueueWsActionTest {
+
+  @Rule
+  public UserSessionRule userSession = UserSessionRule.standalone();
+
+  @Rule
+  public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+  TaskFormatter formatter = new TaskFormatter(dbTester.getDbClient());
+  CeQueueWsAction underTest = new CeQueueWsAction(userSession, dbTester.getDbClient(), formatter);
+  WsActionTester tester = new WsActionTester(underTest);
+
+  @Test
+  public void get_all_queue() {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+    insert("T1", "PROJECT_1", CeQueueDto.Status.PENDING);
+    insert("T2", "PROJECT_2", CeQueueDto.Status.IN_PROGRESS);
+
+    TestResponse wsResponse = tester.newRequest()
+      .setMediaType(MimeTypes.PROTOBUF)
+      .execute();
+
+    // verify the protobuf response
+    WsCe.QueueResponse queueResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.QueueResponse.PARSER);
+    assertThat(queueResponse.getTasksCount()).isEqualTo(2);
+    assertThat(queueResponse.getTasks(0).getId()).isEqualTo("T1");
+    assertThat(queueResponse.getTasks(0).getStatus()).isEqualTo(WsCe.TaskStatus.PENDING);
+    assertThat(queueResponse.getTasks(0).getComponentId()).isEqualTo("PROJECT_1");
+    assertThat(queueResponse.getTasks(1).getId()).isEqualTo("T2");
+    assertThat(queueResponse.getTasks(1).getStatus()).isEqualTo(WsCe.TaskStatus.IN_PROGRESS);
+    assertThat(queueResponse.getTasks(1).getComponentId()).isEqualTo("PROJECT_2");
+  }
+
+  @Test
+  public void get_queue_of_project() {
+    userSession.addProjectUuidPermissions(UserRole.USER, "PROJECT_1");
+    insert("T1", "PROJECT_1", CeQueueDto.Status.PENDING);
+    insert("T2", "PROJECT_2", CeQueueDto.Status.PENDING);
+    insert("T3", "PROJECT_2", CeQueueDto.Status.IN_PROGRESS);
+
+    TestResponse wsResponse = tester.newRequest()
+      .setParam("componentId", "PROJECT_1")
+      .setMediaType(MimeTypes.PROTOBUF)
+      .execute();
+
+    // verify the protobuf response
+    WsCe.QueueResponse queueResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.QueueResponse.PARSER);
+    assertThat(queueResponse.getTasksCount()).isEqualTo(1);
+    assertThat(queueResponse.getTasks(0).getId()).isEqualTo("T1");
+  }
+
+  private CeQueueDto insert(String taskUuid, String componentUuid, CeQueueDto.Status status) {
+    CeQueueDto queueDto = new CeQueueDto();
+    queueDto.setTaskType(CeTaskTypes.REPORT);
+    queueDto.setComponentUuid(componentUuid);
+    queueDto.setUuid(taskUuid);
+    queueDto.setStatus(status);
+    dbTester.getDbClient().ceQueueDao().insert(dbTester.getSession(), queueDto);
+    dbTester.getSession().commit();
+    return queueDto;
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/SubmitWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/SubmitWsActionTest.java
new file mode 100644 (file)
index 0000000..d929421
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import java.io.InputStream;
+import org.junit.Test;
+import org.mockito.Matchers;
+import org.sonar.core.util.Protobuf;
+import org.sonar.db.ce.CeTaskTypes;
+import org.sonar.server.computation.CeTask;
+import org.sonar.server.computation.ReportSubmitter;
+import org.sonar.server.plugins.MimeTypes;
+import org.sonar.server.ws.TestResponse;
+import org.sonar.server.ws.WsActionTester;
+import org.sonar.test.JsonAssert;
+import org.sonarqube.ws.WsCe;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class SubmitWsActionTest {
+
+  ReportSubmitter reportSubmitter = mock(ReportSubmitter.class);
+  SubmitWsAction underTest = new SubmitWsAction(reportSubmitter);
+  WsActionTester tester = new WsActionTester(underTest);
+
+  @Test
+  public void submit_task_to_the_queue_and_ask_for_immediate_processing() {
+    CeTask task = new CeTask.Builder().setUuid("TASK_1").setType(CeTaskTypes.REPORT).setComponentUuid("PROJECT_1").setSubmitterLogin("robert").build();
+    when(reportSubmitter.submit(eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class))).thenReturn(task);
+
+    TestResponse wsResponse = tester.newRequest()
+      .setParam("projectKey", "my_project")
+      .setParam("projectName", "My Project")
+      .setParam("report", "{binary}")
+      .setMediaType(MimeTypes.PROTOBUF)
+      .setMethod("POST")
+      .execute();
+
+    verify(reportSubmitter).submit(eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class));
+
+    WsCe.SubmitResponse submitResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.SubmitResponse.PARSER);
+    assertThat(submitResponse.getTaskId()).isEqualTo("TASK_1");
+    assertThat(submitResponse.getProjectId()).isEqualTo("PROJECT_1");
+  }
+
+  @Test
+  public void test_example_json_response() {
+    CeTask task = new CeTask.Builder().setUuid("TASK_1").setType(CeTaskTypes.REPORT).setComponentUuid("PROJECT_1").setSubmitterLogin("robert").build();
+    when(reportSubmitter.submit(eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class))).thenReturn(task);
+
+    TestResponse wsResponse = tester.newRequest()
+      .setParam("projectKey", "my_project")
+      .setParam("projectName", "My Project")
+      .setParam("report", "{binary}")
+      .setMediaType(MimeTypes.JSON)
+      .setMethod("POST")
+      .execute();
+
+    JsonAssert.assertJson(tester.getDef().responseExampleAsString()).isSimilarTo(wsResponse.getInput());
+  }
+
+  /**
+   * If project name is not specified, then name is the project key
+   */
+  @Test
+  public void project_name_is_optional() {
+    CeTask task = new CeTask.Builder().setUuid("TASK_1").setType(CeTaskTypes.REPORT).setComponentUuid("PROJECT_1").setSubmitterLogin("robert").build();
+    when(reportSubmitter.submit(eq("my_project"), Matchers.isNull(String.class), eq("my_project"), any(InputStream.class))).thenReturn(task);
+
+    tester.newRequest()
+      .setParam("projectKey", "my_project")
+      .setParam("report", "{binary}")
+      .setMediaType(MimeTypes.PROTOBUF)
+      .setMethod("POST")
+      .execute();
+
+    verify(reportSubmitter).submit(eq("my_project"), Matchers.isNull(String.class), eq("my_project"), any(InputStream.class));
+
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/ws/TaskWsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/ws/TaskWsActionTest.java
new file mode 100644 (file)
index 0000000..defd028
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.computation.ws;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.api.web.UserRole;
+import org.sonar.core.util.Protobuf;
+import org.sonar.db.DbTester;
+import org.sonar.db.ce.CeActivityDto;
+import org.sonar.db.ce.CeQueueDto;
+import org.sonar.db.ce.CeTaskTypes;
+import org.sonar.db.component.ComponentDto;
+import org.sonar.server.exceptions.NotFoundException;
+import org.sonar.server.plugins.MimeTypes;
+import org.sonar.server.tester.UserSessionRule;
+import org.sonar.server.ws.TestResponse;
+import org.sonar.server.ws.WsActionTester;
+import org.sonarqube.ws.WsCe;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class TaskWsActionTest {
+
+  @Rule
+  public UserSessionRule userSession = UserSessionRule.standalone();
+
+  @Rule
+  public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+  TaskFormatter formatter = new TaskFormatter(dbTester.getDbClient());
+  TaskWsAction underTest = new TaskWsAction(dbTester.getDbClient(), formatter, userSession);
+  WsActionTester tester = new WsActionTester(underTest);
+
+  @Test
+  public void task_is_in_queue() throws Exception {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+
+    ComponentDto project = new ComponentDto().setUuid("PROJECT_1").setName("Project One").setKey("P1");
+    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project);
+
+    CeQueueDto queueDto = new CeQueueDto();
+    queueDto.setTaskType(CeTaskTypes.REPORT);
+    queueDto.setUuid("TASK_1");
+    queueDto.setComponentUuid(project.uuid());
+    queueDto.setStatus(CeQueueDto.Status.PENDING);
+    queueDto.setSubmitterLogin("john");
+    dbTester.getDbClient().ceQueueDao().insert(dbTester.getSession(), queueDto);
+    dbTester.getSession().commit();
+
+    TestResponse wsResponse = tester.newRequest()
+      .setMediaType(MimeTypes.PROTOBUF)
+      .setParam("id", "TASK_1")
+      .execute();
+
+    // verify the protobuf response
+    WsCe.TaskResponse taskResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.TaskResponse.PARSER);
+    assertThat(taskResponse.getTask().getId()).isEqualTo("TASK_1");
+    assertThat(taskResponse.getTask().getStatus()).isEqualTo(WsCe.TaskStatus.PENDING);
+    assertThat(taskResponse.getTask().getSubmitterLogin()).isEqualTo("john");
+    assertThat(taskResponse.getTask().getComponentId()).isEqualTo(project.uuid());
+    assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(project.key());
+    assertThat(taskResponse.getTask().getComponentName()).isEqualTo(project.name());
+    assertThat(taskResponse.getTask().hasExecutionTimeMs()).isFalse();
+  }
+
+  @Test
+  public void task_is_archived() throws Exception {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+
+    ComponentDto project = new ComponentDto().setUuid("PROJECT_1").setName("Project One").setKey("P1");
+    dbTester.getDbClient().componentDao().insert(dbTester.getSession(), project);
+
+    CeQueueDto queueDto = new CeQueueDto();
+    queueDto.setTaskType(CeTaskTypes.REPORT);
+    queueDto.setUuid("TASK_1");
+    queueDto.setComponentUuid(project.uuid());
+    CeActivityDto activityDto = new CeActivityDto(queueDto);
+    activityDto.setStatus(CeActivityDto.Status.FAILED);
+    activityDto.setExecutionTimeMs(500L);
+    dbTester.getDbClient().ceActivityDao().insert(dbTester.getSession(), activityDto);
+    dbTester.getSession().commit();
+
+    TestResponse wsResponse = tester.newRequest()
+      .setMediaType(MimeTypes.PROTOBUF)
+      .setParam("id", "TASK_1")
+      .execute();
+
+    // verify the protobuf response
+    WsCe.TaskResponse taskResponse = Protobuf.read(wsResponse.getInputStream(), WsCe.TaskResponse.PARSER);
+    assertThat(taskResponse.getTask().getId()).isEqualTo("TASK_1");
+    assertThat(taskResponse.getTask().getStatus()).isEqualTo(WsCe.TaskStatus.FAILED);
+    assertThat(taskResponse.getTask().getComponentId()).isEqualTo(project.uuid());
+    assertThat(taskResponse.getTask().getComponentKey()).isEqualTo(project.key());
+    assertThat(taskResponse.getTask().getComponentName()).isEqualTo(project.name());
+    assertThat(taskResponse.getTask().getExecutionTimeMs()).isEqualTo(500L);
+  }
+
+  @Test(expected = NotFoundException.class)
+  public void task_not_found() throws Exception {
+    userSession.setGlobalPermissions(UserRole.ADMIN);
+
+    tester.newRequest()
+      .setParam("id", "DOES_NOT_EXIST")
+      .execute();
+  }
+}
index eb8f7d8cd27a24c24b357c4c30523c77c7b29208..44502db6dfbf61746323f3b0e8afc42d3e23604a 100644 (file)
     from ce_activity ca
     <where>
       <if test="query.onlyCurrents">
-        ca.is_last=${_true}
+        and ca.is_last=${_true}
       </if>
       <if test="query.componentUuid != null">
-        ca.component_uuid=#{query.componentUuid}
+        and ca.component_uuid=#{query.componentUuid}
       </if>
       <if test="query.status != null">
-        ca.status=#{query.status}
+        and ca.status=#{query.status}
       </if>
       <if test="query.type != null">
-        ca.task_type=#{query.type}
+        and ca.task_type=#{query.type}
       </if>
     </where>
     order by ca.id desc
index 6031e116e20336f5e6eb0c85fccfbfec72deefc8..1323435fcdcda0c5429de6ded07bffb7c728dcd2 100644 (file)
@@ -108,6 +108,11 @@ public class CeActivityDaoTest {
     query = new CeActivityQuery().setType("views");
     dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10));
     assertThat(dtos).extracting("uuid").containsExactly("TASK_4");
+
+    // select by multiple conditions
+    query = new CeActivityQuery().setType(REPORT).setOnlyCurrents(true).setComponentUuid("PROJECT_1");
+    dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10));
+    assertThat(dtos).extracting("uuid").containsExactly("TASK_2");
   }
 
   @Test
index 54ba9950baf99112210bbcb54ce547fadbc4c856..aa7f58f36e748b5bb319da435f5604f055e41216 100644 (file)
@@ -2822,6 +2822,879 @@ public final class WsCe {
 
   }
 
+  public interface ProjectResponseOrBuilder extends
+      // @@protoc_insertion_point(interface_extends:sonarqube.ws.ce.ProjectResponse)
+      com.google.protobuf.MessageOrBuilder {
+
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    java.util.List<org.sonarqube.ws.WsCe.Task> 
+        getQueueList();
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    org.sonarqube.ws.WsCe.Task getQueue(int index);
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    int getQueueCount();
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    java.util.List<? extends org.sonarqube.ws.WsCe.TaskOrBuilder> 
+        getQueueOrBuilderList();
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    org.sonarqube.ws.WsCe.TaskOrBuilder getQueueOrBuilder(
+        int index);
+
+    /**
+     * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+     */
+    boolean hasCurrent();
+    /**
+     * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+     */
+    org.sonarqube.ws.WsCe.Task getCurrent();
+    /**
+     * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+     */
+    org.sonarqube.ws.WsCe.TaskOrBuilder getCurrentOrBuilder();
+  }
+  /**
+   * Protobuf type {@code sonarqube.ws.ce.ProjectResponse}
+   *
+   * <pre>
+   * GET api/ce/project
+   * </pre>
+   */
+  public  static final class ProjectResponse extends
+      com.google.protobuf.GeneratedMessage implements
+      // @@protoc_insertion_point(message_implements:sonarqube.ws.ce.ProjectResponse)
+      ProjectResponseOrBuilder {
+    // Use ProjectResponse.newBuilder() to construct.
+    private ProjectResponse(com.google.protobuf.GeneratedMessage.Builder builder) {
+      super(builder);
+    }
+    private ProjectResponse() {
+      queue_ = java.util.Collections.emptyList();
+    }
+
+    @java.lang.Override
+    public final com.google.protobuf.UnknownFieldSet
+    getUnknownFields() {
+      return this.unknownFields;
+    }
+    private ProjectResponse(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry) {
+      this();
+      int mutable_bitField0_ = 0;
+      com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+          com.google.protobuf.UnknownFieldSet.newBuilder();
+      try {
+        boolean done = false;
+        while (!done) {
+          int tag = input.readTag();
+          switch (tag) {
+            case 0:
+              done = true;
+              break;
+            default: {
+              if (!parseUnknownField(input, unknownFields,
+                                     extensionRegistry, tag)) {
+                done = true;
+              }
+              break;
+            }
+            case 10: {
+              if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
+                queue_ = new java.util.ArrayList<org.sonarqube.ws.WsCe.Task>();
+                mutable_bitField0_ |= 0x00000001;
+              }
+              queue_.add(input.readMessage(org.sonarqube.ws.WsCe.Task.PARSER, extensionRegistry));
+              break;
+            }
+            case 18: {
+              org.sonarqube.ws.WsCe.Task.Builder subBuilder = null;
+              if (((bitField0_ & 0x00000001) == 0x00000001)) {
+                subBuilder = current_.toBuilder();
+              }
+              current_ = input.readMessage(org.sonarqube.ws.WsCe.Task.PARSER, extensionRegistry);
+              if (subBuilder != null) {
+                subBuilder.mergeFrom(current_);
+                current_ = subBuilder.buildPartial();
+              }
+              bitField0_ |= 0x00000001;
+              break;
+            }
+          }
+        }
+      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+        throw new RuntimeException(e.setUnfinishedMessage(this));
+      } catch (java.io.IOException e) {
+        throw new RuntimeException(
+            new com.google.protobuf.InvalidProtocolBufferException(
+                e.getMessage()).setUnfinishedMessage(this));
+      } finally {
+        if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
+          queue_ = java.util.Collections.unmodifiableList(queue_);
+        }
+        this.unknownFields = unknownFields.build();
+        makeExtensionsImmutable();
+      }
+    }
+    public static final com.google.protobuf.Descriptors.Descriptor
+        getDescriptor() {
+      return org.sonarqube.ws.WsCe.internal_static_sonarqube_ws_ce_ProjectResponse_descriptor;
+    }
+
+    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+        internalGetFieldAccessorTable() {
+      return org.sonarqube.ws.WsCe.internal_static_sonarqube_ws_ce_ProjectResponse_fieldAccessorTable
+          .ensureFieldAccessorsInitialized(
+              org.sonarqube.ws.WsCe.ProjectResponse.class, org.sonarqube.ws.WsCe.ProjectResponse.Builder.class);
+    }
+
+    private int bitField0_;
+    public static final int QUEUE_FIELD_NUMBER = 1;
+    private java.util.List<org.sonarqube.ws.WsCe.Task> queue_;
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    public java.util.List<org.sonarqube.ws.WsCe.Task> getQueueList() {
+      return queue_;
+    }
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    public java.util.List<? extends org.sonarqube.ws.WsCe.TaskOrBuilder> 
+        getQueueOrBuilderList() {
+      return queue_;
+    }
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    public int getQueueCount() {
+      return queue_.size();
+    }
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    public org.sonarqube.ws.WsCe.Task getQueue(int index) {
+      return queue_.get(index);
+    }
+    /**
+     * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+     */
+    public org.sonarqube.ws.WsCe.TaskOrBuilder getQueueOrBuilder(
+        int index) {
+      return queue_.get(index);
+    }
+
+    public static final int CURRENT_FIELD_NUMBER = 2;
+    private org.sonarqube.ws.WsCe.Task current_;
+    /**
+     * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+     */
+    public boolean hasCurrent() {
+      return ((bitField0_ & 0x00000001) == 0x00000001);
+    }
+    /**
+     * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+     */
+    public org.sonarqube.ws.WsCe.Task getCurrent() {
+      return current_ == null ? org.sonarqube.ws.WsCe.Task.getDefaultInstance() : current_;
+    }
+    /**
+     * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+     */
+    public org.sonarqube.ws.WsCe.TaskOrBuilder getCurrentOrBuilder() {
+      return current_ == null ? org.sonarqube.ws.WsCe.Task.getDefaultInstance() : current_;
+    }
+
+    private byte memoizedIsInitialized = -1;
+    public final boolean isInitialized() {
+      byte isInitialized = memoizedIsInitialized;
+      if (isInitialized == 1) return true;
+      if (isInitialized == 0) return false;
+
+      memoizedIsInitialized = 1;
+      return true;
+    }
+
+    public void writeTo(com.google.protobuf.CodedOutputStream output)
+                        throws java.io.IOException {
+      for (int i = 0; i < queue_.size(); i++) {
+        output.writeMessage(1, queue_.get(i));
+      }
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        output.writeMessage(2, getCurrent());
+      }
+      unknownFields.writeTo(output);
+    }
+
+    private int memoizedSerializedSize = -1;
+    public int getSerializedSize() {
+      int size = memoizedSerializedSize;
+      if (size != -1) return size;
+
+      size = 0;
+      for (int i = 0; i < queue_.size(); i++) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeMessageSize(1, queue_.get(i));
+      }
+      if (((bitField0_ & 0x00000001) == 0x00000001)) {
+        size += com.google.protobuf.CodedOutputStream
+          .computeMessageSize(2, getCurrent());
+      }
+      size += unknownFields.getSerializedSize();
+      memoizedSerializedSize = size;
+      return size;
+    }
+
+    private static final long serialVersionUID = 0L;
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseFrom(
+        com.google.protobuf.ByteString data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseFrom(
+        com.google.protobuf.ByteString data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseFrom(byte[] data)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data);
+    }
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseFrom(
+        byte[] data,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws com.google.protobuf.InvalidProtocolBufferException {
+      return PARSER.parseFrom(data, extensionRegistry);
+    }
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input);
+    }
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input, extensionRegistry);
+    }
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseDelimitedFrom(java.io.InputStream input)
+        throws java.io.IOException {
+      return PARSER.parseDelimitedFrom(input);
+    }
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseDelimitedFrom(
+        java.io.InputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseDelimitedFrom(input, extensionRegistry);
+    }
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseFrom(
+        com.google.protobuf.CodedInputStream input)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input);
+    }
+    public static org.sonarqube.ws.WsCe.ProjectResponse parseFrom(
+        com.google.protobuf.CodedInputStream input,
+        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+        throws java.io.IOException {
+      return PARSER.parseFrom(input, extensionRegistry);
+    }
+
+    public Builder newBuilderForType() { return newBuilder(); }
+    public static Builder newBuilder() {
+      return DEFAULT_INSTANCE.toBuilder();
+    }
+    public static Builder newBuilder(org.sonarqube.ws.WsCe.ProjectResponse prototype) {
+      return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
+    }
+    public Builder toBuilder() {
+      return this == DEFAULT_INSTANCE
+          ? new Builder() : new Builder().mergeFrom(this);
+    }
+
+    @java.lang.Override
+    protected Builder newBuilderForType(
+        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+      Builder builder = new Builder(parent);
+      return builder;
+    }
+    /**
+     * Protobuf type {@code sonarqube.ws.ce.ProjectResponse}
+     *
+     * <pre>
+     * GET api/ce/project
+     * </pre>
+     */
+    public static final class Builder extends
+        com.google.protobuf.GeneratedMessage.Builder<Builder> implements
+        // @@protoc_insertion_point(builder_implements:sonarqube.ws.ce.ProjectResponse)
+        org.sonarqube.ws.WsCe.ProjectResponseOrBuilder {
+      public static final com.google.protobuf.Descriptors.Descriptor
+          getDescriptor() {
+        return org.sonarqube.ws.WsCe.internal_static_sonarqube_ws_ce_ProjectResponse_descriptor;
+      }
+
+      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+          internalGetFieldAccessorTable() {
+        return org.sonarqube.ws.WsCe.internal_static_sonarqube_ws_ce_ProjectResponse_fieldAccessorTable
+            .ensureFieldAccessorsInitialized(
+                org.sonarqube.ws.WsCe.ProjectResponse.class, org.sonarqube.ws.WsCe.ProjectResponse.Builder.class);
+      }
+
+      // Construct using org.sonarqube.ws.WsCe.ProjectResponse.newBuilder()
+      private Builder() {
+        maybeForceBuilderInitialization();
+      }
+
+      private Builder(
+          com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+        super(parent);
+        maybeForceBuilderInitialization();
+      }
+      private void maybeForceBuilderInitialization() {
+        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+          getQueueFieldBuilder();
+          getCurrentFieldBuilder();
+        }
+      }
+      public Builder clear() {
+        super.clear();
+        if (queueBuilder_ == null) {
+          queue_ = java.util.Collections.emptyList();
+          bitField0_ = (bitField0_ & ~0x00000001);
+        } else {
+          queueBuilder_.clear();
+        }
+        if (currentBuilder_ == null) {
+          current_ = null;
+        } else {
+          currentBuilder_.clear();
+        }
+        bitField0_ = (bitField0_ & ~0x00000002);
+        return this;
+      }
+
+      public com.google.protobuf.Descriptors.Descriptor
+          getDescriptorForType() {
+        return org.sonarqube.ws.WsCe.internal_static_sonarqube_ws_ce_ProjectResponse_descriptor;
+      }
+
+      public org.sonarqube.ws.WsCe.ProjectResponse getDefaultInstanceForType() {
+        return org.sonarqube.ws.WsCe.ProjectResponse.getDefaultInstance();
+      }
+
+      public org.sonarqube.ws.WsCe.ProjectResponse build() {
+        org.sonarqube.ws.WsCe.ProjectResponse result = buildPartial();
+        if (!result.isInitialized()) {
+          throw newUninitializedMessageException(result);
+        }
+        return result;
+      }
+
+      public org.sonarqube.ws.WsCe.ProjectResponse buildPartial() {
+        org.sonarqube.ws.WsCe.ProjectResponse result = new org.sonarqube.ws.WsCe.ProjectResponse(this);
+        int from_bitField0_ = bitField0_;
+        int to_bitField0_ = 0;
+        if (queueBuilder_ == null) {
+          if (((bitField0_ & 0x00000001) == 0x00000001)) {
+            queue_ = java.util.Collections.unmodifiableList(queue_);
+            bitField0_ = (bitField0_ & ~0x00000001);
+          }
+          result.queue_ = queue_;
+        } else {
+          result.queue_ = queueBuilder_.build();
+        }
+        if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+          to_bitField0_ |= 0x00000001;
+        }
+        if (currentBuilder_ == null) {
+          result.current_ = current_;
+        } else {
+          result.current_ = currentBuilder_.build();
+        }
+        result.bitField0_ = to_bitField0_;
+        onBuilt();
+        return result;
+      }
+
+      public Builder mergeFrom(com.google.protobuf.Message other) {
+        if (other instanceof org.sonarqube.ws.WsCe.ProjectResponse) {
+          return mergeFrom((org.sonarqube.ws.WsCe.ProjectResponse)other);
+        } else {
+          super.mergeFrom(other);
+          return this;
+        }
+      }
+
+      public Builder mergeFrom(org.sonarqube.ws.WsCe.ProjectResponse other) {
+        if (other == org.sonarqube.ws.WsCe.ProjectResponse.getDefaultInstance()) return this;
+        if (queueBuilder_ == null) {
+          if (!other.queue_.isEmpty()) {
+            if (queue_.isEmpty()) {
+              queue_ = other.queue_;
+              bitField0_ = (bitField0_ & ~0x00000001);
+            } else {
+              ensureQueueIsMutable();
+              queue_.addAll(other.queue_);
+            }
+            onChanged();
+          }
+        } else {
+          if (!other.queue_.isEmpty()) {
+            if (queueBuilder_.isEmpty()) {
+              queueBuilder_.dispose();
+              queueBuilder_ = null;
+              queue_ = other.queue_;
+              bitField0_ = (bitField0_ & ~0x00000001);
+              queueBuilder_ = 
+                com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
+                   getQueueFieldBuilder() : null;
+            } else {
+              queueBuilder_.addAllMessages(other.queue_);
+            }
+          }
+        }
+        if (other.hasCurrent()) {
+          mergeCurrent(other.getCurrent());
+        }
+        this.mergeUnknownFields(other.unknownFields);
+        onChanged();
+        return this;
+      }
+
+      public final boolean isInitialized() {
+        return true;
+      }
+
+      public Builder mergeFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws java.io.IOException {
+        org.sonarqube.ws.WsCe.ProjectResponse parsedMessage = null;
+        try {
+          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
+        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
+          parsedMessage = (org.sonarqube.ws.WsCe.ProjectResponse) e.getUnfinishedMessage();
+          throw e;
+        } finally {
+          if (parsedMessage != null) {
+            mergeFrom(parsedMessage);
+          }
+        }
+        return this;
+      }
+      private int bitField0_;
+
+      private java.util.List<org.sonarqube.ws.WsCe.Task> queue_ =
+        java.util.Collections.emptyList();
+      private void ensureQueueIsMutable() {
+        if (!((bitField0_ & 0x00000001) == 0x00000001)) {
+          queue_ = new java.util.ArrayList<org.sonarqube.ws.WsCe.Task>(queue_);
+          bitField0_ |= 0x00000001;
+         }
+      }
+
+      private com.google.protobuf.RepeatedFieldBuilder<
+          org.sonarqube.ws.WsCe.Task, org.sonarqube.ws.WsCe.Task.Builder, org.sonarqube.ws.WsCe.TaskOrBuilder> queueBuilder_;
+
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public java.util.List<org.sonarqube.ws.WsCe.Task> getQueueList() {
+        if (queueBuilder_ == null) {
+          return java.util.Collections.unmodifiableList(queue_);
+        } else {
+          return queueBuilder_.getMessageList();
+        }
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public int getQueueCount() {
+        if (queueBuilder_ == null) {
+          return queue_.size();
+        } else {
+          return queueBuilder_.getCount();
+        }
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public org.sonarqube.ws.WsCe.Task getQueue(int index) {
+        if (queueBuilder_ == null) {
+          return queue_.get(index);
+        } else {
+          return queueBuilder_.getMessage(index);
+        }
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public Builder setQueue(
+          int index, org.sonarqube.ws.WsCe.Task value) {
+        if (queueBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          ensureQueueIsMutable();
+          queue_.set(index, value);
+          onChanged();
+        } else {
+          queueBuilder_.setMessage(index, value);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public Builder setQueue(
+          int index, org.sonarqube.ws.WsCe.Task.Builder builderForValue) {
+        if (queueBuilder_ == null) {
+          ensureQueueIsMutable();
+          queue_.set(index, builderForValue.build());
+          onChanged();
+        } else {
+          queueBuilder_.setMessage(index, builderForValue.build());
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public Builder addQueue(org.sonarqube.ws.WsCe.Task value) {
+        if (queueBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          ensureQueueIsMutable();
+          queue_.add(value);
+          onChanged();
+        } else {
+          queueBuilder_.addMessage(value);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public Builder addQueue(
+          int index, org.sonarqube.ws.WsCe.Task value) {
+        if (queueBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          ensureQueueIsMutable();
+          queue_.add(index, value);
+          onChanged();
+        } else {
+          queueBuilder_.addMessage(index, value);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public Builder addQueue(
+          org.sonarqube.ws.WsCe.Task.Builder builderForValue) {
+        if (queueBuilder_ == null) {
+          ensureQueueIsMutable();
+          queue_.add(builderForValue.build());
+          onChanged();
+        } else {
+          queueBuilder_.addMessage(builderForValue.build());
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public Builder addQueue(
+          int index, org.sonarqube.ws.WsCe.Task.Builder builderForValue) {
+        if (queueBuilder_ == null) {
+          ensureQueueIsMutable();
+          queue_.add(index, builderForValue.build());
+          onChanged();
+        } else {
+          queueBuilder_.addMessage(index, builderForValue.build());
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public Builder addAllQueue(
+          java.lang.Iterable<? extends org.sonarqube.ws.WsCe.Task> values) {
+        if (queueBuilder_ == null) {
+          ensureQueueIsMutable();
+          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+              values, queue_);
+          onChanged();
+        } else {
+          queueBuilder_.addAllMessages(values);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public Builder clearQueue() {
+        if (queueBuilder_ == null) {
+          queue_ = java.util.Collections.emptyList();
+          bitField0_ = (bitField0_ & ~0x00000001);
+          onChanged();
+        } else {
+          queueBuilder_.clear();
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public Builder removeQueue(int index) {
+        if (queueBuilder_ == null) {
+          ensureQueueIsMutable();
+          queue_.remove(index);
+          onChanged();
+        } else {
+          queueBuilder_.remove(index);
+        }
+        return this;
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public org.sonarqube.ws.WsCe.Task.Builder getQueueBuilder(
+          int index) {
+        return getQueueFieldBuilder().getBuilder(index);
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public org.sonarqube.ws.WsCe.TaskOrBuilder getQueueOrBuilder(
+          int index) {
+        if (queueBuilder_ == null) {
+          return queue_.get(index);  } else {
+          return queueBuilder_.getMessageOrBuilder(index);
+        }
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public java.util.List<? extends org.sonarqube.ws.WsCe.TaskOrBuilder> 
+           getQueueOrBuilderList() {
+        if (queueBuilder_ != null) {
+          return queueBuilder_.getMessageOrBuilderList();
+        } else {
+          return java.util.Collections.unmodifiableList(queue_);
+        }
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public org.sonarqube.ws.WsCe.Task.Builder addQueueBuilder() {
+        return getQueueFieldBuilder().addBuilder(
+            org.sonarqube.ws.WsCe.Task.getDefaultInstance());
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public org.sonarqube.ws.WsCe.Task.Builder addQueueBuilder(
+          int index) {
+        return getQueueFieldBuilder().addBuilder(
+            index, org.sonarqube.ws.WsCe.Task.getDefaultInstance());
+      }
+      /**
+       * <code>repeated .sonarqube.ws.ce.Task queue = 1;</code>
+       */
+      public java.util.List<org.sonarqube.ws.WsCe.Task.Builder> 
+           getQueueBuilderList() {
+        return getQueueFieldBuilder().getBuilderList();
+      }
+      private com.google.protobuf.RepeatedFieldBuilder<
+          org.sonarqube.ws.WsCe.Task, org.sonarqube.ws.WsCe.Task.Builder, org.sonarqube.ws.WsCe.TaskOrBuilder> 
+          getQueueFieldBuilder() {
+        if (queueBuilder_ == null) {
+          queueBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
+              org.sonarqube.ws.WsCe.Task, org.sonarqube.ws.WsCe.Task.Builder, org.sonarqube.ws.WsCe.TaskOrBuilder>(
+                  queue_,
+                  ((bitField0_ & 0x00000001) == 0x00000001),
+                  getParentForChildren(),
+                  isClean());
+          queue_ = null;
+        }
+        return queueBuilder_;
+      }
+
+      private org.sonarqube.ws.WsCe.Task current_ = null;
+      private com.google.protobuf.SingleFieldBuilder<
+          org.sonarqube.ws.WsCe.Task, org.sonarqube.ws.WsCe.Task.Builder, org.sonarqube.ws.WsCe.TaskOrBuilder> currentBuilder_;
+      /**
+       * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+       */
+      public boolean hasCurrent() {
+        return ((bitField0_ & 0x00000002) == 0x00000002);
+      }
+      /**
+       * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+       */
+      public org.sonarqube.ws.WsCe.Task getCurrent() {
+        if (currentBuilder_ == null) {
+          return current_ == null ? org.sonarqube.ws.WsCe.Task.getDefaultInstance() : current_;
+        } else {
+          return currentBuilder_.getMessage();
+        }
+      }
+      /**
+       * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+       */
+      public Builder setCurrent(org.sonarqube.ws.WsCe.Task value) {
+        if (currentBuilder_ == null) {
+          if (value == null) {
+            throw new NullPointerException();
+          }
+          current_ = value;
+          onChanged();
+        } else {
+          currentBuilder_.setMessage(value);
+        }
+        bitField0_ |= 0x00000002;
+        return this;
+      }
+      /**
+       * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+       */
+      public Builder setCurrent(
+          org.sonarqube.ws.WsCe.Task.Builder builderForValue) {
+        if (currentBuilder_ == null) {
+          current_ = builderForValue.build();
+          onChanged();
+        } else {
+          currentBuilder_.setMessage(builderForValue.build());
+        }
+        bitField0_ |= 0x00000002;
+        return this;
+      }
+      /**
+       * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+       */
+      public Builder mergeCurrent(org.sonarqube.ws.WsCe.Task value) {
+        if (currentBuilder_ == null) {
+          if (((bitField0_ & 0x00000002) == 0x00000002) &&
+              current_ != null &&
+              current_ != org.sonarqube.ws.WsCe.Task.getDefaultInstance()) {
+            current_ =
+              org.sonarqube.ws.WsCe.Task.newBuilder(current_).mergeFrom(value).buildPartial();
+          } else {
+            current_ = value;
+          }
+          onChanged();
+        } else {
+          currentBuilder_.mergeFrom(value);
+        }
+        bitField0_ |= 0x00000002;
+        return this;
+      }
+      /**
+       * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+       */
+      public Builder clearCurrent() {
+        if (currentBuilder_ == null) {
+          current_ = null;
+          onChanged();
+        } else {
+          currentBuilder_.clear();
+        }
+        bitField0_ = (bitField0_ & ~0x00000002);
+        return this;
+      }
+      /**
+       * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+       */
+      public org.sonarqube.ws.WsCe.Task.Builder getCurrentBuilder() {
+        bitField0_ |= 0x00000002;
+        onChanged();
+        return getCurrentFieldBuilder().getBuilder();
+      }
+      /**
+       * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+       */
+      public org.sonarqube.ws.WsCe.TaskOrBuilder getCurrentOrBuilder() {
+        if (currentBuilder_ != null) {
+          return currentBuilder_.getMessageOrBuilder();
+        } else {
+          return current_ == null ?
+              org.sonarqube.ws.WsCe.Task.getDefaultInstance() : current_;
+        }
+      }
+      /**
+       * <code>optional .sonarqube.ws.ce.Task current = 2;</code>
+       */
+      private com.google.protobuf.SingleFieldBuilder<
+          org.sonarqube.ws.WsCe.Task, org.sonarqube.ws.WsCe.Task.Builder, org.sonarqube.ws.WsCe.TaskOrBuilder> 
+          getCurrentFieldBuilder() {
+        if (currentBuilder_ == null) {
+          currentBuilder_ = new com.google.protobuf.SingleFieldBuilder<
+              org.sonarqube.ws.WsCe.Task, org.sonarqube.ws.WsCe.Task.Builder, org.sonarqube.ws.WsCe.TaskOrBuilder>(
+                  getCurrent(),
+                  getParentForChildren(),
+                  isClean());
+          current_ = null;
+        }
+        return currentBuilder_;
+      }
+
+      // @@protoc_insertion_point(builder_scope:sonarqube.ws.ce.ProjectResponse)
+    }
+
+    // @@protoc_insertion_point(class_scope:sonarqube.ws.ce.ProjectResponse)
+    private static final org.sonarqube.ws.WsCe.ProjectResponse DEFAULT_INSTANCE;
+    static {
+      DEFAULT_INSTANCE = new org.sonarqube.ws.WsCe.ProjectResponse();
+    }
+
+    public static org.sonarqube.ws.WsCe.ProjectResponse getDefaultInstance() {
+      return DEFAULT_INSTANCE;
+    }
+
+    public static final com.google.protobuf.Parser<ProjectResponse> PARSER =
+        new com.google.protobuf.AbstractParser<ProjectResponse>() {
+      public ProjectResponse parsePartialFrom(
+          com.google.protobuf.CodedInputStream input,
+          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+          throws com.google.protobuf.InvalidProtocolBufferException {
+        try {
+          return new ProjectResponse(input, extensionRegistry);
+        } catch (RuntimeException e) {
+          if (e.getCause() instanceof
+              com.google.protobuf.InvalidProtocolBufferException) {
+            throw (com.google.protobuf.InvalidProtocolBufferException)
+                e.getCause();
+          }
+          throw e;
+        }
+      }
+    };
+
+    @java.lang.Override
+    public com.google.protobuf.Parser<ProjectResponse> getParserForType() {
+      return PARSER;
+    }
+
+    public org.sonarqube.ws.WsCe.ProjectResponse getDefaultInstanceForType() {
+      return DEFAULT_INSTANCE;
+    }
+
+  }
+
   public interface TaskOrBuilder extends
       // @@protoc_insertion_point(interface_extends:sonarqube.ws.ce.Task)
       com.google.protobuf.MessageOrBuilder {
@@ -4815,6 +5688,11 @@ public final class WsCe {
   private static
     com.google.protobuf.GeneratedMessage.FieldAccessorTable
       internal_static_sonarqube_ws_ce_ActivityResponse_fieldAccessorTable;
+  private static com.google.protobuf.Descriptors.Descriptor
+    internal_static_sonarqube_ws_ce_ProjectResponse_descriptor;
+  private static
+    com.google.protobuf.GeneratedMessage.FieldAccessorTable
+      internal_static_sonarqube_ws_ce_ProjectResponse_fieldAccessorTable;
   private static com.google.protobuf.Descriptors.Descriptor
     internal_static_sonarqube_ws_ce_Task_descriptor;
   private static
@@ -4836,17 +5714,19 @@ public final class WsCe {
       "eueResponse\022$\n\005tasks\030\001 \003(\0132\025.sonarqube.w" +
       "s.ce.Task\"f\n\020ActivityResponse\022,\n\006paging\030" +
       "\001 \001(\0132\034.sonarqube.ws.commons.Paging\022$\n\005t" +
-      "asks\030\002 \003(\0132\025.sonarqube.ws.ce.Task\"\224\002\n\004Ta" +
-      "sk\022\n\n\002id\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022\023\n\013componen" +
-      "tId\030\003 \001(\t\022\024\n\014componentKey\030\004 \001(\t\022\025\n\rcompo",
-      "nentName\030\005 \001(\t\022+\n\006status\030\006 \001(\0162\033.sonarqu" +
-      "be.ws.ce.TaskStatus\022\023\n\013submittedAt\030\007 \001(\t" +
-      "\022\026\n\016submitterLogin\030\010 \001(\t\022\021\n\tstartedAt\030\t " +
-      "\001(\t\022\022\n\nfinishedAt\030\n \001(\t\022\026\n\016isLastFinishe" +
-      "d\030\013 \001(\010\022\027\n\017executionTimeMs\030\014 \001(\003*Q\n\nTask" +
-      "Status\022\013\n\007PENDING\020\000\022\017\n\013IN_PROGRESS\020\001\022\013\n\007" +
-      "SUCCESS\020\002\022\n\n\006FAILED\020\003\022\014\n\010CANCELED\020\004B\032\n\020o" +
-      "rg.sonarqube.wsB\004WsCeH\001"
+      "asks\030\002 \003(\0132\025.sonarqube.ws.ce.Task\"_\n\017Pro" +
+      "jectResponse\022$\n\005queue\030\001 \003(\0132\025.sonarqube." +
+      "ws.ce.Task\022&\n\007current\030\002 \001(\0132\025.sonarqube.",
+      "ws.ce.Task\"\224\002\n\004Task\022\n\n\002id\030\001 \001(\t\022\014\n\004type\030" +
+      "\002 \001(\t\022\023\n\013componentId\030\003 \001(\t\022\024\n\014componentK" +
+      "ey\030\004 \001(\t\022\025\n\rcomponentName\030\005 \001(\t\022+\n\006statu" +
+      "s\030\006 \001(\0162\033.sonarqube.ws.ce.TaskStatus\022\023\n\013" +
+      "submittedAt\030\007 \001(\t\022\026\n\016submitterLogin\030\010 \001(" +
+      "\t\022\021\n\tstartedAt\030\t \001(\t\022\022\n\nfinishedAt\030\n \001(\t" +
+      "\022\026\n\016isLastFinished\030\013 \001(\010\022\027\n\017executionTim" +
+      "eMs\030\014 \001(\003*Q\n\nTaskStatus\022\013\n\007PENDING\020\000\022\017\n\013" +
+      "IN_PROGRESS\020\001\022\013\n\007SUCCESS\020\002\022\n\n\006FAILED\020\003\022\014" +
+      "\n\010CANCELED\020\004B\032\n\020org.sonarqube.wsB\004WsCeH\001"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
         new com.google.protobuf.Descriptors.FileDescriptor.    InternalDescriptorAssigner() {
@@ -4885,8 +5765,14 @@ public final class WsCe {
       com.google.protobuf.GeneratedMessage.FieldAccessorTable(
         internal_static_sonarqube_ws_ce_ActivityResponse_descriptor,
         new java.lang.String[] { "Paging", "Tasks", });
-    internal_static_sonarqube_ws_ce_Task_descriptor =
+    internal_static_sonarqube_ws_ce_ProjectResponse_descriptor =
       getDescriptor().getMessageTypes().get(4);
+    internal_static_sonarqube_ws_ce_ProjectResponse_fieldAccessorTable = new
+      com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+        internal_static_sonarqube_ws_ce_ProjectResponse_descriptor,
+        new java.lang.String[] { "Queue", "Current", });
+    internal_static_sonarqube_ws_ce_Task_descriptor =
+      getDescriptor().getMessageTypes().get(5);
     internal_static_sonarqube_ws_ce_Task_fieldAccessorTable = new
       com.google.protobuf.GeneratedMessage.FieldAccessorTable(
         internal_static_sonarqube_ws_ce_Task_descriptor,
index 5ab5e4ab58a45754b8211064a793c7395ec42547..ea42379745577562f8e15693fb32b976ff43ae2a 100644 (file)
@@ -48,6 +48,12 @@ message ActivityResponse {
   repeated Task tasks = 2;
 }
 
+// GET api/ce/project
+message ProjectResponse {
+  repeated Task queue = 1;
+  optional Task current = 2;
+}
+
 message Task {
   optional string id = 1;
   optional string type = 2;