diff options
author | subhash kumar singh <subhash.kumar.singh@huawei.com> | 2018-03-27 09:59:57 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-03-27 09:59:57 +0000 |
commit | 1728b94a35c33719e87c664ecc726db4b07dc20c (patch) | |
tree | 6634c30917445f90c565b12e144ae98a942e94ea | |
parent | 63209d5f04eef41c54b3ab04e1950e17a4e8e2bb (diff) | |
parent | b62e343f9338ed662805c2bee1772082ef4631ff (diff) |
Merge changes I72578476,I9eef1884,Ie79342fc,I828f860a,I8c5cce76, ...
* changes:
Add policy feature in onap beijing products
Add policy basic auth onap beijing
Add state info in help message
Discover command state and persist
Intrdouce command state
Strip off poduct name from service name in help
13 files changed, 220 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 diff --git a/framework/src/test/resources/open-cli-schema/sample-test-schema.yaml b/framework/src/test/resources/open-cli-schema/sample-test-schema.yaml index f4894b3f..2ab2127a 100644 --- a/framework/src/test/resources/open-cli-schema/sample-test-schema.yaml +++ b/framework/src/test/resources/open-cli-schema/sample-test-schema.yaml @@ -6,6 +6,7 @@ info: service: test type: cmd author: Kanagaraj Manickam kanagaraj.manickam@huawei.com + state: experimental parameters: - name: bool-param type: bool diff --git a/products/onap-beijing/auth/src/main/java/org/onap/cli/cmd/auth/OnapPolicyBasicAuthLoginCommandBeijing.java b/products/onap-beijing/auth/src/main/java/org/onap/cli/cmd/auth/OnapPolicyBasicAuthLoginCommandBeijing.java new file mode 100644 index 00000000..faa4a1f2 --- /dev/null +++ b/products/onap-beijing/auth/src/main/java/org/onap/cli/cmd/auth/OnapPolicyBasicAuthLoginCommandBeijing.java @@ -0,0 +1,30 @@ +/* + * 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.cmd.auth; + +import org.onap.cli.fw.error.OnapCommandException; +import org.onap.cli.fw.http.cmd.BasicAuthLoginCommand; +import org.onap.cli.fw.schema.OnapCommandSchema; + +@OnapCommandSchema(schema = "basic-login-onap-sdc-beijing.yaml") +public class OnapPolicyBasicAuthLoginCommandBeijing extends BasicAuthLoginCommand { + + @Override + protected void run() throws OnapCommandException { + //don't do anything... + } +} diff --git a/products/onap-beijing/auth/src/main/resources/open-cli-schema/basic-login-onap-policy-beijing.yaml b/products/onap-beijing/auth/src/main/resources/open-cli-schema/basic-login-onap-policy-beijing.yaml new file mode 100644 index 00000000..5596ec65 --- /dev/null +++ b/products/onap-beijing/auth/src/main/resources/open-cli-schema/basic-login-onap-policy-beijing.yaml @@ -0,0 +1,46 @@ +# 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. + +open_cli_schema_version: 1.0 + +name: policy-basic-login + +description: ONAP basic login auth command + + +info: + product: onap-beijing + service: policy-basic-auth + type: auth + author: ONAP CLI Team onap-discuss@lists.onap.org + + +results: + direction: portrait + attributes: + - name: Authorization + description: Authorization + scope: short + type: string + default_value: Basic dGVzdHBkcDphbHBoYTEyMw== + - name: Environment + description: Environment + scope: short + type: string + default_value: ONAP-CLI + - name: ClientAuth + description: Client Auth + scope: short + type: string + default_value: cHl0aG9uOnRlc3Q=
\ No newline at end of file diff --git a/products/onap-beijing/features/policy/pom.xml b/products/onap-beijing/features/policy/pom.xml new file mode 100644 index 00000000..1bc21aca --- /dev/null +++ b/products/onap-beijing/features/policy/pom.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 + http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onap.cli</groupId> + <artifactId>cli-products-onap-beijing-features</artifactId> + <version>2.0.0</version> + </parent> + + <artifactId>cli-products-onap-beijing-features-policy</artifactId> + <name>cli/products/onap-beijing/features/policy</name> + <packaging>jar</packaging> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + </plugin> + </plugins> + </build> +</project> diff --git a/products/onap-beijing/features/pom.xml b/products/onap-beijing/features/pom.xml index d49f8b1d..313b7429 100644 --- a/products/onap-beijing/features/pom.xml +++ b/products/onap-beijing/features/pom.xml @@ -36,6 +36,7 @@ <module>msb</module> <module>so</module> <module>sdc</module> + <module>policy</module> </modules> <build> |