From 3a57c653e3416c32b0affb20483ab10856f9b1ef Mon Sep 17 00:00:00 2001 From: Marian Dubai Date: Thu, 20 Nov 2014 11:03:24 +0100 Subject: [PATCH] Fix checkstyle warnings in config-persister-file-xml-adapter. Change-Id: Ia7cd7eda114225cfc35ec301535d5aaec0fa8794 Signed-off-by: Marian Dubai --- .../file/xml/XmlFileStorageAdapter.java | 21 +++++++++---------- .../storage/file/xml/model/Config.java | 9 ++++---- .../file/xml/model/ConfigSnapshot.java | 5 ++--- .../file/xml/model/SnapshotHandler.java | 4 ++-- .../file/xml/FileStorageAdapterTest.java | 3 ++- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/XmlFileStorageAdapter.java b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/XmlFileStorageAdapter.java index 02f9f8b80a..7badc4b294 100644 --- a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/XmlFileStorageAdapter.java +++ b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/XmlFileStorageAdapter.java @@ -12,6 +12,11 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import java.io.File; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.SortedSet; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.config.persist.api.Persister; import org.opendaylight.controller.config.persist.api.PropertiesProvider; @@ -21,17 +26,11 @@ import org.opendaylight.controller.config.persist.storage.file.xml.model.ConfigS import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.SortedSet; - /** * StorageAdapter that stores configuration in an xml file. */ public class XmlFileStorageAdapter implements StorageAdapter, Persister { - private static final Logger LOGGER = LoggerFactory.getLogger(XmlFileStorageAdapter.class); + private static final Logger LOG = LoggerFactory.getLogger(XmlFileStorageAdapter.class); public static final String FILE_STORAGE_PROP = "fileStorage"; public static final String NUMBER_OF_BACKUPS = "numberOfBackups"; @@ -42,15 +41,15 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister { @Override public Persister instantiate(PropertiesProvider propertiesProvider) { File storage = extractStorageFileFromProperties(propertiesProvider); - LOGGER.debug("Using file {}", storage.getAbsolutePath()); + LOG.debug("Using file {}", storage.getAbsolutePath()); // Create file if it does not exist File parentFile = storage.getAbsoluteFile().getParentFile(); if (parentFile.exists() == false) { - LOGGER.debug("Creating parent folders {}", parentFile); + LOG.debug("Creating parent folders {}", parentFile); parentFile.mkdirs(); } if (storage.exists() == false) { - LOGGER.debug("Storage file does not exist, creating empty file"); + LOG.debug("Storage file does not exist, creating empty file"); try { boolean result = storage.createNewFile(); if (result == false) @@ -87,7 +86,7 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister { } else { numberOfStoredBackups = Integer.MAX_VALUE; } - LOGGER.trace("Property {} set to {}", NUMBER_OF_BACKUPS, numberOfStoredBackups); + LOG.trace("Property {} set to {}", NUMBER_OF_BACKUPS, numberOfStoredBackups); return result; } diff --git a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/Config.java b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/Config.java index fb84651ca1..354c8c0540 100644 --- a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/Config.java +++ b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/Config.java @@ -12,8 +12,9 @@ import com.google.common.base.Optional; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.io.Files; -import org.apache.commons.lang3.StringUtils; - +import java.io.File; +import java.io.IOException; +import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; @@ -21,9 +22,7 @@ import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; -import java.io.File; -import java.io.IOException; -import java.util.List; +import org.apache.commons.lang3.StringUtils; @XmlRootElement(name = "persisted-snapshots") public final class Config { diff --git a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java index 03b03befe0..4f050640c5 100644 --- a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java +++ b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java @@ -7,15 +7,14 @@ */ package org.opendaylight.controller.config.persist.storage.file.xml.model; +import java.util.SortedSet; import java.util.TreeSet; -import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; - import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.SortedSet; +import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; @XmlRootElement(name = ConfigSnapshot.SNAPSHOT_ROOT_ELEMENT_NAME) public class ConfigSnapshot { diff --git a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/SnapshotHandler.java b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/SnapshotHandler.java index dd39410409..8214b36970 100644 --- a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/SnapshotHandler.java +++ b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/SnapshotHandler.java @@ -7,13 +7,13 @@ */ package org.opendaylight.controller.config.persist.storage.file.xml.model; +import java.io.StringReader; +import java.io.StringWriter; import javax.xml.bind.ValidationEventHandler; import javax.xml.bind.annotation.DomHandler; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import java.io.StringReader; -import java.io.StringWriter; class SnapshotHandler implements DomHandler { diff --git a/opendaylight/config/config-persister-file-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/xml/FileStorageAdapterTest.java b/opendaylight/config/config-persister-file-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/xml/FileStorageAdapterTest.java index 942ba4c4b3..3ea9a48a5d 100644 --- a/opendaylight/config/config-persister-file-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/xml/FileStorageAdapterTest.java +++ b/opendaylight/config/config-persister-file-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/xml/FileStorageAdapterTest.java @@ -8,11 +8,12 @@ package org.opendaylight.controller.config.persist.storage.file.xml; -import static org.junit.Assert.assertFalse; import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; + import com.google.common.base.Charsets; import java.io.File; import java.io.FileNotFoundException; -- 2.36.6