remove debug statements

This commit is contained in:
tcbuzor 2019-09-14 23:07:23 -05:00
parent 575a7d4979
commit dca496aa3b
3 changed files with 37 additions and 97 deletions

View File

@ -148,19 +148,11 @@ Refine.DatabaseSourceUI.prototype.attachUI = function(body) {
jdbcQueryInfo.databasePassword = $( "#currentDatabasePasswordInput" ).val(); jdbcQueryInfo.databasePassword = $( "#currentDatabasePasswordInput" ).val();
jdbcQueryInfo.initialDatabase = $( "#currentInitialDatabaseInput" ).val(); jdbcQueryInfo.initialDatabase = $( "#currentInitialDatabaseInput" ).val();
jdbcQueryInfo.query = $.trim($( "#queryTextArea" ).val()); jdbcQueryInfo.query = $.trim($( "#queryTextArea" ).val());
// if(jdbcQueryInfo.query && jdbcQueryInfo.query.length > 0 ) {
// self._executeQuery(jdbcQueryInfo);
// }else{
// window.alert($.i18n('database-source/alert-query'));
// }
if(self.validateQuery(jdbcQueryInfo.query)) { if(self.validateQuery(jdbcQueryInfo.query)) {
self._executeQuery(jdbcQueryInfo); self._executeQuery(jdbcQueryInfo);
} }
}); });
@ -251,11 +243,8 @@ Refine.DatabaseSourceUI.prototype._editConnection = function(connectionInfo) {
$( "#menuListUl" ).empty(); $( "#menuListUl" ).empty();
var items = []; var items = [];
$.each(settings.savedConnections,function(index,savedConnection){ $.each(settings.savedConnections,function(index,savedConnection){
// items.push('<a href="#" class="list-group-item list-group-item-action">'
// + '<span class="context-menu-one context-menu-text" >' + savedConnection.connectionName + '</span>' items.push('<li class="pure-menu-item sc-list"><a href="#" class="pure-menu-link context-menu-one">'
// + '<span class="sc-context-more-vert pull-right"> </span> </a>');
items.push('<li class="pure-menu-item sc-list"><a href="#" class="pure-menu-link context-menu-one">'
+ '<span class="context-menu-text" >' + savedConnection.connectionName + '</span>' + '<span class="context-menu-text" >' + savedConnection.connectionName + '</span>'
+ '<span class="sc-context-more-vert pull-right"> </span></a></li>'); + '<span class="sc-context-more-vert pull-right"> </span></a></li>');
}) })
@ -275,26 +264,23 @@ Refine.DatabaseSourceUI.prototype._executeQuery = function(jdbcQueryInfo) {
//remove start line //remove start line
var dismiss = DialogSystem.showBusy($.i18n('database-import/checking')); var dismiss = DialogSystem.showBusy($.i18n('database-import/checking'));
//$("#executeQueryBtn").text('Please wait ...').attr('disabled','disabled');
$.post( $.post(
"command/database/test-query", "command/database/test-query",
jdbcQueryInfo, jdbcQueryInfo,
function(jdbcConnectionResult) { function(jdbcConnectionResult) {
// $("#executeQueryBtn").text('Preview Query Result').removeAttr('disabled');
dismiss(); dismiss();
self._controller.startImportingDocument(jdbcQueryInfo); self._controller.startImportingDocument(jdbcQueryInfo);
}, },
"json" "json"
).fail(function( jqXhr, textStatus, errorThrown ){ ).fail(function( jqXhr, textStatus, errorThrown ){
//$("#executeQueryBtn").text('Preview Query Result').removeAttr('disabled');
dismiss(); dismiss();
alert( textStatus + ':' + errorThrown ); alert( textStatus + ':' + errorThrown );
}); });
//remove end line
//self._controller.startImportingDocument(jdbcQueryInfo);
} }
Refine.DatabaseSourceUI.prototype._saveConnection = function(jdbcConnectionInfo) { Refine.DatabaseSourceUI.prototype._saveConnection = function(jdbcConnectionInfo) {
@ -304,16 +290,11 @@ Refine.DatabaseSourceUI.prototype._saveConnection = function(jdbcConnectionInfo)
jdbcConnectionInfo, jdbcConnectionInfo,
function(settings) { function(settings) {
if(settings){ if(settings){
// self._elmts.scListGroupDiv.empty();
self._elmts.menuListUl.empty(); self._elmts.menuListUl.empty();
var items = []; var items = [];
$.each(settings.savedConnections,function(index,savedConnection){ $.each(settings.savedConnections,function(index,savedConnection){
// items.push('<a href="#" class="list-group-item list-group-item-action">'
// + '<span class="context-menu-one context-menu-text" >' + savedConnection.connectionName + '</span>'
// + '<span class="sc-context-more-vert pull-right"> </span> </a>');
items.push('<li class="pure-menu-item sc-list"><a href="#" class="pure-menu-link context-menu-one">' items.push('<li class="pure-menu-item sc-list"><a href="#" class="pure-menu-link context-menu-one">'
+ '<span class="context-menu-text" >' + savedConnection.connectionName + '</span>' + '<span class="context-menu-text" >' + savedConnection.connectionName + '</span>'
+ '<span class="sc-context-more-vert pull-right"> </span></a></li>'); + '<span class="sc-context-more-vert pull-right"> </span></a></li>');
@ -339,14 +320,10 @@ Refine.DatabaseSourceUI.prototype._loadSavedConnections = function() {
if(settings){ if(settings){
self._elmts.menuListUl.empty(); self._elmts.menuListUl.empty();
//self._elmts.scListGroupDiv.empty();
var items = []; var items = [];
$.each(settings.savedConnections,function(index,savedConnection){ $.each(settings.savedConnections,function(index,savedConnection){
// items.push('<a href="#" class="list-group-item list-group-item-action context-menu-one">'
// + '<span class="context-menu-text" >' + savedConnection.connectionName + '</span>'
// + '<span class="sc-context-more-vert pull-right"> </span> </a>');
items.push('<li class="pure-menu-item sc-list"><a href="#" class="pure-menu-link context-menu-one">' items.push('<li class="pure-menu-item sc-list"><a href="#" class="pure-menu-link context-menu-one">'
+ '<span class="context-menu-text" >' + savedConnection.connectionName + '</span>' + '<span class="context-menu-text" >' + savedConnection.connectionName + '</span>'
+ '<span class="sc-context-more-vert pull-right"> </span></a></li>'); + '<span class="sc-context-more-vert pull-right"> </span></a></li>');
@ -354,7 +331,7 @@ Refine.DatabaseSourceUI.prototype._loadSavedConnections = function() {
}) })
self._elmts.menuListUl.append(items.join('')); self._elmts.menuListUl.append(items.join(''));
// self._elmts.scListGroupDiv.append(items.join(''));
} }
}, },
@ -407,12 +384,10 @@ Refine.DatabaseSourceUI.prototype._connect = function(jdbcConnectionInfo) {
+ jdbcConnectionInfo.databasePort + "/" + jdbcConnectionInfo.databasePort + "/"
+ jdbcConnectionInfo.initialDatabase; + jdbcConnectionInfo.initialDatabase;
//alert("connectionParam::" + connectionParam);
$( "#connectionParameterSpan" ).text(connectionParam); $( "#connectionParameterSpan" ).text(connectionParam);
// self._body.find('.newConnectionDiv').hide(); $( "#newConnectionDiv" ).hide();
// self._body.find('.sqlEditorDiv').show(); $( "#sqlEditorDiv" ).show();
$( "#newConnectionDiv" ).hide();
$( "#sqlEditorDiv" ).show();
}else{ }else{
window.alert("Unable to establish connection to database"); window.alert("Unable to establish connection to database");
@ -428,34 +403,20 @@ Refine.DatabaseSourceUI.prototype._connect = function(jdbcConnectionInfo) {
}; };
Refine.DatabaseSourceUI.prototype._getConnectionInfo = function() { Refine.DatabaseSourceUI.prototype._getConnectionInfo = function() {
var self = this; var self = this;
var jdbcConnectionInfo = {}; var jdbcConnectionInfo = {};
jdbcConnectionInfo.connectionName = $.trim(self._elmts.connectionNameInput[0].value); jdbcConnectionInfo.connectionName = $.trim(self._elmts.connectionNameInput[0].value);
jdbcConnectionInfo.databaseType = $.trim(self._elmts.databaseTypeSelect[0].value);
// window.alert('input:' + jdbcConnectionInfo.connectionName + ' output:' + self._removeScriptTag(jdbcConnectionInfo.connectionName) ); jdbcConnectionInfo.databaseServer = $.trim(self._elmts.databaseHostInput[0].value);
jdbcConnectionInfo.databasePort = $.trim(self._elmts.databasePortInput[0].value);
jdbcConnectionInfo.databaseType = $.trim(self._elmts.databaseTypeSelect[0].value); jdbcConnectionInfo.databaseUser = $.trim(self._elmts.databaseUserInput[0].value);
jdbcConnectionInfo.databaseServer = $.trim(self._elmts.databaseHostInput[0].value); jdbcConnectionInfo.databasePassword = $.trim(self._elmts.databasePasswordInput[0].value);
jdbcConnectionInfo.databasePort = $.trim(self._elmts.databasePortInput[0].value); jdbcConnectionInfo.initialDatabase = $.trim(self._elmts.initialDatabaseInput[0].value);
jdbcConnectionInfo.databaseUser = $.trim(self._elmts.databaseUserInput[0].value); jdbcConnectionInfo.initialSchema = $.trim(self._elmts.initialSchemaInput[0].value);
jdbcConnectionInfo.databasePassword = $.trim(self._elmts.databasePasswordInput[0].value); return jdbcConnectionInfo;
jdbcConnectionInfo.initialDatabase = $.trim(self._elmts.initialDatabaseInput[0].value);
jdbcConnectionInfo.initialSchema = $.trim(self._elmts.initialSchemaInput[0].value);
return jdbcConnectionInfo;
} }
Refine.DatabaseSourceUI.prototype._removeScriptTag = function(input) {
var div = document.createElement('div');
div.innerHTML = s;
var scripts = div.getElementsByTagName('script');
var i = scripts.length;
while (i--) {
scripts[i].parentNode.removeChild(scripts[i]);
}
return div.innerHTML;
};
Refine.DatabaseSourceUI.prototype._validateNewConnectionForm = function() { Refine.DatabaseSourceUI.prototype._validateNewConnectionForm = function() {
@ -480,24 +441,15 @@ Refine.DatabaseSourceUI.prototype._validateNewConnectionForm = function() {
if(alphaNumConnNameTestResult == false){ if(alphaNumConnNameTestResult == false){
window.alert($.i18n('database-source/alert-conn-name-invalid-character')); window.alert($.i18n('database-source/alert-conn-name-invalid-character'));
return false; return false;
}else if(connectionNameInput.contains("<script>") || connectionNameInput.contains("<img>")){
window.alert($.i18n('database-source/alert-conn-name-invalid-character'));
return false;
}else if (databaseHostInput.length === 0) { }else if (databaseHostInput.length === 0) {
window.alert($.i18n('database-source/alert-server')); window.alert($.i18n('database-source/alert-server'));
return false; return false;
}else if(databaseHostInput.contains("<script>") || databaseHostInput.contains("<img>")){
window.alert($.i18n('database-source/alert-db-host-invalid-character'));
return false;
}else if(databasePortInput.length === 0){ }else if(databasePortInput.length === 0){
window.alert($.i18n('database-source/alert-port')); window.alert($.i18n('database-source/alert-port'));
return false; return false;
}else if(databaseUserInput.length === 0){ }else if(databaseUserInput.length === 0){
window.alert($.i18n('database-source/alert-user')); window.alert($.i18n('database-source/alert-user'));
return false; return false;
}else if(databaseUserInput.contains("<script>") || databaseUserInput.contains("<img>")){
window.alert($.i18n('database-source/alert-db-user-invalid-character'));
return false;
}else if(initialDatabaseInput.length === 0){ }else if(initialDatabaseInput.length === 0){
window.alert($.i18n('database-source/alert-initial-database')); window.alert($.i18n('database-source/alert-initial-database'));
return false; return false;

View File

@ -133,35 +133,22 @@ public class SavedConnectionCommand extends DatabaseCommand {
writer.writeStartObject(); writer.writeStartObject();
String sanitizedConnName = Encode.forHtml(savedConnection.getConnectionName());
writer.writeStringField("connectionName", savedConnection.getConnectionName());
// writer.writeStringField("connectionName", savedConnection.getConnectionName());
writer.writeStringField("connectionName", sanitizedConnName);
writer.writeStringField("databaseType", savedConnection.getDatabaseType()); writer.writeStringField("databaseType", savedConnection.getDatabaseType());
writer.writeStringField("databaseHost", savedConnection.getDatabaseHost());
String sanitizedHost = Encode.forHtml(savedConnection.getDatabaseHost());
// writer.writeStringField("databaseHost", savedConnection.getDatabaseHost());
writer.writeStringField("databaseHost", sanitizedHost);
writer.writeNumberField("databasePort", savedConnection.getDatabasePort()); writer.writeNumberField("databasePort", savedConnection.getDatabasePort());
writer.writeStringField("databaseName", savedConnection.getDatabaseName());
String sanitizedDbName = Encode.forHtml(savedConnection.getDatabaseName());
// writer.writeStringField("databaseName", savedConnection.getDatabaseName());
writer.writeStringField("databaseName", sanitizedDbName);
String dbPasswd = savedConnection.getDatabasePassword(); String dbPasswd = savedConnection.getDatabasePassword();
if(dbPasswd != null && !dbPasswd.isEmpty()) { if(dbPasswd != null && !dbPasswd.isEmpty()) {
dbPasswd = DatabaseUtils.decrypt(savedConnection.getDatabasePassword()); dbPasswd = DatabaseUtils.decrypt(savedConnection.getDatabasePassword());
} }
writer.writeStringField("databasePassword", dbPasswd); writer.writeStringField("databasePassword", dbPasswd);
writer.writeStringField("databaseSchema", savedConnection.getDatabaseSchema());
writer.writeStringField("databaseUser", savedConnection.getDatabaseUser());
writer.writeStringField("databaseSchema", savedConnection.getDatabaseSchema());
String sanitizedDbUser = Encode.forHtml(savedConnection.getDatabaseUser());
// writer.writeStringField("databaseUser", savedConnection.getDatabaseUser());
writer.writeStringField("databaseUser", sanitizedDbUser);
logger.info("Input DB User:{}, SanitizedDbUser:{}", savedConnection.getDatabaseUser(), sanitizedDbUser);
writer.writeEndObject(); writer.writeEndObject();
writer.writeEndArray(); writer.writeEndArray();

View File

@ -161,7 +161,7 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
assertFalse(result.isEmpty(), "Valid response Message expected!"); assertFalse(result.isEmpty(), "Valid response Message expected!");
ObjectNode json = ParsingUtilities.mapper.readValue(result, ObjectNode.class); ObjectNode json = ParsingUtilities.mapper.readValue(result, ObjectNode.class);
System.out.println("json:" + json); // System.out.println("json:" + json);
ArrayNode savedConnections = (ArrayNode) json.get("savedConnections"); ArrayNode savedConnections = (ArrayNode) json.get("savedConnections");
Assert.assertNotNull(savedConnections); Assert.assertNotNull(savedConnections);
@ -235,7 +235,6 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
Assert.assertEquals(savedConnections.size(), 1); Assert.assertEquals(savedConnections.size(), 1);
ObjectNode sc = (ObjectNode)savedConnections.get(0); ObjectNode sc = (ObjectNode)savedConnections.get(0);
//System.out.println("sc" + sc);
String newDbHost = sc.get("databaseHost").asText(); String newDbHost = sc.get("databaseHost").asText();
Assert.assertEquals(newDbHost, newHost); Assert.assertEquals(newDbHost, newHost);
} }
@ -323,7 +322,7 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
assertFalse(result.isEmpty(), "Valid response Message expected!"); assertFalse(result.isEmpty(), "Valid response Message expected!");
ObjectNode json = ParsingUtilities.mapper.readValue(result, ObjectNode.class); ObjectNode json = ParsingUtilities.mapper.readValue(result, ObjectNode.class);
System.out.println("json:" + json); //System.out.println("json:" + json);
ArrayNode savedConnections = (ArrayNode) json.get("savedConnections"); ArrayNode savedConnections = (ArrayNode) json.get("savedConnections");
Assert.assertNotNull(savedConnections); Assert.assertNotNull(savedConnections);
@ -333,5 +332,7 @@ public class SavedConnectionCommandTest extends DBExtensionTests{
Assert.assertEquals(len, 1); Assert.assertEquals(len, 1);
} }
} }