diff options
Diffstat (limited to 'profiles')
3 files changed, 33 insertions, 4 deletions
diff --git a/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java b/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java index 40ccf5c4..bc864529 100644 --- a/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java +++ b/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import org.apache.commons.io.FileUtils; import org.onap.cli.fw.cmd.OnapCommand; import org.onap.cli.fw.cmd.conf.OnapCommandCmdConstants; import org.onap.cli.fw.cmd.error.OnapCommandCmdFailure; @@ -175,11 +176,13 @@ public class OpenCommandShellCmd extends OnapCommand { //add oclip specific environment variables if (this.getExecutionContext() != null) { envs.add("OPEN_CLI_REQUEST_ID=" + this.getExecutionContext().getRequestId()); + if (this.getExecutionContext().getProfile() != null) { + envs.add("OPEN_CLI_PROFILE=" + this.getExecutionContext().getProfile()); + } if (OnapCommandRegistrar.getRegistrar().getHost() != null) { envs.add("OPEN_CLI_RPC_HOST=" + OnapCommandRegistrar.getRegistrar().getHost()); envs.add("OPEN_CLI_RPC_PORT=" + OnapCommandRegistrar.getRegistrar().getPort()); } - //mrkanag set the profile OPEN_CLI_PROFILE } for (String env: this.getEnvs().keySet()) { @@ -315,7 +318,32 @@ public class OpenCommandShellCmd extends OnapCommand { int idxE = line.indexOf("}", idxS); String tmpName = line.substring(idxS + 7, idxE); tmpName = tmpName.trim(); - result.put("tmp:" + tmpName, this.getOutputAttributeFilePath(tmpName, true)); + String tmpTkns[] = tmpName.split(":"); + String tmpFileName; + String paramName; + if (tmpTkns.length == 2) { + tmpFileName = tmpTkns[0]; + paramName = tmpTkns[1]; + } else { + tmpFileName = tmpTkns[0]; + paramName = null; + } + + String tmpFilePath = this.getOutputAttributeFilePath(tmpFileName, true); + if (paramName != null) { + //Write the value of input params into file before passing to command + try { + FileUtils.touch(new File(tmpFilePath)); + FileUtils.writeStringToFile(new File(tmpFilePath), + this.getParametersMap().get(paramName).getValue().toString()); + } catch (IOException e) { + // NO SONAR + } + } + + result.put("tmp:" + tmpFileName, tmpFilePath); //used in output parsing + result.put("tmp:" + tmpName, tmpFilePath); //used in line replacement + currentIdx = idxE + 1; } return result; diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/error/OnapCommandFailedMocoGenerate.java b/profiles/http/src/main/java/org/onap/cli/fw/http/error/OnapCommandFailedMocoGenerate.java index 12a645c4..9d6274ac 100644 --- a/profiles/http/src/main/java/org/onap/cli/fw/http/error/OnapCommandFailedMocoGenerate.java +++ b/profiles/http/src/main/java/org/onap/cli/fw/http/error/OnapCommandFailedMocoGenerate.java @@ -17,12 +17,13 @@ package org.onap.cli.fw.http.error; import org.onap.cli.fw.error.OnapCommandException; +import org.onap.cli.fw.error.OnapCommandWarning; /** * Invalid data for generating moco json . * */ -public class OnapCommandFailedMocoGenerate extends OnapCommandException { +public class OnapCommandFailedMocoGenerate extends OnapCommandWarning { private static final long serialVersionUID = -5386652726982792831L; 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 5cab0a68..d1f88df4 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 @@ -171,7 +171,7 @@ public class OnapCommandHttpUtils { /** * In case of empty response body [] or {} **/ - if (resultHttp.getBody().length() <= 2) { + if (resultHttp.getBody() != null && resultHttp.getBody().length() <= 2) { return result; } |