fix missing port from server when doing tx-registry redirections

This commit is contained in:
Grahame Grieve 2024-11-27 04:44:19 +00:00
parent 4be38a5e0c
commit 17b22424f6
1 changed files with 13 additions and 4 deletions

View File

@ -320,15 +320,24 @@ public class TerminologyClientManager {
serverList = decideWhichServer(s); serverList = decideWhichServer(s);
// testing support // testing support
try { try {
serverList.replace("tx.fhir.org", new URL(getMasterClient().getAddress()).getHost()); serverList.replace("tx.fhir.org", host());
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
} }
resMap.put(s, serverList); // resMap.put(s, serverList);
save(); save();
} }
return serverList; return serverList;
} }
private String host() throws MalformedURLException {
URL url = new URL(getMasterClient().getAddress());
if (url.getPort() != 0) {
return url.getHost()+":"+url.getPort();
} else {
return url.getHost();
}
}
private ServerOptionList decideWhichServer(String url) { private ServerOptionList decideWhichServer(String url) {
if (IGNORE_TX_REGISTRY || !useEcosystem) { if (IGNORE_TX_REGISTRY || !useEcosystem) {
return new ServerOptionList(getMasterClient().getAddress()); return new ServerOptionList(getMasterClient().getAddress());
@ -545,7 +554,7 @@ public class TerminologyClientManager {
} }
if (server.contains("://tx.fhir.org")) { if (server.contains("://tx.fhir.org")) {
try { try {
server = server.replace("tx.fhir.org", new URL(getMasterClient().getAddress()).getHost()); server = server.replace("tx.fhir.org", host());
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
} }
} }
@ -627,7 +636,7 @@ public class TerminologyClientManager {
} }
if (server.contains("://tx.fhir.org")) { if (server.contains("://tx.fhir.org")) {
try { try {
server = server.replace("tx.fhir.org", new URL(getMasterClient().getAddress()).getHost()); server = server.replace("tx.fhir.org", host());
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
} }
} }