Package org.sonar.api.utils.text

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


    UserSession.get().checkComponentPermission(UserRole.CODEVIEWER, fileKey);

    DbSession session = dbClient.openSession(false);
    try {
      ComponentDto component = findComponent(fileKey, session);
      JsonWriter json = response.newJsonWriter().beginObject();
      String duplications = findDataFromComponent(fileKey, CoreMetrics.DUPLICATIONS_DATA_KEY, session);
      List<DuplicationsParser.Block> blocks = parser.parse(component, duplications, session);
      duplicationsJsonWriter.write(blocks, json, session);
      json.endObject().close();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here


  @Override
  public void handle(Request request, Response response) throws Exception {
    UserSession session = UserSession.get();

    JsonWriter json = response.newJsonWriter();
    json.beginObject();

    // Current filter (optional)
    Integer filterId = request.paramAsInt("id");
    DefaultIssueFilter filter = null;
    if (filterId != null && filterId >= 0) {
      filter = service.find((long) filterId, session);
    }

    // Permissions
    json.prop("canManageFilters", session.isLoggedIn());
    json.prop("canBulkChange", session.isLoggedIn());

    // Selected filter
    if (filter != null) {
      issueFilterWriter.write(session, filter, json);
    }

    // Favorite filters, if logged in
    if (session.isLoggedIn()) {
      List<DefaultIssueFilter> favorites = service.findFavoriteFilters(session);
      json.name("favorites").beginArray();
      for (DefaultIssueFilter favorite : favorites) {
        json
          .beginObject()
          .prop("id", favorite.id())
          .prop("name", favorite.name())
          .endObject();
      }
      json.endArray();
    }

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

      .membership(request.param(QGatesWs.PARAM_QUERY) == null ? request.param(QGatesWs.PARAM_SELECTED) : ProjectQgateAssociationQuery.ANY)
      .projectSearch(request.param(QGatesWs.PARAM_QUERY))
      .pageIndex(request.paramAsInt(QGatesWs.PARAM_PAGE))
      .pageSize(request.paramAsInt(QGatesWs.PARAM_PAGE_SIZE))
      .build());
    JsonWriter writer = response.newJsonWriter();
    writer.beginObject().prop("more", associations.hasMoreResults());
    writer.name("results").beginArray();
    for (ProjectQgateAssociation project : associations.projects()) {
      writer.beginObject().prop("id", project.id()).prop("name", project.name()).prop(QGatesWs.PARAM_SELECTED, project.isMember()).endObject();
    }
    writer.endArray().endObject().close();
  }
View Full Code Here

      .setHandler(this);
  }

  @Override
  public void handle(Request request, Response response) {
    JsonWriter writer = response.newJsonWriter().beginObject().name("qualitygates").beginArray();
    for (QualityGateDto qgate : qualityGates.list()) {
      QGatesWs.writeQualityGate(qgate, writer);
    }
    writer.endArray();
    QualityGateDto defaultQgate = qualityGates.getDefault();
    if (defaultQgate != null) {
      writer.prop("default", defaultQgate.getId());
    }
    writer.endObject().close();
  }
View Full Code Here

      .setHandler(this);
  }

  @Override
  public void handle(Request request, Response response) {
    JsonWriter writer = response.newJsonWriter().beginObject();
    addPermissions(writer);
    addPeriods(writer);
    addMetrics(writer);
    writer.endObject().close();
  }
View Full Code Here

  }

  @Override
  public void handle(Request request, Response response) {
    QualityGateDto newQualityGate = qualityGates.copy(QGatesWs.parseId(request, QGatesWs.PARAM_ID), request.mandatoryParam(QGatesWs.PARAM_NAME));
    JsonWriter writer = response.newJsonWriter();
    QGatesWs.writeQualityGate(newQualityGate, writer).close();
  }
View Full Code Here

  }

  @Override
  public void handle(Request request, Response response) {
    QualityGateDto newQualityGate = qualityGates.create(request.mandatoryParam(QGatesWs.PARAM_NAME));
    JsonWriter writer = response.newJsonWriter();
    QGatesWs.writeQualityGate(newQualityGate, writer).close();
  }
View Full Code Here

  @Override
  public void handle(Request request, Response response) throws Exception {
    UserSession session = UserSession.get();
    DefaultIssueFilter filter = service.find(request.mandatoryParamAsLong("id"), session);

    JsonWriter json = response.newJsonWriter();
    json.beginObject();
    issueFilterWriter.write(session, filter, json);
    json.endObject();
    json.close();
  }
View Full Code Here

    checkOneOfIdOrNamePresent(qGateId, qGateName);

    QualityGateDto qGate = qGateId == null ? qualityGates.get(qGateName) : qualityGates.get(qGateId);
    qGateId = qGate.getId();

    JsonWriter writer = response.newJsonWriter().beginObject()
      .prop(QGatesWs.PARAM_ID, qGate.getId())
      .prop(QGatesWs.PARAM_NAME, qGate.getName());
    Collection<QualityGateConditionDto> conditions = qualityGates.listConditions(qGateId);
    if (!conditions.isEmpty()) {
      writer.name("conditions").beginArray();
      for (QualityGateConditionDto condition : conditions) {
        QGatesWs.writeQualityGateCondition(condition, writer);
      }
      writer.endArray();
    }
    writer.endObject().close();
  }
View Full Code Here

  }

  @Override
  public void handle(Request request, Response response) throws Exception {
    UserSession session = UserSession.get();
    JsonWriter json = response.newJsonWriter();
    json.beginObject().name("favoriteFilters").beginArray();
    if (session.isLoggedIn()) {
      for (DefaultIssueFilter favorite : service.findFavoriteFilters(session)) {
        json.beginObject();
        json.prop("id", favorite.id());
        json.prop("name", favorite.name());
        json.prop("user", favorite.user());
        json.prop("shared", favorite.shared());
        // no need to export description and query fields
        json.endObject();
      }
    }
    json.endArray().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.