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.ExiParameters;
\r
19 import org.opendaylight.controller.netconf.util.xml.XmlElement;
\r
20 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
\r
21 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
\r
22 import org.slf4j.Logger;
\r
23 import org.slf4j.LoggerFactory;
\r
24 import org.w3c.dom.Document;
\r
25 import org.w3c.dom.Element;
\r
27 import com.siemens.ct.exi.exceptions.EXIException;
\r
29 public class DefaultStartExi extends AbstractNetconfOperation implements DefaultNetconfOperation {
\r
31 public static final String START_EXI = "start-exi";
\r
33 private static NetconfSession netconfSession;
\r
35 private static final Logger logger = LoggerFactory.getLogger(DefaultStartExi.class);
\r
37 public DefaultStartExi(String netconfSessionIdForReporting) {
\r
38 super(netconfSessionIdForReporting);
\r
42 protected HandlingPriority canHandle(String operationName,
\r
43 String netconfOperationNamespace) {
\r
44 if (operationName.equals(START_EXI) == false)
\r
45 return HandlingPriority.CANNOT_HANDLE;
\r
46 if (netconfOperationNamespace
\r
47 .equals(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0) == false)
\r
48 return HandlingPriority.CANNOT_HANDLE;
\r
50 return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY;
\r
54 protected Element handle(Document document, XmlElement operationElement,
\r
55 NetconfOperationRouter opRouter) throws NetconfDocumentedException {
\r
58 Element getSchemaResult = document
\r
59 .createElement(XmlNetconfConstants.OK);
\r
60 XmlUtil.addNamespaceAttr(getSchemaResult,
\r
61 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
\r
65 ExiParameters exiParams = new ExiParameters();
\r
66 exiParams.setParametersFromXmlElement(operationElement);
\r
68 netconfSession.addExiDecoder(ExiDecoderHandler.HANDLER_NAME, new ExiDecoderHandler(exiParams));
\r
69 netconfSession.addExiEncoderAfterMessageSent(ExiEncoderHandler.HANDLER_NAME,new ExiEncoderHandler(exiParams));
\r
71 } catch (EXIException e) {
\r
72 getSchemaResult = document
\r
73 .createElement(XmlNetconfConstants.RPC_ERROR);
\r
76 logger.info("{} operation successful", START_EXI);
\r
77 logger.debug("received start-exi message {} ", XmlUtil.toString(document));
\r
78 return getSchemaResult;
\r
83 public void setNetconfSession(NetconfSession s) {
\r
87 public NetconfSession getNetconfSession() {
\r
88 return netconfSession;
\r