From 7b27a8acf25d5d92a0160360175b5d0ecd2ef4d7 Mon Sep 17 00:00:00 2001 From: Dhrumin Desai Date: Thu, 6 Feb 2020 14:26:41 -0500 Subject: Added policyNodes, db, tls support Change-Id: Id960c156eb8da67e6792c6dbc1a60892d28703b0 Issue-ID: DCAEGEN2-164 Issue-ID: DCAEGEN2-1873 Issue-ID: DCAEGEN2-1995 Issue-ID: DCAEGEN2-1859 Signed-off-by: Dhrumin Desai --- .../org/onap/blueprintgenerator/core/Fixes.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java') diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java index cbff42b..3a4b457 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java @@ -29,6 +29,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.List; public class Fixes { private static ArrayList lines = new ArrayList(); @@ -40,6 +41,7 @@ public class Fixes { FileReader fr = new FileReader(translateFile); BufferedReader br = new BufferedReader(fr); while((line = br.readLine()) != null) { +// lines.add(ensureNoSingleQuotes(line)); if(line.contains("'")) { line = line.replace("'", ""); } @@ -67,4 +69,36 @@ public class Fixes { throw new RuntimeException(e); } } + + /** + * Remove single quotes from a line from a blueprint + */ + private static String ensureNoSingleQuotes(String line) { + // TODO: Should probably use regex instead + // REVIEW: The condition under which to remove the single quotes + if ((line.contains("concat") || line.contains("default: ")) && line.contains("'")) { + return line.replace("'", ""); + } else { + return line; + } + } + + /** + * Takes in an entire blueprint (YAML) in a string buffer and post processes it to apply + * "fixes" like removing unwanted single quotes. + */ + public static String applyFixes(String bp) { + List lines = new ArrayList(); + + String[] linesPre = bp.split("\n"); + System.out.println(String.format("To post-processing #lines: %d", linesPre.length)); + + for (String line : linesPre) { + lines.add(ensureNoSingleQuotes(line)); + } + + return String.join("\n", lines); + } + + } -- cgit 1.2.3-korg