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(); // 创建监听服务