From 6781793d98fbc2c36728773fc20923c004d4b4be Mon Sep 17 00:00:00 2001 From: Dylan Hall Date: Mon, 11 Nov 2024 12:50:31 -0500 Subject: [PATCH] FI-3387: Bump dependencies (#77) --- build.gradle.kts | 11 ++++--- .../java/org/mitre/inferno/Validator.java | 32 ++++++++++++++++--- .../java/org/mitre/inferno/ValidatorTest.java | 6 ++-- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8f49ac5..0c695ae 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,16 +15,19 @@ repositories { } dependencies { - implementation("ca.uhn.hapi.fhir", "org.hl7.fhir.validation", "6.2.8") + implementation("ca.uhn.hapi.fhir", "org.hl7.fhir.validation", "6.4.0") // validator dependency needed for terminology (why can't it get this automatically?) - implementation("com.squareup.okhttp3", "okhttp", "4.9.0") + implementation("com.squareup.okhttp3", "okhttp", "4.12.0") + + // validator dependency needed to prevent a ClassNotFoundException + implementation("org.fhir:ucum:1.0.8") // GSON for our JSON needs - implementation("com.google.code.gson", "gson", "2.10.1") + implementation("com.google.code.gson", "gson", "2.11.0") // Basic logging. Reload4J is a security-focused fork of Log4J 1.x - implementation("org.slf4j", "slf4j-reload4j", "2.0.7") + implementation("org.slf4j", "slf4j-reload4j", "2.0.16") // Web Server implementation("com.sparkjava", "spark-core", "2.9.4") diff --git a/src/main/java/org/mitre/inferno/Validator.java b/src/main/java/org/mitre/inferno/Validator.java index b75258f..f8c137d 100644 --- a/src/main/java/org/mitre/inferno/Validator.java +++ b/src/main/java/org/mitre/inferno/Validator.java @@ -27,6 +27,9 @@ import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; import org.hl7.fhir.utilities.npm.NpmPackage; +import org.hl7.fhir.utilities.npm.PackageClient; +import org.hl7.fhir.utilities.npm.PackageInfo; +import org.hl7.fhir.utilities.npm.PackageServer; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.validation.BaseValidator; import org.hl7.fhir.validation.BaseValidator.ValidationControl; @@ -68,12 +71,14 @@ public Validator(String igDir, boolean displayIssuesAreWarnings) throws Exceptio final String txServer = getTxServerUrl(); final String txLog = null; final String fhirVersion = "4.0.1"; + final boolean useEcosystem = true; ValidationEngineBuilder engineBuilder = new ValidationEngineBuilder().withTxServer( txServer, txLog, - FhirPublication.fromCode(fhirVersion) + FhirPublication.fromCode(fhirVersion), + useEcosystem ); hl7Validator = engineBuilder.fromSource(definitions); @@ -103,7 +108,8 @@ public Validator(String igDir, boolean displayIssuesAreWarnings) throws Exceptio } } - hl7Validator.connectToTSServer(txServer, txLog, FhirPublication.fromCode(fhirVersion)); + hl7Validator.connectToTSServer( + txServer, txLog, FhirPublication.fromCode(fhirVersion), useEcosystem); hl7Validator.setDoNative(false); hl7Validator.setAnyExtensionsAllowed(true); hl7Validator.setDisplayWarnings(displayIssuesAreWarnings); @@ -210,11 +216,27 @@ public Map getKnownIGs() throws IOException { String canonical = e.getValue().canonical(); igs.put(id, canonical); } - // Add IGs known to the package manager, replacing any conflicting package IDs - packageManager.listAllIds(igs); + // Add IGs known to the package manager + for (PackageServer next : packageManager.getPackageServers()) { + // https://github.com/hapifhir/org.hl7.fhir.core/blob/6.2.8/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java#L585 + listSpecs(igs, next); + } + return igs; } + // copied from + // https://github.com/hapifhir/org.hl7.fhir.core/blob/6.2.8/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/FilesystemPackageCacheManager.java#L318 + private void listSpecs(Map specList, PackageServer server) throws IOException { + PackageClient pc = new PackageClient(server); + List matches = pc.search(null, null, null, false); + for (PackageInfo m : matches) { + if (!specList.containsKey(m.getId())) { + specList.put(m.getId(), m.getUrl()); + } + } + } + /** * Load a profile into the validator. * @@ -229,7 +251,7 @@ public void loadProfile(byte[] profile) throws IOException { LOGGER.info("Loaded profile from file, url: " + sd.getUrl() + " version: " + sd.getVersion()); } else if (resource != null) { LOGGER.info("Loaded resource from file but it wasn't a StructureDefinition, it was a " - + resource.fhirType()); + + resource.fhirType()); } } diff --git a/src/test/java/org/mitre/inferno/ValidatorTest.java b/src/test/java/org/mitre/inferno/ValidatorTest.java index c41eddc..dda9613 100644 --- a/src/test/java/org/mitre/inferno/ValidatorTest.java +++ b/src/test/java/org/mitre/inferno/ValidatorTest.java @@ -160,19 +160,19 @@ void getKnownIGs() throws IOException { @Test void loadIg() throws Exception { - // A small subset of the profiles in mCODE 3.0.0 + // A small subset of the profiles in mCODE 4.0.0 List profilesToLoad = Arrays.asList( "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-disease-status", "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-patient", "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-related-medication-request", "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-related-surgical-procedure", - "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-stage-group" + "http://hl7.org/fhir/us/mcode/StructureDefinition/mcode-cancer-stage" ); assertTrue(profilesToLoad.stream().noneMatch(this::isProfileLoaded)); // Because the version isn't given, this should load the "current" version of hl7.fhir.us.mcode // Note this means that if a new version is published that changes the profile names - // (as has happened in updates 1->2 and 2->3) this test may fail + // (as has happened in updates 1->2, 2->3, and 3->4) this test may fail IgResponse ig = validator.loadIg("hl7.fhir.us.mcode", null); assertEquals("hl7.fhir.us.mcode", ig.id); assertTrue(ig.profiles.containsAll(profilesToLoad));