Merge pull request #295 from hapifhir/gg-v5022

Gg v5.0.22 work
This commit is contained in:
Grahame Grieve 2020-08-07 13:16:55 +10:00 committed by GitHub
commit 0ae7aeacc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 92 additions and 59 deletions

View File

@ -0,0 +1,7 @@
Validator:
* no changes
Other code:
* Continue to work on connection timeout issues
* Fix bug in DiagnosticReportRenderer (wrong element accessed)
* change type of resource parameter to ResourceRender.build

View File

@ -107,6 +107,7 @@ public class ClientUtils {
private String password; private String password;
private ToolingClientLogger logger; private ToolingClientLogger logger;
private int retryCount; private int retryCount;
private HttpClient httpclient;
public HttpHost getProxy() { public HttpHost getProxy() {
return proxy; return proxy;
@ -291,14 +292,11 @@ public class ClientUtils {
while (!ok) { while (!ok) {
try { try {
tryCount++; tryCount++;
HttpClient httpclient = new DefaultHttpClient(); if (httpclient == null) {
HttpParams params = httpclient.getParams(); makeClient(proxy);
HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_CONNECT);
HttpConnectionParams.setSoTimeout(params, timeout < 1 ? this.timeout : timeout * 1000);
if(proxy != null) {
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
} }
HttpParams params = httpclient.getParams();
HttpConnectionParams.setSoTimeout(params, timeout < 1 ? this.timeout : timeout * 1000);
request.setEntity(new ByteArrayEntity(payload)); request.setEntity(new ByteArrayEntity(payload));
log(request); log(request);
response = httpclient.execute(request); response = httpclient.execute(request);
@ -313,7 +311,7 @@ public class ClientUtils {
} }
} else { } else {
if (tryCount > 1) { if (tryCount > 1) {
System.out.println("Giving up: "+ioe.getMessage()+" ("+(System.currentTimeMillis()-t)+"ms / "+Utilities.describeSize(payload.length)+" for "+message+")"); System.out.println("Giving up: "+ioe.getMessage()+" (R3 / "+(System.currentTimeMillis()-t)+"ms / "+Utilities.describeSize(payload.length)+" for "+message+")");
} }
throw new EFhirClientException("Error sending HTTP Post/Put Payload: "+ioe.getMessage(), ioe); throw new EFhirClientException("Error sending HTTP Post/Put Payload: "+ioe.getMessage(), ioe);
} }
@ -322,6 +320,18 @@ public class ClientUtils {
return response; return response;
} }
@SuppressWarnings("deprecation")
public void makeClient(HttpHost proxy) {
httpclient = new DefaultHttpClient();
HttpParams params = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_CONNECT);
HttpConnectionParams.setSoTimeout(params, timeout);
HttpConnectionParams.setSoKeepalive(params, true);
if(proxy != null) {
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
}
/** /**
* *
* @param request * @param request
@ -331,13 +341,8 @@ public class ClientUtils {
protected HttpResponse sendRequest(HttpUriRequest request) { protected HttpResponse sendRequest(HttpUriRequest request) {
HttpResponse response = null; HttpResponse response = null;
try { try {
HttpClient httpclient = new DefaultHttpClient(); if (httpclient == null) {
log(request); makeClient(proxy);
HttpParams params = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(params, timeout);
HttpConnectionParams.setSoTimeout(params, timeout);
if(proxy != null) {
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
} }
response = httpclient.execute(request); response = httpclient.execute(request);
} catch(IOException ioe) { } catch(IOException ioe) {
@ -582,7 +587,9 @@ public class ClientUtils {
HttpResponse response = null; HttpResponse response = null;
try { try {
log(request); log(request);
HttpClient httpclient = new DefaultHttpClient(); if (httpclient == null) {
makeClient(proxy);
}
request.setEntity(new ByteArrayEntity(payload)); request.setEntity(new ByteArrayEntity(payload));
response = httpclient.execute(request); response = httpclient.execute(request);
log(response); log(response);

View File

@ -107,6 +107,7 @@ public class ClientUtils {
private String password; private String password;
private ToolingClientLogger logger; private ToolingClientLogger logger;
private int retryCount; private int retryCount;
private HttpClient httpclient;
public HttpHost getProxy() { public HttpHost getProxy() {
return proxy; return proxy;
@ -291,14 +292,11 @@ public class ClientUtils {
while (!ok) { while (!ok) {
try { try {
tryCount++; tryCount++;
HttpClient httpclient = new DefaultHttpClient(); if (httpclient == null) {
HttpParams params = httpclient.getParams(); makeClient(proxy);
HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_CONNECT);
HttpConnectionParams.setSoTimeout(params, timeout < 1 ? this.timeout : timeout * 1000);
if(proxy != null) {
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
} }
HttpParams params = httpclient.getParams();
HttpConnectionParams.setSoTimeout(params, timeout < 1 ? this.timeout : timeout * 1000);
request.setEntity(new ByteArrayEntity(payload)); request.setEntity(new ByteArrayEntity(payload));
log(request); log(request);
response = httpclient.execute(request); response = httpclient.execute(request);
@ -313,7 +311,7 @@ public class ClientUtils {
} }
} else { } else {
if (tryCount > 1) { if (tryCount > 1) {
System.out.println("Giving up: "+ioe.getMessage()+" ("+(System.currentTimeMillis()-t)+"ms / "+Utilities.describeSize(payload.length)+" for "+message+")"); System.out.println("Giving up: "+ioe.getMessage()+" (R4 / "+(System.currentTimeMillis()-t)+"ms / "+Utilities.describeSize(payload.length)+" for "+message+")");
} }
throw new EFhirClientException("Error sending HTTP Post/Put Payload: "+ioe.getMessage(), ioe); throw new EFhirClientException("Error sending HTTP Post/Put Payload: "+ioe.getMessage(), ioe);
} }
@ -322,6 +320,18 @@ public class ClientUtils {
return response; return response;
} }
@SuppressWarnings("deprecation")
public void makeClient(HttpHost proxy) {
httpclient = new DefaultHttpClient();
HttpParams params = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_CONNECT);
HttpConnectionParams.setSoTimeout(params, timeout);
HttpConnectionParams.setSoKeepalive(params, true);
if(proxy != null) {
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
}
/** /**
* *
* @param request * @param request
@ -331,13 +341,8 @@ public class ClientUtils {
protected HttpResponse sendRequest(HttpUriRequest request) { protected HttpResponse sendRequest(HttpUriRequest request) {
HttpResponse response = null; HttpResponse response = null;
try { try {
HttpClient httpclient = new DefaultHttpClient(); if (httpclient == null) {
log(request); makeClient(proxy);
HttpParams params = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(params, timeout);
HttpConnectionParams.setSoTimeout(params, timeout);
if(proxy != null) {
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
} }
response = httpclient.execute(request); response = httpclient.execute(request);
} catch(IOException ioe) { } catch(IOException ioe) {
@ -583,7 +588,9 @@ public class ClientUtils {
HttpResponse response = null; HttpResponse response = null;
try { try {
log(request); log(request);
HttpClient httpclient = new DefaultHttpClient(); if (httpclient == null) {
makeClient(proxy);
}
request.setEntity(new ByteArrayEntity(payload)); request.setEntity(new ByteArrayEntity(payload));
response = httpclient.execute(request); response = httpclient.execute(request);
log(response); log(response);

View File

@ -570,8 +570,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
CacheToken cacheToken = txCache.generateExpandToken(vs, hierarchical); CacheToken cacheToken = txCache.generateExpandToken(vs, hierarchical);
ValueSetExpansionOutcome res; ValueSetExpansionOutcome res;
res = txCache.getExpansion(cacheToken); res = txCache.getExpansion(cacheToken);
if (res != null) if (res != null) {
return res; return res;
}
Parameters p = expParameters.copy(); Parameters p = expParameters.copy();
p.setParameter("includeDefinition", false); p.setParameter("includeDefinition", false);
p.setParameter("excludeNested", !hierarchical); p.setParameter("excludeNested", !hierarchical);

View File

@ -79,7 +79,7 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
if (dr.has("issued")) { if (dr.has("issued")) {
tr = tbl.tr(); tr = tbl.tr();
tr.td().tx("Reported"); tr.td().tx("Reported");
eff = (DataType) getProperty(dr, "effective[x]").value().getBase(); eff = (DataType) getProperty(dr, "issued").value().getBase();
render(tr.td(), getProperty(dr, "issued").value()); render(tr.td(), getProperty(dr, "issued").value());
} }

View File

@ -50,7 +50,7 @@ public abstract class ResourceRenderer extends DataRenderer {
this.rcontext = rcontext; this.rcontext = rcontext;
} }
public XhtmlNode build(DomainResource dr) throws FHIRFormatError, DefinitionException, FHIRException, IOException, EOperationOutcome { public XhtmlNode build(Resource dr) throws FHIRFormatError, DefinitionException, FHIRException, IOException, EOperationOutcome {
XhtmlNode x = new XhtmlNode(NodeType.Element, "div"); XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
render(x, dr); render(x, dr);
return x; return x;

View File

@ -144,7 +144,7 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
throw new FHIRException(warningMessage); throw new FHIRException(warningMessage);
} }
if (cs!=null && cs.getContent() == CodeSystemContentMode.COMPLETE) { if (cs!=null && (cs.getContent() == CodeSystemContentMode.COMPLETE || cs.getContent() == CodeSystemContentMode.FRAGMENT)) {
res = validateCode(code, cs); res = validateCode(code, cs);
} else { } else {
// it's in the expansion, but we could find it in a code system // it's in the expansion, but we could find it in a code system

View File

@ -72,19 +72,22 @@ public class ResourceUtilities {
} }
public static String getErrorDescription(OperationOutcome error) { public static String getErrorDescription(OperationOutcome error) {
if (error.hasText() && error.getText().hasDiv()) if (error.hasText() && error.getText().hasDiv()) {
return new XhtmlComposer(XhtmlComposer.XML).composePlainText(error.getText().getDiv()); return new XhtmlComposer(XhtmlComposer.XML).composePlainText(error.getText().getDiv());
}
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
for (OperationOutcomeIssueComponent t : error.getIssue()) for (OperationOutcomeIssueComponent t : error.getIssue()) {
if (t.getSeverity() == IssueSeverity.ERROR) if (t.getSeverity() == IssueSeverity.ERROR) {
b.append("Error:" +t.getDetails()+"\r\n"); b.append("Error:" +t.getDetails()+"\r\n");
else if (t.getSeverity() == IssueSeverity.FATAL) } else if (t.getSeverity() == IssueSeverity.FATAL) {
b.append("Fatal:" +t.getDetails()+"\r\n"); b.append("Fatal:" +t.getDetails()+"\r\n");
else if (t.getSeverity() == IssueSeverity.WARNING) } else if (t.getSeverity() == IssueSeverity.WARNING) {
b.append("Warning:" +t.getDetails()+"\r\n"); b.append("Warning:" +t.getDetails()+"\r\n");
else if (t.getSeverity() == IssueSeverity.INFORMATION) } else if (t.getSeverity() == IssueSeverity.INFORMATION) {
b.append("Information:" +t.getDetails()+"\r\n"); b.append("Information:" +t.getDetails()+"\r\n");
}
}
return b.toString(); return b.toString();
} }

View File

@ -107,6 +107,7 @@ public class ClientUtils {
private String password; private String password;
private ToolingClientLogger logger; private ToolingClientLogger logger;
private int retryCount; private int retryCount;
private HttpClient httpclient;
public HttpHost getProxy() { public HttpHost getProxy() {
return proxy; return proxy;
@ -291,14 +292,11 @@ public class ClientUtils {
while (!ok) { while (!ok) {
try { try {
tryCount++; tryCount++;
HttpClient httpclient = new DefaultHttpClient(); if (httpclient == null) {
HttpParams params = httpclient.getParams(); makeClient(proxy);
HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_CONNECT);
HttpConnectionParams.setSoTimeout(params, timeout < 1 ? this.timeout : timeout * 1000);
if(proxy != null) {
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
} }
HttpParams params = httpclient.getParams();
HttpConnectionParams.setSoTimeout(params, timeout < 1 ? this.timeout : timeout * 1000);
request.setEntity(new ByteArrayEntity(payload)); request.setEntity(new ByteArrayEntity(payload));
log(request); log(request);
response = httpclient.execute(request); response = httpclient.execute(request);
@ -313,7 +311,7 @@ public class ClientUtils {
} }
} else { } else {
if (tryCount > 1) { if (tryCount > 1) {
System.out.println("Giving up: "+ioe.getMessage()+" ("+(System.currentTimeMillis()-t)+"ms / "+Utilities.describeSize(payload.length)+" for "+message+")"); System.out.println("Giving up: "+ioe.getMessage()+" (R5 / "+(System.currentTimeMillis()-t)+"ms / "+Utilities.describeSize(payload.length)+" for "+message+")");
} }
throw new EFhirClientException("Error sending HTTP Post/Put Payload: "+ioe.getMessage(), ioe); throw new EFhirClientException("Error sending HTTP Post/Put Payload: "+ioe.getMessage(), ioe);
} }
@ -322,6 +320,18 @@ public class ClientUtils {
return response; return response;
} }
@SuppressWarnings("deprecation")
public void makeClient(HttpHost proxy) {
httpclient = new DefaultHttpClient();
HttpParams params = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_CONNECT);
HttpConnectionParams.setSoTimeout(params, timeout);
HttpConnectionParams.setSoKeepalive(params, true);
if(proxy != null) {
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
}
/** /**
* *
* @param request * @param request
@ -331,13 +341,8 @@ public class ClientUtils {
protected HttpResponse sendRequest(HttpUriRequest request) { protected HttpResponse sendRequest(HttpUriRequest request) {
HttpResponse response = null; HttpResponse response = null;
try { try {
HttpClient httpclient = new DefaultHttpClient(); if (httpclient == null) {
log(request); makeClient(proxy);
HttpParams params = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(params, timeout);
HttpConnectionParams.setSoTimeout(params, timeout);
if(proxy != null) {
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
} }
response = httpclient.execute(request); response = httpclient.execute(request);
} catch(IOException ioe) { } catch(IOException ioe) {
@ -583,7 +588,9 @@ public class ClientUtils {
HttpResponse response = null; HttpResponse response = null;
try { try {
log(request); log(request);
HttpClient httpclient = new DefaultHttpClient(); if (httpclient == null) {
makeClient(proxy);
}
request.setEntity(new ByteArrayEntity(payload)); request.setEntity(new ByteArrayEntity(payload));
response = httpclient.execute(request); response = httpclient.execute(request);
log(response); log(response);

View File

@ -728,8 +728,9 @@ public class FHIRToolingClient {
List<Header> headers = null; List<Header> headers = null;
Parameters p = expParams == null ? new Parameters() : expParams.copy(); Parameters p = expParams == null ? new Parameters() : expParams.copy();
p.addParameter().setName("valueSet").setResource(source); p.addParameter().setName("valueSet").setResource(source);
for (String n : params.keySet()) for (String n : params.keySet()) {
p.addParameter().setName(n).setValue(new StringType(params.get(n))); p.addParameter().setName(n).setValue(new StringType(params.get(n)));
}
ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params), ResourceRequest<Resource> result = utils.issuePostRequest(resourceAddress.resolveOperationUri(ValueSet.class, "expand", params),
utils.getResourceAsByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, "ValueSet/$expand?url="+source.getUrl(), TIMEOUT_OPERATION_EXPAND); utils.getResourceAsByteArray(p, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(), headers, "ValueSet/$expand?url="+source.getUrl(), TIMEOUT_OPERATION_EXPAND);
result.addErrorStatus(410);//gone result.addErrorStatus(410);//gone