- public void writeTo(StructuredData t, Class<?> type, Type genericType, Annotation[] annotations,
- MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
- throws IOException, WebApplicationException {
- JsonWriter writer = new JsonWriter(new OutputStreamWriter(entityStream, "UTF-8"));
- writer.setIndent(" ");
- JsonMapper jsonMapper = new JsonMapper();
- jsonMapper.write(writer, t.getData(), (DataNodeContainer) t.getSchema());
+ public void writeTo(final StructuredData t, final Class<?> type, final Type genericType, final Annotation[] annotations,
+ final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream)
+ throws IOException, WebApplicationException {
+ CompositeNode data = t.getData();
+ if (data == null) {
+ throw new RestconfDocumentedException(Response.Status.NOT_FOUND);
+ }
+
+ JsonWriter writer = new JsonWriter(new OutputStreamWriter(entityStream, Charsets.UTF_8));
+
+ if (t.isPrettyPrintMode()) {
+ writer.setIndent(" ");
+ } else {
+ writer.setIndent("");
+ }
+ JsonMapper jsonMapper = new JsonMapper(t.getMountPoint());
+ jsonMapper.write(writer, data, (DataNodeContainer) t.getSchema());