Browse Source

Pull request #9564: REPORT-76370 提供一个数据连接前置检查接口&设计器数据连接保存

Merge in DESIGN/design from ~RINOUX/design:release/11.0 to release/11.0

* commit 'a0d3528ab968cc4bd3a9afa32e0751bc5a2230a9':
  REPORT-76370 提供一个数据连接前置检查接口&设计器数据连接保存
newui
rinoux 2 years ago
parent
commit
0ecdf240f5
  1. 19
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

19
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -1,8 +1,6 @@
package com.fr.design.data.datapane.connect;
import com.fr.base.TemplateUtils;
import com.fr.config.RemoteConfigEvent;
import com.fr.data.core.db.JDBCSecurityChecker;
import com.fr.data.impl.Connection;
import com.fr.data.impl.ConnectionBean;
import com.fr.data.impl.JDBCDatabaseConnection;
@ -187,7 +185,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
case ADDED:
case UPDATED:
addedOrUpdatedConnections.add(new ConnectionBean(s, StringUtils.EMPTY, connection));
if (connection instanceof JDBCDatabaseConnection){
if (connection instanceof JDBCDatabaseConnection) {
DatabaseConnectionMetricHandler.handleSaveConnection((JDBCDatabaseConnection) connection, null);
}
default:
@ -195,22 +193,19 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
}
});
this.checkSecurity(addedOrUpdatedConnections);
this.validateConnections(addedOrUpdatedConnections);
this.alterConnections(removedConnNames, addedOrUpdatedConnections);
}
private void checkSecurity(List<ConnectionBean> addedOrUpdatedConnections) throws Exception {
private void validateConnections(List<ConnectionBean> addedOrUpdatedConnections) throws Exception {
for (ConnectionBean connectionBean : addedOrUpdatedConnections) {
Connection connection = connectionBean.getConnection();
if (connection instanceof JDBCDatabaseConnection) {
try {
JDBCSecurityChecker.checkURL(TemplateUtils.render(((JDBCDatabaseConnection) connection).getURL()));
JDBCSecurityChecker.checkValidationQuery(((JDBCDatabaseConnection) connection).getDbcpAttr().getValidationQuery());
} catch (SQLException e) {
throw new SQLException(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Invalid_Config", connectionBean.getName()) + ", " + e.getMessage(), e.getCause());
}
try {
connection.validateSettings();
} catch (Exception e) {
throw new SQLException(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Invalid_Config", connectionBean.getName()) + ", " + e.getMessage(), e.getCause());
}
}

Loading…
Cancel
Save