private Source loadXml(String theSystemId, String theSchemaName) { String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSchemaName; ourLog.debug("Going to load resource: {}", pathToBase); InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase); if (baseIs == null) { throw new InternalErrorException("Schema not found. " + RESOURCES_JAR_NOTE); } baseIs = new BOMInputStream(baseIs, false); InputStreamReader baseReader = new InputStreamReader(baseIs, Charset.forName("UTF-8")); Source baseSource = new StreamSource(baseReader, theSystemId); //FIXME resource leak return baseSource; }
@Override public LSInput resolveResource(String theType, String theNamespaceURI, String thePublicId, String theSystemId, String theBaseURI) { if (theSystemId != null && SCHEMA_NAMES.contains(theSystemId)) { LSInputImpl input = new LSInputImpl(); input.setPublicId(thePublicId); input.setSystemId(theSystemId); input.setBaseURI(theBaseURI); // String pathToBase = "ca/uhn/fhir/model/" + myVersion + "/schema/" + theSystemId; String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSystemId; ourLog.debug("Loading referenced schema file: " + pathToBase); InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase); if (baseIs == null) { throw new InternalErrorException("Schema file not found: " + pathToBase); } input.setByteStream(baseIs); //FIXME resource leak return input; } throw new ConfigurationException("Unknown schema: " + theSystemId); } }
Map<String, ValueSet> defaultValueSets = myDefaultValueSets; if (defaultValueSets == null) { String path = theContext.getVersion().getPathToSchemaDefinitions().replace("/schema", "/valueset") + "/valuesets.xml"; InputStream valuesetText = DefaultProfileValidationSupport.class.getResourceAsStream(path); if (valuesetText == null) {
String profileClasspath = theCtx.getVersion().getPathToSchemaDefinitions().replace("/schema", "/profile"); String profileCpName = profileClasspath + '/' + theResourceName.toLowerCase() + ".profile.xml"; String profileText;
private ISchematronResource getSchematronAndCache(IValidationContext<IBaseResource> theCtx, Class<? extends IBaseResource> theClass) { synchronized (myClassToSchematron) { ISchematronResource retVal = myClassToSchematron.get(theClass); if (retVal != null) { return retVal; } String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName().toLowerCase() + ".sch"; try (InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase)) { if (baseIs == null) { throw new InternalErrorException("Failed to load schematron for resource '" + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName() + "'. " + SchemaBaseValidator.RESOURCES_JAR_NOTE); } } catch (IOException e) { ourLog.error("Failed to close stream", e); } retVal = SchematronResourceSCH.fromClassPath(pathToBase); myClassToSchematron.put(theClass, retVal); return retVal; } } }
ourLog.info("Loading ValueSets..."); FhirContext ctx = FhirContext.forDstu2(); String path = ctx.getVersion().getPathToSchemaDefinitions().replace("/schema", "/valueset") + "/valuesets.xml";
ctx.getVersion().getPathToSchemaDefinitions(); vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/valueset/" + "valuesets.xml"), "UTF-8"); } catch (IOException e) {
theCtx.getVersion().getPathToSchemaDefinitions(); vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/dstu3/model/valueset/" + "valuesets.xml"), "UTF-8"); } catch (IOException e) {
theCtx.getVersion().getPathToSchemaDefinitions(); vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/r4/model/valueset/" + "valuesets.xml"), "UTF-8"); } catch (IOException e) {
private Source loadXml(String theSystemId, String theSchemaName) { String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSchemaName; ourLog.debug("Going to load resource: {}", pathToBase); InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase); if (baseIs == null) { throw new InternalErrorException("Schema not found. " + RESOURCES_JAR_NOTE); } baseIs = new BOMInputStream(baseIs, false); InputStreamReader baseReader = new InputStreamReader(baseIs, Charset.forName("UTF-8")); Source baseSource = new StreamSource(baseReader, theSystemId); //FIXME resource leak return baseSource; }
@Override public LSInput resolveResource(String theType, String theNamespaceURI, String thePublicId, String theSystemId, String theBaseURI) { if (theSystemId != null && SCHEMA_NAMES.contains(theSystemId)) { LSInputImpl input = new LSInputImpl(); input.setPublicId(thePublicId); input.setSystemId(theSystemId); input.setBaseURI(theBaseURI); // String pathToBase = "ca/uhn/fhir/model/" + myVersion + "/schema/" + theSystemId; String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSystemId; ourLog.debug("Loading referenced schema file: " + pathToBase); InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase); if (baseIs == null) { throw new InternalErrorException("Schema file not found: " + pathToBase); } input.setByteStream(baseIs); //FIXME resource leak return input; } throw new ConfigurationException("Unknown schema: " + theSystemId); } }
Map<String, ValueSet> defaultValueSets = myDefaultValueSets; if (defaultValueSets == null) { String path = theContext.getVersion().getPathToSchemaDefinitions().replace("/schema", "/valueset") + "/valuesets.xml"; InputStream valuesetText = DefaultProfileValidationSupport.class.getResourceAsStream(path); if (valuesetText == null) {
String profileClasspath = theCtx.getVersion().getPathToSchemaDefinitions().replace("/schema", "/profile"); String profileCpName = profileClasspath + '/' + theResourceName.toLowerCase() + ".profile.xml"; String profileText;
private ISchematronResource getSchematronAndCache(IValidationContext<IBaseResource> theCtx, Class<? extends IBaseResource> theClass) { synchronized (myClassToSchematron) { ISchematronResource retVal = myClassToSchematron.get(theClass); if (retVal != null) { return retVal; } String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName().toLowerCase() + ".sch"; try (InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase)) { if (baseIs == null) { throw new InternalErrorException("Failed to load schematron for resource '" + theCtx.getFhirContext().getResourceDefinition(theCtx.getResource()).getBaseDefinition().getName() + "'. " + SchemaBaseValidator.RESOURCES_JAR_NOTE); } } catch (IOException e) { ourLog.error("Failed to close stream", e); } retVal = SchematronResourceSCH.fromClassPath(pathToBase); myClassToSchematron.put(theClass, retVal); return retVal; } } }