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.java1
-rw-r--r--framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java9
-rw-r--r--framework/src/main/java/org/onap/cli/fw/info/OnapCommandState.java53
-rw-r--r--framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java14
-rw-r--r--framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java13
-rw-r--r--framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java8
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java5
-rw-r--r--framework/src/main/resources/open-cli.properties2
8 files changed, 101 insertions, 4 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 6f1741e5..7ea4ddaa 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
@@ -58,6 +58,7 @@ public class OnapCommandConstants {
public static final String INFO_TYPE = "type";
public static final String INFO_AUTHOR = "author";
public static final String INFO_IGNORE = "ignore";
+ public static final String INFO_STATE = "state";
//parameters
public static final String PARAMETERS = "parameters";
diff --git a/framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java b/framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java
index 1496bcbb..55009a49 100644
--- a/framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java
+++ b/framework/src/main/java/org/onap/cli/fw/info/OnapCommandInfo.java
@@ -31,6 +31,8 @@ public class OnapCommandInfo {
private OnapCommandType type = OnapCommandType.CMD;
+ private OnapCommandState state = OnapCommandState.STABLE;
+
private boolean ignore = false;
public String getProduct() {
@@ -73,5 +75,12 @@ public class OnapCommandInfo {
this.ignore = ignore;
}
+ public OnapCommandState getState() {
+ return state;
+ }
+
+ public void setState(OnapCommandState state) {
+ this.state = state;
+ }
} \ No newline at end of file
diff --git a/framework/src/main/java/org/onap/cli/fw/info/OnapCommandState.java b/framework/src/main/java/org/onap/cli/fw/info/OnapCommandState.java
new file mode 100644
index 00000000..782a630d
--- /dev/null
+++ b/framework/src/main/java/org/onap/cli/fw/info/OnapCommandState.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2018 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.info;
+
+import org.onap.cli.fw.error.OnapCommandInvalidCommandType;
+import org.onap.cli.fw.error.OnapCommandInvalidParameterType;
+
+/**
+ * Command life cycle state.
+ *
+ */
+public enum OnapCommandState {
+
+ EXPERIMENTAL,
+ STABLE,
+ DEPRECATED;
+
+ /**
+ * Get command state.
+ *
+ * @param name
+ * type name
+ * @return type
+ * @throws OnapCommandInvalidParameterType
+ * exception
+ */
+ public static OnapCommandState get(String name) throws OnapCommandInvalidCommandType {
+ if (EXPERIMENTAL.name().equalsIgnoreCase(name)) {
+ return EXPERIMENTAL;
+ } else if (STABLE.name().equalsIgnoreCase(name)) {
+ return STABLE;
+ } else if (DEPRECATED.name().equalsIgnoreCase(name)) {
+ return DEPRECATED;
+ } else {
+ throw new OnapCommandInvalidCommandType(name);
+ }
+ }
+}
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 15a086c7..34dc6b6d 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
@@ -366,13 +366,22 @@ public class OnapCommandRegistrar {
attrSrv.setScope(OnapCommandResultAttributeScope.SHORT);
help.getRecords().add(attrSrv);
+ OnapCommandResultAttribute attrState = new OnapCommandResultAttribute();
+ attrState.setName(OnapCommandConstants.INFO_STATE.toUpperCase());
+ attrState.setDescription(OnapCommandConstants.INFO_STATE);
+ attrState.setScope(OnapCommandResultAttributeScope.SHORT);
+ help.getRecords().add(attrState);
+
+
OnapCommandResultAttribute attrDesc = new OnapCommandResultAttribute();
attrDesc.setName(OnapCommandConstants.DESCRIPTION.toUpperCase());
attrDesc.setDescription(OnapCommandConstants.DESCRIPTION);
attrDesc.setScope(OnapCommandResultAttributeScope.SHORT);
help.getRecords().add(attrDesc);
- for (String cmdName : isEnabledProductVersionOnly ? OnapCommandUtils.sort(this.listCommandsForEnabledProductVersion()) : OnapCommandUtils.sort(this.listCommands())) {
+ for (String cmdName : isEnabledProductVersionOnly ?
+ OnapCommandUtils.sort(this.listCommandsForEnabledProductVersion()) :
+ OnapCommandUtils.sort(this.listCommands())) {
OnapCommand cmd;
try {
if (!isEnabledProductVersionOnly) {
@@ -385,8 +394,9 @@ public class OnapCommandRegistrar {
attr.getValues().add(cmdName);
}
- attrSrv.getValues().add(cmd.printVersion());
+ attrSrv.getValues().add(cmd.getInfo().getService());
attrDesc.getValues().add(cmd.getDescription());
+ attrState.getValues().add(cmd.getInfo().getState().name());
} catch (OnapCommandException e) {
throw new OnapCommandHelpFailed(e);
}
diff --git a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java
index af444b8f..df30a240 100644
--- a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java
+++ b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java
@@ -18,6 +18,7 @@ package org.onap.cli.fw.schema;
import org.onap.cli.fw.cmd.OnapCommandType;
import org.onap.cli.fw.conf.OnapCommandConstants;
+import org.onap.cli.fw.info.OnapCommandState;
import java.util.ArrayList;
import java.util.List;
@@ -55,6 +56,8 @@ public class OnapCommandSchemaInfo {
private String ignore = OnapCommandConstants.BOOLEAN_FALSE;
+ private String state = OnapCommandState.STABLE.name();
+
public String getSchemaName() {
return schemaName;
}
@@ -126,4 +129,14 @@ public class OnapCommandSchemaInfo {
public List<String> getSampleFiles() {
return sampleFiles;
}
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+
}
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 628ddf3a..06d688b4 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
@@ -30,6 +30,7 @@ import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_PARAMS_LIST;
import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_PARAMS_MANDATORY_LIST;
import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_PRODUCT;
import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_SERVICE;
+import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_STATE;
import static org.onap.cli.fw.conf.OnapCommandConstants.INFO_TYPE;
import static org.onap.cli.fw.conf.OnapCommandConstants.INPUT_PARAMS_LIST;
import static org.onap.cli.fw.conf.OnapCommandConstants.INPUT_PARAMS_MANDATORY_LIST;
@@ -67,7 +68,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.io.FileUtils;
import org.onap.cli.fw.cmd.OnapCommand;
import org.onap.cli.fw.cmd.OnapCommandType;
import org.onap.cli.fw.conf.OnapCommandConfig;
@@ -79,6 +79,7 @@ import org.onap.cli.fw.error.OnapCommandParameterNameConflict;
import org.onap.cli.fw.error.OnapCommandParameterOptionConflict;
import org.onap.cli.fw.error.OnapCommandSchemaNotFound;
import org.onap.cli.fw.info.OnapCommandInfo;
+import org.onap.cli.fw.info.OnapCommandState;
import org.onap.cli.fw.input.OnapCommandParameter;
import org.onap.cli.fw.input.OnapCommandParameterType;
import org.onap.cli.fw.output.OnapCommandPrintDirection;
@@ -248,6 +249,11 @@ public class OnapCommandSchemaLoader {
info.setCommandType(OnapCommandType.get(obj.toString()));
break;
+ case INFO_STATE:
+ Object state = infoMap.get(key1);
+ info.setState(OnapCommandState.get(state.toString()));
+ break;
+
case INFO_AUTHOR:
Object mode = infoMap.get(key1);
info.setAuthor(mode.toString());
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
index d0789d74..9bdd8a51 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
@@ -278,6 +278,11 @@ public class OnapCommandDiscoveryUtils {
if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_IGNORE) != null) {
schema.setIgnore(infoMap.get(OnapCommandConstants.INFO_IGNORE).toString());
}
+
+ if (infoMap != null && infoMap.get(OnapCommandConstants.INFO_STATE) != null) {
+ schema.setState(infoMap.get(OnapCommandConstants.INFO_STATE).toString());
+ }
+
schema.setSchemaProfile(identitySchemaProfileType(resourceMap));
extSchemas.add(schema);
diff --git a/framework/src/main/resources/open-cli.properties b/framework/src/main/resources/open-cli.properties
index 79800fbc..cdb6dd12 100644
--- a/framework/src/main/resources/open-cli.properties
+++ b/framework/src/main/resources/open-cli.properties
@@ -6,7 +6,7 @@ cli.discover_always=false
cli.schema.base.sections=open_cli_schema_version,name,description,parameters,results,info
cli.schema.base.sections.mandatory=open_cli_schema_version
-cli.schema.base.info.sections=product,service,type,author,ignore
+cli.schema.base.info.sections=product,service,type,author,ignore,state
cli.schema.base.info.sections.mandatory=product,service
cli.schema.base.parameters.sections=name,description,type,short_option,long_option, is_optional,default_value,is_secured,is_include,is_default_param