2 * Copyright (c) 2014 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
9 package org.opendaylight.controller.netconf.test.tool;
11 import com.google.common.base.Optional;
12 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
13 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
14 import org.opendaylight.controller.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation;
15 import org.opendaylight.controller.netconf.util.xml.XmlElement;
16 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
17 import org.w3c.dom.Document;
18 import org.w3c.dom.Element;
20 class SimulatedGetConfig extends AbstractConfigNetconfOperation {
22 private final DataList storage;
24 SimulatedGetConfig(final String netconfSessionIdForReporting, final DataList storage) {
25 super(null, netconfSessionIdForReporting);
26 this.storage = storage;
30 protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) throws NetconfDocumentedException {
31 final Element element = XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
33 for(final XmlElement e : storage.getConfigList()) {
34 final Element domElement = e.getDomElement();
35 element.appendChild(element.getOwnerDocument().importNode(domElement, true));
42 protected String getOperationName() {
43 return XmlNetconfConstants.GET_CONFIG;