BUG-472 Initial EXI encoder/decoder implementation in Netconf
[controller.git] / opendaylight / netconf / netconf-impl / src / main / java / org / opendaylight / controller / netconf / impl / mapping / operations / DefaultStopExi.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.controller.netconf.impl.mapping.operations;\r
9 \r
10 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;\r
11 import org.opendaylight.controller.netconf.impl.NetconfServerSession;\r
12 import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation;\r
13 import org.opendaylight.controller.netconf.util.xml.XmlElement;\r
14 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;\r
15 import org.opendaylight.controller.netconf.util.xml.XmlUtil;\r
16 import org.slf4j.Logger;\r
17 import org.slf4j.LoggerFactory;\r
18 import org.w3c.dom.Document;\r
19 import org.w3c.dom.Element;\r
20 \r
21 public class DefaultStopExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation {\r
22 \r
23     public static final String STOP_EXI = "stop-exi";\r
24     private NetconfServerSession netconfSession;\r
25 \r
26     private static final Logger logger = LoggerFactory\r
27             .getLogger(DefaultStartExi.class);\r
28 \r
29     public DefaultStopExi(String netconfSessionIdForReporting) {\r
30         super(netconfSessionIdForReporting);\r
31     }\r
32 \r
33     @Override\r
34     protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {\r
35         logger.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement));\r
36 \r
37         netconfSession.stopExiCommunication();\r
38 \r
39         Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);\r
40         logger.trace("{} operation successful", STOP_EXI);\r
41         return getSchemaResult;\r
42     }\r
43 \r
44     @Override\r
45     protected String getOperationName() {\r
46         return STOP_EXI;\r
47     }\r
48 \r
49     @Override\r
50     protected String getOperationNamespace() {\r
51         return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0;\r
52     }\r
53 \r
54     @Override\r
55     public void setNetconfSession(NetconfServerSession s) {\r
56         this.netconfSession = s;\r
57     }\r
58 }\r