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

Sup 1481 java bridge reads #467

Merged
merged 2 commits into from
Nov 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actions/docusign.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ exports.generateDocusignViewURL = {
blockedConnectionTypes: [],
outputExample: {},
version: 'v2',
transaction: 'read',
transaction: 'write',
cacheEnabled : false,
databases: ["informixoltp", "common_oltp"],
inputs: {
Expand Down
16 changes: 11 additions & 5 deletions initializers/dataAccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@ function parameterizeQuery(query, params, callback) {
});
}

function isSafeToUseJavaBridge(sql) {
var lowerSQL = sql.toLowerCase();
return lowerSQL.indexOf("insert") === -1 && lowerSQL.indexOf("update") === -1 && lowerSQL.indexOf("delete") === -1;
}

function executePreparedStatement(api, sql, parameters, connection, next, db) {
async.waterfall([
function (cb) {
parameterizeQuery(sql, parameters, cb);
}, function (parametrizedQuery, cb) {
sql = parametrizedQuery;

if (api.helper.readTransaction) {
if (isSafeToUseJavaBridge(sql) && api.helper.readTransaction) {
api.log("Calling Java Bridge", "debug");

api.log(sql, "debug");
Expand Down Expand Up @@ -304,7 +309,9 @@ exports.dataAccess = function (api, next) {
return;
}

if (!api.helper.readTransaction) {
sql = queries[queryName].sql;

if (!isSafeToUseJavaBridge(sql) || !api.helper.readTransaction) {
connection = connectionMap[queries[queryName].db];
error = helper.checkObject(connection, "connection");
}
Expand All @@ -314,7 +321,6 @@ exports.dataAccess = function (api, next) {
return;
}

sql = queries[queryName].sql;
if (!sql) {
api.log('Unregistered query ' + queryName + ' is asked for.', 'error');
next('The query for name ' + queryName + ' is not registered');
Expand Down Expand Up @@ -354,7 +360,7 @@ exports.dataAccess = function (api, next) {
return;
}

if (!api.helper.readTransaction) {
if (!isSafeToUseJavaBridge(sql) || !api.helper.readTransaction) {
connection = connectionMap[dbName];
error = helper.checkObject(connection, "connection");
}
Expand All @@ -368,4 +374,4 @@ exports.dataAccess = function (api, next) {
}
};
next();
};
};