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.messages.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);
33 private NetconfServerSession netconfSession = null;
35 public DefaultStartExi(final SessionIdType sessionId) {
40 public Document handle(final Document message,
41 final NetconfOperationChainedExecution subsequentOperation) throws DocumentedException {
42 if (LOG.isDebugEnabled()) {
43 LOG.debug("Received start-exi message {} ", XmlUtil.toString(message));
47 netconfSession.startExiCommunication(new NetconfMessage(message));
48 } catch (final IllegalArgumentException e) {
49 throw new DocumentedException("Failed to parse EXI parameters", e, ErrorType.PROTOCOL,
50 ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
53 return super.handle(message, subsequentOperation);
57 protected Element handleWithNoSubsequentOperations(final Document document,
58 final XmlElement operationElement) {
59 final Element getSchemaResult = document.createElementNS(NamespaceURN.BASE, XmlNetconfConstants.OK);
60 LOG.trace("{} operation successful", START_EXI);
61 return getSchemaResult;
65 protected String getOperationName() {
70 protected String getOperationNamespace() {
71 return NamespaceURN.EXI;
75 public void setNetconfSession(final NetconfServerSession netconfServerSession) {
76 netconfSession = netconfServerSession;