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