Return Location in resp header for notif subscrip 31/91731/1
authorJamo Luhrsen <jluhrsen@gmail.com>
Fri, 31 Jul 2020 19:24:22 +0000 (12:24 -0700)
committerJamo Luhrsen <jluhrsen@gmail.com>
Sat, 1 Aug 2020 16:17:43 +0000 (16:17 +0000)
For rfc8040 responses we are not getting the Location
returned in the response header. This addresses that.

Pulling this work from master commit in work for NETCONF-312
This patch https://git.opendaylight.org/gerrit/c/netconf/+/90371

JIRA: NETCONF-676

Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com>
Change-Id: Ia84da3b9cf0789328af72607c8f739ff81c331a4

restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/NormalizedNodeJsonBodyWriter.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/NormalizedNodeXmlBodyWriter.java

index 67fea4db2f9cb68f8d4943f2e71c051f46dfe1d1..ec3df98aea5ea04074ccd2fc45c45e5c04fbbf01 100644 (file)
@@ -17,6 +17,7 @@ import java.lang.reflect.Type;
 import java.net.URI;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
@@ -95,6 +96,12 @@ public class NormalizedNodeJsonBodyWriter implements MessageBodyWriter<Normalize
             jsonWriter.endObject();
             jsonWriter.flush();
         }
+
+        if (httpHeaders != null) {
+            for (final Map.Entry<String, Object> entry : context.getNewHeaders().entrySet()) {
+                httpHeaders.add(entry.getKey(), entry.getValue());
+            }
+        }
     }
 
     private static void writeNormalizedNode(final JsonWriter jsonWriter,
index 9d849ec565001c49b76a495bc53c00cfea3f3ab1..a89caa90c96a20e3698c5d79ad466f66320f44b9 100644 (file)
@@ -14,6 +14,7 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import javanet.staxutils.IndentingXMLStreamWriter;
 import javax.ws.rs.Produces;
@@ -84,6 +85,11 @@ public class NormalizedNodeXmlBodyWriter implements MessageBodyWriter<Normalized
         if (context.getData() == null) {
             return;
         }
+        if (httpHeaders != null) {
+            for (final Map.Entry<String, Object> entry : context.getNewHeaders().entrySet()) {
+                httpHeaders.add(entry.getKey(), entry.getValue());
+            }
+        }
 
         XMLStreamWriter xmlWriter;
         try {