use of org.apache.jena.atlas.json.JsonValue in project jena by apache.
the class ActionTasks method execGet.
private void execGet(HttpAction action, String name) {
if (name == null)
log.info(format("[%d] Tasks", action.id));
else
log.info(format("[%d] Task %s", action.id, name));
JsonValue responseBody = null;
if (name == null) {
JsonBuilder builder = new JsonBuilder();
builder.startArray();
for (AsyncPool pool : pools) {
for (AsyncTask aTask : pool.tasks()) {
//builder.value(aTask.getTaskId()) ;
descOneTask(builder, aTask);
}
}
builder.finishArray();
responseBody = builder.build();
} else {
for (AsyncPool pool : pools) {
// Assumes first is only.
AsyncTask aTask = pool.getTask(name);
if (aTask != null) {
JsonBuilder builder = new JsonBuilder();
descOneTask(builder, aTask);
responseBody = builder.build();
}
}
}
if (responseBody == null)
ServletOps.errorNotFound("Task '" + name + "' not found");
ServletOps.setNoCache(action);
ServletOps.sendJsonReponse(action, responseBody);
}
use of org.apache.jena.atlas.json.JsonValue in project jena by apache.
the class LibJsonTest method read.
/** Round trip string->json->string->json, compare two JOSN steps */
public static void read(String string) {
JsonValue v = JSON.parseAny(string);
writeRead(v);
}
use of org.apache.jena.atlas.json.JsonValue in project jena by apache.
the class ServletOps method uploadResponse.
/** response to a upload operation of some kind. */
public static void uploadResponse(HttpAction action, UploadDetails details) {
if (details.getExistedBefore().equals(PreState.ABSENT))
ServletOps.successCreated(action);
else
// successNoContent if empty body.
ServletOps.success(action);
JsonValue v = details.detailsJson();
ServletOps.sendJson(action, v);
}
use of org.apache.jena.atlas.json.JsonValue in project jena by apache.
the class TestAdmin method task_4.
@Test
public void task_4() {
// Timing dependent.
// Create a "short" running task
String x = execSleepTask(null, 1);
// Check exists in the list of all tasks (should be "finished")
checkInTasks(x);
String url = ServerCtl.urlRoot() + "$/tasks/" + x;
boolean finished = false;
for (int i = 0; i < 10; i++) {
if (i != 0)
Lib.sleep(25);
JsonValue v = httpGetJson(url);
checkTask(v);
if (v.getAsObject().hasKey("finished")) {
finished = true;
break;
}
}
if (!finished)
fail("Task has not finished");
}
use of org.apache.jena.atlas.json.JsonValue in project jena by apache.
the class TestAdmin method checkJsonDatasetsAll.
private static void checkJsonDatasetsAll(JsonValue v) {
assertNotNull(v.getAsObject().get("datasets"));
JsonArray a = v.getAsObject().get("datasets").getAsArray();
for (JsonValue v2 : a) checkJsonDatasetsOne(v2);
}
Aggregations