Removed sonar warnings. 04/46704/4
authorDana Kutenicsova <dana.kutenics@gmail.com>
Wed, 5 Oct 2016 20:03:08 +0000 (22:03 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Mon, 14 Nov 2016 14:00:17 +0000 (14:00 +0000)
Change-Id: I030527e8d6ec5762e63707b157b77a4f21683bbb
Signed-off-by: Dana Kutenicsova <dana.kutenics@gmail.com>
opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/CapabilityStrippingConfigSnapshotHolder.java
opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/ConfigPusherImpl.java
opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/PersisterAggregator.java
opendaylight/config/config-persister-impl/src/main/java/org/opendaylight/controller/config/persist/impl/osgi/ConfigPersisterActivator.java

index bcc0fa4..2794822 100644 (file)
@@ -40,7 +40,8 @@ public class CapabilityStrippingConfigSnapshotHolder implements ConfigSnapshotHo
     }
 
     private static class StripCapabilitiesResult {
-        private final SortedSet<String> requiredCapabilities, obsoleteCapabilities;
+        private final SortedSet<String> requiredCapabilities;
+        private final SortedSet<String> obsoleteCapabilities;
 
         private StripCapabilitiesResult(SortedSet<String> requiredCapabilities, SortedSet<String> obsoleteCapabilities) {
             this.requiredCapabilities = Collections.unmodifiableSortedSet(requiredCapabilities);
index d93bd7d..6fcc7dc 100644 (file)
@@ -24,7 +24,6 @@ import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 import javax.management.MBeanServerConnection;
 import org.opendaylight.controller.config.api.ConflictingVersionException;
@@ -34,15 +33,12 @@ import org.opendaylight.controller.config.facade.xml.ConfigExecution;
 import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
 import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory;
 import org.opendaylight.controller.config.facade.xml.mapping.config.Config;
-import org.opendaylight.controller.config.facade.xml.osgi.YangStoreService;
-import org.opendaylight.controller.config.facade.xml.util.Util;
 import org.opendaylight.controller.config.persist.api.ConfigPusher;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 import org.opendaylight.controller.config.persist.api.Persister;
 import org.opendaylight.controller.config.util.capability.Capability;
 import org.opendaylight.controller.config.util.xml.DocumentedException;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Element;
@@ -263,22 +259,6 @@ public class ConfigPusherImpl implements ConfigPusher {
         }
     }
 
-    private static Set<String> computeNotFoundCapabilities(Set<String> expectedCapabilities, YangStoreService yangStoreService) {
-
-        Collection<String> actual = Collections2.transform(yangStoreService.getModules(), new Function<Module, String>() {
-            @Nullable
-            @Override
-            public String apply(Module input) {
-                final String withoutRevision = input.getNamespace().toString() + "?module=" + input.getName();
-                return !input.getRevision().equals(NO_REVISION) ? withoutRevision + "&revision=" + Util.writeDate(input.getRevision()) : withoutRevision;
-            }
-        });
-
-        Set<String> allNotFound = new HashSet<>(expectedCapabilities);
-        allNotFound.removeAll(actual);
-        return allNotFound;
-    }
-
     private void sleep() {
         try {
             Thread.sleep(100);
index f60eece..ebe9982 100644 (file)
@@ -87,12 +87,21 @@ public final class PersisterAggregator implements Persister {
         }
     }
 
+    /**
+     * Persisters ordered by 'netconf.config.persister' property.
+     */
+    private final List<PersisterWithConfiguration> persisterWithConfigurations;
+
+    public PersisterAggregator(List<PersisterWithConfiguration> persisterWithConfigurations) {
+        this.persisterWithConfigurations = persisterWithConfigurations;
+    }
+
     private static PersisterWithConfiguration loadConfiguration(final String index, final PropertiesProvider propertiesProvider) {
 
         String classKey = index + "." + ConfigPersisterActivator.STORAGE_ADAPTER_CLASS_PROP_SUFFIX;
         String storageAdapterClass = propertiesProvider.getProperty(classKey);
         StorageAdapter storageAdapter;
-        if (storageAdapterClass == null || storageAdapterClass.equals("")) {
+        if (storageAdapterClass == null || storageAdapterClass.isEmpty()) {
             throw new IllegalStateException("No persister is defined in " +
                     propertiesProvider.getFullKeyForReporting(classKey)
                     + " property. Persister is not operational");
@@ -106,11 +115,8 @@ public final class PersisterAggregator implements Persister {
             }
             storageAdapter = StorageAdapter.class.cast(clazz.newInstance());
 
-            boolean readOnly = false;
             String readOnlyProperty = propertiesProvider.getProperty(index + "." + "readonly");
-            if (readOnlyProperty != null && readOnlyProperty.equals("true")) {
-                readOnly = true;
-            }
+            boolean readOnly = Boolean.parseBoolean(readOnlyProperty);
 
             PropertiesProviderAdapterImpl innerProvider = new PropertiesProviderAdapterImpl(propertiesProvider, index);
             Persister storage = storageAdapter.instantiate(innerProvider);
@@ -120,16 +126,6 @@ public final class PersisterAggregator implements Persister {
         }
     }
 
-    /**
-     * Persisters ordered by 'netconf.config.persister' property.
-     */
-    private final List<PersisterWithConfiguration> persisterWithConfigurations;
-
-    public PersisterAggregator(List<PersisterWithConfiguration> persisterWithConfigurations) {
-        this.persisterWithConfigurations = persisterWithConfigurations;
-
-    }
-
     public static PersisterAggregator createFromProperties(PropertiesProvider propertiesProvider) {
         List<PersisterWithConfiguration> persisterWithConfigurations = new ArrayList<>();
         String prefixes = propertiesProvider.getProperty("active");
index 66c43c2..c67522e 100644 (file)
@@ -68,9 +68,9 @@ public class ConfigPersisterActivator implements BundleActivator {
             public ConfigSubsystemFacadeFactory addingService(ServiceReference<ConfigSubsystemFacadeFactory> reference) {
                 LOG.debug("Got addingService(SchemaContextProvider) event");
                 // Yang store service should not be registered multiple times
-                ConfigSubsystemFacadeFactory ConfigSubsystemFacadeFactory = reference.getBundle().getBundleContext().getService(reference);
-                startPusherThread(configs, maxWaitForCapabilitiesMillis, ConfigSubsystemFacadeFactory, conflictingVersionTimeoutMillis, persisterAggregator);
-                return ConfigSubsystemFacadeFactory;
+                ConfigSubsystemFacadeFactory configSubsystemFacadeFactory = reference.getBundle().getBundleContext().getService(reference);
+                startPusherThread(configs, maxWaitForCapabilitiesMillis, configSubsystemFacadeFactory, conflictingVersionTimeoutMillis, persisterAggregator);
+                return configSubsystemFacadeFactory;
             }
 
             @Override