summaryrefslogtreecommitdiffstats
path: root/cadi/core/src/main
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2019-02-03 06:09:34 -0600
committerInstrumental <jonathan.gathman@att.com>2019-02-03 06:09:46 -0600
commit59ffb7d529245c3bd0233dbf6cb0ae9fe9ccb856 (patch)
tree48f79984b766211d0f570f50485cbe288dd2f990 /cadi/core/src/main
parente36daf12cf4c5aa4b22fa3cec66a79ff2e2b8b94 (diff)
Approval Batch, prep better JUnit
Issue-ID: AAF-740 Change-Id: Id9e8ca121c9bf92c2f98c7a61631e2417bba70b1 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/core/src/main')
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java32
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java4
3 files changed, 29 insertions, 9 deletions
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java
index 3466a8d8..d5c88464 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/taf/basic/BasicHttpTaf.java
@@ -83,7 +83,7 @@ public class BasicHttpTaf implements HttpTaf {
mapIds=null;
} else {
try {
- mapIds = new MapBathConverter(access, new CSV(csvFile));
+ mapIds = new MapBathConverter(access, new CSV(access,csvFile));
} catch (IOException | CadiException e) {
access.log(e,"Bath Map Conversion is not initialzed (non fatal)");
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java
index ed4fcde6..a834db51 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/CSV.java
@@ -30,7 +30,9 @@ import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
+import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.Access.Level;
/**
* Read CSV file for various purposes
@@ -40,17 +42,26 @@ import org.onap.aaf.cadi.CadiException;
*/
public class CSV {
private File csv;
+ private Access access;
+ private boolean processAll;
- public CSV(File file) {
+ public CSV(Access access, File file) {
+ this.access = access;
csv = file;
+ processAll = false;
}
- public CSV(String csvFilename) {
+ public CSV(Access access, String csvFilename) {
+ this.access = access;
csv = new File(csvFilename);
+ processAll = false;
}
-
- /**
+ public CSV processAll() {
+ processAll = true;
+ return this;
+ }
+ /*
* Create your code to accept the List<String> row.
*
* Your code may keep the List... CSV does not hold onto it.
@@ -117,7 +128,15 @@ public class CSV {
row.add(sb.toString());
sb.setLength(0);
}
- visitor.visit(row);
+ try {
+ visitor.visit(row);
+ } catch (CadiException e) {
+ if(processAll) {
+ access.log(Level.ERROR,e);
+ } else {
+ throw e;
+ }
+ }
}
}
} finally {
@@ -147,7 +166,8 @@ public class CSV {
} else {
ps.append(',');
}
- if(o instanceof String[]) {
+ if(o == null) {
+ } else if(o instanceof String[]) {
for(String str : (String[])o) {
print(str);
}
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java
index 9751969e..417351f5 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/util/Vars.java
@@ -31,8 +31,8 @@ public class Vars {
* @return
*/
public static String convert(final String text, final List<String> vars) {
- String[] array = new String[vars.size()];
StringBuilder sb = new StringBuilder();
+ Object[] array = new Object[vars.size()];
convert(sb,text,vars.toArray(array));
return sb.toString();
}
@@ -44,7 +44,7 @@ public class Vars {
* @param vars
* @return
*/
- public static String convert(final StringBuilder holder, final String text, final String ... vars) {
+ public static String convert(final StringBuilder holder, final String text, final Object ... vars) {
StringBuilder sb = null;
int idx,index=0,prev = 0;