Set reference validation policy on hapi.fhir.org

This commit is contained in:
jamesagnew 2020-09-08 05:51:10 -04:00
parent 0e34f16890
commit f3a5433c06
5 changed files with 47 additions and 22 deletions

View File

@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
import ca.uhn.fhir.jpa.validation.ValidationSettings;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
import ca.uhn.fhir.validation.IValidatorModule; import ca.uhn.fhir.validation.IValidatorModule;
import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ResultSeverityEnum;
@ -15,6 +16,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.dstu2.model.Subscription;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -81,6 +83,15 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
return daoConfig().getModelConfig(); return daoConfig().getModelConfig();
} }
@Override
@Bean
public ValidationSettings validationSettings() {
ValidationSettings retVal = super.validationSettings();
retVal.setLocalReferenceValidationDefaultPolicy(IResourceValidator.ReferenceValidationPolicy.CHECK_VALID);
return retVal;
}
@Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceDstu1", destroyMethod = "close")
public DataSource dataSource() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();

View File

@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
import ca.uhn.fhir.jpa.validation.ValidationSettings;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ResultSeverityEnum;
import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor; import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor;
@ -15,6 +16,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.dstu2.model.Subscription;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -80,6 +82,17 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
} }
@Override
@Bean
public ValidationSettings validationSettings() {
ValidationSettings retVal = super.validationSettings();
retVal.setLocalReferenceValidationDefaultPolicy(IResourceValidator.ReferenceValidationPolicy.CHECK_VALID);
return retVal;
}
@Override @Override
@Bean(autowire = Autowire.BY_TYPE) @Bean(autowire = Autowire.BY_TYPE)
public DatabaseBackedPagingProvider databaseBackedPagingProvider() { public DatabaseBackedPagingProvider databaseBackedPagingProvider() {

View File

@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
import ca.uhn.fhir.jpa.validation.ValidationSettings;
import ca.uhn.fhir.rest.client.interceptor.ThreadLocalCapturingInterceptor; import ca.uhn.fhir.rest.client.interceptor.ThreadLocalCapturingInterceptor;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ResultSeverityEnum;
@ -16,6 +17,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.dstu2.model.Subscription;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -81,6 +83,15 @@ public class TestR4Config extends BaseJavaConfigR4 {
} }
@Override
@Bean
public ValidationSettings validationSettings() {
ValidationSettings retVal = super.validationSettings();
retVal.setLocalReferenceValidationDefaultPolicy(IResourceValidator.ReferenceValidationPolicy.CHECK_VALID);
return retVal;
}
@Bean(name = "myPersistenceDataSourceR4", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceR4", destroyMethod = "close")
public DataSource dataSource() { public DataSource dataSource() {
BasicDataSource retVal = new BasicDataSource(); BasicDataSource retVal = new BasicDataSource();

View File

@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory; import ca.uhn.fhir.jpa.search.LuceneSearchMappingFactory;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect; import ca.uhn.fhir.jpa.util.DerbyTenSevenHapiFhirDialect;
import ca.uhn.fhir.jpa.validation.ValidationSettings;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
import ca.uhn.fhir.validation.ResultSeverityEnum; import ca.uhn.fhir.validation.ResultSeverityEnum;
import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor; import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor;
@ -15,6 +16,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.dialect.PostgreSQL94Dialect; import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hl7.fhir.dstu2.model.Subscription; import org.hl7.fhir.dstu2.model.Subscription;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -79,6 +81,16 @@ public class TestR5Config extends BaseJavaConfigR5 {
return daoConfig().getModelConfig(); return daoConfig().getModelConfig();
} }
@Override
@Bean
public ValidationSettings validationSettings() {
ValidationSettings retVal = super.validationSettings();
retVal.setLocalReferenceValidationDefaultPolicy(IResourceValidator.ReferenceValidationPolicy.CHECK_VALID);
return retVal;
}
@Bean(name = "myPersistenceDataSourceR5", destroyMethod = "close") @Bean(name = "myPersistenceDataSourceR5", destroyMethod = "close")
public DataSource dataSource() { public DataSource dataSource() {

View File

@ -38,8 +38,6 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta
private boolean assumeValidRestReferences; private boolean assumeValidRestReferences;
private List<String> myExtensionDomains = Collections.emptyList(); private List<String> myExtensionDomains = Collections.emptyList();
private IResourceValidator.IValidatorResourceFetcher validatorResourceFetcher; private IResourceValidator.IValidatorResourceFetcher validatorResourceFetcher;
private volatile FhirContext myDstu2Context;
private volatile FhirContext myHl7OrgDstu2Context;
/** /**
* Constructor * Constructor
@ -136,8 +134,6 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta
/** /**
* Returns the {@link IValidationSupport validation support} in use by this validator. Default is an instance of * Returns the {@link IValidationSupport validation support} in use by this validator. Default is an instance of
* DefaultProfileValidationSupport if the no-arguments constructor for this object was used. * DefaultProfileValidationSupport if the no-arguments constructor for this object was used.
*
* @return
*/ */
public IValidationSupport getValidationSupport() { public IValidationSupport getValidationSupport() {
return myValidationSupport; return myValidationSupport;
@ -276,24 +272,6 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta
return wrappedWorkerContext; return wrappedWorkerContext;
} }
private FhirContext getDstu2Context() {
FhirContext dstu2Context = myDstu2Context;
if (dstu2Context == null) {
dstu2Context = FhirContext.forDstu2();
myDstu2Context = dstu2Context;
}
return dstu2Context;
}
private FhirContext getHl7OrgDstu2Context() {
FhirContext hl7OrgDstu2Context = myHl7OrgDstu2Context;
if (hl7OrgDstu2Context == null) {
hl7OrgDstu2Context = FhirContext.forDstu2Hl7Org();
myHl7OrgDstu2Context = hl7OrgDstu2Context;
}
return hl7OrgDstu2Context;
}
public IResourceValidator.IValidatorResourceFetcher getValidatorResourceFetcher() { public IResourceValidator.IValidatorResourceFetcher getValidatorResourceFetcher() {
return validatorResourceFetcher; return validatorResourceFetcher;
} }