Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 805d753

Browse files
committed
Merge pull request #467 from appirio-tech/sup-1481-java-bridge-reads
Sup 1481 java bridge reads
2 parents 77f7a1d + 0afc487 commit 805d753

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

actions/docusign.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ exports.generateDocusignViewURL = {
310310
blockedConnectionTypes: [],
311311
outputExample: {},
312312
version: 'v2',
313-
transaction: 'read',
313+
transaction: 'write',
314314
cacheEnabled : false,
315315
databases: ["informixoltp", "common_oltp"],
316316
inputs: {

initializers/dataAccess.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,19 @@ function parameterizeQuery(query, params, callback) {
113113
});
114114
}
115115

116+
function isSafeToUseJavaBridge(sql) {
117+
var lowerSQL = sql.toLowerCase();
118+
return lowerSQL.indexOf("insert") === -1 && lowerSQL.indexOf("update") === -1 && lowerSQL.indexOf("delete") === -1;
119+
}
120+
116121
function executePreparedStatement(api, sql, parameters, connection, next, db) {
117122
async.waterfall([
118123
function (cb) {
119124
parameterizeQuery(sql, parameters, cb);
120125
}, function (parametrizedQuery, cb) {
121126
sql = parametrizedQuery;
122127

123-
if (api.helper.readTransaction) {
128+
if (isSafeToUseJavaBridge(sql) && api.helper.readTransaction) {
124129
api.log("Calling Java Bridge", "debug");
125130

126131
api.log(sql, "debug");
@@ -304,7 +309,9 @@ exports.dataAccess = function (api, next) {
304309
return;
305310
}
306311

307-
if (!api.helper.readTransaction) {
312+
sql = queries[queryName].sql;
313+
314+
if (!isSafeToUseJavaBridge(sql) || !api.helper.readTransaction) {
308315
connection = connectionMap[queries[queryName].db];
309316
error = helper.checkObject(connection, "connection");
310317
}
@@ -314,7 +321,6 @@ exports.dataAccess = function (api, next) {
314321
return;
315322
}
316323

317-
sql = queries[queryName].sql;
318324
if (!sql) {
319325
api.log('Unregistered query ' + queryName + ' is asked for.', 'error');
320326
next('The query for name ' + queryName + ' is not registered');
@@ -354,7 +360,7 @@ exports.dataAccess = function (api, next) {
354360
return;
355361
}
356362

357-
if (!api.helper.readTransaction) {
363+
if (!isSafeToUseJavaBridge(sql) || !api.helper.readTransaction) {
358364
connection = connectionMap[dbName];
359365
error = helper.checkObject(connection, "connection");
360366
}
@@ -368,4 +374,4 @@ exports.dataAccess = function (api, next) {
368374
}
369375
};
370376
next();
371-
};
377+
};

0 commit comments

Comments
 (0)