fix problems fetching packages

This commit is contained in:
Grahame Grieve 2020-03-31 10:15:49 +11:00
parent d6ee58d47a
commit 753d3bd971
4 changed files with 24 additions and 9 deletions

View File

@ -285,7 +285,12 @@ public class NpmPackage {
}
public void readStream(InputStream tgz, String desc, boolean progress) throws IOException {
GzipCompressorInputStream gzipIn = new GzipCompressorInputStream(tgz);
GzipCompressorInputStream gzipIn;
try {
gzipIn = new GzipCompressorInputStream(tgz);
} catch (Exception e) {
throw new IOException("Error reading "+(desc == null ? "package" : desc)+": "+e.getMessage(), e);
}
try (TarArchiveInputStream tarIn = new TarArchiveInputStream(gzipIn)) {
TarArchiveEntry entry;

View File

@ -317,12 +317,14 @@ public class PackageCacheManager {
private InputStreamWithSrc loadFromPackageServer(String id, String v) {
PackageClient pc = new PackageClient(PRIMARY_SERVER);
String u = null;
InputStream stream;
try {
if (Utilities.noString(v)) {
v = pc.getLatestVersion(id);
}
stream = pc.fetch(id, v);
u = pc.url(id, v);
} catch (IOException e) {
pc = new PackageClient(SECONDARY_SERVER);
try {
@ -330,12 +332,10 @@ public class PackageCacheManager {
v = pc.getLatestVersion(id);
}
stream = pc.fetch(id, v);
u = pc.url(id, v);
} catch (IOException e1) {
// ok, well, we'll try the old way
stream = fetchTheOldWay(id, v);
if (stream == null) {
throw new FHIRException("The package '"+id+"#"+v+"' is not known to the package server ('"+PRIMARY_SERVER+"')");
}
return fetchTheOldWay(id, v);
}
}
return new InputStreamWithSrc(stream, pc.url(id, v), v);
@ -769,7 +769,7 @@ public class PackageCacheManager {
}
// ----- the old way, from before package server, while everything gets onto the package server
private InputStream fetchTheOldWay(String id, String v) {
private InputStreamWithSrc fetchTheOldWay(String id, String v) {
String url = getUrlForPackage(id);
if (url == null) {
try {
@ -781,6 +781,9 @@ public class PackageCacheManager {
if (url == null) {
throw new FHIRException("Unable to resolve package id "+id);
}
if (url.contains("/ImplementationGuide/")) {
url = url.substring(0, url.indexOf("/ImplementationGuide/"));
}
String pu = Utilities.pathURL(url, "package-list.json");
String aurl = pu;
JsonObject json;
@ -790,7 +793,8 @@ public class PackageCacheManager {
String pv = Utilities.pathURL(url, v, "package.tgz");
try {
aurl = pv;
return fetchFromUrlSpecific(pv, true);
InputStreamWithSrc src = new InputStreamWithSrc(fetchFromUrlSpecific(pv, true), pv, v);
return src;
} catch (Exception e1) {
throw new FHIRException("Error fetching package directly ("+pv+"), or fetching package list for "+id+" from "+pu+": "+e1.getMessage(), e1);
}
@ -801,7 +805,8 @@ public class PackageCacheManager {
JsonObject vo = (JsonObject) e;
if (v.equals(JSONUtil.str(vo, "version"))) {
aurl = Utilities.pathURL(JSONUtil.str(vo, "path"), "package.tgz");
return fetchFromUrlSpecific(Utilities.pathURL(JSONUtil.str(vo, "path"), "package.tgz"), true);
String u = Utilities.pathURL(JSONUtil.str(vo, "path"), "package.tgz");
return new InputStreamWithSrc(fetchFromUrlSpecific(u, true), u, v);
}
}

View File

@ -66,6 +66,7 @@ public class I18nConstants {
public final static String QUESTIONNAIRE_QR_ITEM_DATENOOPTIONS = "Questionnaire_QR_Item_DateNoOptions";
public final static String QUESTIONNAIRE_QR_ITEM_DISPLAY = "Questionnaire_QR_Item_Display";
public final static String QUESTIONNAIRE_QR_ITEM_GROUP = "Questionnaire_QR_Item_Group";
public final static String QUESTIONNAIRE_QR_ITEM_GROUP_ANSWER = "Questionnaire_QR_Item_GroupAnswer";
public final static String QUESTIONNAIRE_QR_ITEM_INTNOOPTIONS = "Questionnaire_QR_Item_IntNoOptions";
public final static String QUESTIONNAIRE_QR_ITEM_MISSING = "Questionnaire_QR_Item_Missing";
public final static String QUESTIONNAIRE_QR_ITEM_NOCODING = "Questionnaire_QR_Item_NoCoding";
@ -99,6 +100,8 @@ public class I18nConstants {
public final static String QUESTIONNAIRE_Q_ENABLEWHEN_NOLINK = "Questionnaire_Q_EnableWhen_NoLink";
public final static String QUESTIONNAIRE_Q_ENABLEWHEN_NOTARGET = "Questionnaire_Q_EnableWhen_NoTarget";
public final static String QUESTIONNAIRE_Q_ENABLEWHEN_SELF = "Questionnaire_Q_EnableWhen_Self";
public final static String MEASURE_MR_M_NONE = "Measure_MR_M_None";
public final static String MEASURE_MR_M_NOTFOUND = "Measure_MR_M_NotFound";
public final static String REFERENCE_REF_AGGREGATION = "Reference_REF_Aggregation";
public final static String REFERENCE_REF_BADTARGETTYPE = "Reference_REF_BadTargetType";
public final static String REFERENCE_REF_BADTARGETTYPE2 = "Reference_REF_BadTargetType2";
@ -237,6 +240,8 @@ public class I18nConstants {
public final static String SLICE_ENCOUNTERED_MIDWAY_THROUGH_SET_PATH___ID___ = "Slice_encountered_midway_through_set_path___id___";
public final static String UNABLE_TO_RESOLVE_ACTUAL_TYPE_ = "Unable_to_resolve_actual_type_";
public final static String UNSUPPORTED_VERSION_R1 = "Unsupported_version_R1";
public final static String UNSUPPORTED_VERSION_R2 = "Unsupported_version_R2";
public final static String UNSUPPORTED_VERSION_R2B = "Unsupported_version_R2B";
public final static String UNSUPPORTED_FIXED_VALUE_TYPE_FOR_DISCRIMINATOR_FOR_SLICE__ = "Unsupported_fixed_value_type_for_discriminator_for_slice__";
public final static String UNSUPPORTED_CODEABLECONCEPT_PATTERN__EXTENSIONS_ARE_NOT_ALLOWED__FOR_DISCRIMINATOR_FOR_SLICE_ = "Unsupported_CodeableConcept_pattern__extensions_are_not_allowed__for_discriminator_for_slice_";
public final static String UNSUPPORTED_CODEABLECONCEPT_PATTERN__MUST_HAVE_AT_LEAST_ONE_CODING__FOR_DISCRIMINATOR_FOR_SLICE_ = "Unsupported_CodeableConcept_pattern__must_have_at_least_one_coding__for_discriminator_for_slice_";

View File

@ -17,7 +17,7 @@
<properties>
<hapi_fhir_version>4.2.0</hapi_fhir_version>
<validator_test_case_version>1.1.2-SNAPSHOT</validator_test_case_version>
<validator_test_case_version>1.1.3-SNAPSHOT</validator_test_case_version>
</properties>
<artifactId>org.hl7.fhir.core</artifactId>