Bump upstreams
[netconf.git] / protocol / netconf-server / src / main / java / org / opendaylight / netconf / server / 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.server.mapping.operations;
9
10 import org.opendaylight.netconf.api.NamespaceURN;
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.server.NetconfServerSession;
15 import org.opendaylight.netconf.server.api.operations.AbstractSingletonNetconfOperation;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19 import org.w3c.dom.Document;
20 import org.w3c.dom.Element;
21
22 public class DefaultStopExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation {
23     private static final Logger LOG = LoggerFactory.getLogger(DefaultStopExi.class);
24
25     public static final String STOP_EXI = "stop-exi";
26
27     private NetconfServerSession netconfSession = null;
28
29     public DefaultStopExi(final SessionIdType sessionId) {
30         super(sessionId);
31     }
32
33     @Override
34     protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
35         LOG.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement));
36
37         netconfSession.stopExiCommunication();
38
39         Element getSchemaResult = document.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.OK);
40         LOG.trace("{} operation successful", STOP_EXI);
41         return getSchemaResult;
42     }
43
44     @Override
45     protected String getOperationName() {
46         return STOP_EXI;
47     }
48
49     @Override
50     protected String getOperationNamespace() {
51         return NamespaceURN.EXI;
52     }
53
54     @Override
55     public void setNetconfSession(final NetconfServerSession netconfServerSession) {
56         netconfSession = netconfServerSession;
57     }
58 }