use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class SearchAction method handle.
@Override
public void handle(Request request, Response response) {
QgateProjectFinder.Association associations = projectFinder.find(ProjectQgateAssociationQuery.builder().gateId(request.mandatoryParam(QualityGatesWsParameters.PARAM_GATE_ID)).membership(request.param(QualityGatesWsParameters.PARAM_QUERY) == null ? request.param(Param.SELECTED) : ProjectQgateAssociationQuery.ANY).projectSearch(request.param(QualityGatesWsParameters.PARAM_QUERY)).pageIndex(request.paramAsInt(QualityGatesWsParameters.PARAM_PAGE)).pageSize(request.paramAsInt(QualityGatesWsParameters.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(Param.SELECTED, project.isMember()).endObject();
}
writer.endArray().endObject().close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class InstalledAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkIsSystemAdministrator();
Collection<PluginInfo> pluginInfoList = searchPluginInfoList();
JsonWriter jsonWriter = response.newJsonWriter();
jsonWriter.setSerializeEmptys(false);
jsonWriter.beginObject();
List<String> additionalFields = request.paramAsStrings(WebService.Param.FIELDS);
writePluginInfoList(jsonWriter, pluginInfoList, additionalFields == null ? Collections.<String>emptyList() : additionalFields);
jsonWriter.endObject();
jsonWriter.close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class CopyAction method handle.
@Override
public void handle(Request request, Response response) {
QualityGateDto newQualityGate = qualityGates.copy(QualityGatesWs.parseId(request, PARAM_ID), request.mandatoryParam(PARAM_NAME));
JsonWriter writer = response.newJsonWriter();
QualityGatesWs.writeQualityGate(newQualityGate, writer).close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class OldRestoreAction method writeResponse.
private void writeResponse(JsonWriter json, BulkChangeResult result) {
QualityProfileDto profile = result.profile();
if (profile != null) {
String languageKey = profile.getLanguage();
Language language = languages.get(languageKey);
JsonWriter jsonProfile = json.beginObject().name("profile").beginObject();
jsonProfile.prop("key", profile.getKey()).prop("name", profile.getName()).prop("language", languageKey).prop("isDefault", false).prop("isInherited", false);
if (language != null) {
jsonProfile.prop("languageName", language.getName());
}
jsonProfile.endObject();
}
json.prop("ruleSuccesses", result.countSucceeded());
json.prop("ruleFailures", result.countFailed());
json.endObject().close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class RestoreAction method writeResponse.
private void writeResponse(JsonWriter json, BulkChangeResult result) {
QualityProfileDto profile = result.profile();
if (profile != null) {
String languageKey = profile.getLanguage();
Language language = languages.get(languageKey);
JsonWriter jsonProfile = json.beginObject().name("profile").beginObject();
jsonProfile.prop("key", profile.getKey()).prop("name", profile.getName()).prop("language", languageKey).prop("isDefault", false).prop("isInherited", false);
if (language != null) {
jsonProfile.prop("languageName", language.getName());
}
jsonProfile.endObject();
}
json.prop("ruleSuccesses", result.countSucceeded());
json.prop("ruleFailures", result.countFailed());
json.endObject().close();
}
Aggregations