use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class AvailableAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkIsSystemAdministrator();
JsonWriter jsonWriter = response.newJsonWriter();
jsonWriter.beginObject();
Optional<UpdateCenter> updateCenter = updateCenterFactory.getUpdateCenter(DO_NOT_FORCE_REFRESH);
writePlugins(jsonWriter, updateCenter);
pluginWSCommons.writeUpdateCenterProperties(jsonWriter, updateCenter);
jsonWriter.endObject();
jsonWriter.close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class QPMeasureData method toJson.
public static String toJson(QPMeasureData data) {
StringWriter json = new StringWriter();
try (JsonWriter writer = JsonWriter.of(json)) {
writer.beginArray();
for (QualityProfile profile : data.getProfiles()) {
writer.beginObject().prop("key", profile.getQpKey()).prop("language", profile.getLanguageKey()).prop("name", profile.getQpName()).prop("rulesUpdatedAt", UtcDateUtils.formatDateTime(profile.getRulesUpdatedAt())).endObject();
}
writer.endArray();
}
return json.toString();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class IndexAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
List<ComponentDto> projects = getAuthorizedComponents(dbSession, searchComponents(dbSession, request));
JsonWriter json = response.newJsonWriter();
json.beginArray();
for (ComponentDto project : projects) {
addProject(json, project);
}
json.endArray();
json.close();
}
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class ProvisionedAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkLoggedIn();
SearchOptions options = new SearchOptions().setPage(request.mandatoryParamAsInt(Param.PAGE), request.mandatoryParamAsInt(Param.PAGE_SIZE));
Set<String> desiredFields = desiredFields(request);
String query = request.param(Param.TEXT_QUERY);
try (DbSession dbSession = dbClient.openSession(false)) {
OrganizationDto organization = support.getOrganization(dbSession, request.getParam(PARAM_ORGANIZATION).or(defaultOrganizationProvider.get()::getKey));
userSession.checkPermission(PROVISION_PROJECTS, organization);
RowBounds rowBounds = new RowBounds(options.getOffset(), options.getLimit());
List<ComponentDto> projects = dbClient.componentDao().selectProvisioned(dbSession, organization.getUuid(), query, QUALIFIERS_FILTER, rowBounds);
int nbOfProjects = dbClient.componentDao().countProvisioned(dbSession, organization.getUuid(), query, QUALIFIERS_FILTER);
JsonWriter json = response.newJsonWriter().beginObject();
writeProjects(projects, json, desiredFields);
options.writeJson(json, nbOfProjects);
json.endObject().close();
}
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class RenameAction method handle.
@Override
public void handle(Request request, Response response) {
long idToRename = QualityGatesWs.parseId(request, QualityGatesWsParameters.PARAM_ID);
QualityGateDto renamedQualityGate = qualityGates.rename(idToRename, request.mandatoryParam(QualityGatesWsParameters.PARAM_NAME));
JsonWriter writer = response.newJsonWriter();
QualityGatesWs.writeQualityGate(renamedQualityGate, writer).close();
}
Aggregations