From 95b8dd4632f688f6893c7ed16b7a71490ed09910 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 3 Jul 2024 21:40:17 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-114391=20-=20=E3=80=90=E5=BE=AE=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E9=80=82=E9=85=8D=E3=80=91=E8=BF=9C=E7=A8=8B&?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=AE=BE=E8=AE=A1=E5=99=A8=E8=83=BD=E5=A4=9F?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E5=90=AF=E5=8A=A8=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/connect/ConnectionListPane.java | 7 +++-- .../datapane/preview/PreviewTablePane.java | 9 ++++-- .../fr/design/env/HttpWorkspaceConnector.java | 29 ++++++++++++++----- .../java/com/fr/design/utils/DesignUtils.java | 3 +- .../java/com/fr/env/RemoteWorkspaceURL.java | 4 +-- .../boot/init/DesignPreLoadComponent.java | 2 +- 6 files changed, 36 insertions(+), 18 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 0923283345..c587faa5ee 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 @@ -195,10 +195,11 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh public void populate(Map connectionMap) { List nameObjectList = new ArrayList(); populatedConnectionsSnapshot.clear(); - for (Map.Entry entry : ConnectionConfigProviderFactory.getConfigProvider().getConnections().entrySet()) { - nameObjectList.add(new NameObject(entry.getKey(), entry.getValue())); + List beans = ConnectionRepository.getInstance().getAll(); + for (com.fr.workspace.server.entity.connection.ConnectionBean entry : beans) { + nameObjectList.add(new NameObject(entry.getName(), entry.getConnection())); try { - populatedConnectionsSnapshot.put(entry.getKey(), (Connection) entry.getValue().clone()); + populatedConnectionsSnapshot.put(entry.getName(), (Connection) entry.getConnection().clone()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index ffac1388c6..fe1d122a3a 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -38,6 +38,8 @@ import com.fr.function.TIME; import com.fr.general.FRFont; import com.fr.general.data.DataModel; import com.fr.log.FineLoggerFactory; +import com.fr.workspace.server.entity.connection.ConnectionBean; +import com.fr.workspace.server.repository.connection.ConnectionRepository; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -587,9 +589,10 @@ public class PreviewTablePane extends BasicPane { */ private void testDBTableDataConnection(TableData tableData) throws Exception { if (tableData instanceof DBTableData) { - boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase()); - if (!status) { - throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); + try { + ConnectionRepository.getInstance().testConnection(new ConnectionBean(((DBTableData) tableData).getDatabase())); + } catch (Exception e) { + throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), e); } } } diff --git a/designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java b/designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java index e8f8209b41..116ef9ec73 100644 --- a/designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java +++ b/designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java @@ -35,20 +35,33 @@ public class HttpWorkspaceConnector implements WorkspaceConnector { @Override public boolean testConnection(WorkspaceConnectionInfo connectionInfo) throws Exception { - LoginResponseInfoBean bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); + FineWorkspaceHttpClient client = FineWorkspaceHttpClient.create("Http-Client", connectionInfo); + LoginResponseInfoBean bean; + try { + bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); + } catch (Exception e) { + client.closePool(); + throw e; + } + return StringUtils.isNotEmpty(bean.getAccessToken()); } @Override public WorkspaceClient connect(WorkspaceConnectionInfo connectionInfo) throws Exception { FineWorkspaceHttpClient client = FineWorkspaceHttpClient.create("Http-Client", connectionInfo); - LoginResponseInfoBean bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); - WorkspaceConnection connection = new WorkspaceConnection( - UUID.randomUUID().toString(), - connectionInfo.getUserName(), - HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(), - InetAddress.getLocalHost().getHostAddress()); - client.updateConnection(connection); + try { + LoginResponseInfoBean bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); + WorkspaceConnection connection = new WorkspaceConnection( + UUID.randomUUID().toString(), + connectionInfo.getUserName(), + HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(), + InetAddress.getLocalHost().getHostAddress()); + client.updateConnection(connection); + } catch (Exception e) { + client.closePool(); + throw e; + } client.startHeartBeat(); CompatibleRegister.registerCompatibleEnv(); return client; diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index f218a15e23..90702e6af2 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -1,5 +1,6 @@ package com.fr.design.utils; +import com.fanruan.workplace.http.HttpConstants; import com.fr.base.FeedBackInfo; import com.fr.base.ServerConfig; import com.fr.base.Utils; @@ -437,7 +438,7 @@ public class DesignUtils { } private static String getWebBrowserPath() { - String urlPath = WorkContext.getCurrent().getPath(); + String urlPath = WorkContext.getCurrent().getPath() + HttpConstants.FR; DesignerEnvProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); if (processor != null) { //cas访问的时候, url要处理下. diff --git a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java index 1dcd2220f6..d03e447c45 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java +++ b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java @@ -133,8 +133,8 @@ public class RemoteWorkspaceURL implements FCloneable { String prefix = isHttps ? HTTPS : HTTP; String portColon = StringUtils.isNotEmpty(port) ? ":" : StringUtils.EMPTY; String webAppNameSlash = StringUtils.isNotEmpty(web) ? "/" : StringUtils.EMPTY; - String servletNameSlash = StringUtils.isNotEmpty(servlet) ? "/" : StringUtils.EMPTY; - this.url = prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash + servlet; + String servletNameSlash = "/"; + this.url = prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash; return this.url; } 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 14083d5182..8e2f939ffe 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 @@ -218,7 +218,7 @@ public class DesignPreLoadComponent { try { beforeAllStart(); //清空临时文件 - TmpFileUtils.cleanUpInnerTmpFiles(); + Runtime.getRuntime().addShutdownHook(new Thread(TmpFileUtils::cleanUpInnerTmpFiles)); RestartHelper.deleteRecordFilesWhenStart(); CloudCenter.getInstance(); // 创建监听服务