aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java b/main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java
index ed47bc68..be88aed0 100644
--- a/main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java
+++ b/main/src/main/java/org/onap/cli/main/utils/OnapCliUtils.java
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import net.minidev.json.JSONObject;
+import org.apache.commons.io.FileUtils;
import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandInvalidParameterValue;
import org.onap.cli.fw.input.OnapCommandParameter;
@@ -110,6 +111,11 @@ public class OnapCliUtils {
paramMap.get(shortOptionMap.get(args.get(i))).getName()));
i++;
continue;
+ } if (paramMap.get(shortOptionMap.get(args.get(i))).getParameterType().equals(ParameterType.TEXT)) {
+ paramMap.get(shortOptionMap.get(args.get(i))).setValue(readTextStringFromUrl(args.get(i + 1),
+ paramMap.get(shortOptionMap.get(args.get(i))).getName()));
+ i++;
+ continue;
} else if (paramMap.get(shortOptionMap.get(args.get(i))).getParameterType()
.equals(ParameterType.ARRAY)) {
Object value = paramMap.get(shortOptionMap.get(args.get(i))).getValue();
@@ -171,6 +177,11 @@ public class OnapCliUtils {
paramMap.get(longOptionMap.get(args.get(i))).getName()));
i++;
continue;
+ } else if (paramMap.get(longOptionMap.get(args.get(i))).getParameterType().equals(ParameterType.TEXT)) {
+ paramMap.get(longOptionMap.get(args.get(i))).setValue(readTextStringFromUrl(args.get(i + 1),
+ paramMap.get(longOptionMap.get(args.get(i))).getName()));
+ i++;
+ continue;
} else if (paramMap.get(longOptionMap.get(args.get(i))).getParameterType()
.equals(ParameterType.ARRAY)) {
Object value = paramMap.get(longOptionMap.get(args.get(i))).getValue();
@@ -248,6 +259,14 @@ public class OnapCliUtils {
}
}
+ private static String readTextStringFromUrl(String input, String argName) throws OnapCliInvalidArgument {
+ try {
+ return FileUtils.readFileToString(new File(input));
+ } catch (IOException e) {
+ throw new OnapCliInvalidArgument(argName, e);
+ }
+ }
+
private static List<String> convertJsonToListString(String arg, String json) throws OnapCliInvalidArgument {
TypeReference<List<String>> mapType = new TypeReference<List<String>>() {
};