Package org.sonar.api.utils.text

Examples of org.sonar.api.utils.text.JsonWriter


  public final void handle(Request request, Response response) throws Exception {
    QueryContext context = getQueryContext(request);
    QUERY query = doQuery(request);
    Result<DOMAIN> result = doSearch(query, context);

    JsonWriter json = response.newJsonWriter().beginObject();
    this.writeStatistics(json, result, context);
    doContextResponse(request, context, result, json);
    if (context.isFacet()) {
      writeFacets(request, context, result, json);
    }
    json.endObject().close();
  }
View Full Code Here


  }

  @Override
  public void handle(Request request, Response response) {
    Set<String> tags = service.listTags();
    JsonWriter json = response.newJsonWriter().beginObject();
    json.name("tags").beginArray();
    for (String tag : tags) {
      json.value(tag);
    }
    json.endArray().endObject().close();
  }
View Full Code Here

    SearchOptions searchOptions = SearchOptions.create(request);
    QueryContext queryContext = mapping.newQueryOptions(searchOptions);

    Result<Activity> results = logService.search(query, queryContext);

    JsonWriter json = response.newJsonWriter().beginObject();
    searchOptions.writeStatistics(json, results);
    writeReports(results, json, searchOptions);
    json.endObject().close();
  }
View Full Code Here

    List<String> sourceHtml = sourceService.getLinesAsHtml(fileKey, from, to);
    if (sourceHtml == null) {
      throw new NotFoundException("File '" + fileKey + "' has no sources");
    }

    JsonWriter json = response.newJsonWriter().beginObject();
    writeSource(sourceHtml, from, json);

    json.endObject().close();
  }
View Full Code Here

    String fileKey = request.mandatoryParam("key");

    String authors = service.getScmAuthorData(fileKey);
    String dates = service.getScmDateData(fileKey);

    JsonWriter json = response.newJsonWriter().beginObject();
    int from = Math.max(request.mandatoryParamAsInt("from"), 1);
    int to = (Integer) ObjectUtils.defaultIfNull(request.paramAsInt("to"), Integer.MAX_VALUE);
    scmWriter.write(authors, dates, from, to, request.mandatoryParamAsBoolean("commits_by_line"), json);
    json.endObject().close();
  }
View Full Code Here

  @Override
  public void handle(Request request, Response response) throws Exception {
    List<AnalysisReportDto> reports = queue.all();

    JsonWriter json = response.newJsonWriter().beginObject();
    writeReports(reports, json);
    json.endObject();
    json.close();
  }
View Full Code Here

      Locale locale = UserSession.get().locale();
      String localeParam = request.param("locale");
      if (localeParam != null) {
        locale = LocaleUtils.toLocale(localeParam);
      }
      JsonWriter json = response.newJsonWriter().beginObject();
      for (String messageKey: i18n.getPropertyKeys()) {
        json.prop(messageKey, i18n.message(locale, messageKey, messageKey));
      }
      json.endObject().close();
    }
  }
View Full Code Here

  }


  private void test(String authors, String dates, int from, int to, boolean group, String expected) throws JSONException {
    StringWriter output = new StringWriter();
    JsonWriter jsonWriter = JsonWriter.of(output);
    jsonWriter.beginObject();
    writer.write(authors, dates, from, to, group, jsonWriter);
    jsonWriter.endObject();
    JSONAssert.assertEquals(output.toString(), expected, true);
  }
View Full Code Here

    );
  }

  private void test(UserSession userSession, DefaultIssueFilter filter, String expected) throws JSONException {
    StringWriter output = new StringWriter();
    JsonWriter jsonWriter = JsonWriter.of(output);
    jsonWriter.beginObject();
    writer.write(userSession, filter, jsonWriter);
    jsonWriter.endObject();
    JSONAssert.assertEquals(output.toString(), expected, true);
  }
View Full Code Here

  @Override
  public void handle(Request request, Response response) {
    String issueKey = request.mandatoryParam("key");

    JsonWriter json = response.newJsonWriter();
    json.beginObject().name("issue").beginObject();

    DbSession session = dbClient.openSession(false);
    try {
      Issue issue = issueService.getByKey(issueKey);

      writeIssue(session, issue, json);
      actionsWriter.writeActions(issue, json);
      actionsWriter.writeTransitions(issue, json);
      writeComments(issue, json);
      writeChangelog(issue, json);

    } finally {
      session.close();
    }

    json.endObject().endObject().close();
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.utils.text.JsonWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.