Accept-Language

This commit is contained in:
Grahame Grieve 2023-08-25 16:21:56 +02:00
parent 7eaa723ec9
commit 333ffc340e
11 changed files with 73 additions and 4 deletions

View File

@ -204,4 +204,10 @@ public class TerminologyClientR2 implements ITerminologyClient {
public String getServerVersion() {
return client.getServerVersion();
}
@Override
public ITerminologyClient setLanguage(String lang) {
client.setLanguage(lang);
return this;
}
}

View File

@ -206,4 +206,10 @@ public class TerminologyClientR3 implements ITerminologyClient {
public String getServerVersion() {
return client.getServerVersion();
}
@Override
public ITerminologyClient setLanguage(String lang) {
client.setLanguage(lang);
return this;
}
}

View File

@ -214,4 +214,10 @@ public class TerminologyClientR4 implements ITerminologyClient {
public String getServerVersion() {
return client.getServerVersion();
}
@Override
public ITerminologyClient setLanguage(String lang) {
client.setLanguage(lang);
return this;
}
}

View File

@ -194,4 +194,10 @@ public class TerminologyClientR5 implements ITerminologyClient {
public String getServerVersion() {
return client.getServerVersion();
}
@Override
public ITerminologyClient setLanguage(String lang) {
client.setLanguage(lang);
return this;
}
}

View File

@ -105,6 +105,7 @@ public class ClientUtils {
private ToolingClientLogger logger;
private int retryCount;
private String userAgent;
private String acceptLang;
public HttpHost getProxy() {
return proxy;
@ -294,6 +295,9 @@ public class ClientUtils {
if (!Utilities.noString(userAgent)) {
request.addHeader("User-Agent", userAgent);
}
if (!Utilities.noString(acceptLang)) {
request.addHeader("Accept-Language", acceptLang);
}
if (format != null) {
request.addHeader("Accept", format);
@ -722,4 +726,7 @@ public class ClientUtils {
this.userAgent = userAgent;
}
public void setLanguage(String language) {
this.acceptLang = language;
}
}

View File

@ -895,4 +895,8 @@ public class FHIRToolingClient {
public String getServerVersion() {
return conf == null ? null : conf.getSoftware().getVersion();
}
public void setLanguage(String lang) {
utils.setLanguage(lang);
}
}

View File

@ -82,6 +82,7 @@ public class FHIRToolingClient {
private String password;
private String userAgent;
private EnumSet<FhirPublication> allowedVersions;
private String acceptLang;
//Pass endpoint for client - URI
public FHIRToolingClient(String baseServiceUrl, String userAgent) throws URISyntaxException {
@ -593,6 +594,9 @@ public class FHIRToolingClient {
}
if (!Utilities.noString(userAgent)) {
builder.add("User-Agent: "+userAgent);
}
if (!Utilities.noString(acceptLang)) {
builder.add("Accept-Language: "+acceptLang);
}
return builder.build();
}
@ -619,5 +623,9 @@ public class FHIRToolingClient {
checkCapabilities();
return capabilities == null ? null : capabilities.getSoftware().getVersion();
}
public void setLanguage(String lang) {
this.acceptLang = lang;
}
}

View File

@ -83,6 +83,7 @@ public class FHIRToolingClient {
private String username;
private String password;
private String userAgent;
private String acceptLang;
// Pass endpoint for client - URI
public FHIRToolingClient(String baseServiceUrl, String userAgent) throws URISyntaxException {
@ -554,6 +555,11 @@ public class FHIRToolingClient {
if (!Utilities.noString(userAgent)) {
builder.add("User-Agent: " + userAgent);
}
if (!Utilities.noString(acceptLang)) {
builder.add("Accept-Language: "+acceptLang);
}
return builder.build();
}
@ -579,4 +585,8 @@ public class FHIRToolingClient {
checkCapabilities();
return capabilities == null ? null : capabilities.getSoftware().getVersion();
}
public void setLanguage(String lang) {
this.acceptLang = lang;
}
}

View File

@ -65,4 +65,5 @@ public interface ITerminologyClient {
ClientHeaders getClientHeaders();
ITerminologyClient setClientHeaders(ClientHeaders clientHeaders);
ITerminologyClient setUserAgent(String userAgent);
ITerminologyClient setLanguage(String lang);
}

View File

@ -103,6 +103,9 @@ public class FHIRToolingClient {
private String password;
private String userAgent;
private String acceptLang;
//Pass endpoint for client - URI
public FHIRToolingClient(String baseServiceUrl, String userAgent) throws URISyntaxException {
preferredResourceFormat = ResourceFormat.RESOURCE_JSON;
@ -584,6 +587,11 @@ public class FHIRToolingClient {
if (!Utilities.noString(userAgent)) {
builder.add("User-Agent: "+userAgent);
}
if (!Utilities.noString(acceptLang)) {
builder.add("Accept-Language: "+acceptLang);
}
return builder.build();
}
@ -615,6 +623,10 @@ public class FHIRToolingClient {
}
return capabilities == null ? null : capabilities.getSoftware().getVersion();
}
public void setLanguage(String lang) {
this.acceptLang = lang;
}
}

View File

@ -190,11 +190,12 @@ public class TxTester {
}
JsonObject ext = externals == null ? null : externals.getJsonObject(fn);
String lang = test.asString("Accept-Language");
String msg = null;
if (test.asString("operation").equals("expand")) {
msg = expand(tx, setup, req, resp, fp, profile, ext);
msg = expand(tx, setup, req, resp, fp, lang, profile, ext);
} else if (test.asString("operation").equals("validate-code")) {
msg = validate(tx, setup, req, resp, fp, profile, ext);
msg = validate(tx, setup, req, resp, fp, lang, profile, ext);
} else {
throw new Exception("Unknown Operation "+test.asString("operation"));
}
@ -243,10 +244,11 @@ public class TxTester {
return new URI(server).getHost();
}
private String expand(ITerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp, Parameters profile, JsonObject ext) throws IOException {
private String expand(ITerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp, String lang, Parameters profile, JsonObject ext) throws IOException {
for (Resource r : setup) {
p.addParameter().setName("tx-resource").setResource(r);
}
tx.setLanguage(lang);
p.getParameter().addAll(profile.getParameter());
String vsj;
try {
@ -267,11 +269,12 @@ public class TxTester {
return diff;
}
private String validate(ITerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp, Parameters profile, JsonObject ext) throws IOException {
private String validate(ITerminologyClient tx, List<Resource> setup, Parameters p, String resp, String fp, String lang, Parameters profile, JsonObject ext) throws IOException {
for (Resource r : setup) {
p.addParameter().setName("tx-resource").setResource(r);
}
p.getParameter().addAll(profile.getParameter());
tx.setLanguage(lang);
String pj;
try {
Parameters po = tx.validateVS(p);