Decouple config and netconf subsystems.
[controller.git] / opendaylight / netconf / netconf-util / src / main / java / org / opendaylight / controller / netconf / util / mapping / AbstractLastNetconfOperation.java
index d6d57c50aceabf543bcc367bb8022ccc79b1ec72..96553a4defb6d221acd38837b28129ec271950fa 100644 (file)
@@ -7,15 +7,13 @@
  */
 package org.opendaylight.controller.netconf.util.mapping;
 
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import com.google.common.base.Preconditions;
-
 public abstract class AbstractLastNetconfOperation extends AbstractNetconfOperation {
 
     protected AbstractLastNetconfOperation(String netconfSessionIdForReporting) {
@@ -24,9 +22,13 @@ public abstract class AbstractLastNetconfOperation extends AbstractNetconfOperat
 
     @Override
     protected Element handle(Document document, XmlElement operationElement,
-            NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
-        Preconditions.checkArgument(subsequentOperation.isExecutionTermination(),
-                "No netconf operation expected to be subsequent to %s, but is %s", this, subsequentOperation);
+            NetconfOperationChainedExecution subsequentOperation) throws DocumentedException {
+        if (!subsequentOperation.isExecutionTermination()){
+            throw new DocumentedException(String.format("No netconf operation expected to be subsequent to %s, but is %s", this, subsequentOperation),
+                    DocumentedException.ErrorType.application,
+                    DocumentedException.ErrorTag.malformed_message,
+                    DocumentedException.ErrorSeverity.error);
+        }
 
         return handleWithNoSubsequentOperations(document, operationElement);
     }
@@ -36,5 +38,5 @@ public abstract class AbstractLastNetconfOperation extends AbstractNetconfOperat
         return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;
     }
 
-    protected abstract Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException;
+    protected abstract Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws DocumentedException;
 }