Browse Source

REPORT-22114 远程设计配置界面优先以直接 url 地址填写的为准并尽可能保证联动

bugfix/10.0
yaoh.wu 5 years ago
parent
commit
db8e1b7e14
  1. 1
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  2. 36
      designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java
  3. 35
      designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java

1
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -643,6 +643,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
remoteWorkspaceURL.setPort(port);
remoteWorkspaceURL.setWeb(web);
remoteWorkspaceURL.setServlet(servlet);
remoteWorkspaceURL.resetUrl();
}

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

@ -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

35
designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java → designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java vendored

@ -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() {
Loading…
Cancel
Save