aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/main')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java2
-rw-r--r--framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java26
-rw-r--r--framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java4
3 files changed, 30 insertions, 2 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java
index 408f4f69..39204237 100644
--- a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java
+++ b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java
@@ -114,6 +114,8 @@ public class OnapCommandConstants {
public static final String DATA_DIRECTORY = "data";
public static final String DISCOVERY_FILE = "cli-schema.json";
public static final String DATA_PATH_JSON_PATTERN = DATA_DIRECTORY + JSON_PATTERN;
+ public static final String DATA_PATH_PROFILE_JSON = "-profile.json";
+ public static final String DATA_PATH_PROFILE_JSON_PATTERN = DATA_DIRECTORY + "/**/*" + DATA_PATH_PROFILE_JSON;
public static final String DISCOVER_ALWAYS = "discover_always";
public static final String PARAM_CACHE_FILE_NAME = "global-profile";
diff --git a/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java b/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
index 55833167..ee6dbed3 100644
--- a/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
+++ b/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
@@ -18,6 +18,8 @@ package org.onap.cli.fw.input.cache;
import static org.onap.cli.fw.conf.OnapCommandConstants.DATA_DIRECTORY;
import static org.onap.cli.fw.conf.OnapCommandConstants.DATA_PATH_JSON_PATTERN;
+import static org.onap.cli.fw.conf.OnapCommandConstants.DATA_PATH_PROFILE_JSON;
+import static org.onap.cli.fw.conf.OnapCommandConstants.DATA_PATH_PROFILE_JSON_PATTERN;
import java.io.File;
import java.io.IOException;
@@ -132,7 +134,7 @@ public class OnapCommandParameterCache {
Resource[] resources = OnapCommandDiscoveryUtils.findResources(DATA_DIRECTORY);
if (resources != null && resources.length == 1) {
String path = resources[0].getURI().getPath();
- File file = new File(path + File.separator + profileName + ".json");
+ File file = new File(path + File.separator + profileName + DATA_PATH_PROFILE_JSON);
ObjectMapper mapper = new ObjectMapper();
mapper.writerWithDefaultPrettyPrinter().writeValue(file, params);
}
@@ -146,7 +148,7 @@ public class OnapCommandParameterCache {
List<OnapCommandParamEntity> params = new ArrayList<>();
try {
- Resource resource = OnapCommandDiscoveryUtils.findResource(profileName + ".json",
+ Resource resource = OnapCommandDiscoveryUtils.findResource(profileName + DATA_PATH_PROFILE_JSON,
DATA_PATH_JSON_PATTERN);
if (resource != null) {
File file = new File(resource.getURI().getPath());
@@ -160,4 +162,24 @@ public class OnapCommandParameterCache {
return params;
}
+
+ public List<String> getProfiles() {
+ List<String> profiles = new ArrayList<>();
+
+ Resource[] resources;
+ try {
+ resources = OnapCommandDiscoveryUtils.findResources(DATA_PATH_PROFILE_JSON_PATTERN);
+ } catch (IOException e) {
+ throw new RuntimeException(e); // NOSONAR
+ }
+
+ if (resources != null && resources.length > 0) {
+ for (Resource res : resources) {
+ String profile = res.getFilename().substring(0, res.getFilename().indexOf(DATA_PATH_PROFILE_JSON));
+ profiles.add(profile);
+ }
+ }
+
+ return profiles;
+ }
}
diff --git a/framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java b/framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java
index 854b55be..8ba215e6 100644
--- a/framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java
+++ b/framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java
@@ -94,6 +94,10 @@ public class OnapCommandRegistrar {
this.paramCache.setProfile(profileName);
}
+ public List<String> getUserProfiles() {
+ return paramCache.getProfiles();
+ }
+
private static OnapCommandRegistrar registrar = null;
/**