Browse Source

Merge pull request #14415 in DESIGN/design from mss/2.0 to fbp-1.0

* commit '57feeb548c8e83dbb674783472997d54bd48dfc4':
  REPORT-114392 FR-FBP版本本地设计适配 数据连接适配
  REPORT-114392 FR-FBP版本本地设计适配 数据连接适配
fbp-1.0
superman 4 months ago
parent
commit
b39105d503
  1. 3
      build.gradle
  2. 2
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  3. 2
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  4. 11
      designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java
  5. 14
      designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java
  6. 2
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  7. 2
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapper.java
  8. 2
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java
  9. 2
      designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java
  10. 2
      designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java

3
build.gradle

@ -83,6 +83,7 @@ allprojects {
// //
implementation 'com.fr.portal:fine-portal:' + apiVersion implementation 'com.fr.portal:fine-portal:' + apiVersion
implementation 'com.fr.portal:fine-portal-api:' + apiVersion implementation 'com.fr.portal:fine-portal-api:' + apiVersion
implementation 'com.fr.portal:fine-portal-datasource:' + carinaVersion
// cbb // cbb
implementation 'com.fr.essential:fine-essential:' + cbbVersion implementation 'com.fr.essential:fine-essential:' + cbbVersion
implementation 'com.fr.cbb:fine-universal-skeleton:' + cbbVersion implementation 'com.fr.cbb:fine-universal-skeleton:' + cbbVersion
@ -98,6 +99,7 @@ allprojects {
implementation 'com.fr.auth:fine-auth:' + apiVersion implementation 'com.fr.auth:fine-auth:' + apiVersion
implementation 'com.fr.auth:fine-auth-api:' + apiVersion implementation 'com.fr.auth:fine-auth-api:' + apiVersion
// lic // lic
implementation 'com.fr.license:fine-license:' + apiVersion
implementation 'com.fr.license:fine-license-api:' + apiVersion implementation 'com.fr.license:fine-license-api:' + apiVersion
// cluster // cluster
implementation 'com.fr.cluster:fine-cluster-api:' + apiVersion implementation 'com.fr.cluster:fine-cluster-api:' + apiVersion
@ -116,7 +118,6 @@ allprojects {
implementation 'io.socket:socket.io-client:0.7.0' implementation 'io.socket:socket.io-client:0.7.0'
implementation('com.fr.third:fine-third:' + frVersion) { exclude group: "com.fr.cbb", module: "fine-cbb" } implementation('com.fr.third:fine-third:' + frVersion) { exclude group: "com.fr.cbb", module: "fine-cbb" }
implementation 'com.fr.core:fine-core:' + frDevVersion implementation 'com.fr.core:fine-core:' + frDevVersion
implementation 'com.fr.activator:fine-activator:' + frVersion
implementation 'com.fr.datasource:fine-datasource-api:' + fdlVersion implementation 'com.fr.datasource:fine-datasource-api:' + fdlVersion
implementation 'com.fr.datasource:fine-datasource-core:' + fdlVersion implementation 'com.fr.datasource:fine-datasource-core:' + fdlVersion
implementation 'com.fr.datasource:fine-datasource-web:' + fdlVersion implementation 'com.fr.datasource:fine-datasource-web:' + fdlVersion

2
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -444,7 +444,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return TableData.EMPTY_TABLEDATA; return TableData.EMPTY_TABLEDATA;
} }
try { try {
ConnectionRepository.getInstance().testConnection(new ConnectionBean(database)); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(database));
connect = true; connect = true;
} catch (Exception ignored) { } catch (Exception ignored) {
connect= false; connect= false;

2
designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java

@ -432,7 +432,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
// 返回连接结果 // 返回连接结果
DriverPage.updateCache(); DriverPage.updateCache();
final Exception[] exception = new Exception[1]; final Exception[] exception = new Exception[1];
ConnectionRepository.getInstance().testConnection(new ConnectionBean(database)); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(database));
return null; return null;
} }

11
designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java

