use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class DbMigrationStatusAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
Optional<Long> currentVersion = databaseVersion.getVersion();
checkState(currentVersion.isPresent(), NO_CONNECTION_TO_DB);
JsonWriter json = response.newJsonWriter();
try {
DatabaseVersion.Status status = databaseVersion.getStatus();
if (status == DatabaseVersion.Status.UP_TO_DATE || status == DatabaseVersion.Status.REQUIRES_DOWNGRADE) {
write(json, databaseMigrationState);
} else if (!database.getDialect().supportsMigration()) {
writeNotSupportedResponse(json);
} else {
switch(databaseMigrationState.getStatus()) {
case RUNNING:
case FAILED:
case SUCCEEDED:
write(json, databaseMigrationState);
break;
case NONE:
writeMigrationRequiredResponse(json);
break;
default:
throw new IllegalArgumentException(UNSUPPORTED_DATABASE_MIGRATION_STATUS);
}
}
} finally {
json.close();
}
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class PendingAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkIsSystemAdministrator();
ImmutableMap<String, Plugin> compatiblePluginsByKey = compatiblePluginsByKey(updateCenterMatrixFactory);
JsonWriter jsonWriter = response.newJsonWriter();
jsonWriter.beginObject();
writePlugins(jsonWriter, compatiblePluginsByKey);
jsonWriter.endObject();
jsonWriter.close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class BulkRuleActivationActions method writeResponse.
private static void writeResponse(BulkChangeResult result, Response response) {
JsonWriter json = response.newJsonWriter().beginObject();
json.prop("succeeded", result.countSucceeded());
json.prop("failed", result.countFailed());
writeErrors(json, result.getErrors());
json.endObject().close();
}
use of org.sonar.api.utils.text.JsonWriter in project sonarqube by SonarSource.
the class ListAction method handle.
@Override
public void handle(Request request, Response response) {
JsonWriter writer = response.newJsonWriter().beginObject().name("qualitygates").beginArray();
for (QualityGateDto qgate : qualityGates.list()) {
QualityGatesWs.writeQualityGate(qgate, writer);
}
writer.endArray();
QualityGateDto defaultQgate = qualityGates.getDefault();
if (defaultQgate != null) {
writer.prop("default", defaultQgate.getId());
}
writer.endObject().close();
}
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 {
request.param(PARAM_FORMAT);
JsonWriter json = response.newJsonWriter();
json.beginArray();
doHandle(json, request);
json.endArray();
json.close();
}
Aggregations