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;h=b9b30a5eaaa2b52b4967e102e373a578cf08b2ea;hb=9c9d6e69da3aff2d0576d8c15ea0fa0692595b6d;hp=9e84be6c31c32d1a5bbfeb778b8ec05e0b899095;hpb=b369c0185a99952c3609aad40ebeba3e4be8c5b2;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 index 9e84be6c31..b9b30a5eaa 100644 --- 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 @@ -7,15 +7,14 @@ */ package org.opendaylight.controller.netconf.impl.mapping.operations; -import org.opendaylight.controller.netconf.api.NetconfSession; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; -import org.opendaylight.controller.netconf.api.NetconfOperationRouter; -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.api.NetconfDocumentedException.ErrorSeverity; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType; +import org.opendaylight.controller.netconf.api.NetconfMessage; +import org.opendaylight.controller.netconf.impl.NetconfServerSession; +import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution; +import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation; import org.opendaylight.controller.netconf.util.xml.XmlElement; import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.util.xml.XmlUtil; @@ -23,70 +22,50 @@ 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 class DefaultStartExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation { public static final String START_EXI = "start-exi"; - private NetconfSession netconfSession; - private static final Logger logger = LoggerFactory.getLogger(DefaultStartExi.class); + private NetconfServerSession netconfSession; 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); - + public Document handle(Document message, + NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException { + logger.debug("Received start-exi message {} ", XmlUtil.toString(message)); 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); + netconfSession.startExiCommunication(new NetconfMessage(message)); + } catch (IllegalArgumentException e) { + throw new NetconfDocumentedException("Failed to parse EXI parameters", ErrorType.protocol, + ErrorTag.operation_failed, ErrorSeverity.error); } - logger.info("{} operation successful", START_EXI); - logger.debug("received start-exi message {} ", XmlUtil.toString(document)); - return getSchemaResult; - + return super.handle(message, subsequentOperation); } @Override - public void setNetconfSession(NetconfSession s) { - netconfSession = s; + protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException { + Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK); + logger.trace("{} operation successful", START_EXI); + return getSchemaResult; } - public NetconfSession getNetconfSession() { - return netconfSession; + @Override + protected String getOperationName() { + return START_EXI; } + @Override + protected String getOperationNamespace() { + return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0; + } + @Override + public void setNetconfSession(NetconfServerSession s) { + netconfSession = s; + } }