2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\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
8 package org.opendaylight.controller.netconf.impl.mapping.operations;
\r
10 import org.opendaylight.controller.netconf.api.NetconfSession;
\r
11 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
\r
12 import org.opendaylight.controller.netconf.api.NetconfOperationRouter;
\r
13 import org.opendaylight.controller.netconf.impl.mapping.ExiDecoderHandler;
\r
14 import org.opendaylight.controller.netconf.impl.mapping.ExiEncoderHandler;
\r
15 import org.opendaylight.controller.netconf.mapping.api.DefaultNetconfOperation;
\r
16 import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
\r
17 import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation;
\r
18 import org.opendaylight.controller.netconf.util.xml.XmlElement;
\r
19 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
\r
20 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
\r
21 import org.slf4j.Logger;
\r
22 import org.slf4j.LoggerFactory;
\r
23 import org.w3c.dom.Document;
\r
24 import org.w3c.dom.Element;
\r
26 public class DefaultStopExi extends AbstractNetconfOperation implements DefaultNetconfOperation {
\r
28 public static final String STOP_EXI = "stop-exi";
\r
29 private NetconfSession netconfSession;
\r
31 private static final Logger logger = LoggerFactory
\r
32 .getLogger(DefaultStartExi.class);
\r
34 public DefaultStopExi(String netconfSessionIdForReporting) {
\r
35 super(netconfSessionIdForReporting);
\r
39 protected HandlingPriority canHandle(String operationName,
\r
40 String netconfOperationNamespace) {
\r
41 if (operationName.equals(STOP_EXI) == false)
\r
42 return HandlingPriority.CANNOT_HANDLE;
\r
43 if (netconfOperationNamespace
\r
44 .equals(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0) == false)
\r
45 return HandlingPriority.CANNOT_HANDLE;
\r
47 return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;
\r
51 protected Element handle(Document document, XmlElement operationElement,
\r
52 NetconfOperationRouter opRouter) throws NetconfDocumentedException {
\r
54 netconfSession.remove(ExiDecoderHandler.class);
\r
55 netconfSession.removeAfterMessageSent(ExiEncoderHandler.HANDLER_NAME);
\r
57 Element getSchemaResult = document.createElement(XmlNetconfConstants.OK);
\r
58 XmlUtil.addNamespaceAttr(getSchemaResult,
\r
59 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
\r
60 logger.info("{} operation successful", STOP_EXI);
\r
61 logger.debug("received stop-exi message {} ", XmlUtil.toString(document));
\r
62 return getSchemaResult;
\r
66 public void setNetconfSession(NetconfSession s) {
\r
67 this.netconfSession = s;
\r
70 public NetconfSession getNetconfSession() {
\r
71 return netconfSession;
\r