Bug 5898 - PATCH success "ok" field has wrong JSON value 23/41123/1
authorIvan Hrasko <ihrasko@cisco.com>
Thu, 30 Jun 2016 08:54:05 +0000 (10:54 +0200)
committerIvan Hrasko <ihrasko@cisco.com>
Thu, 30 Jun 2016 08:54:05 +0000 (10:54 +0200)
- empty value is represented as an array with value null

Change-Id: Ie8315d5a18756fd12d3b7a7de693dfd1c569945a
Signed-off-by: Ivan Hrasko <ihrasko@cisco.com>
opendaylight/restconf/sal-rest-connector/src/main/java/org/opendaylight/netconf/sal/rest/impl/PATCHJsonBodyWriter.java

index 9f9ab949339890eaeb4de347ab2214cea15fe97e..70237df1f7680054ed44b70bbacfd7a2ad6b8a3a 100644 (file)
@@ -54,7 +54,7 @@ public class PATCHJsonBodyWriter implements MessageBodyWriter<PATCHStatusContext
         jsonWriter.beginObject();
         jsonWriter.name("patch-id").value(patchStatusContext.getPatchId());
         if (patchStatusContext.isOk()) {
-            jsonWriter.name("ok").nullValue();
+            reportSuccess(jsonWriter);
         } else {
             if (patchStatusContext.getGlobalErrors() != null) {
                 reportErrors(patchStatusContext.getGlobalErrors(), jsonWriter);
@@ -71,7 +71,7 @@ public class PATCHJsonBodyWriter implements MessageBodyWriter<PATCHStatusContext
                     reportErrors(patchStatusEntity.getEditErrors(), jsonWriter);
                 } else {
                     if (patchStatusEntity.isOk()) {
-                        jsonWriter.name("ok").nullValue();
+                        reportSuccess(jsonWriter);
                     }
                 }
                 jsonWriter.endObject();
@@ -85,6 +85,10 @@ public class PATCHJsonBodyWriter implements MessageBodyWriter<PATCHStatusContext
 
     }
 
+    private void reportSuccess(JsonWriter jsonWriter) throws IOException {
+        jsonWriter.name("ok").beginArray().nullValue().endArray();
+    }
+
     private static void reportErrors(List<RestconfError> errors, JsonWriter jsonWriter) throws IOException {
         jsonWriter.name("errors");
         jsonWriter.beginObject();