package org.opendaylight.controller.netconf.impl.mapping.operations;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.api.NetconfSession;
-import org.opendaylight.controller.netconf.mapping.api.DefaultNetconfOperation;
+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.api.xml.XmlNetconfConstants;
+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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-
-import com.google.common.base.Optional;
-
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 static final Logger LOG = LoggerFactory.getLogger(DefaultStartExi.class);
+ private NetconfServerSession netconfSession;
- public DefaultStartExi(String netconfSessionIdForReporting) {
+ public DefaultStartExi(final String netconfSessionIdForReporting) {
super(netconfSessionIdForReporting);
}
@Override
- protected String getOperationName() {
- return START_EXI;
- }
-
- @Override
- protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
-
- Element getSchemaResult = XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
-
- throw new UnsupportedOperationException("Not implemented");
+ public Document handle(final Document message,
+ final NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
+ if (LOG.isDebugEnabled()) {
+ LOG.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.trace("{} 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(final Document document, final XmlElement operationElement) throws NetconfDocumentedException {
+ Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
+ LOG.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(final NetconfServerSession s) {
+ netconfSession = s;
+ }
}