From 268be523fb1142138a3f710642b5773453841eeb Mon Sep 17 00:00:00 2001 From: "priyanka.akhade" Date: Thu, 18 Jun 2020 15:11:08 +0530 Subject: code improvements Signed-off-by: priyanka.akhade Issue-ID: CLI-270 Change-Id: If9eab4bc8642c7c20a841d58c8a9e2bf5ae6c98b --- .../org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java | 20 ++++++++++---------- .../fw/cmd/schema/OnapCommandSchemaCmdLoader.java | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'profiles/command') 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 0ed930d1..eb7b808b 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 @@ -83,7 +83,7 @@ public class OpenCommandShellCmd extends OnapCommand { return successStatusCodes; } - public void setSuccessStatusCodes(ArrayList successStatusCodes) { + public void setSuccessStatusCodes(List successStatusCodes) { this.successStatusCodes = successStatusCodes; } @@ -197,7 +197,7 @@ public class OpenCommandShellCmd extends OnapCommand { FileOutputStream stderrStream = null; String outputValue = ""; - try { + try { //NOSONAR pr.setTimeout(timeout); if (this.getExecutionContext() != null) { @@ -370,7 +370,7 @@ public class OpenCommandShellCmd extends OnapCommand { // Process jsonpath macros List values = new ArrayList<>(); - String processedPattern = ""; + StringBuilder processedPattern = new StringBuilder(); currentIdx = 0; int maxRows = 1; // in normal case, only one row will be there while (currentIdx < line.length()) { @@ -378,7 +378,7 @@ public class OpenCommandShellCmd extends OnapCommand { if (idxS == -1) { idxS = line.indexOf("$e{", currentIdx); //check for error stream if (idxS == -1) { - processedPattern += line.substring(currentIdx); + processedPattern.append(line.substring(currentIdx)); break; } } @@ -405,23 +405,23 @@ public class OpenCommandShellCmd extends OnapCommand { maxRows = arr.size(); } } - processedPattern += line.substring(currentIdx, idxS) + "%s"; + processedPattern.append(line.substring(currentIdx, idxS) + "%s"); values.add(value); currentIdx = idxE + 1; } - if (processedPattern.isEmpty()) { + if (processedPattern.toString().isEmpty()) { result.add(line); return result; } else { for (int i = 0; i < maxRows; i++) { currentIdx = 0; - String bodyProcessedLine = ""; + StringBuilder bodyProcessedLine = new StringBuilder(); int positionalIdx = 0; // %s positional idx while (currentIdx < processedPattern.length()) { int idxS = processedPattern.indexOf("%s", currentIdx); if (idxS == -1) { - bodyProcessedLine += processedPattern.substring(currentIdx); + bodyProcessedLine.append(processedPattern.substring(currentIdx)); break; } @@ -441,7 +441,7 @@ public class OpenCommandShellCmd extends OnapCommand { } } - bodyProcessedLine += processedPattern.substring(currentIdx, idxS) + valStr; + bodyProcessedLine.append(processedPattern.substring(currentIdx, idxS) + valStr); currentIdx = idxEnd; positionalIdx++; } catch (OnapCommandResultEmpty e) { @@ -450,7 +450,7 @@ public class OpenCommandShellCmd extends OnapCommand { throw new OnapCommandResultMapProcessingFailed(line, e); } } - result.add(bodyProcessedLine); + result.add(bodyProcessedLine.toString()); } return result; diff --git a/profiles/command/src/main/java/org/onap/cli/fw/cmd/schema/OnapCommandSchemaCmdLoader.java b/profiles/command/src/main/java/org/onap/cli/fw/cmd/schema/OnapCommandSchemaCmdLoader.java index 965bd2b1..676aeb30 100644 --- a/profiles/command/src/main/java/org/onap/cli/fw/cmd/schema/OnapCommandSchemaCmdLoader.java +++ b/profiles/command/src/main/java/org/onap/cli/fw/cmd/schema/OnapCommandSchemaCmdLoader.java @@ -44,9 +44,9 @@ public class OnapCommandSchemaCmdLoader { * @throws OnapCommandException * on error */ - public static ArrayList parseCmdSchema(OpenCommandShellCmd cmd, + public static List parseCmdSchema(OpenCommandShellCmd cmd, final Map values, - boolean validate) throws OnapCommandException { + boolean validate) throws OnapCommandException { //NOSONAR ArrayList errorList = new ArrayList<>(); Map valMap = (Map) values.get(OnapCommandCmdConstants.CMD); -- cgit 1.2.3-korg