From 753d3bd971f2733789ffb5aee849c5ff4edc79f6 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 31 Mar 2020 10:15:49 +1100 Subject: [PATCH] fix problems fetching packages --- .../hl7/fhir/utilities/cache/NpmPackage.java | 7 ++++++- .../utilities/cache/PackageCacheManager.java | 19 ++++++++++++------- .../fhir/utilities/i18n/I18nConstants.java | 5 +++++ pom.xml | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java index 2ab1a3389..e4da6c317 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java @@ -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; diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java index e7a07e052..ce1f0045d 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/PackageCacheManager.java @@ -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); } } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java index 212e9f0e2..b915ceb1a 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java @@ -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_"; diff --git a/pom.xml b/pom.xml index f218991a6..1b06bc0ba 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 4.2.0 - 1.1.2-SNAPSHOT + 1.1.3-SNAPSHOT org.hl7.fhir.core