summaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-artifact-handler/provider
diff options
context:
space:
mode:
authorPatrick Brady <patrick.brady@att.com>2019-07-19 13:03:02 -0700
committerPatrick Brady <patrick.brady@att.com>2019-07-24 21:55:06 +0000
commite0bdc35d8428a574c6decc6075b8d8ef98f05d5f (patch)
tree03d05da149d7b374b90b44f708f68739126a3a05 /appc-inbound/appc-artifact-handler/provider
parente93b3251120e3bc8aeec497852a287a5c909d1b4 (diff)
Add value of the arguments
Also apply the valueof to non svc context arguments. The original code would always treat null arguments as null strings. This replaces that functionality in the prepared statements. Change-Id: I88ab22c87b86a8f5ff41946757c40a399c37a6c3 Signed-off-by: Patrick Brady <patrick.brady@att.com> Issue-ID: OJSI-25
Diffstat (limited to 'appc-inbound/appc-artifact-handler/provider')
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DbLibServiceQueries.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DbLibServiceQueries.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DbLibServiceQueries.java
index ad4242ae0..d02eb55ec 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DbLibServiceQueries.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DbLibServiceQueries.java
@@ -70,10 +70,23 @@ public class DbLibServiceQueries {
public QueryStatus query(String query, SvcLogicContext ctx) {
ArrayList<String> arguments = new ArrayList<>();
query = CtxParameterizedResolver.resolveCtxVars(query, ctx, arguments);
- return query(query, ctx, arguments);
+ return performQuery(query, ctx, null, arguments);
+ }
+
+ public QueryStatus query(String query, String prefix, SvcLogicContext ctx) {
+ ArrayList<String> arguments = new ArrayList<>();
+ query = CtxParameterizedResolver.resolveCtxVars(query, ctx, arguments);
+ return performQuery(query, ctx, prefix, arguments);
}
public QueryStatus query(String query, SvcLogicContext ctx, ArrayList<String> arguments) {
+ return performQuery(query, ctx, null, valueOfArrayList(arguments));
+ }
+ public QueryStatus query(String query, SvcLogicContext ctx, String prefix, ArrayList<String> arguments) {
+ return performQuery(query, ctx, prefix, valueOfArrayList(arguments));
+ }
+
+ private QueryStatus performQuery(String query, SvcLogicContext ctx, String prefix, ArrayList<String> arguments) {
CachedRowSet result = null;
try {
@@ -82,7 +95,7 @@ public class DbLibServiceQueries {
log.debug("No data found");
return QueryStatus.NOT_FOUND;
} else {
- CtxParameterizedResolver.saveCachedRowSetToCtx(result, ctx, null, dbLibService);
+ CtxParameterizedResolver.saveCachedRowSetToCtx(result, ctx, prefix, dbLibService);
}
} catch (SQLException e) {
log.error("Exception in query()",e);
@@ -94,10 +107,14 @@ public class DbLibServiceQueries {
public QueryStatus save(String query, SvcLogicContext ctx) {
ArrayList<String> arguments = new ArrayList<>();
query = CtxParameterizedResolver.resolveCtxVars(query, ctx, arguments);
- return save(query,ctx,arguments);
+ return performSave(query, arguments);
}
public QueryStatus save(String query, SvcLogicContext ctx, ArrayList<String> arguments) {
+ return performSave(query, valueOfArrayList(arguments));
+ }
+
+ private QueryStatus performSave(String query, ArrayList<String> arguments) {
boolean success = false;
try {
success = dbLibService.writeData(query, arguments, null);
@@ -150,5 +167,16 @@ public class DbLibServiceQueries {
}
return dbLibService;
}
+
+ //By using String.valueOf on the array list items, we can store any null values as
+ //Strings with the value "null". This mirrors the way queries worked prior to the
+ //prepared statements.
+ private ArrayList<String> valueOfArrayList(ArrayList<String> original) {
+ ArrayList<String> valueOfList = new ArrayList<>();
+ for(String s : original) {
+ valueOfList.add(String.valueOf(s));
+ }
+ return valueOfList;
+ }
}