diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 9b97c43599..1e80ae9ec4 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -643,6 +643,7 @@ public class RemoteEnvPane extends BasicBeanPane { remoteWorkspaceURL.setPort(port); remoteWorkspaceURL.setWeb(web); remoteWorkspaceURL.setServlet(servlet); + remoteWorkspaceURL.resetUrl(); } 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 f7f5e6aeeb..06e38a5cc8 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java +++ b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java @@ -1,10 +1,9 @@ package com.fr.env; +import com.fr.stable.AssistUtils; import com.fr.stable.FCloneable; import com.fr.stable.StringUtils; -import java.util.Objects; - /** * @author yaohwu */ @@ -42,6 +41,7 @@ public class RemoteWorkspaceURL implements FCloneable { private String port; private String web; private String servlet; + private String url; /** @@ -51,7 +51,7 @@ public class RemoteWorkspaceURL implements FCloneable { * @param url x:x/x/x/x */ public RemoteWorkspaceURL(String url) { - + this.url = url; // 没有写协议名称 默认 使用 http 协议 if (!url.startsWith(HTTPS) && !url.startsWith(HTTP)) { url = HTTP + url; @@ -116,11 +116,15 @@ public class RemoteWorkspaceURL implements FCloneable { } public String getURL() { + if (this.url != null) { + return url; + } 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; - return prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash + servlet; + this.url = prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash + servlet; + return this.url; } @@ -164,26 +168,24 @@ public class RemoteWorkspaceURL implements FCloneable { return servlet; } + public void resetUrl() { + this.url = null; + } + @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RemoteWorkspaceURL that = (RemoteWorkspaceURL) o; - return isHttps == that.isHttps && - Objects.equals(host, that.host) && - Objects.equals(port, that.port) && - Objects.equals(web, that.web) && - Objects.equals(servlet, that.servlet); + return o instanceof RemoteWorkspaceURL && AssistUtils.equals(isHttps, ((RemoteWorkspaceURL) o).isHttps) + && AssistUtils.equals(host, ((RemoteWorkspaceURL) o).host) + && AssistUtils.equals(port, ((RemoteWorkspaceURL) o).port) + && AssistUtils.equals(web, ((RemoteWorkspaceURL) o).web) + && AssistUtils.equals(servlet, ((RemoteWorkspaceURL) o).servlet) + && AssistUtils.equals(url, ((RemoteWorkspaceURL) o).url); } @Override public int hashCode() { - return Objects.hash(isHttps, host, port, web, servlet); + return AssistUtils.hashCode(isHttps, host, port, web, servlet, url); } @Override diff --git a/designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java b/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java similarity index 81% rename from designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java rename to designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java index 2c6a0ab39a..731093c153 100644 --- a/designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java +++ b/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java @@ -8,7 +8,40 @@ import static org.junit.Assert.assertEquals; /** * @author yaohwu */ -public class RemoteEnvURLTest { +public class RemoteWorkspaceURLTest { + + + @Test + public void testUrlReset() { + + String a = "https://yaohwu:8080/webroot/app/c/d"; + RemoteWorkspaceURL workspaceURL = new RemoteWorkspaceURL(a); + Assert.assertEquals(a, workspaceURL.getURL()); + Assert.assertEquals("app", workspaceURL.getServlet()); + Assert.assertEquals("webroot", workspaceURL.getWeb()); + Assert.assertEquals("yaohwu", workspaceURL.getHost()); + Assert.assertEquals("8080", workspaceURL.getPort()); + Assert.assertTrue(workspaceURL.getHttps()); + + workspaceURL.setHttps(false); + workspaceURL.setHost("finereport"); + + Assert.assertEquals(a, workspaceURL.getURL()); + Assert.assertEquals("app", workspaceURL.getServlet()); + Assert.assertEquals("webroot", workspaceURL.getWeb()); + Assert.assertEquals("finereport", workspaceURL.getHost()); + Assert.assertEquals("8080", workspaceURL.getPort()); + Assert.assertFalse(workspaceURL.getHttps()); + + workspaceURL.resetUrl(); + + Assert.assertEquals("http://finereport:8080/webroot/app", workspaceURL.getURL()); + Assert.assertEquals("app", workspaceURL.getServlet()); + Assert.assertEquals("webroot", workspaceURL.getWeb()); + Assert.assertEquals("finereport", workspaceURL.getHost()); + Assert.assertEquals("8080", workspaceURL.getPort()); + Assert.assertFalse(workspaceURL.getHttps()); + } @Test public void testURLParser() {