diff --git a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientFactory.java b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientFactory.java index 0603dba05..56cc4ae74 100644 --- a/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientFactory.java +++ b/org.hl7.fhir.convertors/src/main/java/org/hl7/fhir/convertors/txClient/TerminologyClientFactory.java @@ -4,7 +4,7 @@ import java.net.URISyntaxException; import org.hl7.fhir.r5.terminologies.TerminologyClient; import org.hl7.fhir.utilities.FhirPublication; -import org.hl7.fhir.utilities.Servers; + import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.VersionUtilities; @@ -61,7 +61,7 @@ public class TerminologyClientFactory { private static String checkEndsWith(String term, String url) { if (url.endsWith(term)) return url; - if (Servers.isTxFhirOrg(url)) { + if (Utilities.isTxFhirOrgServer(url)) { return Utilities.pathURL(url, term); } return url; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java index 56ed41179..6987d1fc0 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java @@ -21,7 +21,8 @@ import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.TerminologyCapabilities; import org.hl7.fhir.r5.utils.client.network.Client; import org.hl7.fhir.r5.utils.client.network.ResourceRequest; -import org.hl7.fhir.utilities.Servers; + +import org.hl7.fhir.utilities.settings.FhirSettings; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -38,7 +39,7 @@ import static org.mockito.Mockito.times; class FHIRToolingClientTest { - String TX_ADDR = Servers.TX_SERVER_DEV; + String TX_ADDR = FhirSettings.getTxFhirDevelopment(); Header h1 = new Header("header1", "value1"); Header h2 = new Header("header2", "value2"); diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Servers.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Servers.java deleted file mode 100644 index dbc64d4aa..000000000 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Servers.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.hl7.fhir.utilities; - -public class Servers { - - public static final String TX_SERVER_PROD = "http://tx.fhir.org"; - public static final String TX_SERVER_DEV = "http://tx-dev.fhir.org"; - public static final String TX_SERVER_LOCAL = "http://local.fhir.org"; - - public static boolean isTxFhirOrg(String s) { - return Utilities.startsWithInList(s.replace("https://", "http://"), TX_SERVER_PROD, TX_SERVER_DEV, TX_SERVER_LOCAL); - } - -} diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java index 76371ab78..7710748d1 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java @@ -64,6 +64,7 @@ import java.util.zip.ZipInputStream; import org.apache.commons.io.FileUtils; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.utilities.FileNotifier.FileNotifier2; +import org.hl7.fhir.utilities.settings.FhirSettings; import javax.annotation.Nullable; @@ -1961,4 +1962,8 @@ public class Utilities { //} + public static boolean isTxFhirOrgServer(String s) { + return Utilities.startsWithInList(s.replace("https://", "http://"), FhirSettings.getTxFhirProduction(), FhirSettings.getTxFhirDevelopment(), FhirSettings.getTxFhirLocal()); + } + } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/NpmPackage.java index 8f8a6ef18..b5b3679da 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/NpmPackage.java @@ -1224,6 +1224,10 @@ public class NpmPackage { public String toString() { return "NpmPackage "+name()+"#"+version()+" [path=" + path + "]"; } + + public String getFilePath(String d) throws IOException { + return Utilities.path(path, "package", d); + } } \ No newline at end of file diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettings.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettings.java index 2f4e74c5a..c9e95f671 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettings.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettings.java @@ -11,9 +11,9 @@ import java.io.IOException; import java.io.InputStream; - public class FhirSettings { + public static final String FHIR_SETTINGS_PATH = "fhir.settings.path"; private static String explicitFilePath = null; private static Boolean prohibitNetworkAccess; @@ -136,6 +136,28 @@ public class FhirSettings { prohibitNetworkAccess = value; } + + public static String getTxFhirProduction() { + getInstance(); + return instance.fhirSettings.getTxFhirProduction() == null + ? FhirSettingsPOJO.TX_SERVER_PROD + : instance.fhirSettings.getTxFhirProduction(); + } + + public static String getTxFhirDevelopment() { + getInstance(); + return instance.fhirSettings.getTxFhirDevelopment() == null + ? FhirSettingsPOJO.TX_SERVER_PROD + : instance.fhirSettings.getTxFhirDevelopment(); + } + + public static String getTxFhirLocal() { + getInstance(); + return instance.fhirSettings.getTxFhirLocal() == null + ? FhirSettingsPOJO.TX_SERVER_PROD + : instance.fhirSettings.getTxFhirLocal(); + } + private static FhirSettings instance = null; private static FhirSettings getInstance() { @@ -187,4 +209,5 @@ public class FhirSettings { protected static String getDefaultSettingsPath() throws IOException { return Utilities.path(System.getProperty("user.home"), ".fhir", "fhir-settings.json"); } + } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettingsPOJO.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettingsPOJO.java index 72a832984..170a2724e 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettingsPOJO.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/settings/FhirSettingsPOJO.java @@ -13,6 +13,11 @@ import java.util.Map; @AllArgsConstructor public class FhirSettingsPOJO { + + protected static final String TX_SERVER_PROD = "http://tx.fhir.org"; + protected static final String TX_SERVER_DEV = "http://tx-dev.fhir.org"; + protected static final String TX_SERVER_LOCAL = "http://local.fhir.org"; + private String fhirDirectory; private Map apiKeys; @@ -30,6 +35,10 @@ public class FhirSettingsPOJO { private Boolean prohibitNetworkAccess; + private String txFhirProduction; + private String txFhirDevelopment; + private String txFhirLocal; + protected FhirSettingsPOJO() { apiKeys = null; npmPath = null; @@ -38,5 +47,8 @@ public class FhirSettingsPOJO { diffToolPath = null; tempPath = null; testIgsPath = null; + txFhirProduction = TX_SERVER_PROD; + txFhirDevelopment = TX_SERVER_DEV; + txFhirLocal = TX_SERVER_LOCAL; } } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorCli.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorCli.java index 3b1f618a9..d6dd2d9bd 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorCli.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorCli.java @@ -335,6 +335,9 @@ public class ValidatorCli { case SNAPSHOT: validationService.generateSnapshot(cliContext, validator); break; + case INSTALL: + validationService.install(cliContext, validator); + break; case SPREADSHEET: validationService.generateSpreadsheet(cliContext, validator); break; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java index 176c3640e..5a94bbf06 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/model/CliContext.java @@ -9,8 +9,9 @@ import java.util.Objects; import org.hl7.fhir.r5.terminologies.JurisdictionUtilities; import org.hl7.fhir.r5.utils.validation.BundleValidationRule; -import org.hl7.fhir.utilities.Servers; + import org.hl7.fhir.utilities.VersionUtilities; +import org.hl7.fhir.utilities.settings.FhirSettings; import org.hl7.fhir.validation.cli.utils.EngineMode; import org.hl7.fhir.validation.cli.utils.QuestionnaireMode; import org.hl7.fhir.validation.cli.utils.ValidationLevel; @@ -62,7 +63,7 @@ public class CliContext { @JsonProperty("htmlOutput") private String htmlOutput = null; @JsonProperty("txServer") - private String txServer = Servers.TX_SERVER_PROD; + private String txServer = FhirSettings.getTxFhirProduction(); @JsonProperty("sv") private String sv = null; @JsonProperty("txLog") diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Common.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Common.java index f047240bf..c45c13144 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Common.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Common.java @@ -2,9 +2,10 @@ package org.hl7.fhir.validation.cli.utils; import org.hl7.fhir.r5.model.Constants; import org.hl7.fhir.utilities.FhirPublication; -import org.hl7.fhir.utilities.Servers; + import org.hl7.fhir.utilities.TimeTracker; import org.hl7.fhir.utilities.VersionUtilities; +import org.hl7.fhir.utilities.settings.FhirSettings; import org.hl7.fhir.validation.ValidationEngine; public class Common { @@ -75,7 +76,7 @@ public class Common { * Default validation engine will point to "http://tx.fhir.org" terminology server. */ public static ValidationEngine getValidationEngine(String version, String definitions, String txLog, TimeTracker tt) throws Exception { - return getValidationEngine(version, Servers.TX_SERVER_PROD, definitions, txLog, tt); + return getValidationEngine(version, FhirSettings.getTxFhirProduction(), definitions, txLog, tt); } public static ValidationEngine getValidationEngine(String version, String txServer, String definitions, String txLog, TimeTracker tt) throws Exception { diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java index 7c09589b9..f57412913 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/comparison/tests/ComparisonTests.java @@ -46,7 +46,7 @@ import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.test.utils.TestingUtilities; -import org.hl7.fhir.utilities.Servers; + import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.VersionUtilities; @@ -54,6 +54,7 @@ import org.hl7.fhir.utilities.npm.CommonPackages; import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; import org.hl7.fhir.utilities.npm.NpmPackage; import org.hl7.fhir.utilities.npm.ToolsVersion; +import org.hl7.fhir.utilities.settings.FhirSettings; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.xhtml.XhtmlComposer; @@ -94,7 +95,7 @@ public class ComparisonTests { private static IWorkerContext context; private JsonObject content; - private static final String DEF_TX = Servers.TX_SERVER_DEV; + private static final String DEF_TX = FhirSettings.getTxFhirDevelopment(); private static final String HEADER = ""; private static final String BREAK = "
"; private static final String FOOTER = ""; diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/ExternalTerminologyServiceTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/ExternalTerminologyServiceTests.java index 1f748f03a..5c9982ddc 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/ExternalTerminologyServiceTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/terminology/tests/ExternalTerminologyServiceTests.java @@ -22,8 +22,9 @@ import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.Constants; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.test.utils.TestingUtilities; -import org.hl7.fhir.utilities.Servers; + import org.hl7.fhir.utilities.json.model.JsonObject; +import org.hl7.fhir.utilities.settings.FhirSettings; import org.hl7.fhir.validation.special.TxTester; import org.hl7.fhir.validation.special.TxTester.ITxTesterLoader; @@ -47,8 +48,8 @@ public class ExternalTerminologyServiceTests implements ITxTesterLoader { private JsonObject test; } - private static final String SERVER = Servers.TX_SERVER_DEV; -// private static final String SERVER = Servers.TX_SERVER_LOCAL; + private static final String SERVER = FhirSettings.getTxFhirDevelopment(); +// private static final String SERVER = FhirSettings.getTxFhirLocal(); @Parameters(name = "{index}: id {0}") public static Iterable data() throws IOException { diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/ResourceValidationTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/ResourceValidationTests.java index 8d350a0b7..098066fba 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/ResourceValidationTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/ResourceValidationTests.java @@ -25,8 +25,9 @@ import org.hl7.fhir.r5.test.utils.CompareUtilities; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.utils.validation.IResourceValidator; import org.hl7.fhir.utilities.FhirPublication; -import org.hl7.fhir.utilities.Servers; + import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.settings.FhirSettings; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.validation.instance.InstanceValidator; import org.hl7.fhir.validation.tests.ValidationEngineTests; @@ -47,7 +48,7 @@ public class ResourceValidationTests { TestingUtilities.injectCorePackageLoader(); if (val == null) { ctxt = TestingUtilities.getSharedWorkerContext(); - engine = TestUtilities.getValidationEngine("hl7.fhir.r5.core#5.0.0", Servers.TX_SERVER_DEV, null, FhirPublication.R5, true, "5.0.0"); + engine = TestUtilities.getValidationEngine("hl7.fhir.r5.core#5.0.0", FhirSettings.getTxFhirDevelopment(), null, FhirPublication.R5, true, "5.0.0"); val = engine.getValidator(null); val.setDebug(false); } diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationEngineTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationEngineTests.java index dc79c88cb..bd0c566e5 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationEngineTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationEngineTests.java @@ -4,7 +4,8 @@ import java.util.ArrayList; import java.util.List; import org.hl7.fhir.utilities.FhirPublication; -import org.hl7.fhir.utilities.Servers; + +import org.hl7.fhir.utilities.settings.FhirSettings; import org.hl7.fhir.utilities.tests.CacheVerificationLogger; import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; import org.hl7.fhir.r5.model.OperationOutcome; @@ -21,8 +22,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class ValidationEngineTests { - private static final String DEF_TX = Servers.TX_SERVER_DEV; -// private static final String DEF_TX = Servers.TX_SERVER_LOCAL; + private static final String DEF_TX = FhirSettings.getTxFhirDevelopment(); +// private static final String DEF_TX = FhirSettings.getTxFhirLocal(); public static boolean inbuild; diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java index bb3ac87d9..6fefd8b33 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/ValidationTests.java @@ -72,6 +72,7 @@ import org.hl7.fhir.utilities.SimpleHTTPClient.HTTPResult; import org.hl7.fhir.utilities.json.JsonTrackingParser; import org.hl7.fhir.utilities.json.JsonUtilities; import org.hl7.fhir.utilities.npm.NpmPackage; +import org.hl7.fhir.utilities.settings.FhirSettings; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.validation.IgLoader; import org.hl7.fhir.validation.ValidationEngine; @@ -404,7 +405,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe private ValidationEngine buildVersionEngine(String ver, String txLog) throws Exception { - String server = Servers.TX_SERVER_DEV; + String server = FhirSettings.getTxFhirDevelopment(); switch (ver) { case "1.0": return TestUtilities.getValidationEngine("hl7.fhir.r2.core#1.0.2", server, txLog, FhirPublication.DSTU2, true, "1.0.2"); case "1.4": return TestUtilities.getValidationEngine("hl7.fhir.r2b.core#1.4.0", server, txLog, FhirPublication.DSTU2016May, true, "1.4.0");