fix ig loading from direct URL (#1559)
This commit is contained in:
parent
d99fbfa191
commit
5783481a26
|
@ -668,29 +668,21 @@ public class IgLoader implements IValidationEngineLoader {
|
||||||
InputStream stream = null;
|
InputStream stream = null;
|
||||||
if (explore) {
|
if (explore) {
|
||||||
stream = fetchFromUrlSpecific(Utilities.pathURL(src, "package.tgz"), true);
|
stream = fetchFromUrlSpecific(Utilities.pathURL(src, "package.tgz"), true);
|
||||||
if (stream != null)
|
if (stream != null) {
|
||||||
return loadPackage(stream, Utilities.pathURL(src, "package.tgz"), false);
|
try {
|
||||||
// todo: these options are deprecated - remove once all IGs have been rebuilt post R4 technical correction
|
return loadPackage(stream, Utilities.pathURL(src, "package.tgz"), false);
|
||||||
stream = fetchFromUrlSpecific(Utilities.pathURL(src, "igpack.zip"), true);
|
} catch (Exception e) {
|
||||||
if (stream != null)
|
// nothing
|
||||||
return readZip(stream);
|
}
|
||||||
stream = fetchFromUrlSpecific(Utilities.pathURL(src, "validator.pack"), true);
|
}
|
||||||
if (stream != null)
|
|
||||||
return readZip(stream);
|
|
||||||
stream = fetchFromUrlSpecific(Utilities.pathURL(src, "validator.pack"), true);
|
|
||||||
//// -----
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok, having tried all that... now we'll just try to access it directly
|
// ok, having tried all that... now we'll just try to access it directly
|
||||||
byte[] cnt;
|
byte[] cnt;
|
||||||
List<String> errors = new ArrayList<>();
|
List<String> errors = new ArrayList<>();
|
||||||
if (stream != null) {
|
cnt = fetchFromUrlSpecific(src, "application/json", true, errors);
|
||||||
cnt = TextFile.streamToBytes(stream);
|
if (cnt == null) {
|
||||||
} else {
|
cnt = fetchFromUrlSpecific(src, "application/xml", true, errors);
|
||||||
cnt = fetchFromUrlSpecific(src, "application/json", true, errors);
|
|
||||||
if (cnt == null) {
|
|
||||||
cnt = fetchFromUrlSpecific(src, "application/xml", true, errors);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (cnt == null) {
|
if (cnt == null) {
|
||||||
throw new FHIRException("Unable to fetch content from " + src + " (" + errors.toString() + ")");
|
throw new FHIRException("Unable to fetch content from " + src + " (" + errors.toString() + ")");
|
||||||
|
@ -740,7 +732,8 @@ public class IgLoader implements IValidationEngineLoader {
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Manager.FhirFormat checkFormat(byte[] cnt, String filename) {
|
private Manager.FhirFormat checkFormat(byte[] cnt, String filename) throws IOException {
|
||||||
|
String text = TextFile.bytesToString(cnt);
|
||||||
System.out.println(" ..Detect format for " + filename);
|
System.out.println(" ..Detect format for " + filename);
|
||||||
try {
|
try {
|
||||||
org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(cnt);
|
org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(cnt);
|
||||||
|
|
Loading…
Reference in New Issue