use of org.apache.jena.atlas.json.JsonBuilder in project jena by apache.
the class IRIValidatorJSON method execute.
public static JsonObject execute(ValidationAction action) {
JsonBuilder obj = new JsonBuilder();
obj.startObject();
String[] args = getArgs(action, paramIRI);
if (args.length == 0)
ServletOps.errorBadRequest("No IRIs supplied");
obj.key(jIRIs);
obj.startArray();
for (String iriStr : args) {
obj.startObject();
obj.key(jIRI).value(iriStr);
IRI iri = iriFactory.create(iriStr);
List<String> errors = new ArrayList<>();
List<String> warnings = new ArrayList<>();
if (iri.isRelative())
warnings.add("Relative IRI: " + iriStr);
Iterator<Violation> vIter = iri.violations(true);
for (; vIter.hasNext(); ) {
Violation v = vIter.next();
String str = v.getShortMessage();
if (v.isError())
errors.add(str);
else
warnings.add(str);
}
obj.key(jErrors);
obj.startArray();
for (String msg : errors) obj.value(msg);
obj.finishArray();
obj.key(jWarnings);
obj.startArray();
for (String msg : warnings) obj.value(msg);
obj.finishArray();
obj.finishObject();
}
obj.finishArray();
obj.finishObject();
return obj.build().getAsObject();
}
use of org.apache.jena.atlas.json.JsonBuilder in project jena by apache.
the class UploadDetails method detailsJson.
public static JsonValue detailsJson(long count, long tripleCount, long quadCount) {
JsonBuilder b = new JsonBuilder();
b.startObject("details");
b.key(jCount).value(count);
b.key(jTriplesCount).value(tripleCount);
b.key(jQuadsCount).value(quadCount);
b.finishObject("details");
return b.build();
}
use of org.apache.jena.atlas.json.JsonBuilder in project jena by apache.
the class Async method asJson.
public static JsonValue asJson(AsyncTask asyncTask) {
JsonBuilder builder = new JsonBuilder();
builder.startObject("outer");
builder.key(JsonConst.taskId).value(asyncTask.getTaskId());
if (asyncTask.getOriginatingRequestId() > 0)
builder.key(JsonConst.taskRequestId).value(asyncTask.getOriginatingRequestId());
builder.finishObject("outer");
return builder.build();
}
use of org.apache.jena.atlas.json.JsonBuilder in project jena by apache.
the class StoreParamsCodec method encodeToJson.
public static JsonObject encodeToJson(StoreParams params) {
JsonBuilder builder = new JsonBuilder();
// "StoreParams" is an internal alignment marker - not in the JSON.
builder.startObject("StoreParams");
encode(builder, key(fFileMode), params.getFileMode().name());
encode(builder, key(fBlockSize), params.getBlockSize());
encode(builder, key(fBlockReadCacheSize), params.getBlockReadCacheSize());
encode(builder, key(fBlockWriteCacheSize), params.getBlockWriteCacheSize());
encode(builder, key(fNode2NodeIdCacheSize), params.getNode2NodeIdCacheSize());
encode(builder, key(fNodeId2NodeCacheSize), params.getNodeId2NodeCacheSize());
encode(builder, key(fNodeMissCacheSize), params.getNodeMissCacheSize());
encode(builder, key(fIndexNode2Id), params.getIndexNode2Id());
encode(builder, key(fIndexId2Node), params.getIndexId2Node());
encode(builder, key(fPrimaryIndexTriples), params.getPrimaryIndexTriples());
encode(builder, key(fTripleIndexes), params.getTripleIndexes());
encode(builder, key(fPrimaryIndexQuads), params.getPrimaryIndexQuads());
encode(builder, key(fQuadIndexes), params.getQuadIndexes());
encode(builder, key(fPrimaryIndexPrefix), params.getPrimaryIndexPrefix());
encode(builder, key(fPrefixIndexes), params.getPrefixIndexes());
encode(builder, key(fIndexPrefix), params.getIndexPrefix());
encode(builder, key(fPrefixNode2Id), params.getPrefixNode2Id());
encode(builder, key(fPrefixId2Node), params.getPrefixId2Node());
builder.finishObject("StoreParams");
return (JsonObject) builder.build();
}
use of org.apache.jena.atlas.json.JsonBuilder 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();
}
Aggregations