@ -6,6 +6,7 @@ import com.fr.decision.webservice.bean.datasource.ConnectionInfoBean;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.security.encryption.transmission.TransmissionEncryptionManager;
import com.fr.workspace.server.repository.connection.BaseConnectionSource; import com.fr.workspace.server.repository.connection.BaseConnectionSource;
import java.sql.SQLException; import java.sql.SQLException;
@ -18,6 +19,16 @@ import java.sql.SQLException;
*/ */
public class LocalConnectionSource extends BaseConnectionSource { public class LocalConnectionSource extends BaseConnectionSource {
@Override
public void testConnection(ConnectionInfoBean database) throws Exception {
try {
// 暂时这么处理,后续最好拉到外层包装一下
TransmissionEncryptionManager.setTransEncryptionLevel(1);
dataOperator.testConnectionWithException(ConnectionProcessorFactory.createConnection(database));
} finally {
TransmissionEncryptionManager.removeTransEncryptionLevel();
}
}
@Override @Override
public void add(ConnectionInfoBean bean) throws Exception { public void add(ConnectionInfoBean bean) throws Exception {
Connection connection = ConnectionProcessorFactory.createConnection(bean); Connection connection = ConnectionProcessorFactory.createConnection(bean);

14
designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java

@ -19,10 +19,10 @@ import com.fr.decision.webservice.bean.datasource.JDBCConnectionBean;
import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor;
import com.fr.security.encryption.transmission.TransmissionEncryptors; import com.fr.security.encryption.transmission.TransmissionEncryptionManager;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.fasterxml.jackson.databind.ObjectMapper; import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
import com.fr.workspace.server.repository.WorkplaceConstants;
/** /**
* 数据连接传输工具类 * 数据连接传输工具类
* *
@ -95,7 +95,7 @@ public class ConnectionInfoBeanHelper {
.user(jdbcConnection.getUser()) .user(jdbcConnection.getUser())
.driver(jdbcConnection.getDriver()) .driver(jdbcConnection.getDriver())
// 关键中的关键,由设计器发出的请求如果要携带密码,不能传明文,必须必须必须传加密后的密码 // 关键中的关键,由设计器发出的请求如果要携带密码,不能传明文,必须必须必须传加密后的密码
.password(withPassword ? TransmissionEncryptors.getInstance().encrypt(jdbcConnection.getPassword()) : DecisionServiceConstants.DEFAULT_PASSWORD) .password(withPassword ? encrypt(jdbcConnection.getPassword()) : DecisionServiceConstants.DEFAULT_PASSWORD)
.schema(jdbcConnection.getSchema()) .schema(jdbcConnection.getSchema())
.url(jdbcConnection.getURL()) .url(jdbcConnection.getURL())
.creator(jdbcConnection.getCreator()) .creator(jdbcConnection.getCreator())
@ -126,4 +126,12 @@ public class ConnectionInfoBeanHelper {
.verifyCa(jdbcConnection.getSsl().getSslType() == SslType.NORMAL && ((NormalSsl) jdbcConnection.getSsl()).isVerifyCa()); .verifyCa(jdbcConnection.getSsl().getSslType() == SslType.NORMAL && ((NormalSsl) jdbcConnection.getSsl()).isVerifyCa());
} }
private static String encrypt(String password) {
// 如果是空密码或者默认密码,就返回默认的星号回去
if (StringUtils.isEmpty(password) || StringUtils.equals(password, DecisionServiceConstants.DEFAULT_PASSWORD)) {
return DecisionServiceConstants.DEFAULT_PASSWORD;
}
return TransmissionEncryptionManager.getInstance().getEncryption(WorkplaceConstants.getEncryptionMode()).encrypt(password, WorkplaceConstants.getEncryptionKey());
}
} }

2
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -590,7 +590,7 @@ public class PreviewTablePane extends BasicPane {
private void testDBTableDataConnection(TableData tableData) throws Exception { private void testDBTableDataConnection(TableData tableData) throws Exception {
if (tableData instanceof DBTableData) { if (tableData instanceof DBTableData) {
try { try {
ConnectionRepository.getInstance().testConnection(new ConnectionBean(((DBTableData) tableData).getDatabase(), tableData.getName())); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(tableData.getName(), ((DBTableData) tableData).getDatabase()));
} catch (Exception e) { } catch (Exception e) {
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), e); throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), e);
} }

2
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapper.java

@ -195,7 +195,7 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
if (tableData instanceof StoreProcedure) { if (tableData instanceof StoreProcedure) {
try { try {
connectionBar.start(); connectionBar.start();
ConnectionRepository.getInstance().testConnection(new ConnectionBean(((StoreProcedure) getTableData()).getDatabaseConnection())); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(((StoreProcedure) getTableData()).getDatabaseConnection()));
} catch (Exception e){ } catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));

2
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java

@ -182,7 +182,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
PreviewTablePane.resetPreviewTable(); PreviewTablePane.resetPreviewTable();
connectionBar.start(); connectionBar.start();
try { try {
ConnectionRepository.getInstance().testConnection(new ConnectionBean(((StoreProcedure) getTableData()).getDatabaseConnection())); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(((StoreProcedure) getTableData()).getDatabaseConnection()));
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
connectionBar.close(); connectionBar.close();

2
designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java vendored

@ -2,6 +2,7 @@ package com.fr.design.env;
import com.fanruan.workplace.http.HttpConstants; import com.fanruan.workplace.http.HttpConstants;
import com.fanruan.workplace.http.RepositoryManager; import com.fanruan.workplace.http.RepositoryManager;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.server.repository.authority.RemoteAuthorityRepository; import com.fr.workspace.server.repository.authority.RemoteAuthorityRepository;
import com.fr.workspace.server.repository.compatible.register.CompatibleRegister; import com.fr.workspace.server.repository.compatible.register.CompatibleRegister;
@ -57,6 +58,7 @@ public class HttpWorkspaceConnector implements WorkspaceConnector {
if (StringUtils.isEmpty(bean.getAccessToken())) { if (StringUtils.isEmpty(bean.getAccessToken())) {
throw new RuntimeException("Empty token, try connect again and check server"); throw new RuntimeException("Empty token, try connect again and check server");
} }
FineLoggerFactory.getLogger().info("[connector] infos:{}", bean.getAccessToken());
WorkspaceConnection connection = new WorkspaceConnection( WorkspaceConnection connection = new WorkspaceConnection(
UUID.randomUUID().toString(), UUID.randomUUID().toString(),
connectionInfo.getUserName(), connectionInfo.getUserName(),

2
designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java

@ -104,7 +104,7 @@ public class TableViewList extends UIList {
//总共给3次连接的机会 //总共给3次连接的机会
while (!status && count > 0) { while (!status && count > 0) {
try { try {
ConnectionRepository.getInstance().testConnection(new ConnectionBean(datasource, databaseName)); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(databaseName, datasource));
status = true; status = true;
break; break;
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save