Browse Source

REPORT-35253 切换远程到本地设计器的问题

feature/big-screen
hades 4 years ago
parent
commit
44d31554d8
  1. 27
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  2. 25
      designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java

27
designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -1,16 +1,39 @@
package com.fr.design.env; package com.fr.design.env;
import com.fr.design.DesignerEnvManager;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.security.SecurityToolbox; import com.fr.security.SecurityToolbox;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import java.util.HashSet;
import java.util.Set;
public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
private static final Set<String> FILTER_SET = new HashSet<>();
private static final String HTTPS = "https://";
private static final String HTTP = "http://";
private static final String DEFAULT_SERVLET_NAME = "decision";
private static final String PATH = ProjectConstants.FORWARD_SLASH + ProjectConstants.WEBAPP_NAME + ProjectConstants.FORWARD_SLASH + DEFAULT_SERVLET_NAME;
private static final String HOST_NAME = "127.0.0.1";
private static final String LOCAL_HOTS_NAME = "localhost";
private static final String QUOTATION = ":";
private static final String PORT = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort());
static {
FILTER_SET.add(HTTP + HOST_NAME + QUOTATION + PORT + PATH);
FILTER_SET.add(HTTPS + HOST_NAME + QUOTATION + PORT + PATH);
FILTER_SET.add(HTTP + LOCAL_HOTS_NAME + QUOTATION + PORT + PATH);
FILTER_SET.add(HTTPS + LOCAL_HOTS_NAME + QUOTATION + PORT + PATH);
}
private String name; private String name;
private String remindTime; private String remindTime;
@ -109,6 +132,10 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
@Override @Override
public boolean checkValid() { public boolean checkValid() {
boolean result = false; boolean result = false;
if (FILTER_SET.contains(connection.getUrl())) {
FineLoggerFactory.getLogger().error("url is same with local designer");
return result;
}
try { try {
result = WorkContext.getConnector().testConnection(connection); result = WorkContext.getConnector().testConnection(connection);
} catch (Exception e) { } catch (Exception e) {

25
designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java vendored

@ -0,0 +1,25 @@
package com.fr.design.env;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/7/15
*/
public class RemoteDesignerWorkspaceInfoTest extends TestCase {
public void testCheckValid() {
RemoteDesignerWorkspaceInfo workspaceInfo0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://localhost:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo3 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://localhost:8075/webroot/decision", "admin", "123", "", "", true));
Assert.assertFalse(workspaceInfo0.checkValid());
Assert.assertFalse(workspaceInfo1.checkValid());
Assert.assertFalse(workspaceInfo2.checkValid());
Assert.assertFalse(workspaceInfo3.checkValid());
}
}
Loading…
Cancel
Save