- Added exi capability utilities, handlers and necessary modifications
[controller.git] / opendaylight / netconf / netconf-impl / src / main / java / org / opendaylight / controller / netconf / impl / mapping / operations / DefaultStopExi.java
diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java
new file mode 100644 (file)
index 0000000..98a7205
--- /dev/null
@@ -0,0 +1,73 @@
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.controller.netconf.impl.mapping.operations;\r
+\r
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;\r
+import org.opendaylight.controller.netconf.api.NetconfOperationRouter;\r
+import org.opendaylight.controller.netconf.api.NetconfSession;\r
+import org.opendaylight.controller.netconf.impl.mapping.ExiDecoderHandler;\r
+import org.opendaylight.controller.netconf.impl.mapping.ExiEncoderHandler;\r
+import org.opendaylight.controller.netconf.mapping.api.DefaultNetconfOperation;\r
+import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;\r
+import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation;\r
+import org.opendaylight.controller.netconf.util.xml.XmlElement;\r
+import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;\r
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+\r
+public class DefaultStopExi extends AbstractNetconfOperation implements DefaultNetconfOperation {\r
+\r
+    public static final String STOP_EXI = "stop-exi";\r
+    private NetconfSession netconfSession;\r
+\r
+    private static final Logger logger = LoggerFactory\r
+            .getLogger(DefaultStartExi.class);\r
+\r
+    public DefaultStopExi(String netconfSessionIdForReporting) {\r
+        super(netconfSessionIdForReporting);\r
+    }\r
+\r
+    @Override\r
+    protected HandlingPriority canHandle(String operationName,\r
+            String netconfOperationNamespace) {\r
+        if (operationName.equals(STOP_EXI) == false)\r
+            return HandlingPriority.CANNOT_HANDLE;\r
+        if (netconfOperationNamespace\r
+                .equals(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0) == false)\r
+            return HandlingPriority.CANNOT_HANDLE;\r
+\r
+        return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;\r
+    }\r
+\r
+    @Override\r
+    protected Element handle(Document document, XmlElement operationElement,\r
+            NetconfOperationRouter opRouter) throws NetconfDocumentedException {\r
+\r
+        netconfSession.remove(ExiDecoderHandler.class);\r
+        netconfSession.removeAfterMessageSent(ExiEncoderHandler.HANDLER_NAME);\r
+\r
+        Element getSchemaResult = document.createElement(XmlNetconfConstants.OK);\r
+        XmlUtil.addNamespaceAttr(getSchemaResult,\r
+                XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);\r
+        logger.info("{} operation successful", STOP_EXI);\r
+        logger.debug("received stop-exi message {} ", XmlUtil.toString(document));\r
+        return getSchemaResult;\r
+    }\r
+\r
+    @Override\r
+    public void setNetconfSession(NetconfSession s) {\r
+        this.netconfSession = s;\r
+    }\r
+\r
+    public NetconfSession getNetconfSession() {\r
+        return netconfSession;\r
+    }\r
+}
\ No newline at end of file