summaryrefslogtreecommitdiffstats
path: root/profiles
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-12-21 12:44:57 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-12-21 12:44:57 +0530
commit82b9e1fb1673b2ea2cf16c074ce0c76c200fff8a (patch)
treeaecf13e01e0e5f74854f35c26ec89c36a58ba892 /profiles
parente8e6e21d2ecf21920a338860ee21a11c6278caaf (diff)
Add is_deafult_parm and is_default_attr
Issue-ID: CLI-66 Change-Id: Id6789ffda5d8ae93f4927564844bde36ecd88678 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'profiles')
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java2
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java4
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java8
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java26
-rw-r--r--profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml6
5 files changed, 31 insertions, 15 deletions
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java b/profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java
index 4b1752af..aa1368ec 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/auth/OnapCommandHttpAuthClient.java
@@ -116,7 +116,7 @@ public class OnapCommandHttpAuthClient {
if (cmd.getService().isModeDirect()){
return cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_HOST_URL).getValue().toString();
} else { //Catalog mode
- OnapCommand catalog = OnapCommandRegistrar.getRegistrar().get("catalog");
+ OnapCommand catalog = OnapCommandRegistrar.getRegistrar().get("catalog", cmd.getInfo().getProduct());
Map<String, String> paramsOverrides = new HashMap<>();
paramsOverrides.put(OnapCommandHttpConstants.CATALOG_SERVICE_NAME, cmd.getService().getName());
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java b/profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java
index 7178be81..12309341 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/cmd/OnapHttpCommand.java
@@ -102,8 +102,8 @@ public class OnapHttpCommand extends OnapCommand {
}
@Override
- protected List<String> initializeProfileSchema() throws OnapCommandException {
- return OnapCommandSchemaHttpLoader.loadHttpSchema(this, this.getSchemaName(), true, false);
+ protected List<String> initializeProfileSchema(boolean validate) throws OnapCommandException {
+ return OnapCommandSchemaHttpLoader.loadHttpSchema(this, this.getSchemaName(), true, validate);
}
@Override
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java b/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
index 1ce0433c..5b6df29d 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/connect/OnapHttpConnection.java
@@ -65,12 +65,16 @@ import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.onap.cli.fw.http.conf.OnapCommandHttpConstants;
import org.onap.cli.fw.http.error.OnapCommandHttpFailure;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Helps to make http connection.<br>
*/
public class OnapHttpConnection {
+ private static Logger LOG = LoggerFactory.getLogger(OnapHttpConnection.class);
+
private HttpClient httpClient = null;
Map<String, String> mapCommonHeaders = new HashMap<String, String> ();
@@ -331,8 +335,10 @@ public class OnapHttpConnection {
} catch (ParseException | IOException e) {
throw new OnapCommandHttpFailure(e);
} finally {
+ String info = input + " " + result;
+ LOG.info(info);
if (this.debug) {
- this.debugDetails = input + " " + result;
+ this.debugDetails = info;
}
}
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
index e4d2cf06..cd918783 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
@@ -38,6 +38,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jayway.jsonpath.JsonPath;
+import com.jayway.jsonpath.PathNotFoundException;
import net.minidev.json.JSONArray;
@@ -169,21 +170,26 @@ public class OnapCommandHttpUtils {
int idxE = headerProcessedLine.indexOf("}", idxS);
String jsonPath = headerProcessedLine.substring(idxS + 3, idxE);
jsonPath = jsonPath.trim();
+ Object value = new Object();
try {
// JSONArray or String
- Object value = JsonPath.read(resultHttp.getBody(), jsonPath);
- if (value instanceof JSONArray) {
- JSONArray arr = (JSONArray) value;
- if (arr.size() > maxRows) {
- maxRows = arr.size();
- }
- }
- bodyProcessedPattern += headerProcessedLine.substring(currentIdx, idxS) + "%s";
- values.add(value);
- currentIdx = idxE + 1;
+ value = JsonPath.read(resultHttp.getBody(), jsonPath);
+ } catch (PathNotFoundException e1) {
+ //set to blank for those entries which are missing from the output json
+ value = "";
} catch (Exception e) {
throw new OnapCommandHttpInvalidResponseBody(jsonPath, e);
}
+
+ if (value instanceof JSONArray) {
+ JSONArray arr = (JSONArray) value;
+ if (arr.size() > maxRows) {
+ maxRows = arr.size();
+ }
+ }
+ bodyProcessedPattern += headerProcessedLine.substring(currentIdx, idxS) + "%s";
+ values.add(value);
+ currentIdx = idxE + 1;
}
if (bodyProcessedPattern.isEmpty()) {
diff --git a/profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml b/profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml
index d7fbe03c..9029e273 100644
--- a/profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml
+++ b/profiles/http/src/main/resources/open-cli-schema/http/default_input_parameters_http.yaml
@@ -13,6 +13,7 @@ parameters:
long_option: host-username
default_value: $s{env:OPEN_CLI_HOST_USERNAME}
is_optional: false
+ is_default_param: true
- name: host-password
type: string
description: Host user password
@@ -21,6 +22,7 @@ parameters:
default_value: $s{env:OPEN_CLI_HOST_PASSWORD}
is_secured: true
is_optional: false
+ is_default_param: true
- name: host-url
type: url
description: host url in http(s)
@@ -28,9 +30,11 @@ parameters:
long_option: host-url
is_optional: false
default_value: $s{env:OPEN_CLI_HOST_URL}
+ is_default_param: true
- name: no-auth
type: bool
description: whether to authenticate user or not
short_option: a
long_option: no-auth
- default_value: false \ No newline at end of file
+ default_value: false
+ is_default_param: true \ No newline at end of file