Browse Source

Merge pull request #10307 in DESIGN/design from bugfix/11.0 to feature/x

* commit 'e93c6277ffdc14b86a673243ea8d9cc0b7cb64ad':
  REPORT-81416 导入正确的包
  REPORT-81270 远程连接配置界面处理IPV6格式的url--忽略异常+单元测试
  REPORT-81270 远程连接配置界面处理IPV6格式的url--代码调整
  REPORT-81270 远程连接配置界面处理IPV6格式的url--代码调整
  REPORT-81270 远程连接配置界面处理IPV6格式的url
  REPORT-81270 远程连接配置界面处理IPV6格式的url
  REPORT-81270 远程连接配置界面处理IPV6格式的url
  REPORT-81270 远程连接配置界面处理IPV6格式的url
feature/x
superman 2 years ago
parent
commit
c8b395f174
  1. 30
      designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java
  2. 10
      designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java

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

@ -1,13 +1,20 @@
package com.fr.env; package com.fr.env;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.FCloneable; import com.fr.stable.FCloneable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.net.URI;
import java.net.URISyntaxException;
import com.fr.third.guava.base.Strings;
/** /**
* @author yaohwu * @author yaohwu
*/ */
public class RemoteWorkspaceURL implements FCloneable { public class RemoteWorkspaceURL implements FCloneable {
private static final String IPV6_JUDGE_SYMBOL = "[";
private static final String IPV6_JUDGE_SYMBOL2 = "]";
public static final String SYSTEM_LOGIN_PATH = "#management/system/login"; public static final String SYSTEM_LOGIN_PATH = "#management/system/login";
@ -98,6 +105,8 @@ public class RemoteWorkspaceURL implements FCloneable {
parserWebAndServlet(lefts); parserWebAndServlet(lefts);
} }
} }
//判断一下IPV6
this.refreshIPV6Format();
} }
public boolean hasDefaultHostName() { public boolean hasDefaultHostName() {
@ -129,6 +138,27 @@ public class RemoteWorkspaceURL implements FCloneable {
return this.url; return this.url;
} }
/**
* IPV6地址格式不同,处理字符串的方式不同,需要处理的是port和host
* 形如 http://[XXXX::XXXX:XXXX:XXXX:XXXX]:8080/webroot/decision
*/
public void refreshIPV6Format() {
String url = this.url;
if (Strings.isNullOrEmpty(url)) {
return;
}
if (!url.contains(IPV6_JUDGE_SYMBOL) || !url.contains(IPV6_JUDGE_SYMBOL2)) {
return;
}
URI uri = null;
try {
uri = new URI(url);
this.host = uri.getHost();
this.port = String.valueOf(uri.getPort());
} catch (URISyntaxException ignored) {
}
}
public void setHttps(boolean https) { public void setHttps(boolean https) {
isHttps = https; isHttps = https;

10
designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java vendored

@ -242,4 +242,14 @@ public class RemoteWorkspaceURLTest {
assertEquals("servlet", b.getServlet()); assertEquals("servlet", b.getServlet());
//others begin //others begin
} }
@Test
public void testIPV6Url() {
String trueUrl = "http://[fe80::4d83:cc10:9f6f:3303]:8080/webroot/decision";
RemoteWorkspaceURL remoteWorkspaceURL1 = new RemoteWorkspaceURL(trueUrl);
assertEquals("[fe80::4d83:cc10:9f6f:3303]", remoteWorkspaceURL1.getHost());
assertEquals("8080", remoteWorkspaceURL1.getPort());
assertEquals("webroot", remoteWorkspaceURL1.getWeb());
assertEquals("decision", remoteWorkspaceURL1.getServlet());
}
} }

Loading…
Cancel
Save