From 55e0996d14681ebd8faf9a5654adf7b27f658a88 Mon Sep 17 00:00:00 2001 From: Tomas Cere Date: Tue, 7 Apr 2015 11:49:40 +0200 Subject: [PATCH] Stop SubtreeFitler from rereading reply even if no filter element is present. Change-Id: Ib8c28e4289aa0d8b6c228c5daecec713c1c874f3 Signed-off-by: Tomas Cere --- .../netconf/impl/SubtreeFilter.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java index 2e7accad45..566dfde7c3 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java @@ -31,14 +31,6 @@ public class SubtreeFilter { private static final Logger LOG = LoggerFactory.getLogger(SubtreeFilter.class); static Document applySubtreeFilter(Document requestDocument, Document rpcReply) throws NetconfDocumentedException { - // FIXME: rpcReply document must be reread otherwise some nodes do not inherit namespaces. (services/service) - try { - rpcReply = XmlUtil.readXmlToDocument(XmlUtil.toString(rpcReply, true)); - } catch (SAXException | IOException e) { - LOG.error("Cannot transform document", e); - throw new NetconfDocumentedException("Cannot transform document"); - } - OperationNameAndNamespace operationNameAndNamespace = new OperationNameAndNamespace(requestDocument); if (XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0.equals(operationNameAndNamespace.getNamespace()) && XmlNetconfConstants.GET.equals(operationNameAndNamespace.getOperationName()) || @@ -47,16 +39,26 @@ public class SubtreeFilter { // not implement filtering. Optional maybeFilter = operationNameAndNamespace.getOperationElement().getOnlyChildElementOptionally( XmlNetconfConstants.FILTER, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); - if (maybeFilter.isPresent() && ( - "subtree".equals(maybeFilter.get().getAttribute("type"))|| - "subtree".equals(maybeFilter.get().getAttribute("type", XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0))) - ) { + if (!maybeFilter.isPresent()) { + return rpcReply; + } + // FIXME: rpcReply document must be reread otherwise some nodes do not inherit namespaces. (services/service) + try { + rpcReply = XmlUtil.readXmlToDocument(XmlUtil.toString(rpcReply, true)); + } catch (SAXException | IOException e) { + LOG.error("Cannot transform document", e); + throw new NetconfDocumentedException("Cannot transform document" + e); + } + XmlElement filter = maybeFilter.get(); + if ("subtree".equals(filter.getAttribute("type"))|| + "subtree".equals(filter.getAttribute("type", XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0))) { // do return filtered(maybeFilter.get(), rpcReply); } } + return rpcReply; // return identical document } -- 2.36.6