use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method cachedFetch.
private String cachedFetch(String id, String source) throws IOException {
String tmpDir = System.getProperty("java.io.tmpdir");
String local = Utilities.path(tmpDir, id);
File f = new File(local);
if (f.exists())
return TextFile.fileToString(f);
SimpleHTTPClient http = new SimpleHTTPClient();
HTTPResult res = http.get(source);
res.checkThrowException();
String result = TextFile.bytesToString(res.getContent());
TextFile.stringToFile(result, f);
return result;
}
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 FilesystemPackageCacheManager method loadFromBuildServer.
private void loadFromBuildServer() throws IOException {
SimpleHTTPClient http = new SimpleHTTPClient();
http.trustAllhosts();
HTTPResult res = http.get("https://build.fhir.org/ig/qas.json?nocache=" + System.currentTimeMillis());
res.checkThrowException();
buildInfo = (JsonArray) new com.google.gson.JsonParser().parse(TextFile.bytesToString(res.getContent()));
List<BuildRecord> builds = new ArrayList<>();
for (JsonElement n : buildInfo) {
JsonObject o = (JsonObject) n;
if (o.has("url") && o.has("package-id") && o.get("package-id").getAsString().contains(".")) {
String u = o.get("url").getAsString();
if (u.contains("/ImplementationGuide/"))
u = u.substring(0, u.indexOf("/ImplementationGuide/"));
builds.add(new BuildRecord(u, o.get("package-id").getAsString(), getRepo(o.get("repo").getAsString()), readDate(o.get("date").getAsString())));
}
}
Collections.sort(builds, new BuildRecordSorter());
for (BuildRecord bld : builds) {
if (!ciList.containsKey(bld.getPackageId())) {
ciList.put(bld.getPackageId(), "https://build.fhir.org/ig/" + bld.getRepo());
}
}
// whether it succeeds or not
buildLoaded = true;
}
use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class NpmPackage method fromUrl.
public static NpmPackage fromUrl(String source) throws IOException {
SimpleHTTPClient fetcher = new SimpleHTTPClient();
HTTPResult res = fetcher.get(source + "?nocache=" + System.currentTimeMillis());
res.checkThrowException();
return fromPackage(new ByteArrayInputStream(res.getContent()));
}
use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class PackageClient method fetchUrl.
private InputStream fetchUrl(String source, String accept) throws IOException {
SimpleHTTPClient http = new SimpleHTTPClient();
HTTPResult res = http.get(source, accept);
res.checkThrowException();
return new ByteArrayInputStream(res.getContent());
}
Aggregations