Merge "Take advantage of MultipartTransactionAware"
[controller.git] / opendaylight / netconf / netconf-impl / src / main / java / org / opendaylight / controller / netconf / impl / mapping / operations / DefaultGetSchema.java
index 3e65ed8842f5a0d58fd7d46d7f47f13fbd9b8230..a81bbd62a02a83a5d34fb850d01d9f1f90aa4882 100644 (file)
@@ -8,13 +8,12 @@
 
 package org.opendaylight.controller.netconf.impl.mapping.operations;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.api.NetconfOperationRouter;
 import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
-import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
-import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation;
+import org.opendaylight.controller.netconf.util.mapping.AbstractLastNetconfOperation;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
@@ -23,37 +22,34 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import java.util.HashMap;
-import java.util.Map;
-
-public final class DefaultGetSchema extends AbstractNetconfOperation {
+import com.google.common.base.Optional;
+import com.google.common.collect.Maps;
 
-    private final CapabilityProvider cap;
+public final class DefaultGetSchema extends AbstractLastNetconfOperation {
+    public static final String GET_SCHEMA = "get-schema";
+    public static final String IDENTIFIER = "identifier";
+    public static final String VERSION = "version";
 
     private static final Logger logger = LoggerFactory.getLogger(DefaultGetSchema.class);
+    private final CapabilityProvider cap;
 
     public DefaultGetSchema(CapabilityProvider cap, String netconfSessionIdForReporting) {
         super(netconfSessionIdForReporting);
         this.cap = cap;
     }
 
-    public static final String GET_SCHEMA = "get-schema";
-    public static final String IDENTIFIER = "identifier";
-    public static final String VERSION = "version";
-
     @Override
-    protected HandlingPriority canHandle(String netconfOperationName, String namespace) {
-        if (netconfOperationName.equals("get-schema") == false)
-            return HandlingPriority.CANNOT_HANDLE;
-        if (namespace.equals(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_YANG_IETF_NETCONF_MONITORING) == false)
-            return HandlingPriority.CANNOT_HANDLE;
+    protected String getOperationName() {
+        return GET_SCHEMA;
+    }
 
-        return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;
+    @Override
+    protected String getOperationNamespace() {
+        return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_YANG_IETF_NETCONF_MONITORING;
     }
 
     @Override
-    protected Element handle(Document document, XmlElement xml, NetconfOperationRouter router)
-            throws NetconfDocumentedException {
+    protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws NetconfDocumentedException {
         GetSchemaEntry entry;
 
         try {
@@ -91,7 +87,7 @@ public final class DefaultGetSchema extends AbstractNetconfOperation {
         XmlUtil.addNamespaceAttr(getSchemaResult,
                 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_YANG_IETF_NETCONF_MONITORING);
 
-        logger.info("{} operation successful", GET_SCHEMA);
+        logger.trace("{} operation successful", GET_SCHEMA);
 
         return getSchemaResult;
     }
@@ -113,7 +109,6 @@ public final class DefaultGetSchema extends AbstractNetconfOperation {
             } else {
                 version = Optional.absent();
             }
-
         }
     }
 }