コード例 #1
0
ファイル: TaskAction.java プロジェクト: swarbiv/sonarqube
  @Override
  public void handle(Request wsRequest, Response wsResponse) throws Exception {
    userSession.checkAnyGlobalPermissions(AUTHORIZED_PERMISSIONS);

    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();
        }
      }
      writeProtobuf(wsTaskResponse.build(), wsRequest, wsResponse);

    } finally {
      dbClient.closeSession(dbSession);
    }
  }
コード例 #2
0
  private Optional<WsCe.Task> searchTaskByUuid(DbSession dbSession, ActivityWsRequest request) {
    String textQuery = request.getQuery();
    if (textQuery == null) {
      return Optional.absent();
    }

    Optional<CeQueueDto> queue = dbClient.ceQueueDao().selectByUuid(dbSession, textQuery);
    if (queue.isPresent()) {
      return Optional.of(formatter.formatQueue(dbSession, queue.get()));
    }

    Optional<CeActivityDto> activity = dbClient.ceActivityDao().selectByUuid(dbSession, textQuery);
    if (activity.isPresent()) {
      return Optional.of(formatter.formatActivity(dbSession, activity.get()));
    }

    return Optional.absent();
  }
コード例 #3
0
 private List<WsCe.Task> loadPastTasks(
     DbSession dbSession, ActivityWsRequest request, CeTaskQuery query) {
   List<CeActivityDto> dtos =
       dbClient.ceActivityDao().selectByQuery(dbSession, query, OFFSET, request.getPageSize());
   return formatter.formatActivity(dbSession, dtos);
 }