use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class ValidationTests method fetchRaw.
@Override
public byte[] fetchRaw(IResourceValidator validator, String source) throws MalformedURLException, IOException {
SimpleHTTPClient http = new SimpleHTTPClient();
HTTPResult res = http.get(source);
res.checkThrowException();
return res.getContent();
}
use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class PackageVisitor method processFeed.
private void processFeed(Set<String> list, String str) throws IOException, ParserConfigurationException, SAXException {
System.out.println("Feed " + str);
try {
SimpleHTTPClient fetcher = new SimpleHTTPClient();
HTTPResult res = fetcher.get(str + "?nocache=" + System.currentTimeMillis());
res.checkThrowException();
Document xml = XMLUtil.parseToDom(res.getContent());
for (Element channel : XMLUtil.getNamedChildren(xml.getDocumentElement(), "channel")) {
for (Element item : XMLUtil.getNamedChildren(channel, "item")) {
String pid = XMLUtil.getNamedChildText(item, "title");
if (pid.contains("#")) {
list.add(pid.substring(0, pid.indexOf("#")));
}
}
}
} catch (Exception e) {
System.out.println(" " + e.getMessage());
}
}
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 FilesystemPackageCacheManager method fetchFromUrlSpecific.
private InputStream fetchFromUrlSpecific(String source, boolean optional) throws FHIRException {
try {
SimpleHTTPClient http = new SimpleHTTPClient();
HTTPResult res = http.get(source);
res.checkThrowException();
return new ByteArrayInputStream(res.getContent());
} catch (Exception e) {
if (optional)
return null;
else
throw new FHIRException("Unable to fetch: " + e.getMessage(), e);
}
}
use of org.hl7.fhir.utilities.SimpleHTTPClient in project org.hl7.fhir.core by hapifhir.
the class IgLoader method fetchFromUrlSpecific.
private byte[] fetchFromUrlSpecific(String source, String contentType, boolean optional, List<String> errors) throws FHIRException, IOException {
try {
SimpleHTTPClient http = new SimpleHTTPClient();
try {
// try with cache-busting option and then try withhout in case the server doesn't support that
HTTPResult res = http.get(source + "?nocache=" + System.currentTimeMillis(), contentType);
res.checkThrowException();
return res.getContent();
} catch (Exception e) {
HTTPResult res = http.get(source, contentType);
res.checkThrowException();
return res.getContent();
}
} catch (IOException e) {
if (errors != null) {
errors.add("Error accessing " + source + ": " + e.getMessage());
}
if (optional)
return null;
else
throw e;
}
}
Aggregations