use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class ShowAction method handle.
@Override
public void handle(Request request, Response response) {
Long qGateId = request.paramAsLong(QualityGatesWsParameters.PARAM_ID);
String qGateName = request.param(QualityGatesWsParameters.PARAM_NAME);
checkOneOfIdOrNamePresent(qGateId, qGateName);
QualityGateDto qGate = qGateId == null ? qualityGates.get(qGateName) : qualityGates.get(qGateId);
qGateId = qGate.getId();
JsonWriter writer = response.newJsonWriter().beginObject().prop(QualityGatesWsParameters.PARAM_ID, qGate.getId()).prop(QualityGatesWsParameters.PARAM_NAME, qGate.getName());
Collection<QualityGateConditionDto> conditions = qualityGates.listConditions(qGateId);
if (!conditions.isEmpty()) {
writer.name("conditions").beginArray();
for (QualityGateConditionDto condition : conditions) {
QualityGatesWs.writeQualityGateCondition(condition, writer);
}
writer.endArray();
}
writer.endObject().close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class ExportersAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
JsonWriter json = response.newJsonWriter().beginObject().name("exporters").beginArray();
for (ProfileExporter exporter : exporters) {
json.beginObject().prop("key", exporter.getKey()).prop("name", exporter.getName());
json.name("languages").beginArray();
for (String language : exporter.getSupportedLanguages()) {
json.value(language);
}
json.endArray().endObject();
}
json.endArray().endObject().close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class ImportersAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
JsonWriter json = response.newJsonWriter().beginObject().name("importers").beginArray();
for (ProfileImporter importer : importers) {
json.beginObject().prop("key", importer.getKey()).prop("name", importer.getName()).name("languages").beginArray();
for (String languageKey : importer.getSupportedLanguages()) {
json.value(languageKey);
}
json.endArray().endObject();
}
json.endArray().endObject().close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class ComponentAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
String componentKey = request.mandatoryParam(PARAM_COMPONENT_KEY);
try (DbSession session = dbClient.openSession(false)) {
ComponentDto component = componentFinder.getByKey(session, componentKey);
if (!userSession.hasComponentPermission(USER, component) && !userSession.hasComponentPermission(ADMIN, component) && !userSession.isSystemAdministrator()) {
throw insufficientPrivilegesException();
}
OrganizationDto org = componentFinder.getOrganization(session, component);
Optional<SnapshotDto> analysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(session, component.projectUuid());
JsonWriter json = response.newJsonWriter();
json.beginObject();
writeComponent(json, session, component, org, analysis.orElse(null));
writeProfiles(json, session, component);
writeQualityGate(json, session, component);
if (userSession.hasComponentPermission(ADMIN, component) || userSession.hasPermission(ADMINISTER_QUALITY_PROFILES, org) || userSession.hasPermission(ADMINISTER_QUALITY_GATES, org)) {
writeConfiguration(json, component);
}
writeBreadCrumbs(json, session, component);
json.endObject().close();
}
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class GlobalAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
JsonWriter json = response.newJsonWriter().beginObject();
writePages(json);
writeSettings(json);
writeDeprecatedLogoProperties(json);
writeQualifiers(json);
writeVersion(json);
writeDatabaseProduction(json);
writeOrganizationSupport(json);
json.endObject().close();
}
Aggregations