BUG-3625 Allow replace nested composite nodes in cfg-subsystem
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / operations / editconfig / NoneEditConfigStrategy.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig;
10
11 import java.util.Collections;
12 import java.util.Map;
13 import org.opendaylight.controller.config.util.ConfigTransactionClient;
14 import org.opendaylight.controller.netconf.confignetconfconnector.exception.NetconfConfigHandlingException;
15 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement;
16 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.ServiceRegistryWrapper;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 public class NoneEditConfigStrategy implements EditConfigStrategy {
21
22     private static final Logger LOG = LoggerFactory.getLogger(NoneEditConfigStrategy.class);
23
24     @Override
25     public void executeConfiguration(String module, String instance, Map<String, AttributeConfigElement> configuration,
26                                      ConfigTransactionClient ta, ServiceRegistryWrapper services) throws NetconfConfigHandlingException {
27         if(configuration != null && !configuration.isEmpty()) {
28             for (Map.Entry<String, AttributeConfigElement> attrEntry : configuration.entrySet()) {
29                 if(attrEntry.getValue().getEditStrategy().isPresent()) {
30                     final Map<String, AttributeConfigElement> partialConfig =
31                             Collections.singletonMap(attrEntry.getKey(), attrEntry.getValue());
32                     attrEntry.getValue().getEditStrategy().get().getFittingStrategy()
33                             .executeConfiguration(module, instance, partialConfig, ta, services);
34                 } else {
35                     LOG.debug("Skipping configuration element for {}:{}:{}", module, instance, attrEntry.getKey());
36                 }
37             }
38         } else {
39             LOG.debug("Skipping configuration element for {}:{}", module, instance);
40         }
41     }
42
43 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.