summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java20
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/Constants.java1
-rw-r--r--framework/src/main/java/org/onap/cli/fw/error/OnapCommandProductVersionInvalid.java32
-rw-r--r--framework/src/main/resources/META-INF/services/org.onap.cli.fw.OnapCommand2
4 files changed, 52 insertions, 3 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java b/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java
index 56f04e16..39f684cc 100644
--- a/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java
+++ b/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java
@@ -31,6 +31,7 @@ import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandHelpFailed;
import org.onap.cli.fw.error.OnapCommandInvalidRegistration;
import org.onap.cli.fw.error.OnapCommandNotFound;
+import org.onap.cli.fw.error.OnapCommandProductVersionInvalid;
import org.onap.cli.fw.error.OnapCommandRegistrationFailed;
import org.onap.cli.fw.error.OnapCommandRegistrationVersionMissing;
import org.onap.cli.fw.output.OnapCommandResult;
@@ -54,6 +55,16 @@ public class OnapCommandRegistrar {
private String enabledProductVersion = OnapCommandConfg.getEnabledProductVersion();
+ private boolean isInteractiveMode = false;
+
+ public boolean isInteractiveMode() {
+ return isInteractiveMode;
+ }
+
+ public void setInteractiveMode(boolean isInteractiveMode) {
+ this.isInteractiveMode = isInteractiveMode;
+ }
+
private static OnapCommandRegistrar registrar = null;
/**
@@ -126,7 +137,11 @@ public class OnapCommandRegistrar {
return this.availableProductVersions;
}
- public void setEnabledProductVersion(String version) {
+ public void setEnabledProductVersion(String version) throws OnapCommandProductVersionInvalid {
+ if (!this.availableProductVersions.contains(version)) {
+ throw new OnapCommandProductVersionInvalid(version, availableProductVersions);
+ }
+
this.enabledProductVersion = version;
}
@@ -225,7 +240,8 @@ public class OnapCommandRegistrar {
String errorNote = "";
if (!this.availableProductVersions.contains(configuredProductVersion)) {
errorNote = "** CUATION: Please configure the enabled product version to use one of " + this.availableProductVersions.toString() +
- ".\nTo enable a product version, set env variable CLI_PRODUCT_VERSION or cli.product.version in onap.properties";
+ ".\nTo enable a product version, use one of following methods:\n\t 1. set env variable CLI_PRODUCT_VERSION"
+ + "\n\t 2. set cli.product.version in onap.properties \n\t 3. in interactive mode, use the directive 'use <product version>'";
}
return "CLI version : " + version + "\n"
+ "Available product versions: " + this.availableProductVersions.toString() + "\n"
diff --git a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
index 980b94d3..d27649b0 100644
--- a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
+++ b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
@@ -192,6 +192,7 @@ public class Constants {
public static final String HTTP_SUCCESS_CODE_INVALID = "Invalid http success code.";
public static final String HTTP_SAMPLE_RESPONSE_EMPTY = "Sample response cann't be null or empty";
public static final String HTTP_SAMPLE_RESPONSE_FAILED_PARSING = "The http Sample response json is failed to parse.";
+ public static final String USE_DIRECTIVE = "use";
private Constants() {
}
diff --git a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandProductVersionInvalid.java b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandProductVersionInvalid.java
new file mode 100644
index 00000000..7ec69e6b
--- /dev/null
+++ b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandProductVersionInvalid.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.cli.fw.error;
+
+import java.util.Set;
+
+/**
+ * ONAP command product version is invalid
+ *
+ */
+public class OnapCommandProductVersionInvalid extends OnapCommandException {
+
+ private static final long serialVersionUID = 5513297861129088463L;
+
+ public OnapCommandProductVersionInvalid(String invalidVersion, Set<String> validVersions) {
+ super("0x0031", "Given product version " + invalidVersion + " is invalid. Please use one of " + validVersions);
+ }
+}
diff --git a/framework/src/main/resources/META-INF/services/org.onap.cli.fw.OnapCommand b/framework/src/main/resources/META-INF/services/org.onap.cli.fw.OnapCommand
index 89648bf5..422da568 100644
--- a/framework/src/main/resources/META-INF/services/org.onap.cli.fw.OnapCommand
+++ b/framework/src/main/resources/META-INF/services/org.onap.cli.fw.OnapCommand
@@ -1,2 +1,2 @@
org.onap.cli.fw.cmd.OnapSchemaValidateCommand
-org.onap.cli.fw.cmd.OnapSchemaRefreshCommand \ No newline at end of file
+org.onap.cli.fw.cmd.OnapSchemaRefreshCommand