import com.google.common.base.Charsets;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
import com.google.common.io.Files;
import org.apache.commons.lang3.StringUtils;
import org.opendaylight.controller.config.persist.api.storage.StorageAdapter;
-import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
/**
* StorageAdapter that stores configuration in a plan file.
private File storage;
@Override
- public void setProperties(BundleContext bundleContext) {
- File storage = extractStorageFileFromProperties(bundleContext);
+ public void setProperties(PropertiesProvider propertiesProvider) {
+ File storage = extractStorageFileFromProperties(propertiesProvider);
logger.debug("Using file {}", storage.getAbsolutePath());
// Create file if it does not exist
File parentFile = storage.getAbsoluteFile().getParentFile();
numberOfStoredBackups = numberOfBackups;
}
- private static File extractStorageFileFromProperties(BundleContext bundleContext) {
- String fileStorageProperty = bundleContext.getProperty(FILE_STORAGE_PROP);
- Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + FILE_STORAGE_PROP
- + " in received context :" + bundleContext);
+ private static File extractStorageFileFromProperties(PropertiesProvider propertiesProvider) {
+ String fileStorageProperty = propertiesProvider.getProperty(FILE_STORAGE_PROP);
+ Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(FILE_STORAGE_PROP));
File result = new File(fileStorageProperty);
- String numberOfBAckupsAsString = bundleContext.getProperty(NUMBER_OF_BACKUPS);
+ String numberOfBAckupsAsString = propertiesProvider.getProperty(NUMBER_OF_BACKUPS);
if (numberOfBAckupsAsString != null) {
numberOfStoredBackups = Integer.valueOf(numberOfBAckupsAsString);
} else {
private boolean inLastConfig, inLastSnapshot;
private final StringBuffer snapshotBuffer = new StringBuffer();
- private final Set<String> caps = Sets.newHashSet();
+ private final SortedSet<String> caps = new TreeSet<>();
@Override
public String getResult() {
return Optional.of(xmlContent);
}
- Set<String> getCapabilities() throws IOException, SAXException, ParserConfigurationException {
+ SortedSet<String> getCapabilities() throws IOException, SAXException, ParserConfigurationException {
return caps;
}
private class PersistedConfigImpl implements ConfigSnapshotHolder {
private final String snapshot;
- private final Set<String> caps;
+ private final SortedSet<String> caps;
- public PersistedConfigImpl(Optional<String> configSnapshot, Set<String> capabilities) {
+ public PersistedConfigImpl(Optional<String> configSnapshot, SortedSet<String> capabilities) {
this.snapshot = configSnapshot.get();
this.caps = capabilities;
}
}
@Override
- public Set<String> getCapabilities() {
+ public SortedSet<String> getCapabilities() {
return caps;
}
}