ed23a75204608ed8db360ed9cd1d84c382b456b0
[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     private NetconfServerSession netconfSession;
27
28     public DefaultStopExi(final SessionIdType sessionId) {
29         super(sessionId);
30     }
31
32     @Override
33     protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
34         LOG.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement));
35
36         netconfSession.stopExiCommunication();
37
38         Element getSchemaResult = document.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.OK);
39         LOG.trace("{} operation successful", STOP_EXI);
40         return getSchemaResult;
41     }
42
43     @Override
44     protected String getOperationName() {
45         return STOP_EXI;
46     }
47
48     @Override
49     protected String getOperationNamespace() {
50         return NamespaceURN.EXI;
51     }
52
53     @Override
54     public void setNetconfSession(final NetconfServerSession netconfServerSession) {
55         netconfSession = netconfServerSession;
56     }
57 }