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.server.mapping.operations;
10 import org.opendaylight.netconf.api.DocumentedException;
11 import org.opendaylight.netconf.api.NamespaceURN;
12 import org.opendaylight.netconf.api.NetconfMessage;
13 import org.opendaylight.netconf.api.xml.XmlElement;
14 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
15 import org.opendaylight.netconf.api.xml.XmlUtil;
16 import org.opendaylight.netconf.server.NetconfServerSession;
17 import org.opendaylight.netconf.server.api.operations.AbstractSingletonNetconfOperation;
18 import org.opendaylight.netconf.server.api.operations.NetconfOperationChainedExecution;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
20 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
21 import org.opendaylight.yangtools.yang.common.ErrorTag;
22 import org.opendaylight.yangtools.yang.common.ErrorType;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25 import org.w3c.dom.Document;
26 import org.w3c.dom.Element;
28 public class DefaultStartExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation {
29 public static final String START_EXI = "start-exi";
31 private static final Logger LOG = LoggerFactory.getLogger(DefaultStartExi.class);
32 private NetconfServerSession netconfSession;
34 public DefaultStartExi(final SessionIdType sessionId) {
39 public Document handle(final Document message,
40 final NetconfOperationChainedExecution subsequentOperation) throws DocumentedException {
41 if (LOG.isDebugEnabled()) {
42 LOG.debug("Received start-exi message {} ", XmlUtil.toString(message));
46 netconfSession.startExiCommunication(new NetconfMessage(message));
47 } catch (final IllegalArgumentException e) {
48 throw new DocumentedException("Failed to parse EXI parameters", e, ErrorType.PROTOCOL,
49 ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
52 return super.handle(message, subsequentOperation);
56 protected Element handleWithNoSubsequentOperations(final Document document,
57 final XmlElement operationElement) {
58 final Element getSchemaResult = document.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.OK);
59 LOG.trace("{} operation successful", START_EXI);
60 return getSchemaResult;
64 protected String getOperationName() {
69 protected String getOperationNamespace() {
70 return NamespaceURN.EXI;
74 public void setNetconfSession(final NetconfServerSession netconfServerSession) {
75 netconfSession = netconfServerSession;