Merge "BUG-1105: Implement subtree filtering in netconf"
[controller.git] / opendaylight / netconf / netconf-monitoring / src / main / java / org / opendaylight / controller / netconf / monitoring / Get.java
index 1b32b52e53476917e4ca57b6f25905fcc5bbd537..c277e20553fb3ed469c9f849d624f795f0acf635 100644 (file)
@@ -7,8 +7,7 @@
  */
 package org.opendaylight.controller.netconf.monitoring;
 
-import java.util.Map;
-
+import com.google.common.collect.Maps;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
@@ -24,8 +23,7 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
+import java.util.Map;
 
 public class Get extends AbstractNetconfOperation {
 
@@ -37,9 +35,10 @@ public class Get extends AbstractNetconfOperation {
         this.netconfMonitor = netconfMonitor;
     }
 
-    private Element getPlaceholder(Document innerResult) {
+    private Element getPlaceholder(Document innerResult) throws NetconfDocumentedException {
         try {
-            XmlElement rootElement = XmlElement.fromDomElementWithExpected(innerResult.getDocumentElement(),
+            XmlElement rootElement = null;
+            rootElement = XmlElement.fromDomElementWithExpected(innerResult.getDocumentElement(),
                     XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.RFC4741_TARGET_NAMESPACE);
             return rootElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY).getDomElement();
         } catch (RuntimeException e) {
@@ -63,8 +62,12 @@ public class Get extends AbstractNetconfOperation {
     @Override
     public Document handle(Document requestMessage, NetconfOperationChainedExecution subsequentOperation)
             throws NetconfDocumentedException {
-        Preconditions.checkArgument(subsequentOperation.isExecutionTermination() == false,
-                "Subsequent netconf operation expected by %s", this);
+        if (subsequentOperation.isExecutionTermination()){
+            throw new NetconfDocumentedException(String.format("Subsequent netconf operation expected by %s", this),
+                    NetconfDocumentedException.ErrorType.application,
+                    NetconfDocumentedException.ErrorTag.operation_failed,
+                    NetconfDocumentedException.ErrorSeverity.error);
+        }
 
         try {
             Document innerResult = subsequentOperation.execute(requestMessage);