X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=mod%2Fbpgenerator%2Fcommon%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fblueprintgenerator%2Fservice%2Fbase%2FFixesService.java;h=961528bdb50808f3287fdc911bc39a45c5e49d29;hb=72c2d38329865afa6692454b4fb90ab6f8a70638;hp=4c6debce7c34161ea85abea7d0601515c10c7186;hpb=87f19cde0f6532f5138822fa6f188b763a123235;p=dcaegen2%2Fplatform.git diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/FixesService.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/FixesService.java index 4c6debc..961528b 100644 --- a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/FixesService.java +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/FixesService.java @@ -4,6 +4,7 @@ * * org.onap.dcae * * ================================================================================ * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + * * Copyright (c) 2021 Nokia. All rights reserved. * * ================================================================================ * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. @@ -55,15 +56,15 @@ public class FixesService { FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); for (String line = br.readLine(); line != null; line = br.readLine()) { - if (line.contains("'")) { - line = processLine(line); + String newLine = line; + if (newLine.contains("'")) { + newLine = processLine(newLine); } - if (line.contains("get_input") || line.contains("get_secret") || line + if (newLine.contains("get_input") || newLine.contains("get_secret") || newLine .contains("envs")) { - line = line.replaceAll("'", ""); + newLine = newLine.replace("'", ""); } - - lines.add(line); + lines.add(newLine); } fr.close(); @@ -90,8 +91,8 @@ public class FixesService { * @return */ public String fixStringQuotes(String string) { - String sLines[] = string.split("\n"); - String ret = ""; + String[] sLines = string.split("\n"); + StringBuilder ret = new StringBuilder(); for (String line : sLines) { if (line.contains("get_input") || line.contains("get_secret") @@ -101,15 +102,16 @@ public class FixesService { || line.contains("dmaap") || line.contains(".\"'")) && line.contains("'"))) { - line = line.replaceAll("'", ""); + line = line.replace("'", ""); } if (line.contains("'")) { line = processLine(line); } - ret = ret + "\n" + line; + ret.append("\n"); + ret.append(line); } - return ret; + return ret.toString(); } /** @@ -124,13 +126,14 @@ public class FixesService { FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); for (String line = br.readLine(); line != null; line = br.readLine()) { - if (line.contains("'")) { - line = line.replace("'", ""); + String newLine = line; + if (newLine.contains("'")) { + newLine = newLine.replace("'", ""); } - if (line.contains("\"\"") && (line.contains("m") || line.contains("M"))) { - line = line.replaceAll("\"\"", "\""); + if (newLine.contains("\"\"") && (newLine.contains("m") || newLine.contains("M"))) { + newLine = newLine.replace("\"\"", "\""); } - lines.add(line); + lines.add(newLine); } fr.close(); br.close(); @@ -185,18 +188,18 @@ public class FixesService { } private String processLine(String line) { - return line.replaceAll("'\\{", "{") - .replaceAll("}'", "}") - .replaceAll("'\\[", "[") - .replaceAll("]'", "]") - .replaceAll("'''''", "'") - .replaceAll("'''", "'") - .replaceAll("'''", "") - .replaceAll("''\\{", "'{") - .replaceAll("}''", "}'") - .replaceAll("''\\[", "'[") - .replaceAll("]''", "]'") - .replaceAll("\"''", "'") - .replaceAll("''\"", "'"); + return line.replace("'\\{", "{") + .replace("}'", "}") + .replace("'\\[", "[") + .replace("]'", "]") + .replace("'''''", "'") + .replace("'''", "'") + .replace("'''", "") + .replace("''\\{", "'{") + .replace("}''", "}'") + .replace("''\\[", "'[") + .replace("]''", "]'") + .replace("\"''", "'") + .replace("''\"", "'"); } }