Fix checkstyle warnings for config-netconf-connector
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / operations / editconfig / ReplaceEditConfigStrategy.java
index bc3082ff50f51b4365280e6f37861c7c36cdaaf0..8d786d2c8d17757a7104e2e362499a22836c13ab 100644 (file)
@@ -8,9 +8,10 @@
 
 package org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig;
 
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.management.Attribute;
+import javax.management.ObjectName;
 import org.opendaylight.controller.config.util.ConfigTransactionClient;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.confignetconfconnector.exception.NetconfConfigHandlingException;
@@ -19,25 +20,9 @@ import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.management.Attribute;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-import java.util.Map;
-import java.util.Map.Entry;
-
 public class ReplaceEditConfigStrategy extends AbstractEditConfigStrategy {
 
-    private static final Logger logger = LoggerFactory.getLogger(ReplaceEditConfigStrategy.class);
-
-    private final Multimap<String, String> providedServices;
-
-    public ReplaceEditConfigStrategy() {
-        this.providedServices = HashMultimap.create();
-    }
-
-    public ReplaceEditConfigStrategy(Multimap<String, String> providedServices) {
-        this.providedServices = providedServices;
-    }
+    private static final Logger LOG = LoggerFactory.getLogger(ReplaceEditConfigStrategy.class);
 
     @Override
     void handleMissingInstance(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta,
@@ -51,32 +36,8 @@ public class ReplaceEditConfigStrategy extends AbstractEditConfigStrategy {
                 NetconfDocumentedException.ErrorSeverity.error);
     }
 
-    private void addRefNames(ServiceRegistryWrapper services, Multimap<String, String> providedServices, ConfigTransactionClient ta, ObjectName on) throws InstanceNotFoundException {
-        for (Entry<String, String> namespaceToService : providedServices.entries()) {
-
-            if(services.hasRefName(namespaceToService.getKey(),
-                    namespaceToService.getValue(), on)){
-                continue;
-            }
-
-            String refName = services.getNewDefaultRefName(namespaceToService.getKey(), namespaceToService.getValue(),
-                    ObjectNameUtil.getFactoryName(on), ObjectNameUtil.getInstanceName(on));
-            ta.saveServiceReference(
-                    ta.getServiceInterfaceName(namespaceToService.getKey(), namespaceToService.getValue()), refName, on);
-        }
-    }
-
     @Override
     void executeStrategy(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta, ObjectName on, ServiceRegistryWrapper services) throws NetconfConfigHandlingException {
-        try {
-            addRefNames(services, providedServices, ta, on);
-        } catch (InstanceNotFoundException e) {
-            throw new NetconfConfigHandlingException(String.format("Unable to save default ref name for instance %s. Instance not found. ",on),
-                    NetconfDocumentedException.ErrorType.application,
-                    NetconfDocumentedException.ErrorTag.operation_failed,
-                    NetconfDocumentedException.ErrorSeverity.error);
-        }
-
         for (Entry<String, AttributeConfigElement> configAttributeEntry : configuration.entrySet()) {
             try {
                 AttributeConfigElement ace = configAttributeEntry.getValue();
@@ -84,12 +45,12 @@ public class ReplaceEditConfigStrategy extends AbstractEditConfigStrategy {
                 if (!ace.getResolvedValue().isPresent()) {
                     Object value = ace.getResolvedDefaultValue();
                     ta.setAttribute(on, ace.getJmxName(), new Attribute(ace.getJmxName(), value));
-                    logger.debug("Attribute {} set to default value {} for {}", configAttributeEntry.getKey(), value,
+                    LOG.debug("Attribute {} set to default value {} for {}", configAttributeEntry.getKey(), value,
                             on);
                 } else {
                     Object value = ace.getResolvedValue().get();
                     ta.setAttribute(on, ace.getJmxName(), new Attribute(ace.getJmxName(), value));
-                    logger.debug("Attribute {} set to value {} for {}", configAttributeEntry.getKey(), value, on);
+                    LOG.debug("Attribute {} set to value {} for {}", configAttributeEntry.getKey(), value, on);
                 }
 
             } catch (Exception e) {