summaryrefslogtreecommitdiffstats
path: root/policy-management/src
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-09-20 23:07:21 -0500
committerJorge Hernandez <jh1730@att.com>2017-09-20 23:07:21 -0500
commit42ddcb6dde34fd19523a33b72607dec4ecca31fc (patch)
tree4fa81fc2f9c0e6c46b6bab718297cf2cf2fc88da /policy-management/src
parent38bd1bffbed6faa272bf435c9936e3a99287372e (diff)
load config files in ascending order by name
adding predictibility for environment and controller files loading Change-Id: Id02ddca75dd0dc8da658b64b84e77bef9e82b37c Issue-ID: POLICY-162 Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'policy-management/src')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java14
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();