summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/Constants.java19
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConfg.java6
-rw-r--r--framework/src/main/java/org/onap/cli/fw/error/OnapCommandHttpInvalidResultMap.java32
-rw-r--r--framework/src/main/resources/onap.properties27
-rw-r--r--framework/src/test/resources/onap.properties27
6 files changed, 112 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 97767e14..9b8e81a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,6 @@ coverage-report/
.classpath
.class
.checkstyle
+*.iml
+*.log
+.idea
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 f6a4193f..d559f7aa 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
@@ -22,6 +22,25 @@ package org.onap.cli.fw.conf;
*/
public class Constants {
+ // schema validation
+ public static final String TOP_LEVEL_PARAMS_LIST ="cli.schema.top_level_params_list";
+ public static final String TOP_LEVEL_MANDATORY_LIST ="cli.schema.top_level_mandatory_list";
+ public static final String SERVICE_PARAMS_LIST ="cli.schema.service_params_list";
+ public static final String SERVICE_PARAMS_MANDATORY_LIST ="cli.schema.service_params_mandatory_list";
+ public static final String INPUT_PARAMS_LIST ="cli.schema.input_params_list";
+ public static final String INPUT_PARAMS_MANDATORY_LIST ="cli.schema.input_params_mandatory_list";
+ public static final String RESULT_PARAMS_LIST ="cli.schema.result_params_list";
+ public static final String RESULT_PARAMS_MANDATORY_LIST ="cli.schema.result_params_mandatory_list";
+ public static final String HTTP_SECTIONS ="cli.schema.http_sections";
+ public static final String HTTP_MANDATORY_SECTIONS ="cli.schema.http_mandatory_sections";
+ public static final String HTTP_REQUEST_PARAMS ="cli.schema.http_request_params";
+ public static final String HTTP_REQUEST_MANDATORY_PARAMS ="cli.schema.http_request_mandatory_params";
+ public static final String HTTP_METHODS ="cli.schema.http_methods";
+ public static final String BOOLEAN_VALUE ="cli.schema.boolean_values";
+ public static final String AUTH_VALUES="cli.schema.auth_values";
+ public static final String MODE_VALUES="cli.schema.mode_values";
+
+
public static final String SSLCONTEST_TLS = "TLSV1.2";
public static final String APPLICATION_JSON = "application/json";
public static final String X_AUTH_TOKEN = "x-auth-token";
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 acb2c2b0..1dfd345c 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
@@ -19,6 +19,7 @@ package org.onap.cli.fw.conf;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -133,4 +134,9 @@ public final class OnapCommandConfg {
return Arrays.stream(prps.getProperty(Constants.NO_AUTH_ENABLE_INCLUDE_PARAMS_EXTERNAL_CMD)
.split(",")).map(String::trim).collect(Collectors.toSet());
}
+
+ public static List<String> getSchemaAttrInfo(String key) {
+ return Arrays.stream(prps.getProperty(key).split(",")).map(String::trim).collect(Collectors.toList());
+ }
+
}
diff --git a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandHttpInvalidResultMap.java b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandHttpInvalidResultMap.java
new file mode 100644
index 00000000..491f18cb
--- /dev/null
+++ b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandHttpInvalidResultMap.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.List;
+
+/**
+ * Invalid result map in HTTP section.
+ *
+ */
+public class OnapCommandHttpInvalidResultMap extends OnapCommandException {
+
+ private static final long serialVersionUID = 6676137916023457963L;
+
+ public OnapCommandHttpInvalidResultMap(List<String> invalidParams) {
+ super("0x0028", "Invalide result map parameters : " + invalidParams.toString());
+ }
+}
diff --git a/framework/src/main/resources/onap.properties b/framework/src/main/resources/onap.properties
index 84a86e83..8a2756e4 100644
--- a/framework/src/main/resources/onap.properties
+++ b/framework/src/main/resources/onap.properties
@@ -21,4 +21,29 @@ cli.http.basic.common_headers.x-app-id=X-FromAppId
cli.http.basic.common_headers.x-app-id.value=onap-cli
#TODO mrkanag add support for aaf like defined above for basic
-#cli.service.auth=aaf \ No newline at end of file
+#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_mandatory_list=onap_cmd_schema_version
+
+cli.schema.service_params_list=name,version,auth,mode
+cli.schema.service_params_mandatory_list=name,version
+
+cli.schema.input_params_list=name,description,type,short_option,long_option, is_optional,default_value,is_secured
+cli.schema.input_params_mandatory_list=name,description,type
+
+cli.schema.result_params_list=name,description,scope,type,is_secured
+cli.schema.result_params_mandatory_list=name, description, type
+
+cli.schema.http_sections=request,success_codes,result_map,sample_response
+cli.schema.http_mandatory_sections=equest, success_codes
+
+cli.schema.http_request_params=uri,method,body,headers,queries
+cli.schema.http_request_mandatory_params=uri,method
+
+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 \ No newline at end of file
diff --git a/framework/src/test/resources/onap.properties b/framework/src/test/resources/onap.properties
index 84a86e83..8a2756e4 100644
--- a/framework/src/test/resources/onap.properties
+++ b/framework/src/test/resources/onap.properties
@@ -21,4 +21,29 @@ cli.http.basic.common_headers.x-app-id=X-FromAppId
cli.http.basic.common_headers.x-app-id.value=onap-cli
#TODO mrkanag add support for aaf like defined above for basic
-#cli.service.auth=aaf \ No newline at end of file
+#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_mandatory_list=onap_cmd_schema_version
+
+cli.schema.service_params_list=name,version,auth,mode
+cli.schema.service_params_mandatory_list=name,version
+
+cli.schema.input_params_list=name,description,type,short_option,long_option, is_optional,default_value,is_secured
+cli.schema.input_params_mandatory_list=name,description,type
+
+cli.schema.result_params_list=name,description,scope,type,is_secured
+cli.schema.result_params_mandatory_list=name, description, type
+
+cli.schema.http_sections=request,success_codes,result_map,sample_response
+cli.schema.http_mandatory_sections=equest, success_codes
+
+cli.schema.http_request_params=uri,method,body,headers,queries
+cli.schema.http_request_mandatory_params=uri,method
+
+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 \ No newline at end of file