Browse Source

Merge pull request #9582 in DESIGN/design from release/11.0 to final/11.0

* commit '682081816a55dcfd58dccc9b65b984999a0dd5b7':
  REPORT-76370 提供一个数据连接前置检查接口&写错了应该是远程调用
  REPORT-76370 提供一个数据连接前置检查接口&设计器数据连接保存
new-design
superman 2 years ago
parent
commit
8967a461fb
  1. 16
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

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

@ -1,13 +1,12 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.TemplateUtils;
import com.fr.config.RemoteConfigEvent; import com.fr.config.RemoteConfigEvent;
import com.fr.data.core.db.JDBCSecurityChecker;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.data.impl.ConnectionBean; import com.fr.data.impl.ConnectionBean;
import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.metric.utils.DatabaseConnectionMetricHandler; import com.fr.data.metric.utils.DatabaseConnectionMetricHandler;
import com.fr.data.operator.DataOperator;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.data.MapCompareUtils; import com.fr.design.data.MapCompareUtils;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
@ -187,7 +186,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
case ADDED: case ADDED:
case UPDATED: case UPDATED:
addedOrUpdatedConnections.add(new ConnectionBean(s, StringUtils.EMPTY, connection)); addedOrUpdatedConnections.add(new ConnectionBean(s, StringUtils.EMPTY, connection));
if (connection instanceof JDBCDatabaseConnection){ if (connection instanceof JDBCDatabaseConnection) {
DatabaseConnectionMetricHandler.handleSaveConnection((JDBCDatabaseConnection) connection, null); DatabaseConnectionMetricHandler.handleSaveConnection((JDBCDatabaseConnection) connection, null);
} }
default: default:
@ -195,24 +194,21 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
} }
}); });
this.checkSecurity(addedOrUpdatedConnections); this.validateConnections(addedOrUpdatedConnections);
this.alterConnections(removedConnNames, 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) { for (ConnectionBean connectionBean : addedOrUpdatedConnections) {
Connection connection = connectionBean.getConnection(); Connection connection = connectionBean.getConnection();
if (connection instanceof JDBCDatabaseConnection) {
try { try {
JDBCSecurityChecker.checkURL(TemplateUtils.render(((JDBCDatabaseConnection) connection).getURL())); DataOperator.getInstance().validateConnectionSettings(connection);
JDBCSecurityChecker.checkValidationQuery(((JDBCDatabaseConnection) connection).getDbcpAttr().getValidationQuery()); } catch (Exception e) {
} catch (SQLException e) {
throw new SQLException(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Invalid_Config", connectionBean.getName()) + ", " + e.getMessage(), e.getCause()); throw new SQLException(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Invalid_Config", connectionBean.getName()) + ", " + e.getMessage(), e.getCause());
} }
} }
}
} }

Loading…
Cancel
Save