use of com.fasterxml.jackson.core.JsonGenerator in project geode by apache.
the class JSONUtils method formulateJsonForExistingQuery.
public static String formulateJsonForExistingQuery(String queryId, String oql) {
HeapDataOutputStream outputStream = new HeapDataOutputStream(org.apache.geode.internal.Version.CURRENT);
try {
JsonGenerator generator = enableDisableJSONGeneratorFeature(getObjectMapper().getFactory().createGenerator((OutputStream) outputStream, JsonEncoding.UTF8));
JsonWriter.writeQueryAsJson(generator, queryId, oql);
generator.close();
return new String(outputStream.toByteArray());
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
} finally {
outputStream.close();
}
}
use of com.fasterxml.jackson.core.JsonGenerator in project geode by apache.
the class JSONUtils method convertCollectionToJson.
public static String convertCollectionToJson(Collection<Object> collection) throws JSONException {
HeapDataOutputStream outputStream = new HeapDataOutputStream(org.apache.geode.internal.Version.CURRENT);
try {
JsonGenerator generator = enableDisableJSONGeneratorFeature(getObjectMapper().getFactory().createGenerator((OutputStream) outputStream, JsonEncoding.UTF8));
JsonWriter.writeCollectionAsJson(generator, collection);
generator.close();
return new String(outputStream.toByteArray());
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
} finally {
outputStream.close();
}
}
use of com.fasterxml.jackson.core.JsonGenerator in project jackrabbit-oak by apache.
the class GetLastRevisionHandler method handle.
@Override
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
RemoteSession session = (RemoteSession) request.getAttribute("session");
if (session == null) {
sendInternalServerError(response, "session not found");
return;
}
RemoteRevision revision = session.readLastRevision();
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("application/json");
ServletOutputStream stream = response.getOutputStream();
JsonGenerator generator = new JsonFactory().createJsonGenerator(stream, JsonEncoding.UTF8);
generator.writeStartObject();
generator.writeStringField("revision", revision.asString());
generator.writeEndObject();
generator.flush();
stream.close();
}
use of com.fasterxml.jackson.core.JsonGenerator in project jackrabbit-oak by apache.
the class PostBinaryHandler method handle.
@Override
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
RemoteSession session = (RemoteSession) request.getAttribute("session");
if (session == null) {
sendInternalServerError(response, "session not found");
return;
}
RemoteBinaryId binaryId = session.writeBinary(request.getInputStream());
response.setStatus(HttpServletResponse.SC_CREATED);
response.setContentType("application/json");
ServletOutputStream stream = response.getOutputStream();
JsonGenerator generator = new JsonFactory().createJsonGenerator(stream, JsonEncoding.UTF8);
generator.writeStartObject();
generator.writeStringField("binaryId", binaryId.asString());
generator.writeEndObject();
generator.flush();
stream.close();
}
use of com.fasterxml.jackson.core.JsonGenerator in project jackrabbit-oak by apache.
the class JsonRepresentation method render.
@Override
public void render(PropertyState property, HttpServletResponse response) throws IOException {
JsonGenerator generator = startResponse(response);
render(property, generator);
generator.close();
}
Aggregations