summaryrefslogtreecommitdiffstats
path: root/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java
diff options
context:
space:
mode:
authorDhrumin Desai <dd303q@att.com>2020-02-06 14:26:41 -0500
committerDhrumin Desai <dd303q@att.com>2020-02-19 12:18:30 -0500
commit7b27a8acf25d5d92a0160360175b5d0ecd2ef4d7 (patch)
tree5baa63878fff9188b3d14a34f6ff74b029d3133d /mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java
parent83f85998b01c7937b84549d81f5ec2a07958f96d (diff)
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 <dd303q@att.com>
Diffstat (limited to 'mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java')
-rw-r--r--mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java34
1 files changed, 34 insertions, 0 deletions
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<String> lines = new ArrayList<String>();
@@ -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<String> lines = new ArrayList<String>();
+
+ 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);
+ }
+
+
}