More work on getting legacy code cleaned up
This commit is contained in:
parent
0b513b0845
commit
e5f6c35aea
|
@ -61,11 +61,12 @@ public class BuiltJarDstu2ShadeIT {
|
|||
* Disabled for now - TODO: add the old version of the apache client (the one that
|
||||
* android uses) and see if this passes
|
||||
*/
|
||||
@Test
|
||||
public void testClient() {
|
||||
FhirContext ctx = FhirContext.forDstu2();
|
||||
try {
|
||||
IGenericClient client = ctx.newRestfulGenericClient("http://127.0.0.1:44442/SomeBase");
|
||||
client.capabilities().ofType(Conformance.class).execute()
|
||||
client.capabilities().ofType(Conformance.class).execute();
|
||||
} catch (FhirClientConnectionException e) {
|
||||
// this is good
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package ca.uhn.fhir.rest.annotation;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2017 University Health Network
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @deprecated IdDt can now hold both an ID and a version ID, so a single parameter with the {@link IdParam} annotation may be used
|
||||
*/
|
||||
@Deprecated
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
public @interface VersionIdParam {
|
||||
// just a marker
|
||||
}
|
|
@ -212,10 +212,6 @@ public class ParameterUtil {
|
|||
return findParamAnnotationIndex(theMethod, TagListParam.class);
|
||||
}
|
||||
|
||||
public static Integer findVersionIdParameterIndex(Method theMethod) {
|
||||
return findParamAnnotationIndex(theMethod, VersionIdParam.class);
|
||||
}
|
||||
|
||||
public static Object fromInteger(Class<?> theType, IntegerDt theArgument) {
|
||||
if (theType.equals(IntegerDt.class)) {
|
||||
if (theArgument == null) {
|
||||
|
|
|
@ -62,6 +62,13 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>${argLine} -Dfile.encoding=UTF-8 -Xmx712m</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -51,12 +51,6 @@ public abstract class BaseOutcomeReturningMethodBindingWithResourceIdButNoResour
|
|||
throw new ConfigurationException("Method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName() + "' has no parameter annotated with the @" + IdParam.class.getSimpleName() + " annotation");
|
||||
}
|
||||
|
||||
Integer versionIdParameterIndex = ParameterUtil.findVersionIdParameterIndex(theMethod);
|
||||
if (versionIdParameterIndex != null) {
|
||||
//TODO Use of a deprecated method should be resolved
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName() + "' has a parameter annotated with the @" + VersionIdParam.class.getSimpleName() + " annotation but delete methods may not have this annotation");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -313,7 +313,7 @@ public class MethodUtil {
|
|||
throw new ConfigurationException(b.toString());
|
||||
}
|
||||
param = new ResourceParameter(parameterType);
|
||||
} else if (nextAnnotation instanceof IdParam || nextAnnotation instanceof VersionIdParam) {
|
||||
} else if (nextAnnotation instanceof IdParam) {
|
||||
param = new NullParameter();
|
||||
} else if (nextAnnotation instanceof ServerBase) {
|
||||
param = new ServerBaseParamBinder();
|
||||
|
|
|
@ -41,7 +41,6 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
|||
public class ReadMethodBinding extends BaseResourceReturningMethodBinding implements IClientResponseHandlerHandlesBinary<Object> {
|
||||
private Integer myIdIndex;
|
||||
private boolean mySupportsVersion;
|
||||
private Integer myVersionIdIndex;
|
||||
private Class<? extends IIdType> myIdParameterType;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -51,13 +50,11 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
|
|||
Validate.notNull(theMethod, "Method must not be null");
|
||||
|
||||
Integer idIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext());
|
||||
Integer versionIdIndex = ParameterUtil.findVersionIdParameterIndex(theMethod);
|
||||
|
||||
Class<?>[] parameterTypes = theMethod.getParameterTypes();
|
||||
|
||||
mySupportsVersion = theMethod.getAnnotation(Read.class).version();
|
||||
myIdIndex = idIndex;
|
||||
myVersionIdIndex = versionIdIndex;
|
||||
|
||||
if (myIdIndex == null) {
|
||||
throw new ConfigurationException("@" + Read.class.getSimpleName() + " method " + theMethod.getName() + " on type \"" + theMethod.getDeclaringClass().getName()
|
||||
|
@ -68,9 +65,6 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
|
|||
if (!IIdType.class.isAssignableFrom(myIdParameterType)) {
|
||||
throw new ConfigurationException("ID parameter must be of type IdDt or IdType - Found: " + myIdParameterType);
|
||||
}
|
||||
if (myVersionIdIndex != null && !IdDt.class.equals(parameterTypes[myVersionIdIndex])) {
|
||||
throw new ConfigurationException("Version ID parameter must be of type: " + IdDt.class.getCanonicalName() + " - Found: " + parameterTypes[myVersionIdIndex]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -96,19 +90,12 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
|
|||
public HttpGetClientInvocation invokeClient(Object[] theArgs) {
|
||||
HttpGetClientInvocation retVal;
|
||||
IIdType id = ((IIdType) theArgs[myIdIndex]);
|
||||
if (myVersionIdIndex == null) {
|
||||
String resourceName = getResourceName();
|
||||
if (id.hasVersionIdPart()) {
|
||||
retVal = createVReadInvocation(getContext(), new IdDt(resourceName, id.getIdPart(), id.getVersionIdPart()), resourceName);
|
||||
} else {
|
||||
retVal = createReadInvocation(getContext(), id, resourceName);
|
||||
}
|
||||
} else {
|
||||
IdDt vid = ((IdDt) theArgs[myVersionIdIndex]);
|
||||
String resourceName = getResourceName();
|
||||
|
||||
retVal = createVReadInvocation(getContext(), new IdDt(resourceName, id.getIdPart(), vid.getVersionIdPart()), resourceName);
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < theArgs.length; idx++) {
|
||||
IParameter nextParam = getParameters().get(idx);
|
||||
|
@ -146,7 +133,7 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding implem
|
|||
}
|
||||
|
||||
public boolean isVread() {
|
||||
return mySupportsVersion || myVersionIdIndex != null;
|
||||
return mySupportsVersion;
|
||||
}
|
||||
|
||||
public static HttpGetClientInvocation createAbsoluteReadInvocation(FhirContext theContext, IIdType theId) {
|
||||
|
|
|
@ -21,6 +21,16 @@
|
|||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||
|
@ -31,6 +41,11 @@
|
|||
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-r4</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
||||
|
@ -265,9 +280,11 @@
|
|||
<include>hapi-fhir-structures-dstu2/target/jacoco.exec</include>
|
||||
<include>hapi-fhir-structures-hl7org-dstu2/target/jacoco.exec</include>
|
||||
<include>hapi-fhir-structures-dstu3/target/jacoco.exec</include>
|
||||
<include>hapi-fhir-structures-r4/target/jacoco.exec</include>
|
||||
<include>hapi-fhir-jpaserver-base/target/jacoco.exec</include>
|
||||
<include>hapi-fhir-client-okhttp/target/jacoco.exec</include>
|
||||
<include>hapi-fhir-android/target/jacoco.exec</include>
|
||||
<include>hapi-fhir-validation/target/jacoco.exec</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
@ -290,6 +307,7 @@
|
|||
<sourceDirectory>../hapi-fhir-structures-dstu2/src/test/java</sourceDirectory>
|
||||
<sourceDirectory>../hapi-fhir-structures-hl7org-dstu2/src/test/java</sourceDirectory>
|
||||
<sourceDirectory>../hapi-fhir-structures-dstu3/src/test/java</sourceDirectory>
|
||||
<sourceDirectory>../hapi-fhir-structures-r4/src/test/java</sourceDirectory>
|
||||
<sourceDirectory>../hapi-fhir-jpaserver-base/src/main/java</sourceDirectory>
|
||||
<sourceDirectory>../hapi-fhir-client-okhttp/src/main/java</sourceDirectory>
|
||||
</sourceDirectories>
|
||||
|
@ -359,22 +377,6 @@
|
|||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>cobertura</report>
|
||||
</reports>
|
||||
<configuration>
|
||||
<check>
|
||||
<haltOnFailure>true</haltOnFailure>
|
||||
</check>
|
||||
</configuration>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
|
|
|
@ -239,8 +239,8 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
|
|
@ -56,9 +56,7 @@ public class JpaServerDemoDstu2 extends RestfulServer {
|
|||
* contains bean definitions for a resource provider for each resource type
|
||||
*/
|
||||
String resourceProviderBeanName;
|
||||
if (fhirVersion == FhirVersionEnum.DSTU1) {
|
||||
resourceProviderBeanName = "myResourceProvidersDstu1";
|
||||
} else if (fhirVersion == FhirVersionEnum.DSTU2) {
|
||||
if (fhirVersion == FhirVersionEnum.DSTU2) {
|
||||
resourceProviderBeanName = "myResourceProvidersDstu2";
|
||||
} else if (fhirVersion == FhirVersionEnum.DSTU3) {
|
||||
resourceProviderBeanName = "myResourceProvidersDstu3";
|
||||
|
|
|
@ -15,11 +15,13 @@ import org.springframework.web.cors.CorsConfiguration;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.config.WebsocketDstu2DispatcherConfig;
|
||||
import ca.uhn.fhir.jpa.config.dstu3.WebsocketDstu3DispatcherConfig;
|
||||
import ca.uhn.fhir.jpa.config.r4.WebsocketR4DispatcherConfig;
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.jpa.provider.JpaConformanceProviderDstu2;
|
||||
import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
|
||||
import ca.uhn.fhir.jpa.provider.dstu3.*;
|
||||
import ca.uhn.fhir.jpa.provider.r4.TerminologyUploaderProviderR4;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
|
@ -29,7 +31,7 @@ import ca.uhn.fhirtest.config.*;
|
|||
|
||||
public class TestRestfulServer extends RestfulServer {
|
||||
|
||||
public static final String FHIR_BASEURL_DSTU1 = "fhir.baseurl.dstu1";
|
||||
public static final String FHIR_BASEURL_R4 = "fhir.baseurl.r4";
|
||||
public static final String FHIR_BASEURL_DSTU2 = "fhir.baseurl.dstu2";
|
||||
public static final String FHIR_BASEURL_DSTU3 = "fhir.baseurl.dstu3";
|
||||
public static final String FHIR_BASEURL_TDL2 = "fhir.baseurl.tdl2";
|
||||
|
@ -114,6 +116,24 @@ public class TestRestfulServer extends RestfulServer {
|
|||
plainProviders.add(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class));
|
||||
break;
|
||||
}
|
||||
case "R4": {
|
||||
myAppCtx = new AnnotationConfigWebApplicationContext();
|
||||
myAppCtx.setServletConfig(getServletConfig());
|
||||
myAppCtx.setParent(parentAppCtx);
|
||||
myAppCtx.register(TestR4Config.class, WebsocketR4DispatcherConfig.class);
|
||||
baseUrlProperty = FHIR_BASEURL_R4;
|
||||
myAppCtx.refresh();
|
||||
setFhirContext(FhirContext.forR4());
|
||||
beans = myAppCtx.getBean("myResourceProvidersR4", List.class);
|
||||
plainProviders.add(myAppCtx.getBean("mySystemProviderR4", JpaSystemProviderDstu3.class));
|
||||
systemDao = myAppCtx.getBean("mySystemDaoR4", IFhirSystemDao.class);
|
||||
etagSupport = ETagSupportEnum.ENABLED;
|
||||
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
|
||||
confProvider.setImplementationDescription(implDesc);
|
||||
setServerConformanceProvider(confProvider);
|
||||
plainProviders.add(myAppCtx.getBean(TerminologyUploaderProviderR4.class));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new ServletException("Unknown FHIR version specified in init-param[FhirVersion]: " + fhirVersionParam);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package ca.uhn.fhirtest.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowire;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.to.FhirTesterMvcConfig;
|
||||
|
@ -56,10 +53,10 @@ public class FhirTesterConfig {
|
|||
.withBaseUrl("http://fhirtest.uhn.ca/baseDstu2")
|
||||
.withName("UHN/HAPI Server (DSTU2 FHIR)")
|
||||
.addServer()
|
||||
.withId("home")
|
||||
.withFhirVersion(FhirVersionEnum.DSTU1)
|
||||
.withBaseUrl("http://fhirtest.uhn.ca/baseDstu1")
|
||||
.withName("UHN/HAPI Server (DSTU1 FHIR)")
|
||||
.withId("home_r4")
|
||||
.withFhirVersion(FhirVersionEnum.R4)
|
||||
.withBaseUrl("http://fhirtest.uhn.ca/baseR4")
|
||||
.withName("UHN/HAPI Server (R4 FHIR)")
|
||||
// .addServer()
|
||||
// .withId("tdl_d2")
|
||||
// .withFhirVersion(FhirVersionEnum.DSTU2)
|
||||
|
@ -72,6 +69,11 @@ public class FhirTesterConfig {
|
|||
// .withBaseUrl("http://fhirtest.uhn.ca/testDataLibraryStu3")
|
||||
// .withName("Test Data Library (DSTU3 FHIR)")
|
||||
// .allowsApiKey()
|
||||
.addServer()
|
||||
.withId("hi4")
|
||||
.withFhirVersion(FhirVersionEnum.DSTU3)
|
||||
.withBaseUrl("http://test.fhir.org/r4")
|
||||
.withName("Health Intersections (R4 FHIR)")
|
||||
.addServer()
|
||||
.withId("hi3")
|
||||
.withFhirVersion(FhirVersionEnum.DSTU3)
|
||||
|
|
|
@ -7,7 +7,6 @@ import javax.sql.DataSource;
|
|||
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||
import org.hibernate.dialect.PostgreSQL94Dialect;
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowire;
|
||||
|
@ -21,7 +20,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
import ca.uhn.fhir.jpa.config.BaseJavaConfigDstu3;
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptorDstu3;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
package ca.uhn.fhirtest.config;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hibernate.dialect.PostgreSQL95Dialect;
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowire;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigR4;
|
||||
import ca.uhn.fhir.jpa.dao.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||
import ca.uhn.fhir.validation.ResultSeverityEnum;
|
||||
import ca.uhn.fhirtest.interceptor.PublicSecurityInterceptor;
|
||||
|
||||
@Configuration
|
||||
@Import(CommonConfig.class)
|
||||
@EnableTransactionManagement()
|
||||
public class TestR4Config extends BaseJavaConfigR4 {
|
||||
public static final String FHIR_DB_USERNAME = "${fhir.db.username}";
|
||||
public static final String FHIR_DB_PASSWORD = "${fhir.db.password}";
|
||||
public static final String FHIR_LUCENE_LOCATION_R4 = "${fhir.lucene.location.r4}";
|
||||
|
||||
@Value(TestR4Config.FHIR_DB_USERNAME)
|
||||
private String myDbUsername;
|
||||
|
||||
@Value(TestR4Config.FHIR_DB_PASSWORD)
|
||||
private String myDbPassword;
|
||||
|
||||
@Value(FHIR_LUCENE_LOCATION_R4)
|
||||
private String myFhirLuceneLocation;
|
||||
|
||||
@Bean()
|
||||
public DaoConfig daoConfig() {
|
||||
DaoConfig retVal = new DaoConfig();
|
||||
retVal.setSubscriptionEnabled(true);
|
||||
retVal.setSubscriptionPollDelay(5000);
|
||||
retVal.setSubscriptionPurgeInactiveAfterMillis(DateUtils.MILLIS_PER_HOUR);
|
||||
retVal.setAllowMultipleDelete(true);
|
||||
retVal.setAllowInlineMatchUrlReferences(true);
|
||||
retVal.setAllowExternalReferences(true);
|
||||
retVal.getTreatBaseUrlsAsLocal().add("http://fhirtest.uhn.ca/baseR4");
|
||||
retVal.getTreatBaseUrlsAsLocal().add("https://fhirtest.uhn.ca/baseR4");
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean(autowire = Autowire.BY_TYPE)
|
||||
public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
|
||||
DatabaseBackedPagingProvider retVal = super.databaseBackedPagingProvider();
|
||||
retVal.setDefaultPageSize(20);
|
||||
retVal.setMaximumPageSize(500);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public IServerInterceptor securityInterceptor() {
|
||||
return new PublicSecurityInterceptor();
|
||||
}
|
||||
|
||||
@Bean(name = "myPersistenceDataSourceR4", destroyMethod = "close")
|
||||
public DataSource dataSource() {
|
||||
BasicDataSource retVal = new BasicDataSource();
|
||||
retVal.setDriver(new org.postgresql.Driver());
|
||||
retVal.setUrl("jdbc:postgresql://localhost/fhirtest_r4");
|
||||
retVal.setUsername(myDbUsername);
|
||||
retVal.setPassword(myDbPassword);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean();
|
||||
retVal.setPersistenceUnitName("PU_HapiFhirJpaR4");
|
||||
retVal.setDataSource(dataSource());
|
||||
retVal.setPackagesToScan("ca.uhn.fhir.jpa.entity");
|
||||
retVal.setPersistenceProvider(new HibernatePersistenceProvider());
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private Properties jpaProperties() {
|
||||
Properties extraProperties = new Properties();
|
||||
extraProperties.put("hibernate.dialect", PostgreSQL95Dialect.class.getName());
|
||||
extraProperties.put("hibernate.format_sql", "false");
|
||||
extraProperties.put("hibernate.show_sql", "false");
|
||||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||
extraProperties.put("hibernate.jdbc.batch_size", "20");
|
||||
extraProperties.put("hibernate.cache.use_query_cache", "false");
|
||||
extraProperties.put("hibernate.cache.use_second_level_cache", "false");
|
||||
extraProperties.put("hibernate.cache.use_structured_entries", "false");
|
||||
extraProperties.put("hibernate.cache.use_minimal_puts", "false");
|
||||
extraProperties.put("hibernate.search.default.directory_provider", "filesystem");
|
||||
extraProperties.put("hibernate.search.default.indexBase", myFhirLuceneLocation);
|
||||
extraProperties.put("hibernate.search.lucene_version", "LUCENE_CURRENT");
|
||||
return extraProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bean which validates incoming requests
|
||||
*/
|
||||
@Bean
|
||||
@Lazy
|
||||
public RequestValidatingInterceptor requestValidatingInterceptor() {
|
||||
RequestValidatingInterceptor requestValidator = new RequestValidatingInterceptor();
|
||||
requestValidator.setFailOnSeverity(null);
|
||||
requestValidator.setAddResponseHeaderOnSeverity(null);
|
||||
requestValidator.setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum.INFORMATION);
|
||||
requestValidator.addValidatorModule(instanceValidatorR4());
|
||||
requestValidator.setIgnoreValidatorExceptions(true);
|
||||
|
||||
return requestValidator;
|
||||
}
|
||||
|
||||
|
||||
@Bean()
|
||||
public JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
|
||||
JpaTransactionManager retVal = new JpaTransactionManager();
|
||||
retVal.setEntityManagerFactory(entityManagerFactory);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* This lets the "@Value" fields reference properties from the properties file
|
||||
*/
|
||||
@Bean
|
||||
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
return new PropertySourcesPlaceholderConfigurer();
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ import ca.uhn.fhir.to.model.HomeRequest;
|
|||
public class SubscriptionPlaygroundController extends BaseController {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SubscriptionPlaygroundController.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = { "/subscriptions" })
|
||||
public String subscriptionsHome(final HttpServletRequest theServletRequest, HomeRequest theRequest, final ModelMap theModel) {
|
||||
addCommonParams(theServletRequest, theRequest, theModel);
|
||||
|
@ -31,8 +32,7 @@ public class SubscriptionPlaygroundController extends BaseController {
|
|||
CaptureInterceptor interceptor = new CaptureInterceptor();
|
||||
GenericClient client = theRequest.newClient(theServletRequest, getContext(theRequest), myConfig, interceptor);
|
||||
|
||||
//@formatter:off
|
||||
Bundle resp = client
|
||||
Bundle resp = (Bundle) client
|
||||
.search()
|
||||
.forResource(Subscription.class)
|
||||
// .where(Subscription.TYPE.exactly().code(SubscriptionChannelTypeEnum.WEBSOCKET.getCode()))
|
||||
|
@ -41,7 +41,6 @@ public class SubscriptionPlaygroundController extends BaseController {
|
|||
.sort().ascending(Subscription.STATUS)
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
//@formatter:off
|
||||
|
||||
List<Subscription> subscriptions = new ArrayList<Subscription>();
|
||||
for (Entry next : resp.getEntry()) {
|
||||
|
|
|
@ -41,15 +41,15 @@
|
|||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>fhirServletDstu1</servlet-name>
|
||||
<servlet-name>fhirServletR4</servlet-name>
|
||||
<servlet-class>ca.uhn.fhirtest.TestRestfulServer</servlet-class>
|
||||
<init-param>
|
||||
<param-name>ImplementationDescription</param-name>
|
||||
<param-value>UHN Test Server (DSTU1 Resources)</param-value>
|
||||
<param-value>UHN Test Server (R4 Resources)</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>FhirVersion</param-name>
|
||||
<param-value>DSTU1</param-value>
|
||||
<param-value>R4</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
@ -112,13 +112,8 @@
|
|||
-->
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>fhirServletDstu1</servlet-name>
|
||||
<url-pattern>/base/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>fhirServletDstu1</servlet-name>
|
||||
<url-pattern>/baseDstu1/*</url-pattern>
|
||||
<servlet-name>fhirServletR4</servlet-name>
|
||||
<url-pattern>/baseR4/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
|
|
|
@ -87,6 +87,13 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<argLine>${argLine} -Dfile.encoding=UTF-8 -Xmx712m</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void>
|
|||
|
||||
private Class<? extends IBaseResource> myType;
|
||||
private Integer myIdParamIndex;
|
||||
private Integer myVersionIdParamIndex;
|
||||
private String myResourceName;
|
||||
private Integer myTagListParamIndex;
|
||||
|
||||
|
@ -40,7 +39,6 @@ abstract class BaseAddOrDeleteTagsMethodBinding extends BaseMethodBinding<Void>
|
|||
myResourceName = theContext.getResourceDefinition(myType).getName();
|
||||
|
||||
myIdParamIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext());
|
||||
myVersionIdParamIndex = ParameterUtil.findVersionIdParameterIndex(theMethod);
|
||||
myTagListParamIndex = ParameterUtil.findTagListParameterIndex(theMethod);
|
||||
|
||||
if (myIdParamIndex == null) {
|
||||
|
|
|
@ -57,12 +57,6 @@ public abstract class BaseOutcomeReturningMethodBindingWithResourceIdButNoResour
|
|||
throw new ConfigurationException("Method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName() + "' has no parameter annotated with the @" + IdParam.class.getSimpleName() + " annotation");
|
||||
}
|
||||
|
||||
Integer versionIdParameterIndex = ParameterUtil.findVersionIdParameterIndex(theMethod);
|
||||
if (versionIdParameterIndex != null) {
|
||||
//TODO Use of a deprecated method should be resolved
|
||||
throw new ConfigurationException("Method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName() + "' has a parameter annotated with the @" + VersionIdParam.class.getSimpleName() + " annotation but delete methods may not have this annotation");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -149,7 +149,7 @@ public class MethodUtil {
|
|||
throw new ConfigurationException(b.toString());
|
||||
}
|
||||
param = new ResourceParameter((Class<? extends IBaseResource>) parameterType, theProvider, mode);
|
||||
} else if (nextAnnotation instanceof IdParam || nextAnnotation instanceof VersionIdParam) {
|
||||
} else if (nextAnnotation instanceof IdParam) {
|
||||
param = new NullParameter();
|
||||
} else if (nextAnnotation instanceof ServerBase) {
|
||||
param = new ServerBaseParamBinder();
|
||||
|
|
|
@ -3,15 +3,11 @@ package ca.uhn.fhir.rest.server.method;
|
|||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -20,20 +16,12 @@ import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
|||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.annotation.Elements;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.api.server.IRestfulServer;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.api.server.*;
|
||||
import ca.uhn.fhir.rest.param.ParameterUtil;
|
||||
import ca.uhn.fhir.rest.server.ETagSupportEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.NotModifiedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.*;
|
||||
import ca.uhn.fhir.util.DateUtils;
|
||||
|
||||
public class ReadMethodBinding extends BaseResourceReturningMethodBinding {
|
||||
|
@ -41,7 +29,6 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
|
||||
private Integer myIdIndex;
|
||||
private boolean mySupportsVersion;
|
||||
private Integer myVersionIdIndex;
|
||||
private Class<? extends IIdType> myIdParameterType;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -51,13 +38,11 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
Validate.notNull(theMethod, "Method must not be null");
|
||||
|
||||
Integer idIndex = ParameterUtil.findIdParameterIndex(theMethod, getContext());
|
||||
Integer versionIdIndex = ParameterUtil.findVersionIdParameterIndex(theMethod);
|
||||
|
||||
Class<?>[] parameterTypes = theMethod.getParameterTypes();
|
||||
|
||||
mySupportsVersion = theMethod.getAnnotation(Read.class).version();
|
||||
myIdIndex = idIndex;
|
||||
myVersionIdIndex = versionIdIndex;
|
||||
|
||||
if (myIdIndex == null) {
|
||||
throw new ConfigurationException("@" + Read.class.getSimpleName() + " method " + theMethod.getName() + " on type \"" + theMethod.getDeclaringClass().getName() + "\" does not have a parameter annotated with @" + IdParam.class.getSimpleName());
|
||||
|
@ -67,9 +52,6 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
if (!IIdType.class.isAssignableFrom(myIdParameterType)) {
|
||||
throw new ConfigurationException("ID parameter must be of type IdDt or IdType - Found: " + myIdParameterType);
|
||||
}
|
||||
if (myVersionIdIndex != null && !IdDt.class.equals(parameterTypes[myVersionIdIndex])) {
|
||||
throw new ConfigurationException("Version ID parameter must be of type: " + IdDt.class.getCanonicalName() + " - Found: " + parameterTypes[myVersionIdIndex]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -125,7 +107,7 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
return false;
|
||||
}
|
||||
if (Constants.PARAM_HISTORY.equals(theRequest.getOperation())) {
|
||||
if (mySupportsVersion == false && myVersionIdIndex == null) {
|
||||
if (mySupportsVersion == false) {
|
||||
return false;
|
||||
}
|
||||
if (theRequest.getId().hasVersionIdPart() == false) {
|
||||
|
@ -141,9 +123,6 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
@Override
|
||||
public IBundleProvider invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException {
|
||||
theMethodParams[myIdIndex] = ParameterUtil.convertIdToType(theRequest.getId(), myIdParameterType);
|
||||
if (myVersionIdIndex != null) {
|
||||
theMethodParams[myVersionIdIndex] = new IdDt(theRequest.getId().getVersionIdPart());
|
||||
}
|
||||
|
||||
Object response = invokeServerMethod(theServer, theRequest, theMethodParams);
|
||||
IBundleProvider retVal = toResourceList(response);
|
||||
|
@ -193,13 +172,8 @@ public class ReadMethodBinding extends BaseResourceReturningMethodBinding {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean isBinary() {
|
||||
// return "Binary".equals(getResourceName());
|
||||
// }
|
||||
|
||||
public boolean isVread() {
|
||||
return mySupportsVersion || myVersionIdIndex != null;
|
||||
return mySupportsVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue