use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class TerminologyCacheManager method fillCache.
private void fillCache(String source) throws IOException {
try {
System.out.println("Initialise terminology cache from " + source);
SimpleHTTPClient http = new SimpleHTTPClient();
HTTPResult res = http.get(source + "?nocache=" + System.currentTimeMillis());
res.checkThrowException();
unzip(new ByteArrayInputStream(res.getContent()), cacheFolder);
} catch (Exception e) {
System.out.println("No - can't initialise cache from " + source + ": " + e.getMessage());
}
}
use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class TerminologyCacheManager method commit.
public void commit(String token) throws IOException {
// create a zip of all the files
ByteArrayOutputStream bs = new ByteArrayOutputStream();
zipDirectory(bs);
// post it to
String url = "https://tx.fhir.org/post/tx-cache/" + ghOrg + "/" + ghRepo + "/" + ghBranch + ".zip";
System.out.println("Sending tx-cache to " + url + " (" + Utilities.describeSize(bs.toByteArray().length) + ")");
SimpleHTTPClient http = new SimpleHTTPClient();
http.setUsername(token.substring(0, token.indexOf(':')));
http.setPassword(token.substring(token.indexOf(':') + 1));
// accept doesn't matter
HTTPResult res = http.put(url, "application/zip", bs.toByteArray(), null);
if (res.getCode() >= 300) {
System.out.println("sending cache failed: " + res.getCode());
} else {
System.out.println("Sent cache");
}
}
use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class IgLoader method fetchFromUrlSpecific.
private InputStream fetchFromUrlSpecific(String source, boolean optional) throws FHIRException, IOException {
try {
SimpleHTTPClient http = new SimpleHTTPClient();
HTTPResult res = http.get(source + "?nocache=" + System.currentTimeMillis());
res.checkThrowException();
return new ByteArrayInputStream(res.getContent());
} catch (IOException e) {
if (optional)
return null;
else
throw e;
}
}
use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class ProfileLoader method loadProfileFromUrl.
private static byte[] loadProfileFromUrl(String src) throws FHIRException {
try {
SimpleHTTPClient http = new SimpleHTTPClient();
HTTPResult res = http.get(src + "?nocache=" + System.currentTimeMillis());
res.checkThrowException();
return res.getContent();
} catch (Exception e) {
throw new FHIRException("Unable to find definitions at URL '" + src + "': " + e.getMessage(), e);
}
}
use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class JsonTrackingParser method fetchJson.
public static JsonObject fetchJson(String source) throws IOException {
SimpleHTTPClient fetcher = new SimpleHTTPClient();
HTTPResult res = fetcher.get(source + "?nocache=" + System.currentTimeMillis());
res.checkThrowException();
return parseJson(res.getContent());
}
Aggregations