diff options
Diffstat (limited to 'policy-management/src/main')
-rw-r--r-- | policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java b/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java index e217ee7d..905e50c2 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java +++ b/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java @@ -27,6 +27,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Properties; @@ -208,7 +209,7 @@ public class FileSystemPersistence implements SystemPersistence { @Override public List<Properties> getControllerProperties() { final List<Properties> controllers = new ArrayList<>(); - final File[] controllerFiles = this.configurationDirectory.toFile().listFiles(); + final File[] controllerFiles = this.sortedListFiles(); for (final File controllerFile : controllerFiles) { if (controllerFile.getName().endsWith(PROPERTIES_FILE_CONTROLLER_SUFFIX)) { final int idxSuffix = controllerFile.getName().indexOf(PROPERTIES_FILE_CONTROLLER_SUFFIX); @@ -262,7 +263,7 @@ public class FileSystemPersistence implements SystemPersistence { @Override public List<Properties> getEnvironmentProperties() { final List<Properties> envs = new ArrayList<>(); - final File[] envFiles = this.configurationDirectory.toFile().listFiles(); + final File[] envFiles = this.sortedListFiles(); for (final File envFile : envFiles) { if (envFile.getName().endsWith(ENV_SUFFIX)) { final String name = envFile.getName().substring(0, envFile.getName().indexOf(ENV_SUFFIX)); @@ -290,6 +291,15 @@ public class FileSystemPersistence implements SystemPersistence { } } + /** + * provides a list of files sorted by name in ascending order in the configuration directory + */ + protected File[] sortedListFiles() { + final File[] dirFiles = this.configurationDirectory.toFile().listFiles(); + Arrays.sort(dirFiles, (a, b) -> a.getName().compareTo(b.getName())); + return dirFiles; + } + @Override public String toString() { final StringBuilder builder = new StringBuilder(); |