X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2Fmapping%2Foperations%2FDefaultStartExi.java;fp=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2Fmapping%2Foperations%2FDefaultStartExi.java;h=8f08688f59dbcf456e7b4580bfbd8f1ea661235c;hb=a474fa0e090124ba715dc4251944dd8532c90491;hp=0000000000000000000000000000000000000000;hpb=20bd54c0c63f16541a0ab907165a7ea2d6165442;p=controller.git diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStartExi.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStartExi.java new file mode 100644 index 0000000000..8f08688f59 --- /dev/null +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStartExi.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.netconf.impl.mapping.operations; + +import org.opendaylight.controller.netconf.api.NetconfDocumentedException; +import org.opendaylight.controller.netconf.api.NetconfOperationRouter; +import org.opendaylight.controller.netconf.api.NetconfSession; +import org.opendaylight.controller.netconf.impl.mapping.ExiDecoderHandler; +import org.opendaylight.controller.netconf.impl.mapping.ExiEncoderHandler; +import org.opendaylight.controller.netconf.mapping.api.DefaultNetconfOperation; +import org.opendaylight.controller.netconf.mapping.api.HandlingPriority; +import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation; +import org.opendaylight.controller.netconf.util.xml.ExiParameters; +import org.opendaylight.controller.netconf.util.xml.XmlElement; +import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; +import org.opendaylight.controller.netconf.util.xml.XmlUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import com.siemens.ct.exi.exceptions.EXIException; + +public class DefaultStartExi extends AbstractNetconfOperation implements DefaultNetconfOperation { + + public static final String START_EXI = "start-exi"; + + private static NetconfSession netconfSession; + + private static final Logger logger = LoggerFactory.getLogger(DefaultStartExi.class); + + public DefaultStartExi(String netconfSessionIdForReporting) { + super(netconfSessionIdForReporting); + } + + @Override + protected HandlingPriority canHandle(String operationName, + String netconfOperationNamespace) { + if (operationName.equals(START_EXI) == false) + return HandlingPriority.CANNOT_HANDLE; + if (netconfOperationNamespace + .equals(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0) == false) + return HandlingPriority.CANNOT_HANDLE; + + return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY; + } + + @Override + protected Element handle(Document document, XmlElement operationElement, + NetconfOperationRouter opRouter) throws NetconfDocumentedException { + + + Element getSchemaResult = document + .createElement(XmlNetconfConstants.OK); + XmlUtil.addNamespaceAttr(getSchemaResult, + XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); + + + try { + ExiParameters exiParams = new ExiParameters(); + exiParams.setParametersFromXmlElement(operationElement); + + netconfSession.addExiDecoder(ExiDecoderHandler.HANDLER_NAME, new ExiDecoderHandler(exiParams)); + netconfSession.addExiEncoderAfterMessageSent(ExiEncoderHandler.HANDLER_NAME,new ExiEncoderHandler(exiParams)); + + } catch (EXIException e) { + getSchemaResult = document + .createElement(XmlNetconfConstants.RPC_ERROR); + } + + logger.info("{} operation successful", START_EXI); + logger.debug("received start-exi message {} ", XmlUtil.toString(document)); + return getSchemaResult; + + } + + @Override + public void setNetconfSession(NetconfSession s) { + netconfSession = s; + } + + public NetconfSession getNetconfSession() { + return netconfSession; + } + + +}