Package org.sonar.api.utils.text

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


    String fileKey = request.mandatoryParam(KEY);
    UserSession.get().checkComponentPermission(UserRole.CODEVIEWER, fileKey);
    int line = request.mandatoryParamAsInt(LINE);

    Testable testable = snapshotPerspectives.as(MutableTestable.class, fileKey);
    JsonWriter json = response.newJsonWriter().beginObject();
    if (testable != null) {
      Map<String, Integer> refByTestPlan = newHashMap();
      Map<String, Component> componentsByKey = newHashMap();
      writeTests(testable, line, refByTestPlan, componentsByKey, json);
      writeFiles(refByTestPlan, componentsByKey, json);
    }
    json.endObject().close();
  }
View Full Code Here


  public void handle(Request request, Response response) {
    String fileKey = request.mandatoryParam(KEY);
    UserSession.get().checkComponentPermission(UserRole.CODEVIEWER, fileKey);

    String testData = findTestData(fileKey);
    JsonWriter json = response.newJsonWriter().beginObject();
    if (testData != null) {
      writeFromTestData(testData, json);
    } else {
      MutableTestPlan testPlan = snapshotPerspectives.as(MutableTestPlan.class, fileKey);
      if (testPlan != null) {
        writeFromTestable(testPlan, json);
      }
    }
    json.endObject().close();
  }
View Full Code Here

    String fileKey = request.mandatoryParam(KEY);
    UserSession.get().checkComponentPermission(UserRole.CODEVIEWER, fileKey);
    String test = request.mandatoryParam(TEST);

    MutableTestPlan testPlan = snapshotPerspectives.as(MutableTestPlan.class, fileKey);
    JsonWriter json = response.newJsonWriter().beginObject();
    if (testPlan != null) {
      writeTests(testPlan, test, json);
    }
    json.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);
    writeLogs(results, json, searchOptions);
    json.endObject().close();
  }
View Full Code Here

    }
  }

  private void writeResponse(Response response, RuleKey ruleKey) {
    Rule rule = service.getNonNullByKey(ruleKey);
    JsonWriter json = response.newJsonWriter().beginObject().name("rule");
    mapping.write(rule, json, null /* TODO replace by SearchOptions immutable constant */);
    json.endObject().close();
  }
View Full Code Here

    Rule rule = service.getNonNullByKey(ruleKey);

    Response.Stream stream = response.stream();
    stream.setStatus(409);
    stream.setMediaType(MimeTypes.JSON);
    JsonWriter json = JsonWriter.of(new OutputStreamWriter(stream.output())).beginObject().name("rule");
    mapping.write(rule, json, null /* TODO replace by SearchOptions immutable constant */);
    json.endObject().close();
  }
View Full Code Here

    this.profileLoader = profileLoader;
  }

  @Override
  public void handle(Request request, Response response) throws Exception {
    JsonWriter json = response.newJsonWriter();
    json.beginObject();
    addPermissions(json);
    addProfiles(json);
    addLanguages(json);
    addRuleRepositories(json);
    addStatuses(json);
    addCharacteristics(json);
    json.endObject().close();
  }
View Full Code Here

    RuleKey key = RuleKey.parse(request.mandatoryParam(PARAM_KEY));
    Rule rule = service.getByKey(key);
    if (rule == null) {
      throw new NotFoundException("Rule not found: " + key);
    }
    JsonWriter json = response.newJsonWriter().beginObject().name("rule");
    mapping.write(rule, json, null /* TODO replace by SearchOptions immutable constant */);

    if (request.mandatoryParamAsBoolean(PARAM_ACTIVES)) {
      activeRuleCompleter.completeShow(rule, json);
    }

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

    }
  }

  private void writeResponse(Response response, RuleKey ruleKey) {
    Rule rule = service.getNonNullByKey(ruleKey);
    JsonWriter json = response.newJsonWriter().beginObject().name("rule");
    mapping.write(rule, json, null /* TODO replace by SearchOptions immutable constant */);
    json.endObject().close();
  }
View Full Code Here

      queryContext.addFacets(Arrays.asList("languages", "repositories", "tags"));
    }

    Result<Rule> results = ruleService.search(query, queryContext);

    JsonWriter json = response.newJsonWriter().beginObject();
    searchOptions.writeStatistics(json, results);
    writeRules(results, json, searchOptions);
    if (searchOptions.hasField("actives")) {
      activeRuleCompleter.completeSearch(query, results.getHits(), json);
    }
    if (queryContext.isFacet()) {
      writeFacets(results, json);
    }
    json.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.