2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.impl.mapping.operations;
10 import org.opendaylight.netconf.api.DocumentedException;
11 import org.opendaylight.netconf.api.DocumentedException.ErrorSeverity;
12 import org.opendaylight.netconf.api.DocumentedException.ErrorTag;
13 import org.opendaylight.netconf.api.DocumentedException.ErrorType;
14 import org.opendaylight.netconf.api.NetconfMessage;
15 import org.opendaylight.netconf.api.xml.XmlElement;
16 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
17 import org.opendaylight.netconf.api.xml.XmlUtil;
18 import org.opendaylight.netconf.impl.NetconfServerSession;
19 import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
20 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23 import org.w3c.dom.Document;
24 import org.w3c.dom.Element;
26 public class DefaultStartExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation {
27 public static final String START_EXI = "start-exi";
29 private static final Logger LOG = LoggerFactory.getLogger(DefaultStartExi.class);
30 private NetconfServerSession netconfSession;
32 public DefaultStartExi(final String netconfSessionIdForReporting) {
33 super(netconfSessionIdForReporting);
37 public Document handle(final Document message,
38 final NetconfOperationChainedExecution subsequentOperation) throws DocumentedException {
39 if (LOG.isDebugEnabled()) {
40 LOG.debug("Received start-exi message {} ", XmlUtil.toString(message));
44 netconfSession.startExiCommunication(new NetconfMessage(message));
45 } catch (final IllegalArgumentException e) {
46 throw new DocumentedException("Failed to parse EXI parameters", e, ErrorType.PROTOCOL,
47 ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
50 return super.handle(message, subsequentOperation);
54 protected Element handleWithNoSubsequentOperations(final Document document,
55 final XmlElement operationElement) {
56 final Element getSchemaResult = document.createElementNS(
57 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
58 LOG.trace("{} operation successful", START_EXI);
59 return getSchemaResult;
63 protected String getOperationName() {
68 protected String getOperationNamespace() {
69 return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0;
73 public void setNetconfSession(final NetconfServerSession netconfServerSession) {
74 netconfSession = netconfServerSession;