From cbf541448455a7736e8ad54baeb17357a8956026 Mon Sep 17 00:00:00 2001 From: Vaclav Demcak Date: Tue, 27 Jan 2015 10:34:01 +0100 Subject: [PATCH] Removing { } from NormalizedNodeJsonBodyWriter We'll not need additional starting|ending Json markers by parsing NormalizedNode to stream anymore. JSON writer has changed to GSON : yangtools - https://git.opendaylight.org/gerrit/#/c/13574/11 Patch Set 2: fix imports Change-Id: I746eaaafa146e6269f2ecc3b1eba6743e717899b Signed-off-by: Vaclav Demcak --- .../impl/NormalizedNodeJsonBodyWriter.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeJsonBodyWriter.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeJsonBodyWriter.java index 7a879f3377..03aa31680b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeJsonBodyWriter.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/NormalizedNodeJsonBodyWriter.java @@ -60,17 +60,16 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter httpHeaders, final OutputStream entityStream) throws IOException, WebApplicationException { NormalizedNode data = t.getData(); - InstanceIdentifierContext context = t.getInstanceIdentifierContext(); - DataSchemaNode schema = context.getSchemaNode(); + final InstanceIdentifierContext context = t.getInstanceIdentifierContext(); + final DataSchemaNode schema = context.getSchemaNode(); SchemaPath path = context.getSchemaNode().getPath(); - OutputStreamWriter outputWriter = new OutputStreamWriter(entityStream, Charsets.UTF_8); + final OutputStreamWriter outputWriter = new OutputStreamWriter(entityStream, Charsets.UTF_8); if (data == null) { throw new RestconfDocumentedException(Response.Status.NOT_FOUND); } boolean isDataRoot = false; URI initialNs = null; - outputWriter.write('{'); if (SchemaPath.ROOT.equals(path)) { isDataRoot = true; } else { @@ -80,8 +79,8 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter> iterator = data.getValue().iterator(); + private void writeDataRoot(final OutputStreamWriter outputWriter, final NormalizedNodeWriter nnWriter, final ContainerNode data) throws IOException { + final Iterator> iterator = data.getValue().iterator(); while(iterator.hasNext()) { - DataContainerChild child = iterator.next(); + final DataContainerChild child = iterator.next(); nnWriter.write(child); nnWriter.flush(); } -- 2.36.6