X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-persister-file-xml-adapter%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fpersist%2Fstorage%2Ffile%2Fxml%2FXmlFileStorageAdapter.java;h=8bd420865cea058b89d141883028c70db1882925;hp=e75c62b81db8dce90184d7142042a00fbce3a88f;hb=ce3bb6ec2cefdda6d727ecab822694e8b0824db4;hpb=213aae87ecaccb43f3d909e0455db43511ace381 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 e75c62b81d..8bd420865c 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,19 +41,20 @@ 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) + if (result == false) { throw new RuntimeException("Unable to create storage file " + storage); + } } catch (IOException e) { throw new RuntimeException("Unable to create storage file " + storage, e); } @@ -87,7 +87,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; } @@ -110,10 +110,11 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister { Optional lastSnapshot = Config.fromXml(storage).getLastSnapshot(); - if (lastSnapshot.isPresent()) + if (lastSnapshot.isPresent()) { return Lists.newArrayList(toConfigSnapshot(lastSnapshot.get())); - else + } else { return Collections.emptyList(); + } }