From df58ea9ae29ec08d7b7ecea53152ca751162ea00 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 25 Jul 2024 10:43:06 +0800 Subject: [PATCH 1/5] =?UTF-8?q?REPORT-127453=20frm=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/startup/ui/StartupPageModel.java | 12 ++++++++++-- .../boot/env/function/app/DesignAppComponent.java | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java index a461ee33b5..62b20d50d0 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java @@ -1,5 +1,6 @@ package com.fr.startup.ui; +import com.fr.base.extension.FileExtension; import com.fr.design.DesignerEnvManager; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; @@ -19,7 +20,8 @@ import java.util.stream.Collectors; * created by Harrison on 2022/07/06 **/ public class StartupPageModel { - + private static final String FRM = "frm"; + private static final String FORM = "form"; private StartupWorkspaceBean selectWorkspaceInfo; private List workspaceInfos = new ArrayList<>(); @@ -57,7 +59,13 @@ public class StartupPageModel { for (StartupWorkspaceBean info : infos) { String name = info.getName(); List recentFiles = envManager.getRecentOpenedFilePathList4Env(name); - recentFileMap.put(name, recentFiles); + List checkFiles = new ArrayList<>(); + for (String s : recentFiles) { + if (!s.endsWith(FRM) && !s.endsWith(FORM)) { + checkFiles.add(s); + } + } + recentFileMap.put(name, checkFiles); } return new StartupPageModel(infos, recentFileMap); } diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/function/app/DesignAppComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/function/app/DesignAppComponent.java index e2f59dba9c..55ceb2de9d 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/function/app/DesignAppComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/function/app/DesignAppComponent.java @@ -56,6 +56,6 @@ public class DesignAppComponent { */ @Supplemental public void prepare() { - Carina.getApplicationContext().group(AppGroup.class).addAll(new CptApp(), new CptxApp(), new FormApp(), new XlsApp(), new XlsxApp()); + Carina.getApplicationContext().group(AppGroup.class).addAll(new CptApp(), new CptxApp(), new XlsApp(), new XlsxApp()); } } From cfaeac34c6158127f9451ff8f326e55621d55f81 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 25 Jul 2024 10:45:53 +0800 Subject: [PATCH 2/5] =?UTF-8?q?REPORT-114392=20FR-FBP=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=AE=BE=E8=AE=A1=E9=80=82=E9=85=8D=20?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=8E=AF=E5=A2=83=E7=9B=91=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java | 4 ++-- .../main/java/com/fanruan/boot/env/DesignEnvComponent.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 54cc4cc4d3..99579aae3d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -572,8 +572,8 @@ public abstract class ToolBarMenuDock { if (AlphaFineConfigManager.isALPHALicAvailable()) { shortCuts.add(new AlphaFineAction()); } - - shortCuts.add(new EnvDetectorAction()); + /// fbp本地和远程都暂时不使用环境监测 + //shortCuts.add(new EnvDetectorAction()); //服务平台(仅针对中国大陆) if (GeneralContext.getLocale().equals(Locale.CHINA)) { shortCuts.add(new ServicePlatformAction()); diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java index 700fc12258..9e482c00ca 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java @@ -402,7 +402,8 @@ public class DesignEnvComponent { } private void startEnvPrepare() { - EnvDetectorCenter.getInstance().init(); + /// 环境检测、资源升级都暂不支持 + //EnvDetectorCenter.getInstance().init(); if (WorkContext.getCurrent().isLocal()) { // 如果是切回本地,要初始化成本地仓库 // 如果是切回远程,会在用户创建的时候就同步初始化远程仓库 From ff0cee0c639178688ab0c8e69b3d14fe21f4e7e9 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 25 Jul 2024 12:33:02 +0800 Subject: [PATCH 3/5] =?UTF-8?q?REPORT-114392=20FR-FBP=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=AE=BE=E8=AE=A1=E9=80=82=E9=85=8D=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/connect/ConnectionListPane.java | 105 ++++++++++++++++-- 1 file changed, 96 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index 94debc6c5b..72f948648a 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -3,11 +3,25 @@ package com.fr.design.data.datapane.connect; import com.fanruan.config.impl.data.ConnectionConfigProviderFactory; import com.fanruan.config.impl.data.ConnectionConfigWriterFactory; import com.fr.config.remote.RemoteConfigEvent; +import com.fr.data.auth.AuthenticationType; +import com.fr.data.auth.kerberos.KerberosAuthentication; +import com.fr.data.auth.kerberos.KerberosUtils; import com.fr.data.impl.Connection; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection; +import com.fr.data.pool.DBCPConnectionPoolAttr; +import com.fr.data.security.ssh.BaseSsh; +import com.fr.data.security.ssh.SshType; +import com.fr.data.security.ssh.impl.KeyVerifySsh; +import com.fr.data.security.ssl.BaseSsl; +import com.fr.data.security.ssl.SslType; +import com.fr.data.security.ssl.impl.NormalSsl; +import com.fr.decision.privilege.TransmissionTool; import com.fr.decision.webservice.bean.datasource.ConnectionInfoBean; +import com.fr.decision.webservice.bean.datasource.JDBCConnectionBean; +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.JDBCConnectionProcessor; import com.fr.design.ExtraDesignClassManager; import com.fr.design.data.MapCompareUtils; import com.fr.design.dialog.BasicDialog; @@ -24,10 +38,12 @@ import com.fr.license.database.DBTypes; import com.fr.license.database.DataBaseTypePointManager; import com.fr.license.exception.DataBaseNotSupportedException; import com.fr.log.FineLoggerFactory; +import com.fr.security.encryption.transmission.TransmissionEncryptors; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; +import com.fr.third.fasterxml.jackson.databind.ObjectMapper; import com.fr.workspace.WorkContext; import com.fr.workspace.server.database.DataBaseTypeOperator; import com.fr.workspace.server.entity.connection.BatchConnectionModifyBean; @@ -58,6 +74,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh private final HashMap renameMap = new HashMap<>(); private final Map populatedConnectionsSnapshot = new LinkedHashMap<>(); private static List supportedDatabaseTypes = new ArrayList<>(); + private static ObjectMapper objectMapper = new ObjectMapper(); public ConnectionListPane() { renameMap.clear(); @@ -220,6 +237,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh List removedConnNames = new ArrayList<>(); List addConnections = new ArrayList<>(); List updateConnection = new ArrayList<>(); + List validConnection = new ArrayList<>(); MapCompareUtils.contrastMapEntries(populatedConnectionsSnapshot, updatedMap, (entryEventKind, s, connection) -> { try { switch (entryEventKind) { @@ -227,10 +245,12 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh removedConnNames.add(s); break; case ADDED: - addConnections.add(ConnectionProcessorFactory.createConnectionInfoBean(s, connection)); + addConnections.add(createConnectionInfoBean(s, connection)); + validConnection.add(connection); break; case UPDATED: - updateConnection.add(ConnectionProcessorFactory.createConnectionInfoBean(s, connection)); + updateConnection.add(createConnectionInfoBean(s, connection)); + validConnection.add(connection); break; default: break; @@ -266,21 +286,17 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh } }); - List validateBeans = new ArrayList<>(); - validateBeans.addAll(addConnections); - validateBeans.addAll(updateConnection); - this.validateDatabaseType(validateBeans); + this.validateDatabaseType(validConnection); this.alterConnections(addConnections, removedConnNames, updateConnection); } /** * 校验是否支持所有新增和修改数据连接的数据库类型 */ - public void validateDatabaseType(@NotNull List addedOrUpdatedConnections) throws Exception { + public void validateDatabaseType(@NotNull List addedOrUpdatedConnections) throws Exception { Set notSupportedConnections = new HashSet<>(); if (!addedOrUpdatedConnections.isEmpty()) { - for (ConnectionInfoBean bean : addedOrUpdatedConnections) { - Connection connection = ConnectionProcessorFactory.createConnection(bean); + for (Connection connection : addedOrUpdatedConnections) { // 仅校验jdbc连接,其他插件数据连接不进行校验; if (connection instanceof JDBCDatabaseConnection) { DBTypes dataBaseTypePoint = DataBaseTypePointManager.getInstance().getDataBaseTypePoint(connection.getDriver(), connection.feature()); @@ -317,6 +333,19 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh return false; } + private ConnectionInfoBean createConnectionInfoBean(String name, Connection connection) throws Exception { + if (JDBCConnectionProcessor.KEY.acceptConnections().contains(connection.getClass())) { + ConnectionInfoBean bean = new ConnectionInfoBean(); + bean.setConnectionData(objectMapper.writeValueAsString(convertToJDBCConnectionBean(connection, true))); + bean.setConnectionType(JDBCConnectionProcessor.CONNECTION_TYPE); + bean.setConnectionType(JDBCConnectionProcessor.KEY.getConnectionType(connection)); + bean.setConnectionName(name); + bean.setCreator(connection.getCreator()); + return bean; + } else { + return ConnectionProcessorFactory.createConnectionInfoBean(name, connection); + } + } private void alterConnections(List addConnections, List removedConnNames, List updateConnection) { @@ -385,4 +414,62 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh } } } + + /** + * jdbc的特殊处理 + */ + private JDBCConnectionBean convertToJDBCConnectionBean(Connection connection, boolean withPassword) { + JDBCDatabaseConnection jdbcConnection = (JDBCDatabaseConnection) connection; + JDBCConnectionBean jdbcConnectionBean = new JDBCConnectionBean(); + DBCPConnectionPoolAttr poolAttr = new DBCPConnectionPoolAttr(); + try { + poolAttr = (DBCPConnectionPoolAttr) jdbcConnection.getDbcpAttr().clone(); + } catch (CloneNotSupportedException ignore) { + } + poolAttr.setValidationQuery(TransmissionTool.encrypt(poolAttr.getValidationQuery())); + KerberosAuthentication kerberosAuthentication = null; + if (jdbcConnection.getAuthentication().type() == AuthenticationType.KERBEROS) { + //获取数据连接信息的时候,做一下兼容处理(兼容旧的kerberos形式) + KerberosUtils.compatibilityProcess(((KerberosAuthentication) jdbcConnection.getAuthentication())); + kerberosAuthentication = ((KerberosAuthentication) jdbcConnection.getAuthentication()); + } + //因为设计器创建连接时database属性为空,所以这里直接取数据库保存的fetchSize值,默认值为-1 + return jdbcConnectionBean + .newCharsetName(jdbcConnection.getNewCharsetName()) + .originalCharsetName(jdbcConnection.getOriginalCharsetName()) + .database(jdbcConnection.getDatabase()) + .user(jdbcConnection.getUser()) + .driver(jdbcConnection.getDriver()) + // 关键中的关键,由设计器发出的请求如果要携带密码,不能传明文,必须必须必须传加密后的密码 + .password(withPassword ? TransmissionEncryptors.getInstance().encrypt(jdbcConnection.getPassword()) : DecisionServiceConstants.DEFAULT_PASSWORD) + .schema(jdbcConnection.getSchema()) + .url(jdbcConnection.getURL()) + .creator(jdbcConnection.getCreator()) + .source(jdbcConnection.getDriverSource()) + .connectionPoolAttr(poolAttr.create()) + .authType(kerberosAuthentication != null ? "kerberos" : StringUtils.EMPTY) + .principal(kerberosAuthentication != null ? kerberosAuthentication.getPrincipal() : StringUtils.EMPTY) + .keyPath(kerberosAuthentication != null ? kerberosAuthentication.getKeyPath() : StringUtils.EMPTY) + .krb5Path(kerberosAuthentication != null ? KerberosUtils.getKrb5Path(kerberosAuthentication.getKeyPath(), kerberosAuthentication.getPrincipal()) : StringUtils.EMPTY) + .useJaas(jdbcConnection.getAuthentication().type() == AuthenticationType.KERBEROS && ((KerberosAuthentication) jdbcConnection.getAuthentication()).getUseJaas()) + .fetchSize(jdbcConnection.getFetchSize()).identity(connection.getIdentity()) + .sshType(jdbcConnection.getSsh().getSshType().toString()) + .sshIp(((BaseSsh) jdbcConnection.getSsh()).getIp()) + .usingSsh(jdbcConnection.getSsh().isUsingSsh()) + .sshUser(((BaseSsh) jdbcConnection.getSsh()).getUser()) + .sshPort(((BaseSsh) jdbcConnection.getSsh()).getPort()) + .redirectPort(jdbcConnection.getSsh().getRedirectPort()) + .redirectIp((jdbcConnection.getSsh()).getRedirectIp()) + .sshTimeOut(((BaseSsh) jdbcConnection.getSsh()).getTimeOut()) + .sshSecret(withPassword ? ((BaseSsh) jdbcConnection.getSsh()).getSecret() : DecisionServiceConstants.DEFAULT_PASSWORD) + .sshPrivateKeyPath(jdbcConnection.getSsh().getSshType() == SshType.KEY ? ((KeyVerifySsh) jdbcConnection.getSsh()).getPrivateKeyPath() : StringUtils.EMPTY) + .usingSsl((jdbcConnection.getSsl()).isUsingSsl()) + .sslType(jdbcConnection.getSsl().getSslType().toString()) + .sslClientCertificate(((BaseSsl) jdbcConnection.getSsl()).getClientCertificate()) + .sslClientPrivateKey(((BaseSsl) jdbcConnection.getSsl()).getClientPrivateKey()) + .caCertificate(((BaseSsl) jdbcConnection.getSsl()).getCaCertificate()) + .properties(jdbcConnection.getProperties()) + .verifyCa(jdbcConnection.getSsl().getSslType() == SslType.NORMAL && ((NormalSsl) jdbcConnection.getSsl()).isVerifyCa()); + } + } From 229e00c9a716a01304a0216ef520f75a376fc2aa Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 25 Jul 2024 14:23:22 +0800 Subject: [PATCH 4/5] =?UTF-8?q?REPORT-114392=20FR-FBP=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=AE=BE=E8=AE=A1=E9=80=82=E9=85=8D=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/ChoosePane.java | 6 +- .../datapane/connect/ConnectionListPane.java | 86 ++---------- .../connect/DatabaseConnectionPane.java | 22 +--- .../connect/LocalConnectionSource.java | 5 + .../preview/ConnectionInfoBeanHelper.java | 124 ++++++++++++++++++ .../datapane/preview/PreviewTablePane.java | 2 +- .../wrapper/MultiResultTableDataWrapper.java | 10 +- .../wrapper/StoreProcedureDataWrapper.java | 8 +- .../fr/design/gui/ilist/TableViewList.java | 3 +- 9 files changed, 162 insertions(+), 104 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index 8ab88bbf99..47b1d4d247 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -14,6 +14,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.RefreshLabel.Refreshable; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.design.data.datapane.preview.PreviewLabel; import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; import com.fr.design.data.datapane.preview.PreviewTablePane; @@ -39,6 +40,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.server.connection.DBConnectAuth; +import com.fr.workspace.server.repository.connection.ConnectionRepository; import javax.swing.JList; import javax.swing.JOptionPane; @@ -442,8 +444,10 @@ public class ChoosePane extends BasicBeanPane implements Refresha return TableData.EMPTY_TABLEDATA; } try { - connect = DataOperator.getInstance().testConnection(database); + ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(database)); + connect = true; } catch (Exception ignored) { + connect= false; } if (!connect) { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index 72f948648a..974f8b0d7b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -24,6 +24,7 @@ import com.fr.decision.webservice.v10.datasource.connection.processor.impl.Conne import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor; import com.fr.design.ExtraDesignClassManager; import com.fr.design.data.MapCompareUtils; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.design.dialog.BasicDialog; import com.fr.design.fun.ConnectionProvider; import com.fr.design.gui.controlpane.JListControlPane; @@ -74,7 +75,6 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh private final HashMap renameMap = new HashMap<>(); private final Map populatedConnectionsSnapshot = new LinkedHashMap<>(); private static List supportedDatabaseTypes = new ArrayList<>(); - private static ObjectMapper objectMapper = new ObjectMapper(); public ConnectionListPane() { renameMap.clear(); @@ -245,11 +245,11 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh removedConnNames.add(s); break; case ADDED: - addConnections.add(createConnectionInfoBean(s, connection)); + addConnections.add(ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true)); validConnection.add(connection); break; case UPDATED: - updateConnection.add(createConnectionInfoBean(s, connection)); + updateConnection.add(ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true)); validConnection.add(connection); break; default: @@ -285,8 +285,8 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh return connection instanceof JDBCDatabaseConnection || connection instanceof JNDIDatabaseConnection; } }); - - this.validateDatabaseType(validConnection); + /// 先不管 + //this.validateDatabaseType(validConnection); this.alterConnections(addConnections, removedConnNames, updateConnection); } @@ -333,19 +333,6 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh return false; } - private ConnectionInfoBean createConnectionInfoBean(String name, Connection connection) throws Exception { - if (JDBCConnectionProcessor.KEY.acceptConnections().contains(connection.getClass())) { - ConnectionInfoBean bean = new ConnectionInfoBean(); - bean.setConnectionData(objectMapper.writeValueAsString(convertToJDBCConnectionBean(connection, true))); - bean.setConnectionType(JDBCConnectionProcessor.CONNECTION_TYPE); - bean.setConnectionType(JDBCConnectionProcessor.KEY.getConnectionType(connection)); - bean.setConnectionName(name); - bean.setCreator(connection.getCreator()); - return bean; - } else { - return ConnectionProcessorFactory.createConnectionInfoBean(name, connection); - } - } private void alterConnections(List addConnections, List removedConnNames, List updateConnection) { @@ -389,7 +376,11 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh } public static void showDialog(Window parent) { - Map connectionMap = ConnectionConfigProviderFactory.getConfigProvider().getConnections(); + List beans = ConnectionRepository.getInstance().getAll(); + Map connectionMap = new HashMap<>(); + for (ConnectionBean bean : beans) { + connectionMap.put(bean.getName(), bean.getConnection()); + } final ConnectionManagerPane connectionManagerPane = new ConnectionManagerPane() { @Override public void complete() { @@ -415,61 +406,4 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh } } - /** - * jdbc的特殊处理 - */ - private JDBCConnectionBean convertToJDBCConnectionBean(Connection connection, boolean withPassword) { - JDBCDatabaseConnection jdbcConnection = (JDBCDatabaseConnection) connection; - JDBCConnectionBean jdbcConnectionBean = new JDBCConnectionBean(); - DBCPConnectionPoolAttr poolAttr = new DBCPConnectionPoolAttr(); - try { - poolAttr = (DBCPConnectionPoolAttr) jdbcConnection.getDbcpAttr().clone(); - } catch (CloneNotSupportedException ignore) { - } - poolAttr.setValidationQuery(TransmissionTool.encrypt(poolAttr.getValidationQuery())); - KerberosAuthentication kerberosAuthentication = null; - if (jdbcConnection.getAuthentication().type() == AuthenticationType.KERBEROS) { - //获取数据连接信息的时候,做一下兼容处理(兼容旧的kerberos形式) - KerberosUtils.compatibilityProcess(((KerberosAuthentication) jdbcConnection.getAuthentication())); - kerberosAuthentication = ((KerberosAuthentication) jdbcConnection.getAuthentication()); - } - //因为设计器创建连接时database属性为空,所以这里直接取数据库保存的fetchSize值,默认值为-1 - return jdbcConnectionBean - .newCharsetName(jdbcConnection.getNewCharsetName()) - .originalCharsetName(jdbcConnection.getOriginalCharsetName()) - .database(jdbcConnection.getDatabase()) - .user(jdbcConnection.getUser()) - .driver(jdbcConnection.getDriver()) - // 关键中的关键,由设计器发出的请求如果要携带密码,不能传明文,必须必须必须传加密后的密码 - .password(withPassword ? TransmissionEncryptors.getInstance().encrypt(jdbcConnection.getPassword()) : DecisionServiceConstants.DEFAULT_PASSWORD) - .schema(jdbcConnection.getSchema()) - .url(jdbcConnection.getURL()) - .creator(jdbcConnection.getCreator()) - .source(jdbcConnection.getDriverSource()) - .connectionPoolAttr(poolAttr.create()) - .authType(kerberosAuthentication != null ? "kerberos" : StringUtils.EMPTY) - .principal(kerberosAuthentication != null ? kerberosAuthentication.getPrincipal() : StringUtils.EMPTY) - .keyPath(kerberosAuthentication != null ? kerberosAuthentication.getKeyPath() : StringUtils.EMPTY) - .krb5Path(kerberosAuthentication != null ? KerberosUtils.getKrb5Path(kerberosAuthentication.getKeyPath(), kerberosAuthentication.getPrincipal()) : StringUtils.EMPTY) - .useJaas(jdbcConnection.getAuthentication().type() == AuthenticationType.KERBEROS && ((KerberosAuthentication) jdbcConnection.getAuthentication()).getUseJaas()) - .fetchSize(jdbcConnection.getFetchSize()).identity(connection.getIdentity()) - .sshType(jdbcConnection.getSsh().getSshType().toString()) - .sshIp(((BaseSsh) jdbcConnection.getSsh()).getIp()) - .usingSsh(jdbcConnection.getSsh().isUsingSsh()) - .sshUser(((BaseSsh) jdbcConnection.getSsh()).getUser()) - .sshPort(((BaseSsh) jdbcConnection.getSsh()).getPort()) - .redirectPort(jdbcConnection.getSsh().getRedirectPort()) - .redirectIp((jdbcConnection.getSsh()).getRedirectIp()) - .sshTimeOut(((BaseSsh) jdbcConnection.getSsh()).getTimeOut()) - .sshSecret(withPassword ? ((BaseSsh) jdbcConnection.getSsh()).getSecret() : DecisionServiceConstants.DEFAULT_PASSWORD) - .sshPrivateKeyPath(jdbcConnection.getSsh().getSshType() == SshType.KEY ? ((KeyVerifySsh) jdbcConnection.getSsh()).getPrivateKeyPath() : StringUtils.EMPTY) - .usingSsl((jdbcConnection.getSsl()).isUsingSsl()) - .sslType(jdbcConnection.getSsl().getSslType().toString()) - .sslClientCertificate(((BaseSsl) jdbcConnection.getSsl()).getClientCertificate()) - .sslClientPrivateKey(((BaseSsl) jdbcConnection.getSsl()).getClientPrivateKey()) - .caCertificate(((BaseSsl) jdbcConnection.getSsl()).getCaCertificate()) - .properties(jdbcConnection.getProperties()) - .verifyCa(jdbcConnection.getSsl().getSslType() == SslType.NORMAL && ((NormalSsl) jdbcConnection.getSsl()).isVerifyCa()); - } - } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index 0a00f37041..be7ea004a1 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -14,6 +14,7 @@ import com.fr.data.solution.entity.DriverPage; import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor; import com.fr.data.solution.processor.SolutionProcessor; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; @@ -29,6 +30,7 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; +import com.fr.workspace.server.repository.connection.ConnectionRepository; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -429,25 +431,7 @@ public abstract class DatabaseConnectionPane 0) { try { - ConnectionRepository.getInstance().testConnection(new ConnectionBean(datasource)); + ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(databaseName, datasource)); status = true; break; } catch (Exception e) { From e17feb7436565577db77e99c28e8a72fd3672f64 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 25 Jul 2024 14:51:43 +0800 Subject: [PATCH 5/5] =?UTF-8?q?REPORT-114392=20FR-FBP=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=AE=BE=E8=AE=A1=E9=80=82=E9=85=8D=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/ConfigHelper.java | 5 +- .../boot/init/DesignPreLoadComponent.java | 2 + .../boot/pre/DesignPreStartComponent.java | 49 +++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/ConfigHelper.java b/designer-base/src/main/java/com/fr/design/ConfigHelper.java index 31724d8652..c5fd1668d0 100644 --- a/designer-base/src/main/java/com/fr/design/ConfigHelper.java +++ b/designer-base/src/main/java/com/fr/design/ConfigHelper.java @@ -94,7 +94,10 @@ public class ConfigHelper { return properties; } - private static boolean createFile(File file) throws ResourceIOException { + /** + * 创建配置文件 + */ + public static boolean createFile(File file) throws ResourceIOException { String parent = file.getParent(); if (StringUtils.isNotEmpty(parent)) { createDirectory(parent); diff --git a/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java index 736aa35096..4fd91d49a4 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java @@ -45,6 +45,7 @@ import com.fr.locale.InterMutableKey; import com.fr.locale.LocaleMarker; import com.fr.locale.LocaleScope; import com.fr.locale.LocaleUtils; +import com.fr.locale.international.InternationalLocaleManager; import com.fr.log.FineLoggerFactory; import com.fr.measure.DBMeterFactory; import com.fr.record.DefaultDBMeter; @@ -146,6 +147,7 @@ public class DesignPreLoadComponent { } FrontProviderImpl.init(InterProviderImpl.getInstance()); + InternationalLocaleManager.getInstance().init(); } diff --git a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java index 21bca14bd0..b3363f6d3d 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java @@ -1,5 +1,10 @@ package com.fanruan.boot.pre; +import com.fanruan.boot.FSProperties; +import com.fanruan.fs.FileServer; +import com.fanruan.fs.RepositoryFactory; +import com.fanruan.fs.repository.local.LocalFileRepository; +import com.fanruan.product.ProductConstants; import com.fr.design.ConfigHelper; import com.fanruan.boot.key.StartupArgsShell; import com.fanruan.carina.Carina; @@ -31,11 +36,17 @@ import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.general.CommonIOUtils; import com.fr.general.GeneralUtils; +import com.fr.io.base.ResourcePaths; +import com.fr.io.repository.ResourceRepository; +import com.fr.io.repository.ResourceRepositoryWrapper; +import com.fr.io.utils.ResourceIOUtils; import com.fr.log.FineLoggerFactory; import com.fr.module.engine.event.LifecycleErrorEvent; import com.fr.runtime.FineRuntime; import com.fr.stable.CommonCodeUtils; import com.fr.stable.CommonUtils; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; import com.fr.stable.lifecycle.FineLifecycleFatalError; import com.fr.stable.project.ProjectConstants; import com.fr.stable.resource.ResourceLoader; @@ -56,6 +67,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.InputStream; import java.util.ArrayList; import java.util.concurrent.CompletableFuture; @@ -72,6 +84,9 @@ public class DesignPreStartComponent { private static final String SEPARATOR = "/"; private static final String CPT = ".cpt"; private static final String XML = ".xml"; + private static final String PRE_FILE_ROOT = ProductConstants.getEnvHome() + File.separator + "prefile"; + private static final String PRE_FILE = PRE_FILE_ROOT + File.separator + "check"; + /** * 启动 @@ -84,10 +99,38 @@ public class DesignPreStartComponent { startTenant(); // 3.pluginPrepare,注册插件的反向依赖 startPluginPrepare(); - // 4.正式启动 - startPre(); - // 5.mq + // 4.mq startMq(); + // 5.基础fs + startBasicFs(); + // 6.正式启动 + startPre(); + } + + private void startBasicFs() throws Exception { + // 启动的时候无关环境信息的写缓存里 + checkFile(PRE_FILE); + LocalFileRepository.getSingleton().setWorkRoot(PRE_FILE_ROOT); + ResourceRepository realRepo = RepositoryFactory.getRepo(); + FSProperties fsProperties = Carina.properties(FSProperties.class); + FileServer.init( + new ResourceRepositoryWrapper(LocalFileRepository.getSingleton(), StringUtils.EMPTY), + new ResourceRepositoryWrapper(realRepo, StringUtils.EMPTY), + new ResourceRepositoryWrapper(realRepo, StringUtils.EMPTY), + new ResourceRepositoryWrapper(realRepo.generateTenantsSharedRepo(fsProperties.getTenantsSharedNamespace()), StringUtils.EMPTY)); + + ResourceIOUtils.setUnderlying(FileServer.local()); + ResourceIOUtils.setIsolationMode(false); + + ResourcePaths.register(ProjectConstants.ASSETS_NAME, true); + ResourcePaths.register(ProjectConstants.SCHEDULE_NAME, false); + } + + private void checkFile(String path) { + File file = new File(path); + if (!file.exists()) { + ConfigHelper.createFile(file); + } } private void startMq() throws Exception {