aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java2
-rw-r--r--framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java59
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java3
-rw-r--r--main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java5
4 files changed, 38 insertions, 31 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java
index e051d5dd..71a189e5 100644
--- a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java
+++ b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java
@@ -183,7 +183,7 @@ public class OnapCommandSchemaLoader {
List<String> longOptions = new ArrayList<>();
if (validate) {
- OnapCommandUtils.validateTags(exceptionList, (Map<String, Object>) values, OnapCommandConfig.getCommaSeparatedList(TOP_LEVEL_PARAMS_LIST),
+ OnapCommandUtils.validateTags(exceptionList, values, OnapCommandConfig.getCommaSeparatedList(TOP_LEVEL_PARAMS_LIST),
OnapCommandConfig.getCommaSeparatedList(TOP_LEVEL_MANDATORY_LIST), "root level");
}
diff --git a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java
index 32ececfa..0d68db1c 100644
--- a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java
+++ b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandArtifactStore.java
@@ -263,6 +263,37 @@ public class OnapCommandArtifactStore {
}
}
+ public Artifact setArtifact(Artifact artifact, Artifact existing) throws OnapCommandArtifactNotFound, OnapCommandArtifactContentNotExist, OnapCommandArtifactAlreadyExist, IOException, NoSuchAlgorithmException {
+ if (artifact.getName() == null) {
+ artifact.setName(existing.getName());
+ }
+
+ if (artifact.getDescription() == null) {
+ artifact.setDescription(existing.getDescription());
+ }
+
+ if (artifact.getCategoty() == null) {
+ artifact.setCategoty(existing.getCategoty());
+ }
+
+ if (artifact.getPath()!= null) {
+ if (!new File(artifact.getPath()).exists()) {
+ throw new OnapCommandArtifactContentNotExist(artifact.getPath());
+ }
+ String actual = this.getChecksum(artifact.getPath());
+ if (!existing.getChecksum().equals(actual)) {
+ artifact.setChecksum(actual);
+ artifact.setSize(new File(artifact.getPath()).length() / 1024);
+ }
+ } else {
+ artifact.setPath(existing.getPath());
+ }
+
+ artifact.setCreateAt(existing.getCreateAt());
+ artifact.setLastUpdatedAt(dateFormatter.format(new Date()));
+ return artifact;
+ }
+
public Artifact updateArtifact(String name, String category, Artifact artifact) throws OnapCommandArtifactNotFound, OnapCommandArtifactContentNotExist, OnapCommandArtifactAlreadyExist {
Artifact existing = this.getArtifact(name, category);
String existingStorePath = getArtifactPath(name, category);
@@ -273,33 +304,7 @@ public class OnapCommandArtifactStore {
}
try {
- if (artifact.getName() == null) {
- artifact.setName(existing.getName());
- }
-
- if (artifact.getDescription() == null) {
- artifact.setDescription(existing.getDescription());
- }
-
- if (artifact.getCategoty() == null) {
- artifact.setCategoty(existing.getCategoty());
- }
-
- if (artifact.getPath()!= null) {
- if (!new File(artifact.getPath()).exists()) {
- throw new OnapCommandArtifactContentNotExist(artifact.getPath());
- }
- String actual = this.getChecksum(artifact.getPath());
- if (!existing.getChecksum().equals(actual)) {
- artifact.setChecksum(actual);
- artifact.setSize(new File(artifact.getPath()).length() / 1024);
- }
- } else {
- artifact.setPath(existing.getPath());
- }
-
- artifact.setCreateAt(existing.getCreateAt());
- artifact.setLastUpdatedAt(dateFormatter.format(new Date()));
+ artifact = setArtifact(artifact, existing);
if (artifact.getMetadata().size() > 0) {
//update to existing one
for (Map.Entry<String, String> entry: artifact.getMetadata().entrySet()) {
diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java
index ee9c7b33..08ef640f 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -17,6 +17,7 @@
package org.onap.cli.main;
import java.io.IOException;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -189,7 +190,7 @@ public class OnapCli {
public void handleHelp() {
try {
if (this.printHelp) {
- this.print(IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("oclip-readme.txt")));
+ this.print(IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("oclip-readme.txt") , (Charset) null));
String help = OnapCommandRegistrar.getRegistrar().getHelp();
this.print(help);
this.exitSuccessfully();
diff --git a/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java b/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java
index d0885def..53e90661 100644
--- a/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java
+++ b/main/src/main/java/org/onap/cli/main/utils/OnapCliArgsParser.java
@@ -19,6 +19,7 @@ package org.onap.cli.main.utils;
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -224,7 +225,7 @@ public class OnapCliArgsParser {
try {
File file = new File(input);
if (file.isFile()) {
- return FileUtils.readFileToString(file);
+ return FileUtils.readFileToString(file, (Charset) null);
} else {
return input;
}
@@ -238,7 +239,7 @@ public class OnapCliArgsParser {
try {
File file = new File(input);
if (file.isFile()) {
- String value = FileUtils.readFileToString(file);
+ String value = FileUtils.readFileToString(file, (Charset) null);
YamlReader reader = new YamlReader(value);
value = (String) reader.read();
return value;