From 7fcf1e84c6e2a1b8bfbeaff52b8baa9bc8d418d6 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 18 Aug 2017 12:09:45 +0530 Subject: Move schema validation to load schema Move schema validation to load schema. Issue-Id: CLI-25 Change-Id: I68855caf80cf1b55b41916e124a53b53e7af93d3 Signed-off-by: Subhash Kumar Singh --- .../main/java/org/onap/cli/fw/conf/Constants.java | 19 +++++++++++++ .../org/onap/cli/fw/conf/OnapCommandConfg.java | 6 ++++ .../fw/error/OnapCommandHttpInvalidResultMap.java | 32 ++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 framework/src/main/java/org/onap/cli/fw/error/OnapCommandHttpInvalidResultMap.java (limited to 'framework/src/main/java/org') 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 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 invalidParams) { + super("0x0028", "Invalide result map parameters : " + invalidParams.toString()); + } +} -- cgit 1.2.3-korg