Search in sources :

Example 11 with HTTPResult

use of org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult 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()));
}
Also used : HTTPResult(org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult) SimpleHTTPClient(org.hl7.fhir.utilities.SimpleHTTPClient) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 12 with HTTPResult

use of org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult 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());
}
Also used : HTTPResult(org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult) SimpleHTTPClient(org.hl7.fhir.utilities.SimpleHTTPClient) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 13 with HTTPResult

use of org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult in project org.hl7.fhir.core by hapifhir.

the class ICD11Generator method fetchJson.

private JsonObject fetchJson(String source) throws IOException {
    SimpleHTTPClient http = new SimpleHTTPClient();
    http.addHeader("API-Version", "v2");
    http.addHeader("Accept-Language", "en");
    HTTPResult res = http.get(source, "application/json");
    res.checkThrowException();
    return JsonTrackingParser.parseJson(res.getContent());
}
Also used : HTTPResult(org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult) SimpleHTTPClient(org.hl7.fhir.utilities.SimpleHTTPClient)

Example 14 with HTTPResult

use of org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult in project org.hl7.fhir.core by hapifhir.

the class CKMImporter method loadXml.

private Document loadXml(String address) throws Exception {
    SimpleHTTPClient http = new SimpleHTTPClient();
    HTTPResult res = http.get(address, "application/xml");
    res.checkThrowException();
    InputStream xml = new ByteArrayInputStream(res.getContent());
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    return db.parse(xml);
}
Also used : HTTPResult(org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) SimpleHTTPClient(org.hl7.fhir.utilities.SimpleHTTPClient) ByteArrayInputStream(java.io.ByteArrayInputStream) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream)

Example 15 with HTTPResult

use of org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult in project org.hl7.fhir.core by hapifhir.

the class ValidationEngine method fetchRaw.

@Override
public byte[] fetchRaw(IResourceValidator validator, String source) throws IOException {
    SimpleHTTPClient http = new SimpleHTTPClient();
    HTTPResult res = http.get(source);
    res.checkThrowException();
    return res.getContent();
}
Also used : HTTPResult(org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult)

Aggregations

HTTPResult (org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult)23 SimpleHTTPClient (org.hl7.fhir.utilities.SimpleHTTPClient)17 ByteArrayInputStream (java.io.ByteArrayInputStream)6 IOException (java.io.IOException)6 FHIRException (org.hl7.fhir.exceptions.FHIRException)4 HttpURLConnection (java.net.HttpURLConnection)3 URL (java.net.URL)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 MalformedURLException (java.net.MalformedURLException)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TextFile (org.hl7.fhir.utilities.TextFile)1