diff options
Diffstat (limited to 'framework/src/main')
15 files changed, 220 insertions, 60 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/OnapCommand.java b/framework/src/main/java/org/onap/cli/fw/OnapCommand.java index 08cbc3bc..c65ca9a8 100644 --- a/framework/src/main/java/org/onap/cli/fw/OnapCommand.java +++ b/framework/src/main/java/org/onap/cli/fw/OnapCommand.java @@ -58,6 +58,8 @@ public abstract class OnapCommand { private String cmdSchemaName; + private String cmdVersion; + private OnapService onapService = new OnapService(); private List<OnapCommandParameter> cmdParameters = new ArrayList<>(); @@ -324,4 +326,12 @@ public abstract class OnapCommand { return OnapCommandUtils.help(this); } // (mrkanag) Add toString for all command, parameter, result, etc objects in JSON format + + public void setVersion(String version) { + this.cmdVersion = version; + } + + public String getVersion() { + return this.cmdVersion; + } } 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 567e0381..ca875b35 100644 --- a/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java +++ b/framework/src/main/java/org/onap/cli/fw/OnapCommandRegistrar.java @@ -16,6 +16,14 @@ package org.onap.cli.fw; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.onap.cli.fw.cmd.OnapHttpCommand; import org.onap.cli.fw.conf.Constants; import org.onap.cli.fw.conf.OnapCommandConfg; @@ -24,6 +32,7 @@ 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.OnapCommandRegistrationFailed; +import org.onap.cli.fw.error.OnapCommandRegistrationVersionMissing; import org.onap.cli.fw.output.OnapCommandResult; import org.onap.cli.fw.output.OnapCommandResultAttribute; import org.onap.cli.fw.output.OnapCommandResultAttributeScope; @@ -32,24 +41,17 @@ import org.onap.cli.fw.output.ResultType; import org.onap.cli.fw.utils.ExternalSchema; import org.onap.cli.fw.utils.OnapCommandUtils; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - /** * Onap Command registrar provides a common place, where every command would get registered automatically when its * loaded into JVM. * */ public class OnapCommandRegistrar { - /* - * static { //Start the AOP for logging new OnapCommandLogger(); } - */ + private Map<String, Class<? extends OnapCommand>> registry = new HashMap<>(); + private Set<String> availableProductVersions = new HashSet<>(); + private static OnapCommandRegistrar registrar = null; /** @@ -61,9 +63,15 @@ public class OnapCommandRegistrar { * Command Class * @throws OnapCommandInvalidRegistration * Invalid registration exception + * @throws OnapCommandRegistrationVersionMissing */ - public void register(String name, Class<? extends OnapCommand> cmd) throws OnapCommandInvalidRegistration { - this.registry.put(name, cmd); + public void register(String name, String version, Class<? extends OnapCommand> cmd) throws OnapCommandInvalidRegistration, OnapCommandRegistrationVersionMissing { + if (version == null || version.isEmpty()) { + throw new OnapCommandRegistrationVersionMissing(name); + } + + this.registry.put(name + ":" + version, cmd); + this.availableProductVersions.add(version); } /** @@ -92,6 +100,27 @@ public class OnapCommandRegistrar { } /** + * Get the list of discovered commands for a given product version in registrar. + * + * @return set + */ + public Set<String> listCommandsForEnabledProductVersion() { + String version = OnapCommandConfg.getEnabledProductVersion(); + + Set<String> cmds = new HashSet<>(); + if (!this.availableProductVersions.contains(version)) { + return cmds; + } + + for (String cmd: this.registry.keySet()) { + if (cmd.split(":")[1].equalsIgnoreCase(version)) { + cmds.add(cmd.split(":")[0]); + } + } + return cmds; + } + + /** * Returns map of command to schema. * * @return map @@ -103,7 +132,7 @@ public class OnapCommandRegistrar { List<ExternalSchema> schemas = OnapCommandUtils.findAllExternalSchemas(); if (schemas != null) { for (ExternalSchema schema : schemas) { - map.put(schema.getCmdName(), schema.getSchemaName()); + map.put(schema.getCmdName() + ":" + schema.getCmdVersion(), schema.getSchemaName()); } } if (this.registry != null) { @@ -127,19 +156,23 @@ public class OnapCommandRegistrar { * Exception */ public OnapCommand get(String cmdName) throws OnapCommandException { - OnapCommand cmd; - Class<? extends OnapCommand> cls = registry.get(cmdName); + return this.get(cmdName, OnapCommandConfg.getEnabledProductVersion()); + } + + private OnapCommand get(String cmdName, String version) throws OnapCommandException { + Class<? extends OnapCommand> cls = registry.get(cmdName + ":" + version); if (cls == null) { - throw new OnapCommandNotFound(cmdName); + throw new OnapCommandNotFound(cmdName, version); } + OnapCommand cmd; try { Constructor<?> constr = cls.getConstructor(); cmd = (OnapCommand) constr.newInstance(); String schemaName; if (cmd.getClass().equals(OnapHttpCommand.class)) { // NOSONAR - schemaName = OnapCommandUtils.loadExternalSchemaFromJson(cmdName).getSchemaName(); + schemaName = OnapCommandUtils.loadExternalSchemaFromJson(cmdName, version).getSchemaName(); } else { schemaName = this.getSchemaFileName(cls); } @@ -152,13 +185,13 @@ public class OnapCommandRegistrar { return cmd; } - private void autoDiscover() throws OnapCommandInvalidRegistration { + private void autoDiscover() throws OnapCommandInvalidRegistration, OnapCommandRegistrationVersionMissing { List<Class<OnapCommand>> cmds = OnapCommandUtils.findOnapCommands(); for (Class<OnapCommand> cmd : cmds) { if (cmd.isAnnotationPresent(OnapCommandSchema.class)) { OnapCommandSchema ano = cmd.getAnnotation(OnapCommandSchema.class); - this.register(ano.name(), cmd); + this.register(ano.name(), ano.version(), cmd); } } } @@ -166,15 +199,14 @@ public class OnapCommandRegistrar { private void autoDiscoverHttpSchemas() throws OnapCommandException { List<ExternalSchema> schemas = OnapCommandUtils.loadExternalSchemasFromJson(); for (ExternalSchema schema : schemas) { - this.register(schema.getCmdName(), OnapHttpCommand.class); + if (schema.isHttp()) { + this.register(schema.getCmdName(), schema.getCmdVersion(), OnapHttpCommand.class); + } } } private String getSchemaFileName(Class<? extends OnapCommand> cmd) { OnapCommandSchema ano = (OnapCommandSchema) cmd.getAnnotation(OnapCommandSchema.class); - if (ano.schema().isEmpty()) { - return "onap-" + ano.name() + "-schema.yaml"; - } return ano.schema(); } @@ -188,7 +220,18 @@ public class OnapCommandRegistrar { if (version == null) { version = OnapCommandConfg.getVersion(); } - return version; + + String configuredProductVersion = OnapCommandConfg.getEnabledProductVersion(); + + 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"; + } + return "CLI version : " + version + "\n" + + "Available product versions: " + this.availableProductVersions.toString() + "\n" + + "Enabled product version : " + configuredProductVersion + "\n" + + errorNote; } /** @@ -209,6 +252,12 @@ public class OnapCommandRegistrar { attr.setScope(OnapCommandResultAttributeScope.SHORT); help.getRecords().add(attr); + OnapCommandResultAttribute attrVer = new OnapCommandResultAttribute(); + attrVer.setName(Constants.PRODUCT_VERSION.toUpperCase()); + attrVer.setDescription(Constants.DESCRIPTION); + attrVer.setScope(OnapCommandResultAttributeScope.SHORT); + help.getRecords().add(attrVer); + OnapCommandResultAttribute attrSrv = new OnapCommandResultAttribute(); attrSrv.setName(Constants.SERVICE.toUpperCase()); attrSrv.setDescription(Constants.SERVICE); @@ -224,18 +273,19 @@ public class OnapCommandRegistrar { for (String cmdName : OnapCommandUtils.sort(this.listCommands())) { OnapCommand cmd; try { - cmd = this.get(cmdName); + String []cmdVer = cmdName.split(":"); + cmd = this.get(cmdVer[0], cmdVer[1]); + attr.getValues().add(cmdVer[0]); + attrVer.getValues().add(cmdVer[1]); + attrSrv.getValues().add(cmd.printVersion()); + attrDesc.getValues().add(cmd.getDescription()); } catch (OnapCommandException e) { throw new OnapCommandHelpFailed(e); } - - attr.getValues().add(cmd.getName()); - attrSrv.getValues().add(cmd.printVersion()); - attrDesc.getValues().add(cmd.getDescription()); } try { - return "\n\nOnap sub-commands:\n" + help.print(); + return "\n\nOnap sub-commands:\n" + help.print() + "\n" + this.getVersion(); } catch (OnapCommandException e) { throw new OnapCommandHelpFailed(e); } diff --git a/framework/src/main/java/org/onap/cli/fw/OnapCommandSchema.java b/framework/src/main/java/org/onap/cli/fw/OnapCommandSchema.java index 853d3583..471ab057 100644 --- a/framework/src/main/java/org/onap/cli/fw/OnapCommandSchema.java +++ b/framework/src/main/java/org/onap/cli/fw/OnapCommandSchema.java @@ -40,6 +40,13 @@ public @interface OnapCommandSchema { String name(); /** + * Command version + * + * @return + */ + String version(); + + /** * Schema file name placed under class path * * @return diff --git a/framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java b/framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java index e9d495c6..458a7587 100644 --- a/framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java +++ b/framework/src/main/java/org/onap/cli/fw/ad/OnapAuthClient.java @@ -54,8 +54,6 @@ public class OnapAuthClient { private OnapService service = new OnapService(); - private String authType = OnapCommandConfg.getAuthType(); - private Map<String, String> paramMap = new HashMap<>(); public OnapAuthClient(OnapCredentials creds, boolean debug, OnapService service, List<OnapCommandParameter> params) throws OnapCommandHttpFailure, OnapCommandInvalidParameterValue { @@ -64,7 +62,6 @@ public class OnapAuthClient { for (OnapCommandParameter param : params) { paramMap.put(param.getName(), param.getValue().toString()); } - this.authType = service.getAuthType(); this.http = new OnapHttpConnection(creds.getHostUrl().startsWith("https"), debug); } @@ -88,15 +85,14 @@ public class OnapAuthClient { return; } - if (this.authType.equalsIgnoreCase(Constants.AUTH_BASIC)) { + if (this.service.getAuthType().equalsIgnoreCase(Constants.AUTH_BASIC)) { String authToken = BasicScheme.authenticate(new UsernamePasswordCredentials( creds.getUsername(), creds.getPassword()), "UTF-8", false).getValue(); Map<String, String> mapHeaders = OnapCommandConfg.getBasicCommonHeaders(this.paramMap); - if(this.service.getName() != null){ - mapHeaders.putAll(OnapCommandConfg.getServiceHeaders(this.service.getName(), this.paramMap)); - } + mapHeaders.putAll(OnapCommandConfg.getServiceHeaders(this.service.getName(), this.paramMap)); mapHeaders.put(OnapCommandConfg.getXAuthTokenName(), authToken); + this.http.setCommonHeaders(mapHeaders); return; } diff --git a/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommand.java b/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommand.java index 57432751..81cdfca2 100644 --- a/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommand.java +++ b/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaRefreshCommand.java @@ -30,7 +30,7 @@ import java.util.List; * Refresh external schema. * */ -@OnapCommandSchema(name = "schema-refresh", schema = "schema-refresh.yaml") +@OnapCommandSchema(name = "schema-refresh", version="0.0", schema = "schema-refresh.yaml") public class OnapSchemaRefreshCommand extends OnapCommand { @Override diff --git a/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommand.java b/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommand.java index b1811483..140ac818 100644 --- a/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommand.java +++ b/framework/src/main/java/org/onap/cli/fw/cmd/OnapSchemaValidateCommand.java @@ -29,7 +29,7 @@ import java.util.Map; /** * Validate schema command. */ -@OnapCommandSchema(name = "schema-validate", schema = "schema-validate.yaml") +@OnapCommandSchema(name = "schema-validate", version="0.0", schema = "schema-validate.yaml") public class OnapSchemaValidateCommand extends OnapCommand { @Override 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 e9b158e7..980b94d3 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 @@ -129,6 +129,8 @@ public class Constants { public static final String CONF = "onap.properties"; public static final String ONAP_IGNORE_AUTH = "cli.ignore_auth"; public static final String ONAP_CLI_VERSION = "cli.version"; + public static final String ONAP_CLI_PRODUCT_VERSION = "cli.product.version"; + public static final String ONAP_CLI_PRODUCT_VERSION_ENV_NAME = "CLI_PRODUCT_VERSION"; public static final String HTTP_API_KEY_USE_COOKIES = "cli.http.api_key_use_cookies"; public static final String EXCLUDE_PARAMS_INTERNAL_CMD = "cli.exclude_params_internal_cmd"; public static final String NO_AUTH_DISABLE_INCLUDE_PARAMS_EXTERNAL_CMD = "cli.no_auth_disable_include_params_external_cmd"; @@ -146,7 +148,7 @@ public class Constants { public static final String EXTERNAL_JSON_PATTERN = "/**/*.json"; public static final String EXTERNAL_SCHEMA_PATH_PATERN = EXTERNAL_SCHEMA_DIRECTORY + EXTERNAL_YAML_PATTERN; public static final String EXTERNAL_DISCOVERY_DIRECTORY = "data"; - public static final String EXTERNAL_DISCOVERY_FILE = "external-schema.json"; + public static final String EXTERNAL_DISCOVERY_FILE = "cli-schema.json"; public static final String EXTERNAL_DISCOVERY_DIRECTORY_PATTERN = EXTERNAL_DISCOVERY_DIRECTORY + EXTERNAL_JSON_PATTERN; @@ -177,6 +179,7 @@ public class Constants { public static final String DEFAULT_SCHEMA_FILE_NAME = "default_input_parameters.yaml"; + public static final String PRODUCT_VERSION = "product version"; // Error message public static final String SCHEMA_INVALID_DEFAULT_PARAMS_SECTION = "Invalid default_parameter section"; public static final String SCHEMA_FILE_EMPTY = "The schema file cann't be null or empty"; diff --git a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConfg.java b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConfg.java index 479431f2..5ca0589f 100644 --- a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConfg.java +++ b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConfg.java @@ -68,6 +68,14 @@ public final class OnapCommandConfg { return prps.getProperty(Constants.ONAP_CLI_VERSION); } + public static String getEnabledProductVersion() { + String version = System.getenv(Constants.ONAP_CLI_PRODUCT_VERSION_ENV_NAME); + if (version == null) { + version = prps.getProperty(Constants.ONAP_CLI_PRODUCT_VERSION); + } + return version; + } + /** * checks if cookies based auth. * @@ -103,22 +111,25 @@ public final class OnapCommandConfg { private static Map<String, String> getHeaderValues(String headerKey, Map<String, String> paramMap) { Map<String, String> mapHeaders = new HashMap<String, String> (); - Arrays.stream(prps.getProperty(headerKey) // NOSONAR - .split(",")).map(String::trim).forEach(header -> { - String headerName = prps.getProperty(headerKey+ "." + header); - String headerValue = prps.getProperty(headerKey + "." + header + ".value", null); - if (headerValue != null) { - headerValue = headerValue.replaceAll("uuid", UUID.randomUUID().toString()); - if (headerValue.contains("${")) { - String param = headerValue.substring(headerValue.indexOf("${")+2 ,headerValue.indexOf("}")); - String pattern = "${"+param+"}"; - headerValue = headerValue.replace(pattern, paramMap.getOrDefault(param, param)); + if (prps.containsKey(headerKey)) { + Arrays.stream(prps.getProperty(headerKey) // NOSONAR + .split(",")).map(String::trim).forEach(header -> { + String headerName = prps.getProperty(headerKey+ "." + header); + String headerValue = prps.getProperty(headerKey + "." + header + ".value", null); + if (headerValue != null) { + headerValue = headerValue.replaceAll("uuid", UUID.randomUUID().toString()); + if (headerValue.contains("${")) { + String param = headerValue.substring(headerValue.indexOf("${")+2 ,headerValue.indexOf("}")); + String pattern = "${"+param+"}"; + headerValue = headerValue.replace(pattern, paramMap.getOrDefault(param, param)); + } } - } - mapHeaders.put(headerName, headerValue); - }); + mapHeaders.put(headerName, headerValue); + }); + } return mapHeaders; } + public static Map<String, String> getBasicCommonHeaders(Map<String, String> paramMap) { return getHeaderValues(Constants.SERVICE_AUTH_BASIC_HTTP_HEADERS, paramMap); } diff --git a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandNotFound.java b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandNotFound.java index 172d60bb..4a070fb3 100644 --- a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandNotFound.java +++ b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandNotFound.java @@ -24,7 +24,8 @@ public class OnapCommandNotFound extends OnapCommandException { private static final long serialVersionUID = 6676137916079057963L; - public OnapCommandNotFound(String cmdName) { - super("0x0011", "Command " + cmdName + " is not registered"); + public OnapCommandNotFound(String cmdName, String version) { + super("0x0011", "Command " + cmdName + " is not available for product version " + version + + ". so please check command name or product version set in env variable CLI_PRODUCT_VERSION or cli.product.version in onap.properties"); } } diff --git a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandRegistrationVersionMissing.java b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandRegistrationVersionMissing.java new file mode 100644 index 00000000..2bad5a4c --- /dev/null +++ b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandRegistrationVersionMissing.java @@ -0,0 +1,30 @@ +/* + * 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; + +/** + * Command Not registered in Onap Command Registrar as version missing. + * + */ +public class OnapCommandRegistrationVersionMissing extends OnapCommandException { + + private static final long serialVersionUID = 5513297861129088463L; + + public OnapCommandRegistrationVersionMissing(String cmdName) { + super("0x0031", "Command " + cmdName + " version is missing"); + } +} diff --git a/framework/src/main/java/org/onap/cli/fw/utils/ExternalSchema.java b/framework/src/main/java/org/onap/cli/fw/utils/ExternalSchema.java index e9f19673..12f217ce 100644 --- a/framework/src/main/java/org/onap/cli/fw/utils/ExternalSchema.java +++ b/framework/src/main/java/org/onap/cli/fw/utils/ExternalSchema.java @@ -19,8 +19,11 @@ package org.onap.cli.fw.utils; public class ExternalSchema { private String schemaName; + private String schemaURI; private String cmdName; + private String cmdVersion; private String version; + private String http = "false"; public String getSchemaName() { return schemaName; @@ -46,4 +49,32 @@ public class ExternalSchema { this.version = version; } + public String getCmdVersion() { + return cmdVersion; + } + + public void setCmdVersion(String cmdVersion) { + this.cmdVersion = cmdVersion; + } + + public String getSchemaURI() { + return schemaURI; + } + + public void setSchemaURI(String schemaURI) { + this.schemaURI = schemaURI; + } + + public String getHttp() { + return http; + } + + public void setHttp(String internal) { + this.http = internal; + } + + public boolean isHttp() { + return this.getHttp().equals("true"); + } + } diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java index 625c644b..b31b75cf 100644 --- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java +++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java @@ -25,6 +25,7 @@ import org.onap.cli.fw.ad.OnapCredentials; import org.onap.cli.fw.ad.OnapService; import org.onap.cli.fw.cmd.OnapHttpCommand; import org.onap.cli.fw.cmd.OnapSwaggerCommand; +import org.onap.cli.fw.conf.Constants; import org.onap.cli.fw.conf.OnapCommandConfg; import org.onap.cli.fw.error.OnapCommandDiscoveryFailed; import org.onap.cli.fw.error.OnapCommandException; @@ -372,6 +373,13 @@ public class OnapCommandUtils { } break; + case VERSION: + Object version = values.get(key); + if (version != null) { + cmd.setVersion(version.toString()); + } + break; + case DESCRIPTION: Object description = values.get(key); if (description != null) { @@ -1482,7 +1490,11 @@ public class OnapCommandUtils { for (Entry<String, String> entry : resultMap.entrySet()) { String key = entry.getKey(); - resultsProcessed.put(key, replaceLineFromOutputResults(resultMap.get(key), resultHttp)); + try { + resultsProcessed.put(key, replaceLineFromOutputResults(resultMap.get(key), resultHttp)); + } catch(OnapCommandResultEmpty e) { + // pass // NOSONAR + } } return resultsProcessed; @@ -1508,9 +1520,14 @@ public class OnapCommandUtils { if (resourceMap != null && resourceMap.size() > 0) { ExternalSchema schema = new ExternalSchema(); schema.setSchemaName(resource.getFilename()); + schema.setSchemaURI(resource.getURI().toString()); schema.setCmdName((String) resourceMap.get(NAME)); Object obj = resourceMap.get(ONAP_CMD_SCHEMA_VERSION); schema.setVersion(obj.toString()); + schema.setCmdVersion(resourceMap.get(Constants.VERSION).toString()); + if (resourceMap.get(Constants.HTTP) != null) { + schema.setHttp("true"); + } extSchemas.add(schema); } } @@ -1672,12 +1689,12 @@ public class OnapCommandUtils { * @throws OnapCommandDiscoveryFailed * exception */ - public static ExternalSchema loadExternalSchemaFromJson(String cmd) throws OnapCommandException { + public static ExternalSchema loadExternalSchemaFromJson(String cmd, String version) throws OnapCommandException { List<ExternalSchema> list = loadExternalSchemasFromJson(); ExternalSchema schemaStr = null; if (list != null) { for (ExternalSchema schema : list) { - if (cmd.equals(schema.getCmdName())) { + if (cmd.equals(schema.getCmdName()) && version.equals(schema.getCmdVersion())) { schemaStr = schema; break; } diff --git a/framework/src/main/resources/schema-refresh.yaml b/framework/src/main/resources/onap-cli-schema/schema-refresh.yaml index 59f2496c..56492502 100644 --- a/framework/src/main/resources/schema-refresh.yaml +++ b/framework/src/main/resources/onap-cli-schema/schema-refresh.yaml @@ -1,6 +1,7 @@ onap_cmd_schema_version: 1.0 name: schema-refresh description: Onap command to refresh schemas stored in onap_cli_schema folders. +version: 0.0 service: auth: none name: onap-cli diff --git a/framework/src/main/resources/schema-validate.yaml b/framework/src/main/resources/onap-cli-schema/schema-validate.yaml index 76945793..a4c1fd29 100644 --- a/framework/src/main/resources/schema-validate.yaml +++ b/framework/src/main/resources/onap-cli-schema/schema-validate.yaml @@ -1,6 +1,7 @@ onap_cmd_schema_version: 1.0 name: schema-validate description: Onap command to validate schema +version: 0.0 service: auth: none name: onap-cli diff --git a/framework/src/main/resources/onap.properties b/framework/src/main/resources/onap.properties index 9d59f1e2..9e6b34bd 100644 --- a/framework/src/main/resources/onap.properties +++ b/framework/src/main/resources/onap.properties @@ -12,7 +12,6 @@ cli.no_auth_disable_include_params_external_cmd=onap-username,onap-password,host cli.no_auth_enable_exclude_params_external_cmd=onap-username,onap-password,no-auth cli.no_auth_enable_include_params_external_cmd=host-url -cli.service.auth=aaf cli.http.basic.common_headers=x-auth-token,x-transaction-id,x-app-id cli.http.basic.common_headers.x-auth-token=Authorization cli.http.basic.common_headers.x-transaction-id=X-TransactionId @@ -29,7 +28,7 @@ cli.http.basic.common_headers.sdc.user-id.value=${onap-username} #cli.service.auth=aaf #schema validation -cli.schema.top_level_params_list=onap_cmd_schema_version,name,description,service,parameters,results,http +cli.schema.top_level_params_list=onap_cmd_schema_version,name,version,description,service,parameters,results,http cli.schema.top_level_mandatory_list=onap_cmd_schema_version cli.schema.service_params_list=name,version,auth,mode @@ -52,3 +51,6 @@ cli.schema.http_methods=post,get,delete,put,head cli.schema.boolean_values=true,false cli.schema.auth_values=none,basic cli.schema.mode_values=direct,catalog + +#product version +cli.product.version=cli-1.0 |