diff options
author | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-12-21 12:44:57 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2017-12-21 12:44:57 +0530 |
commit | 82b9e1fb1673b2ea2cf16c074ce0c76c200fff8a (patch) | |
tree | aecf13e01e0e5f74854f35c26ec89c36a58ba892 /profiles/http/src/main/java/org | |
parent | e8e6e21d2ecf21920a338860ee21a11c6278caaf (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/http/src/main/java/org')
4 files changed, 26 insertions, 14 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()) { |