Browse Source

REPORT-114391 - 【微服务适配】远程&本地设计器能够正常启动 完善远程设计

fbp-1.0
Destiny.Lin 5 months ago
parent
commit
95b8dd4632
  1. 7
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  2. 9
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  3. 29
      designer-base/src/main/java/com/fr/design/env/HttpWorkspaceConnector.java
  4. 3
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  5. 4
      designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java
  6. 2
      designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java

7
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<String, Connection> connectionMap) { public void populate(Map<String, Connection> connectionMap) {
List<NameObject> nameObjectList = new ArrayList<NameObject>(); List<NameObject> nameObjectList = new ArrayList<NameObject>();
populatedConnectionsSnapshot.clear(); populatedConnectionsSnapshot.clear();
for (Map.Entry<String, Connection> entry : ConnectionConfigProviderFactory.getConfigProvider().getConnections().entrySet()) { List<com.fr.workspace.server.entity.connection.ConnectionBean> beans = ConnectionRepository.getInstance().getAll();
nameObjectList.add(new NameObject(entry.getKey(), entry.getValue())); for (com.fr.workspace.server.entity.connection.ConnectionBean entry : beans) {
nameObjectList.add(new NameObject(entry.getName(), entry.getConnection()));
try { try {
populatedConnectionsSnapshot.put(entry.getKey(), (Connection) entry.getValue().clone()); populatedConnectionsSnapshot.put(entry.getName(), (Connection) entry.getConnection().clone());
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }

9
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.FRFont;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fr.log.FineLoggerFactory; 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.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
@ -587,9 +589,10 @@ 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) {
boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase()); try {
if (!status) { ConnectionRepository.getInstance().testConnection(new ConnectionBean(((DBTableData) tableData).getDatabase()));
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); } catch (Exception e) {
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), e);
} }
} }
} }

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

@ -35,20 +35,33 @@ public class HttpWorkspaceConnector implements WorkspaceConnector {
@Override @Override
public boolean testConnection(WorkspaceConnectionInfo connectionInfo) throws Exception { 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()); return StringUtils.isNotEmpty(bean.getAccessToken());
} }
@Override @Override
public WorkspaceClient connect(WorkspaceConnectionInfo connectionInfo) throws Exception { public WorkspaceClient connect(WorkspaceConnectionInfo connectionInfo) throws Exception {
FineWorkspaceHttpClient client = FineWorkspaceHttpClient.create("Http-Client", connectionInfo); FineWorkspaceHttpClient client = FineWorkspaceHttpClient.create("Http-Client", connectionInfo);
LoginResponseInfoBean bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); try {
WorkspaceConnection connection = new WorkspaceConnection( LoginResponseInfoBean bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo));
UUID.randomUUID().toString(), WorkspaceConnection connection = new WorkspaceConnection(
connectionInfo.getUserName(), UUID.randomUUID().toString(),
HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(), connectionInfo.getUserName(),
InetAddress.getLocalHost().getHostAddress()); HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(),
client.updateConnection(connection); InetAddress.getLocalHost().getHostAddress());
client.updateConnection(connection);
} catch (Exception e) {
client.closePool();
throw e;
}
client.startHeartBeat(); client.startHeartBeat();
CompatibleRegister.registerCompatibleEnv(); CompatibleRegister.registerCompatibleEnv();
return client; return client;

3
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -1,5 +1,6 @@
package com.fr.design.utils; package com.fr.design.utils;
import com.fanruan.workplace.http.HttpConstants;
import com.fr.base.FeedBackInfo; import com.fr.base.FeedBackInfo;
import com.fr.base.ServerConfig; import com.fr.base.ServerConfig;
import com.fr.base.Utils; import com.fr.base.Utils;
@ -437,7 +438,7 @@ public class DesignUtils {
} }
private static String getWebBrowserPath() { private static String getWebBrowserPath() {
String urlPath = WorkContext.getCurrent().getPath(); String urlPath = WorkContext.getCurrent().getPath() + HttpConstants.FR;
DesignerEnvProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); DesignerEnvProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG);
if (processor != null) { if (processor != null) {
//cas访问的时候, url要处理下. //cas访问的时候, url要处理下.

4
designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java vendored

@ -133,8 +133,8 @@ public class RemoteWorkspaceURL implements FCloneable {
String prefix = isHttps ? HTTPS : HTTP; String prefix = isHttps ? HTTPS : HTTP;
String portColon = StringUtils.isNotEmpty(port) ? ":" : StringUtils.EMPTY; String portColon = StringUtils.isNotEmpty(port) ? ":" : StringUtils.EMPTY;
String webAppNameSlash = StringUtils.isNotEmpty(web) ? "/" : StringUtils.EMPTY; String webAppNameSlash = StringUtils.isNotEmpty(web) ? "/" : StringUtils.EMPTY;
String servletNameSlash = StringUtils.isNotEmpty(servlet) ? "/" : StringUtils.EMPTY; String servletNameSlash = "/";
this.url = prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash + servlet; this.url = prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash;
return this.url; return this.url;
} }

2
designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java

@ -218,7 +218,7 @@ public class DesignPreLoadComponent {
try { try {
beforeAllStart(); beforeAllStart();
//清空临时文件 //清空临时文件
TmpFileUtils.cleanUpInnerTmpFiles(); Runtime.getRuntime().addShutdownHook(new Thread(TmpFileUtils::cleanUpInnerTmpFiles));
RestartHelper.deleteRecordFilesWhenStart(); RestartHelper.deleteRecordFilesWhenStart();
CloudCenter.getInstance(); CloudCenter.getInstance();
// 创建监听服务 // 创建监听服务

Loading…
Cancel
Save