Search in sources :

Example 11 with JsonValue

use of org.apache.jena.atlas.json.JsonValue in project jena by apache.

the class TestAdmin method checkExistsNotActive.

private static void checkExistsNotActive(String name) {
    adminPing(name);
    try {
        askPing(name);
        fail("askPing did not cause an Http Exception");
    } catch (HttpException ex) {
    }
    JsonValue v = getDatasetDescription(name);
    assertFalse(v.getAsObject().get("ds.state").getAsBoolean().value());
}
Also used : JsonValue(org.apache.jena.atlas.json.JsonValue) HttpException(org.apache.jena.atlas.web.HttpException)

Example 12 with JsonValue

use of org.apache.jena.atlas.json.JsonValue in project jena by apache.

the class TestAdmin method list_backups_1.

@Test
public void list_backups_1() {
    try (TypedInputStream in = execHttpGet(ServerCtl.urlRoot() + "$/" + opListBackups)) {
        assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType());
        JsonValue v = JSON.parseAny(in);
        assertNotNull(v.getAsObject().get("backups"));
    }
}
Also used : JsonValue(org.apache.jena.atlas.json.JsonValue) TypedInputStream(org.apache.jena.atlas.web.TypedInputStream) Test(org.junit.Test)

Example 13 with JsonValue

use of org.apache.jena.atlas.json.JsonValue in project jena by apache.

the class json method main.

public static void main(String... args) {
    if (args.length == 0)
        args = new String[] { "-" };
    try {
        for (String fn : args) {
            JsonValue json = null;
            try {
                json = JSON.readAny(fn);
            } catch (JsonParseException ex) {
                String name = fn.equals("-") ? "<stdin>" : fn;
                System.err.println(name + ": " + JsonParseException.formatMessage(ex.getMessage(), ex.getLine(), ex.getColumn()));
                continue;
            }
            JSON.write(IndentedWriter.stdout, json);
            IndentedWriter.stdout.ensureStartOfLine();
        }
    } finally {
        IndentedWriter.stdout.flush();
    }
}
Also used : JsonValue(org.apache.jena.atlas.json.JsonValue) JsonParseException(org.apache.jena.atlas.json.JsonParseException)

Example 14 with JsonValue

use of org.apache.jena.atlas.json.JsonValue in project jena by apache.

the class ActionServerStatus method description.

private void description(HttpAction action) throws IOException {
    ServletOutputStream out = action.response.getOutputStream();
    action.response.setContentType(contentTypeJSON);
    action.response.setCharacterEncoding(charsetUTF8);
    JsonBuilder builder = new JsonBuilder();
    builder.startObject();
    describeServer(builder, action.request.getLocalPort());
    describeDatasets(builder, action.getDataAccessPointRegistry());
    builder.finishObject();
    JsonValue v = builder.build();
    JSON.write(out, v);
    out.println();
    out.flush();
}
Also used : JsonBuilder(org.apache.jena.atlas.json.JsonBuilder) ServletOutputStream(javax.servlet.ServletOutputStream) JsonValue(org.apache.jena.atlas.json.JsonValue)

Example 15 with JsonValue

use of org.apache.jena.atlas.json.JsonValue in project jena by apache.

the class ActionSleep method perform.

@Override
protected void perform(HttpAction action) {
    Runnable task = createRunnable(action);
    AsyncTask aTask = Async.execASyncTask(action, AsyncPool.get(), "sleep", task);
    JsonValue v = Async.asJson(aTask);
    Async.setLocationHeader(action, aTask);
    ServletOps.sendJsonReponse(action, v);
}
Also used : AsyncTask(org.apache.jena.fuseki.async.AsyncTask) JsonValue(org.apache.jena.atlas.json.JsonValue)

Aggregations

JsonValue (org.apache.jena.atlas.json.JsonValue)28 Test (org.junit.Test)7 JsonArray (org.apache.jena.atlas.json.JsonArray)4 JsonObject (org.apache.jena.atlas.json.JsonObject)4 TypedInputStream (org.apache.jena.atlas.web.TypedInputStream)3 JsonBuilder (org.apache.jena.atlas.json.JsonBuilder)2 AsyncTask (org.apache.jena.fuseki.async.AsyncTask)2 ServletOutputStream (javax.servlet.ServletOutputStream)1 JsonParseException (org.apache.jena.atlas.json.JsonParseException)1 JsonString (org.apache.jena.atlas.json.JsonString)1 HttpException (org.apache.jena.atlas.web.HttpException)1 AsyncPool (org.apache.jena.fuseki.async.AsyncPool)1 Node (org.apache.jena.graph.Node)1 LabelToNode (org.apache.jena.riot.lang.LabelToNode)1 Var (org.apache.jena.sparql.core.Var)1 BindingMap (org.apache.jena.sparql.engine.binding.BindingMap)1