Merge branch 'master' of https://github.com/jamesagnew/hapi-fhir into jaxrs-sever-evolution
This commit is contained in:
commit
e652e000ae
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.6-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -12,6 +12,17 @@
|
|||
|
||||
<artifactId>hapi-fhir-base-example-embedded-ws</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2</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>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
|
@ -44,11 +55,6 @@
|
|||
<artifactId>cors-filter</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
|
|
|
@ -4,85 +4,96 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.6-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>hapi-fhir-standalone-overlay-example</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<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-testpage-overlay</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-testpage-overlay</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>classes</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject.extensions</groupId>
|
||||
<artifactId>guice-servlet</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey.contribs</groupId>
|
||||
<artifactId>jersey-guice</artifactId>
|
||||
<version>1.19.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ebaysf.web</groupId>
|
||||
<artifactId>cors-filter</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<overlays>
|
||||
<overlay>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-testpage-overlay</artifactId>
|
||||
</overlay>
|
||||
</overlays>
|
||||
<warName>fhirtester</warName>
|
||||
<failOnMissingWebXml>true</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-testpage-overlay</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>war</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-testpage-overlay</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>classes</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject.extensions</groupId>
|
||||
<artifactId>guice-servlet</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey.contribs</groupId>
|
||||
<artifactId>jersey-guice</artifactId>
|
||||
<version>1.19.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ebaysf.web</groupId>
|
||||
<artifactId>cors-filter</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<overlays>
|
||||
<overlay>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-testpage-overlay</artifactId>
|
||||
</overlay>
|
||||
</overlays>
|
||||
<warName>fhirtester</warName>
|
||||
<failOnMissingWebXml>true</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -2,19 +2,17 @@ package embedded.example;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.*;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor;
|
||||
import ca.uhn.fhir.rest.server.util.ITestingUiClientFactory;
|
||||
import ca.uhn.fhir.to.FhirTesterMvcConfig;
|
||||
import ca.uhn.fhir.to.TesterConfig;
|
||||
import ca.uhn.fhir.util.ITestingUiClientFactory;
|
||||
|
||||
//@formatter:off
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.6-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -45,6 +45,11 @@
|
|||
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-converter</artifactId>
|
||||
|
|
|
@ -8,20 +8,14 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.ConditionalUrlParam;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||
import ca.uhn.fhir.rest.annotation.Update;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.interceptor.auth.AuthorizationInterceptor;
|
||||
import ca.uhn.fhir.rest.server.interceptor.auth.IAuthRule;
|
||||
import ca.uhn.fhir.rest.server.interceptor.auth.RuleBuilder;
|
||||
import ca.uhn.fhir.rest.server.interceptor.auth.*;
|
||||
|
||||
public class AuthorizationInterceptors {
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ package example;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor;
|
||||
import ca.uhn.fhir.util.ITestingUiClientFactory;
|
||||
import ca.uhn.fhir.rest.server.util.ITestingUiClientFactory;
|
||||
|
||||
public class AuthorizingTesterUiClientFactory implements ITestingUiClientFactory {
|
||||
|
||||
|
|
|
@ -2,11 +2,13 @@ package example;
|
|||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.RelatedPerson;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
|
||||
/**
|
||||
* @author Bill de Beaubien on 1/13/2016.
|
||||
|
|
|
@ -4,11 +4,10 @@ import org.hl7.fhir.dstu3.model.Bundle;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.okhttp.client.OkHttpRestfulClientFactory;
|
||||
import ca.uhn.fhir.rest.client.*;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.client.apache.GZipContentInterceptor;
|
||||
import ca.uhn.fhir.rest.client.api.IBasicClient;
|
||||
import ca.uhn.fhir.rest.client.api.*;
|
||||
import ca.uhn.fhir.rest.client.interceptor.*;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
|
||||
public class ClientExamples {
|
||||
|
||||
|
|
|
@ -3,15 +3,10 @@ package example;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.*;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
|
||||
public class ClientTransactionExamples {
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package example;
|
||||
|
||||
import org.hl7.fhir.convertors.NullVersionConverterAdvisor;
|
||||
import org.hl7.fhir.convertors.VersionConvertorAdvisor;
|
||||
import org.hl7.fhir.convertors.VersionConvertor_10_30;
|
||||
import org.hl7.fhir.convertors.VersionConvertor_14_30;
|
||||
import org.hl7.fhir.convertors.*;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
||||
public class ConverterExamples {
|
||||
|
@ -12,7 +9,7 @@ public class ConverterExamples {
|
|||
public void c1020() throws FHIRException {
|
||||
//START SNIPPET: 1020
|
||||
// Create a converter
|
||||
VersionConvertorAdvisor advisor = new NullVersionConverterAdvisor();
|
||||
NullVersionConverterAdvisor30 advisor = new NullVersionConverterAdvisor30();
|
||||
VersionConvertor_10_30 converter = new VersionConvertor_10_30(advisor);
|
||||
|
||||
// Create an input resource to convert
|
||||
|
|
|
@ -6,7 +6,7 @@ import javax.servlet.ServletException;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ package example;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
|
|
|
@ -3,18 +3,12 @@ package example;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.DateTimeType;
|
||||
import org.hl7.fhir.dstu3.model.Extension;
|
||||
import org.hl7.fhir.dstu3.model.HumanName;
|
||||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.dstu3.model.Identifier.IdentifierUse;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.hl7.fhir.dstu3.model.StringType;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
|
||||
public class ExtensionsDstu3 {
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ public class FhirContextIntro {
|
|||
@SuppressWarnings("unused")
|
||||
public static void creatingContext() {
|
||||
// START SNIPPET: creatingContext
|
||||
// Create a context for DSTU1
|
||||
FhirContext ctx = FhirContext.forDstu1();
|
||||
|
||||
// Alternately, create a context for DSTU2
|
||||
// Create a context for DSTU2
|
||||
FhirContext ctxDstu2 = FhirContext.forDstu2();
|
||||
|
||||
// Alternately, create a context for R4
|
||||
FhirContext ctxR4 = FhirContext.forR4();
|
||||
// END SNIPPET: creatingContext
|
||||
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ System.out.println(encoded);
|
|||
|
||||
|
||||
public static void parseMsg() {
|
||||
FhirContext ctx = FhirContext.forDstu1();
|
||||
FhirContext ctx = FhirContext.forR4();
|
||||
|
||||
//START SNIPPET: parseMsg
|
||||
// The following is an example Patient resource
|
||||
|
|
|
@ -1,26 +1,16 @@
|
|||
package example;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.composite.*;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.*;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
|
||||
public class FhirDataModel {
|
||||
|
||||
|
|
|
@ -9,27 +9,15 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.PerformanceOptionsEnum;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome.Issue;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Parameters;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Provenance;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum;
|
||||
import ca.uhn.fhir.model.primitive.DateDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.SummaryEnum;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.model.primitive.*;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.method.SearchStyleEnum;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
|
||||
|
@ -420,16 +408,6 @@ public class GenericClientExample {
|
|||
@SuppressWarnings("unused")
|
||||
public static void history() {
|
||||
IGenericClient client = FhirContext.forDstu2().newRestfulGenericClient("");
|
||||
{
|
||||
ca.uhn.fhir.model.api.Bundle response;
|
||||
// START SNIPPET: historyDstu1
|
||||
response = client
|
||||
.history()
|
||||
.onServer()
|
||||
.andReturnDstu1Bundle()
|
||||
.execute();
|
||||
// END SNIPPET: historyDstu1
|
||||
}
|
||||
{
|
||||
ca.uhn.fhir.model.dstu2.resource.Bundle response;
|
||||
// START SNIPPET: historyDstu2
|
||||
|
|
|
@ -3,17 +3,13 @@ package example;
|
|||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.AuthenticationStrategy;
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
|
||||
import org.apache.http.impl.client.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
|
||||
public class HttpProxy {
|
||||
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
package example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
|
||||
@SuppressWarnings(value= {"serial"})
|
||||
public class JaxRsClient {
|
||||
|
|
|
@ -9,7 +9,7 @@ import javax.ws.rs.Produces;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import ca.uhn.fhir.jaxrs.server.AbstractJaxRsConformanceProvider;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
package example;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
|
@ -17,16 +11,8 @@ import ca.uhn.fhir.model.dstu2.resource.Parameters;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.annotation.ConditionalUrlParam;
|
||||
import ca.uhn.fhir.rest.annotation.Create;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Operation;
|
||||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
|
||||
/**
|
||||
* A demo JaxRs Patient Rest Provider
|
||||
|
|
|
@ -9,8 +9,8 @@ import ca.uhn.fhir.model.dstu2.resource.Patient;
|
|||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
|
||||
@SuppressWarnings("null")
|
||||
|
|
|
@ -6,7 +6,7 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter;
|
||||
|
||||
|
|
|
@ -2,15 +2,13 @@ package example;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.dstu3.model.Identifier.IdentifierUse;
|
||||
import org.hl7.fhir.dstu3.model.OperationOutcome.IssueSeverity;
|
||||
|
@ -18,63 +16,17 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.api.Tag;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.model.api.*;
|
||||
import ca.uhn.fhir.model.api.annotation.Description;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.annotation.AddTags;
|
||||
import ca.uhn.fhir.rest.annotation.At;
|
||||
import ca.uhn.fhir.rest.annotation.ConditionalUrlParam;
|
||||
import ca.uhn.fhir.rest.annotation.*;
|
||||
import ca.uhn.fhir.rest.annotation.Count;
|
||||
import ca.uhn.fhir.rest.annotation.Create;
|
||||
import ca.uhn.fhir.rest.annotation.Delete;
|
||||
import ca.uhn.fhir.rest.annotation.DeleteTags;
|
||||
import ca.uhn.fhir.rest.annotation.Elements;
|
||||
import ca.uhn.fhir.rest.annotation.GetTags;
|
||||
import ca.uhn.fhir.rest.annotation.History;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.IncludeParam;
|
||||
import ca.uhn.fhir.rest.annotation.Metadata;
|
||||
import ca.uhn.fhir.rest.annotation.OptionalParam;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.rest.annotation.RequiredParam;
|
||||
import ca.uhn.fhir.rest.annotation.ResourceParam;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.annotation.Since;
|
||||
import ca.uhn.fhir.rest.annotation.Sort;
|
||||
import ca.uhn.fhir.rest.annotation.TagListParam;
|
||||
import ca.uhn.fhir.rest.annotation.Transaction;
|
||||
import ca.uhn.fhir.rest.annotation.TransactionParam;
|
||||
import ca.uhn.fhir.rest.annotation.Update;
|
||||
import ca.uhn.fhir.rest.annotation.Validate;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.SortOrderEnum;
|
||||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.api.SummaryEnum;
|
||||
import ca.uhn.fhir.rest.api.ValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.api.*;
|
||||
import ca.uhn.fhir.rest.client.api.IBasicClient;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
import ca.uhn.fhir.rest.param.CompositeParam;
|
||||
import ca.uhn.fhir.rest.param.DateParam;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
||||
import ca.uhn.fhir.rest.param.QuantityParam;
|
||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringOrListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.param.TokenOrListParam;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.param.*;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.*;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class RestfulPatientResourceProviderMore implements IResourceProvider {
|
||||
|
@ -1065,60 +1017,6 @@ public MethodOutcome createPatientResource(@ResourceParam Patient thePatient) {
|
|||
}
|
||||
//END SNIPPET: createTags
|
||||
|
||||
//START SNIPPET: tagMethodProvider
|
||||
public class TagMethodProvider
|
||||
{
|
||||
/** Return a list of all tags that exist on the server */
|
||||
@GetTags
|
||||
public TagList getAllTagsOnServer() {
|
||||
return new TagList(); // populate this
|
||||
}
|
||||
|
||||
/** Return a list of all tags that exist on at least one instance
|
||||
* of the given resource type */
|
||||
@GetTags(type=Patient.class)
|
||||
public TagList getTagsForAllResourcesOfResourceType() {
|
||||
return new TagList(); // populate this
|
||||
}
|
||||
|
||||
/** Return a list of all tags that exist on a specific instance
|
||||
* of the given resource type */
|
||||
@GetTags(type=Patient.class)
|
||||
public TagList getTagsForResources(@IdParam IdType theId) {
|
||||
return new TagList(); // populate this
|
||||
}
|
||||
|
||||
/** Return a list of all tags that exist on a specific version
|
||||
* of the given resource type */
|
||||
@GetTags(type=Patient.class)
|
||||
public TagList getTagsForResourceVersion(@IdParam IdType theId) {
|
||||
return new TagList(); // populate this
|
||||
}
|
||||
|
||||
/** Add tags to a resource */
|
||||
@AddTags(type=Patient.class)
|
||||
public void getTagsForResourceVersion(@IdParam IdType theId,
|
||||
@TagListParam TagList theTagList) {
|
||||
// add tags
|
||||
}
|
||||
|
||||
/** Add tags to a resource version */
|
||||
@AddTags(type=Patient.class)
|
||||
public void addTagsToResourceVersion(@IdParam IdType theId,
|
||||
@TagListParam TagList theTagList) {
|
||||
// add tags
|
||||
}
|
||||
|
||||
/** Remove tags from a resource */
|
||||
@DeleteTags(type=Patient.class)
|
||||
public void deleteTagsFromResourceVersion(@IdParam IdType theId,
|
||||
@TagListParam TagList theTagList) {
|
||||
// add tags
|
||||
}
|
||||
|
||||
}
|
||||
//END SNIPPET: tagMethodProvider
|
||||
|
||||
//START SNIPPET: transaction
|
||||
@Transaction
|
||||
public Bundle transaction(@TransactionParam Bundle theInput) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter;
|
||||
|
||||
|
|
|
@ -4,12 +4,10 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.api.Tag;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.model.api.*;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.rest.annotation.Search;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
|
||||
public class TagsExamples {
|
||||
|
||||
|
|
|
@ -8,32 +8,17 @@ import javax.servlet.ServletException;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.hl7.fhir.dstu3.hapi.validation.DefaultProfileValidationSupport;
|
||||
import org.hl7.fhir.dstu3.hapi.validation.FhirInstanceValidator;
|
||||
import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport;
|
||||
import org.hl7.fhir.dstu3.hapi.validation.ValidationSupportChain;
|
||||
import org.hl7.fhir.dstu3.model.CodeSystem;
|
||||
import org.hl7.fhir.dstu3.hapi.validation.*;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem;
|
||||
import org.hl7.fhir.dstu3.model.Observation;
|
||||
import org.hl7.fhir.dstu3.model.OperationOutcome;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.hl7.fhir.dstu3.model.StringType;
|
||||
import org.hl7.fhir.dstu3.model.StructureDefinition;
|
||||
import org.hl7.fhir.instance.model.ValueSet;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent;
|
||||
import org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
import ca.uhn.fhir.validation.IValidatorModule;
|
||||
import ca.uhn.fhir.validation.SchemaBaseValidator;
|
||||
import ca.uhn.fhir.validation.SingleValidationMessage;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
import ca.uhn.fhir.validation.*;
|
||||
import ca.uhn.fhir.validation.schematron.SchematronBaseValidator;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.6-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -32,8 +32,8 @@
|
|||
<configuration>
|
||||
<signature>
|
||||
<groupId>org.codehaus.mojo.signature</groupId>
|
||||
<artifactId>java16</artifactId>
|
||||
<version>1.1</version>
|
||||
<artifactId>java17</artifactId>
|
||||
<version>1.0</version>
|
||||
</signature>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.6-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -37,12 +37,6 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||
|
@ -91,13 +85,6 @@
|
|||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>false</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
|
@ -114,11 +101,8 @@
|
|||
<includes>
|
||||
<include>**/*Dstu2ShadeIT.java</include>
|
||||
</includes>
|
||||
<additionalClasspathElements>
|
||||
<additionalClasspathElement>${basedir}/target/hapi-fhir-android-${project.version}-dstu2.jar</additionalClasspathElement>
|
||||
</additionalClasspathElements>
|
||||
<classpathDependencyExcludes>
|
||||
<classpathDependencyExclude>ca.uhn.hapi.fhir:*</classpathDependencyExclude>
|
||||
<!--<classpathDependencyExclude>ca.uhn.hapi.fhir:*</classpathDependencyExclude>-->
|
||||
<classpathDependencyExclude>org.codehaus.woodstox:woodstox-core-asl</classpathDependencyExclude>
|
||||
<classpathDependencyExclude>org.codehaus.woodstox:stax2-api</classpathDependencyExclude>
|
||||
</classpathDependencyExcludes>
|
||||
|
@ -158,155 +142,6 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
||||
<createSourcesJar>true</createSourcesJar>
|
||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||
<artifactSet>
|
||||
<includes combine.children="append">
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-base</include>
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-client-okhttp</include>
|
||||
<include>org.codehaus.woodstox:woodstox-core-asl</include>
|
||||
<include>javax.xml.stream:stax-api</include>
|
||||
<include>org.codehaus.woodstox:stax2-api</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>javax.xml.stream</pattern>
|
||||
<shadedPattern>ca.uhn.fhir.repackage.javax.xml.stream</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>javax.json</pattern>
|
||||
<shadedPattern>ca.uhn.fhir.repackage.javax.json</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.ctc.wstx.stax</pattern>
|
||||
<shadedPattern>ca.uhn.fhir.repackage.com.ctc.wstx.stax</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters combine.children="append">
|
||||
<!-- Exclude server side stuff, except exceptions which are used clientside -->
|
||||
<filter>
|
||||
<artifact>ca.uhn.hapi.fhir:hapi-fhir-base</artifact>
|
||||
<excludes>
|
||||
<!-- Exclude test stuff which depends on httpservlet -->
|
||||
<exclude>ca/uhn/fhir/util/ITestingUiClientFactory</exclude>
|
||||
<!-- Exclude server side stuff. This could be made nicer if code was divided into shared, server and client -->
|
||||
<!--exclude>ca/uhn/fhir/rest/server/Add*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/Apache*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/Bundle*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/ETag*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/Fifo*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/Hard*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/IBundle*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/IDynamic*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/Incoming*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/IPaging*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/IServerAdd*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/Resource*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/Rest*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/Search*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/Simple*</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/audit/**</exclude>
|
||||
<exclude>ca/uhn/fhir/rest/server/interceptor/**</exclude-->
|
||||
<!-- Exclude Phloc validator to make android libs small -->
|
||||
<exclude>ca/uhn/fhir/validation/schematron/SchematronBaseValidator*</exclude>
|
||||
<!-- Exclude Thymeleaf to make android libs small -->
|
||||
<exclude>ca/uhn/fhir/narrative/*Thymeleaf*</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
<executions>
|
||||
<!-- shaded jar -->
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<!-- dstu jar -->
|
||||
<execution>
|
||||
<id>dstu</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedClassifierName>dstu</shadedClassifierName>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<!-- Exclude server side stuff, except exceptions which are used clientside -->
|
||||
<!--filters>
|
||||
<filter>
|
||||
<artifact>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu</artifact>
|
||||
<excludes>
|
||||
<exclude>ca/uhn/fhir/rest/server/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters-->
|
||||
</configuration>
|
||||
</execution>
|
||||
<!-- dstu2 jar -->
|
||||
<execution>
|
||||
<id>dstu2</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedClassifierName>dstu2</shadedClassifierName>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<!-- Exclude server side stuff, except exceptions which are used clientside -->
|
||||
<!--filters>
|
||||
<filter>
|
||||
<artifact>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2</artifact>
|
||||
<excludes>
|
||||
<exclude>ca/uhn/fhir/rest/server/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters-->
|
||||
</configuration>
|
||||
</execution>
|
||||
<!-- dstu3 jar -->
|
||||
<execution>
|
||||
<id>dstu3</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<shadedClassifierName>dstu3</shadedClassifierName>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<!-- Exclude server side stuff, except exceptions which are used clientside -->
|
||||
<!--filters>
|
||||
<filter>
|
||||
<artifact>ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2</artifact>
|
||||
<excludes>
|
||||
<exclude>ca/uhn/fhir/rest/server/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters-->
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package ca.uhn.fhir.android;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -16,9 +15,8 @@ import org.junit.Test;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
|
||||
public class BuiltJarDstu2IT {
|
||||
|
@ -78,7 +76,7 @@ public class BuiltJarDstu2IT {
|
|||
FhirContext ctx = FhirContext.forDstu2();
|
||||
try {
|
||||
IGenericClient client = ctx.newRestfulGenericClient("http://127.0.0.1:44442/SomeBase");
|
||||
client.conformance();
|
||||
client.capabilities().ofType(Conformance.class).execute();
|
||||
} catch (FhirClientConnectionException e) {
|
||||
// this is good
|
||||
}
|
||||
|
|
|
@ -9,14 +9,12 @@ import java.util.zip.ZipFile;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
|
||||
public class BuiltJarDstu2ShadeIT {
|
||||
|
@ -63,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.conformance();
|
||||
client.capabilities().ofType(Conformance.class).execute();
|
||||
} catch (FhirClientConnectionException e) {
|
||||
// this is good
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package ca.uhn.fhir.android.client;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -12,14 +8,8 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.hl7.fhir.dstu3.model.Binary;
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.OperationOutcome;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.hl7.fhir.dstu3.model.*;
|
||||
import org.junit.*;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
|
@ -28,12 +18,12 @@ import org.mockito.stubbing.Answer;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.util.VersionUtil;
|
||||
import okhttp3.*;
|
||||
|
@ -74,7 +64,7 @@ public class GenericClientDstu3IT {
|
|||
}
|
||||
|
||||
private String expectedUserAgent() {
|
||||
return "HAPI-FHIR/" + VersionUtil.getVersion() + " (FHIR Client; FHIR " + FhirVersionEnum.DSTU3.getFhirVersionString() + "/DSTU3; okhttp/3.4.1)";
|
||||
return "HAPI-FHIR/" + VersionUtil.getVersion() + " (FHIR Client; FHIR " + FhirVersionEnum.DSTU3.getFhirVersionString() + "/DSTU3; okhttp/3.8.1)";
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,6 +94,7 @@ public class GenericClientDstu3IT {
|
|||
.protocol(myProtocol)
|
||||
.code(200)
|
||||
.body(ResponseBody.create(MediaType.parse(Constants.CT_FHIR_XML + "; charset=UTF-8"), respString))
|
||||
.message("")
|
||||
.build();
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
|
@ -141,7 +132,6 @@ public class GenericClientDstu3IT {
|
|||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
int idx = 0;
|
||||
|
||||
//@formatter:off
|
||||
client
|
||||
.search()
|
||||
.forResource(Patient.class)
|
||||
|
@ -151,7 +141,6 @@ public class GenericClientDstu3IT {
|
|||
.and(Patient.ORGANIZATION.hasId((String)null))
|
||||
.returnBundle(Bundle.class)
|
||||
.execute();
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("http://example.com/fhir/Patient", capt.getAllValues().get(idx).url().toString());
|
||||
idx++;
|
||||
|
@ -176,6 +165,7 @@ public class GenericClientDstu3IT {
|
|||
.protocol(myProtocol)
|
||||
.code(200)
|
||||
.body(ResponseBody.create(MediaType.parse(Constants.CT_FHIR_JSON_NEW + "; charset=UTF-8"), respString))
|
||||
.message("")
|
||||
.build();
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
|
@ -207,6 +197,7 @@ public class GenericClientDstu3IT {
|
|||
.protocol(myProtocol)
|
||||
.code(200)
|
||||
.body(body)
|
||||
.message("")
|
||||
.build();
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
|
@ -252,6 +243,7 @@ public class GenericClientDstu3IT {
|
|||
.code(200)
|
||||
.body(ResponseBody.create(MediaType.parse(Constants.CT_FHIR_JSON_NEW + "; charset=UTF-8"), respString))
|
||||
.headers(Headers.of(Constants.HEADER_LOCATION, "http://foo.com/base/Patient/222/_history/3"))
|
||||
.message("")
|
||||
.build();
|
||||
|
||||
IGenericClient client = ourCtx.newRestfulGenericClient("http://example.com/fhir");
|
||||
|
@ -277,6 +269,7 @@ public class GenericClientDstu3IT {
|
|||
.code(200)
|
||||
.body(ResponseBody.create(MediaType.parse(Constants.CT_FHIR_JSON + "; charset=UTF-8"), respString))
|
||||
.headers(Headers.of(Constants.HEADER_LOCATION, "http://foo.com/base/Patient/222/_history/3"))
|
||||
.message("")
|
||||
.build();
|
||||
|
||||
return capt;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.6-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -64,18 +64,18 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||
<artifactId>hapi-fhir-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
|
|
@ -2,22 +2,28 @@ package ca.uhn.fhir.rest.client;
|
|||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.Bundle;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
import ca.uhn.fhir.rest.gclient.ITransactionTyped;
|
||||
|
||||
public class ClientTest {
|
||||
|
||||
private static FhirContext ctx = FhirContext.forDstu1();
|
||||
private static FhirContext ctx = FhirContext.forDstu3();
|
||||
|
||||
@Test
|
||||
public void testTransaction() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.addEntry().setResource(new Patient().setId("Patient/unit_test_patient"));
|
||||
|
||||
Patient patient = new Patient();
|
||||
patient.setId("Patient/unit_test_patient");
|
||||
patient.addName().setFamily("SMITH");
|
||||
|
||||
bundle.addEntry().setResource(patient);
|
||||
|
||||
IGenericClient client = ctx.newRestfulGenericClient("http://127.0.0.1:1/fhir"); // won't connect
|
||||
ITransactionTyped<Bundle> transaction = client.transaction().withBundle(bundle);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>2.6-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -54,25 +54,6 @@
|
|||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
|
@ -89,6 +70,52 @@
|
|||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import static org.junit.Assert.fail;
|
|||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
|
||||
public class MultiVersionJsonParserTest {
|
||||
|
||||
|
@ -16,14 +16,14 @@ public class MultiVersionJsonParserTest {
|
|||
@Test
|
||||
public void testEncodeExtensionFromDifferentVersion() {
|
||||
Patient p = new Patient();
|
||||
p.addIdentifier("urn:sys", "001");
|
||||
p.addIdentifier().setSystem("urn:sys").setValue("001");
|
||||
p.addUndeclaredExtension(false, "http://foo#ext", new QuantityDt(2.2));
|
||||
|
||||
try {
|
||||
FhirContext.forDstu2().newJsonParser().encodeResourceToString(p);
|
||||
FhirContext.forDstu3().newJsonParser().encodeResourceToString(p);
|
||||
fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("This parser is for FHIR version DSTU2 - Can not encode a structure for version DSTU1", e.getMessage());
|
||||
assertEquals("This parser is for FHIR version DSTU3 - Can not encode a structure for version DSTU2", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package ca.uhn.fhir.parser;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -10,16 +8,16 @@ import org.junit.Test;
|
|||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.QuantityComparatorEnum;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
|
||||
public class MultiVersionXmlParserTest {
|
||||
|
||||
private static FhirContext ourCtxDstu1 = FhirContext.forDstu1();
|
||||
private static FhirContext ourCtxDstu2 = FhirContext.forDstu2();
|
||||
private static FhirContext ourCtxDstu3 = FhirContext.forDstu3();
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MultiVersionXmlParserTest.class);
|
||||
|
||||
|
@ -31,20 +29,20 @@ public class MultiVersionXmlParserTest {
|
|||
@Test
|
||||
public void testEncodeExtensionFromDifferentVersion() {
|
||||
Patient p = new Patient();
|
||||
p.addIdentifier("urn:sys", "001");
|
||||
p.addUndeclaredExtension(false, "http://foo#ext", new QuantityDt(QuantityCompararatorEnum.LESSTHAN, 2.2, "g/L"));
|
||||
p.addIdentifier().setSystem("urn:sys").setValue("001");
|
||||
p.addUndeclaredExtension(false, "http://foo#ext", new QuantityDt(QuantityComparatorEnum.LESS_THAN, 2.2, "g/L"));
|
||||
|
||||
String str;
|
||||
str = ourCtxDstu1.newXmlParser().encodeResourceToString(p);
|
||||
str = ourCtxDstu2.newXmlParser().encodeResourceToString(p);
|
||||
ourLog.info(str);
|
||||
assertThat(str, Matchers.stringContainsInOrder("<extension url=\"http://foo#ext\"><valueQuantity><value value=\"2.2\"", "<comparator value=\"<\"", "<units value=\"g/L\"",
|
||||
assertThat(str, Matchers.stringContainsInOrder("<extension url=\"http://foo#ext\"><valueQuantity><value value=\"2.2\"", "<comparator value=\"<\"", "<unit value=\"g/L\"",
|
||||
"</valueQuantity></extension>"));
|
||||
|
||||
try {
|
||||
FhirContext.forDstu2().newXmlParser().encodeResourceToString(p);
|
||||
FhirContext.forDstu3().newXmlParser().encodeResourceToString(p);
|
||||
fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("This parser is for FHIR version DSTU2 - Can not encode a structure for version DSTU1", e.getMessage());
|
||||
assertEquals("This parser is for FHIR version DSTU3 - Can not encode a structure for version DSTU2", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +50,7 @@ public class MultiVersionXmlParserTest {
|
|||
public void testParseResourceReference() {
|
||||
|
||||
Organization o = new Organization();
|
||||
o.getName().setValue("Some Org");
|
||||
o.getNameElement().setValue("Some Org");
|
||||
o.getPartOf().setDisplay("Part Of");
|
||||
|
||||
Patient p = new Patient();
|
||||
|
@ -60,19 +58,19 @@ public class MultiVersionXmlParserTest {
|
|||
p.getManagingOrganization().setDisplay("RR Display");
|
||||
p.getManagingOrganization().setResource(o);
|
||||
|
||||
String res = ourCtxDstu1.newXmlParser().encodeResourceToString(p);
|
||||
String res = ourCtxDstu2.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
try {
|
||||
ourCtxDstu1.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Patient.class, res);
|
||||
ourCtxDstu3.newXmlParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Patient.class, res);
|
||||
fail();
|
||||
} catch (ConfigurationException e) {
|
||||
assertEquals("This context is for FHIR version \"DSTU1\" but the class \"ca.uhn.fhir.model.dstu2.resource.Patient\" is for version \"DSTU2\"", e.getMessage());
|
||||
assertEquals("This context is for FHIR version \"DSTU3\" but the class \"ca.uhn.fhir.model.dstu2.resource.Patient\" is for version \"DSTU2\"", e.getMessage());
|
||||
}
|
||||
try {
|
||||
ourCtxDstu2.newXmlParser().parseResource(ca.uhn.fhir.model.dstu.resource.Patient.class, res);
|
||||
ourCtxDstu3.newXmlParser().parseResource(Patient.class, res);
|
||||
fail();
|
||||
} catch (ConfigurationException e) {
|
||||
assertEquals("This context is for FHIR version \"DSTU2\" but the class \"ca.uhn.fhir.model.dstu.resource.Patient\" is for version \"DSTU1\"", e.getMessage());
|
||||
assertEquals("This context is for FHIR version \"DSTU3\" but the class \"ca.uhn.fhir.model.dstu2.resource.Patient\" is for version \"DSTU2\"", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package ca.uhn.fhir.testmindeps;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
|
||||
public class FhirContextTest {
|
||||
|
||||
@Test
|
||||
public void testWrongVersionDoesntGetInContext1() {
|
||||
public void testWrongVersionDoesntGetInContext2() {
|
||||
|
||||
FhirContext ctx = FhirContext.forDstu1();
|
||||
FhirContext ctx = FhirContext.forDstu2();
|
||||
RuntimeResourceDefinition def = ctx.getResourceDefinition("Patient");
|
||||
assertEquals(Patient.class, def.getImplementingClass());
|
||||
}
|
||||
|
|
|
@ -6,28 +6,25 @@ import static org.junit.Assert.assertNotNull;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.*;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.servlet.ServletHandler;
|
||||
import org.mortbay.jetty.servlet.ServletHolder;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Binary;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Binary;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.util.PortUtil;
|
||||
|
@ -53,10 +50,10 @@ public class ReadTest {
|
|||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
IdentifierDt dt = ourCtx.newXmlParser().parseResource(Patient.class,responseContent).getIdentifierFirstRep();
|
||||
|
||||
assertEquals("1", dt.getSystem().getValueAsString());
|
||||
assertEquals(null, dt.getValue().getValueAsString());
|
||||
assertEquals("1", dt.getSystemElement().getValueAsString());
|
||||
assertEquals(null, dt.getValueElement().getValueAsString());
|
||||
|
||||
Header cl = status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION_LC);
|
||||
org.apache.http.Header cl = status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION_LC);
|
||||
assertNotNull(cl);
|
||||
assertEquals("http://localhost:" + ourPort + "/Patient/1/_history/1", cl.getValue());
|
||||
|
||||
|
@ -77,11 +74,11 @@ public class ReadTest {
|
|||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertEquals("application/x-foo", status.getEntity().getContentType().getValue());
|
||||
|
||||
Header cl = status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION_LC);
|
||||
org.apache.http.Header cl = status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION_LC);
|
||||
assertNotNull(cl);
|
||||
assertEquals("http://localhost:" + ourPort + "/Binary/1/_history/1", cl.getValue());
|
||||
|
||||
Header cd = status.getFirstHeader("content-disposition");
|
||||
org.apache.http.Header cd = status.getFirstHeader("content-disposition");
|
||||
assertNotNull(cd);
|
||||
assertEquals("Attachment;", cd.getValue());
|
||||
|
||||
|
@ -104,10 +101,10 @@ public class ReadTest {
|
|||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
IdentifierDt dt = ourCtx.newXmlParser().parseResource(Patient.class,responseContent).getIdentifierFirstRep();
|
||||
assertEquals("1", dt.getSystem().getValueAsString());
|
||||
assertEquals("2", dt.getValue().getValueAsString());
|
||||
assertEquals("1", dt.getSystemElement().getValueAsString());
|
||||
assertEquals("2", dt.getValueElement().getValueAsString());
|
||||
|
||||
Header cl = status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION_LC);
|
||||
org.apache.http.Header cl = status.getFirstHeader(Constants.HEADER_CONTENT_LOCATION_LC);
|
||||
assertNotNull(cl);
|
||||
assertEquals("http://localhost:" + ourPort + "/Patient/1/_history/1", cl.getValue());
|
||||
}
|
||||
|
@ -149,7 +146,7 @@ public class ReadTest {
|
|||
@Read(version = true)
|
||||
public Patient findPatient(@IdParam IdDt theId) {
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier(theId.getIdPart(), theId.getVersionIdPart());
|
||||
patient.addIdentifier().setSystem(theId.getIdPart()).setValue(theId.getVersionIdPart());
|
||||
patient.setId("Patient/1/_history/1");
|
||||
return patient;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
|
||||
public class ValidatorTest {
|
||||
|
@ -16,14 +16,14 @@ public class ValidatorTest {
|
|||
@Test
|
||||
public void testValidator() {
|
||||
|
||||
FhirContext ctx = FhirContext.forDstu1();
|
||||
FhirContext ctx = FhirContext.forDstu2();
|
||||
FhirValidator val = ctx.newValidator();
|
||||
|
||||
try {
|
||||
val.validateWithResult(new Patient());
|
||||
fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("This parser is for FHIR version DSTU1 - Can not encode a structure for version DSTU2", e.getMessage());
|
||||
assertEquals("This parser is for FHIR version DSTU2 - Can not encode a structure for version DSTU3", e.getMessage());
|
||||
}
|
||||
|
||||
// Phloc is not onthe classpath
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-deployable-pom</artifactId>
|
||||
<version>2.6-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -92,57 +92,6 @@
|
|||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Client -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<optional>true</optional>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<optional>true</optional>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Server -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.context;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/*
|
||||
|
@ -27,28 +28,19 @@ import java.util.*;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import ca.uhn.fhir.context.api.AddProfileTagEnum;
|
||||
import ca.uhn.fhir.context.support.IContextValidationSupport;
|
||||
import ca.uhn.fhir.fluentpath.IFluentPath;
|
||||
import ca.uhn.fhir.i18n.HapiLocalizer;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.IFhirVersion;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.*;
|
||||
import ca.uhn.fhir.model.view.ViewGenerator;
|
||||
import ca.uhn.fhir.narrative.INarrativeGenerator;
|
||||
import ca.uhn.fhir.parser.*;
|
||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||
import ca.uhn.fhir.rest.client.IRestfulClientFactory;
|
||||
import ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory;
|
||||
import ca.uhn.fhir.rest.client.api.IBasicClient;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
import ca.uhn.fhir.rest.server.AddProfileTagEnum;
|
||||
import ca.uhn.fhir.rest.server.IVersionSpecificBundleFactory;
|
||||
import ca.uhn.fhir.util.FhirTerser;
|
||||
import ca.uhn.fhir.util.VersionUtil;
|
||||
import ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory;
|
||||
import ca.uhn.fhir.rest.client.api.*;
|
||||
import ca.uhn.fhir.util.*;
|
||||
import ca.uhn.fhir.validation.FhirValidator;
|
||||
|
||||
/**
|
||||
|
@ -102,7 +94,7 @@ public class FhirContext {
|
|||
|
||||
/**
|
||||
* @deprecated It is recommended that you use one of the static initializer methods instead
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()}
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()} or {@link #forR4()}
|
||||
*/
|
||||
@Deprecated
|
||||
public FhirContext() {
|
||||
|
@ -111,7 +103,7 @@ public class FhirContext {
|
|||
|
||||
/**
|
||||
* @deprecated It is recommended that you use one of the static initializer methods instead
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()}
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()} or {@link #forR4()}
|
||||
*/
|
||||
@Deprecated
|
||||
public FhirContext(Class<? extends IBaseResource> theResourceType) {
|
||||
|
@ -120,7 +112,7 @@ public class FhirContext {
|
|||
|
||||
/**
|
||||
* @deprecated It is recommended that you use one of the static initializer methods instead
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()}
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()} or {@link #forR4()}
|
||||
*/
|
||||
@Deprecated
|
||||
public FhirContext(Class<?>... theResourceTypes) {
|
||||
|
@ -129,7 +121,7 @@ public class FhirContext {
|
|||
|
||||
/**
|
||||
* @deprecated It is recommended that you use one of the static initializer methods instead
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()}
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()} or {@link #forR4()}
|
||||
*/
|
||||
@Deprecated
|
||||
public FhirContext(Collection<Class<? extends IBaseResource>> theResourceTypes) {
|
||||
|
@ -138,7 +130,7 @@ public class FhirContext {
|
|||
|
||||
/**
|
||||
* In most cases it is recommended that you use one of the static initializer methods instead
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()}, but
|
||||
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()} or {@link #forR4()}, but
|
||||
* this method can also be used if you wish to supply the version programmatically.
|
||||
*/
|
||||
public FhirContext(FhirVersionEnum theVersion) {
|
||||
|
@ -153,8 +145,6 @@ public class FhirContext {
|
|||
throw new IllegalStateException(getLocalizer().getMessage(FhirContext.class, "noStructuresForSpecifiedVersion", theVersion.name()));
|
||||
}
|
||||
myVersion = theVersion.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DSTU1.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DSTU1.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DSTU2.isPresentOnClasspath()) {
|
||||
myVersion = FhirVersionEnum.DSTU2.getVersionImplementation();
|
||||
} else if (FhirVersionEnum.DSTU2_HL7ORG.isPresentOnClasspath()) {
|
||||
|
@ -331,11 +321,11 @@ public class FhirContext {
|
|||
|
||||
Map<String, Class<? extends IBaseResource>> nameToType = myVersionToNameToResourceType.get(theVersion);
|
||||
if (nameToType == null) {
|
||||
nameToType = new HashMap<String, Class<? extends IBaseResource>>();
|
||||
Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> existing = Collections.emptyMap();
|
||||
nameToType = new HashMap<>();
|
||||
Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> existing = new HashMap<>();
|
||||
ModelScanner.scanVersionPropertyFile(null, nameToType, theVersion, existing);
|
||||
|
||||
Map<FhirVersionEnum, Map<String, Class<? extends IBaseResource>>> newVersionToNameToResourceType = new HashMap<FhirVersionEnum, Map<String, Class<? extends IBaseResource>>>();
|
||||
Map<FhirVersionEnum, Map<String, Class<? extends IBaseResource>>> newVersionToNameToResourceType = new HashMap<>();
|
||||
newVersionToNameToResourceType.putAll(myVersionToNameToResourceType);
|
||||
newVersionToNameToResourceType.put(theVersion, nameToType);
|
||||
myVersionToNameToResourceType = newVersionToNameToResourceType;
|
||||
|
@ -426,7 +416,11 @@ public class FhirContext {
|
|||
*/
|
||||
public IRestfulClientFactory getRestfulClientFactory() {
|
||||
if (myRestfulClientFactory == null) {
|
||||
myRestfulClientFactory = new ApacheRestfulClientFactory(this);
|
||||
try {
|
||||
myRestfulClientFactory = (IRestfulClientFactory) ReflectionUtil.newInstance(Class.forName("ca.uhn.fhir.rest.client.apache.ApacheRestfulClientFactory"), FhirContext.class, this);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new ConfigurationException("hapi-fhir-client does not appear to be on the classpath");
|
||||
}
|
||||
}
|
||||
return myRestfulClientFactory;
|
||||
}
|
||||
|
@ -466,10 +460,6 @@ public class FhirContext {
|
|||
return !myDefaultTypeForProfile.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be considered experimental and will likely change in future releases
|
||||
* of HAPI. Use with caution!
|
||||
*/
|
||||
public IVersionSpecificBundleFactory newBundleFactory() {
|
||||
return myVersion.newBundleFactory(this);
|
||||
}
|
||||
|
@ -832,7 +822,7 @@ public class FhirContext {
|
|||
public void setValidationSupport(IContextValidationSupport<?, ?, ?, ?, ?, ?> theValidationSupport) {
|
||||
myValidationSupport = theValidationSupport;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "cast" })
|
||||
private List<Class<? extends IElement>> toElementList(Collection<Class<? extends IBaseResource>> theResourceTypes) {
|
||||
if (theResourceTypes == null) {
|
||||
|
@ -844,7 +834,7 @@ public class FhirContext {
|
|||
}
|
||||
return resTypes;
|
||||
}
|
||||
|
||||
|
||||
private void validateInitialized() {
|
||||
// See #610
|
||||
if (!myInitialized) {
|
||||
|
@ -857,13 +847,6 @@ public class FhirContext {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU1 DSTU1}
|
||||
*/
|
||||
public static FhirContext forDstu1() {
|
||||
return new FhirContext(FhirVersionEnum.DSTU1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU2 DSTU2}
|
||||
*/
|
||||
|
@ -895,6 +878,16 @@ public class FhirContext {
|
|||
return new FhirContext(FhirVersionEnum.DSTU3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU3 DSTU3}
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public static FhirContext forR4() {
|
||||
return new FhirContext(FhirVersionEnum.R4);
|
||||
}
|
||||
|
||||
|
||||
private static Collection<Class<? extends IBaseResource>> toCollection(Class<? extends IBaseResource> theResourceType) {
|
||||
ArrayList<Class<? extends IBaseResource>> retVal = new ArrayList<Class<? extends IBaseResource>>(1);
|
||||
retVal.add(theResourceType);
|
||||
|
@ -913,4 +906,33 @@ public class FhirContext {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable set containing all resource names known to this
|
||||
* context
|
||||
*/
|
||||
public Set<String> getResourceNames() {
|
||||
Set<String> resourceNames= new HashSet<>();
|
||||
|
||||
if (myNameToResourceDefinition.isEmpty()) {
|
||||
Properties props = new Properties();
|
||||
try {
|
||||
props.load(myVersion.getFhirVersionPropertiesFile());
|
||||
} catch (IOException theE) {
|
||||
throw new ConfigurationException("Failed to load version properties file");
|
||||
}
|
||||
Enumeration<?> propNames = props.propertyNames();
|
||||
while (propNames.hasMoreElements()){
|
||||
String next = (String) propNames.nextElement();
|
||||
if (next.startsWith("resource.")) {
|
||||
resourceNames.add(next.substring("resource.".length()).trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (RuntimeResourceDefinition next : myNameToResourceDefinition.values()) {
|
||||
resourceNames.add(next.getName());
|
||||
}
|
||||
|
||||
return Collections.unmodifiableSet(resourceNames);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,15 +34,17 @@ public enum FhirVersionEnum {
|
|||
* ***********************
|
||||
*/
|
||||
|
||||
DSTU1("ca.uhn.fhir.model.dstu.FhirDstu1", null, false, new Version("0.0.82")),
|
||||
|
||||
DSTU2("ca.uhn.fhir.model.dstu2.FhirDstu2", null, false, new Version("1.0.2")),
|
||||
|
||||
DSTU2_HL7ORG("org.hl7.fhir.instance.FhirDstu2Hl7Org", DSTU2, true, new Version("1.0.2")),
|
||||
|
||||
DSTU2_1("org.hl7.fhir.dstu2016may.hapi.ctx.FhirDstu2_1", null, true, new Version("1.4.0")),
|
||||
|
||||
DSTU3("org.hl7.fhir.dstu3.hapi.ctx.FhirDstu3", null, true, new Dstu3Version());
|
||||
DSTU3("org.hl7.fhir.dstu3.hapi.ctx.FhirDstu3", null, true, new Dstu3Version()),
|
||||
|
||||
R4("org.hl7.fhir.r4.hapi.ctx.FhirR4", null, true, new R4Version()),
|
||||
|
||||
;
|
||||
|
||||
private final FhirVersionEnum myEquivalent;
|
||||
private final boolean myIsRi;
|
||||
|
@ -138,6 +140,11 @@ public enum FhirVersionEnum {
|
|||
String provideVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* This class attempts to read the FHIR version from the actual model
|
||||
* classes in order to supply an accurate version string even over time
|
||||
*
|
||||
*/
|
||||
private static class Dstu3Version implements IVersionProvider {
|
||||
|
||||
public Dstu3Version() {
|
||||
|
@ -145,7 +152,27 @@ public enum FhirVersionEnum {
|
|||
Class<?> c = Class.forName("org.hl7.fhir.dstu3.model.Constants");
|
||||
myVersion = (String) c.getDeclaredField("VERSION").get(null);
|
||||
} catch (Exception e) {
|
||||
myVersion = "UNKNOWN";
|
||||
myVersion = "3.0.1";
|
||||
}
|
||||
}
|
||||
|
||||
private String myVersion;
|
||||
|
||||
@Override
|
||||
public String provideVersion() {
|
||||
return myVersion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class R4Version implements IVersionProvider {
|
||||
|
||||
public R4Version() {
|
||||
try {
|
||||
Class<?> c = Class.forName("org.hl7.fhir.r4.model.Constants");
|
||||
myVersion = (String) c.getDeclaredField("VERSION").get(null);
|
||||
} catch (Exception e) {
|
||||
myVersion = "4.0.0";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
@ -35,21 +32,11 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam.RuntimeSearchParamStatusEnum;
|
||||
import ca.uhn.fhir.model.api.ExtensionDt;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.model.api.IElement;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.IResourceBlock;
|
||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||
import ca.uhn.fhir.model.api.annotation.Block;
|
||||
import ca.uhn.fhir.model.api.annotation.Child;
|
||||
import ca.uhn.fhir.model.api.annotation.Compartment;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
|
||||
import ca.uhn.fhir.model.api.*;
|
||||
import ca.uhn.fhir.model.api.annotation.*;
|
||||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.util.ReflectionUtil;
|
||||
|
||||
class ModelScanner {
|
||||
|
|
|
@ -84,11 +84,7 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
|
|||
myDatatypeToElementDefinition = new HashMap<Class<? extends IBase>, BaseRuntimeElementDefinition<?>>();
|
||||
myResourceTypes = new ArrayList<Class<? extends IBaseResource>>();
|
||||
|
||||
if (theContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU1)) {
|
||||
myReferenceSuffix = "Resource";
|
||||
} else {
|
||||
myReferenceSuffix = "Reference";
|
||||
}
|
||||
myReferenceSuffix = "Reference";
|
||||
|
||||
for (Class<? extends IBase> next : myChoiceTypes) {
|
||||
|
||||
|
|
|
@ -56,8 +56,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
|
|||
/*
|
||||
* Resource reference - The correct name is 'valueReference' in DSTU2 and 'valueResource' in DSTU1
|
||||
*/
|
||||
boolean dstu1 = (theContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU1));
|
||||
if ((dstu1 && (value != VALUE_REFERENCE)) || (!dstu1 && (value != VALUE_RESOURCE))) {
|
||||
if (value != VALUE_RESOURCE) {
|
||||
myDatatypeToAttributeName.put(theContext.getVersion().getResourceReferenceType(), value);
|
||||
myDatatypeToDefinition.put(BaseResourceReferenceDt.class, def);
|
||||
myDatatypeToDefinition.put(theContext.getVersion().getResourceReferenceType(), def);
|
||||
|
|
|
@ -131,9 +131,6 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
|
|||
|
||||
if (!UrlUtil.isValid(profile)) {
|
||||
String resourceName = "/StructureDefinition/";
|
||||
if (myContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) {
|
||||
resourceName = "/Profile/";
|
||||
}
|
||||
String profileWithUrl = theServerBase + resourceName + profile;
|
||||
if (UrlUtil.isValid(profileWithUrl)) {
|
||||
return profileWithUrl;
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.*;
|
|||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
||||
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
package ca.uhn.fhir.context.api;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
package ca.uhn.fhir.context.api;
|
||||
|
||||
/*
|
||||
* #%L
|
|
@ -32,17 +32,20 @@ import java.util.ResourceBundle;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
|
||||
/**
|
||||
* This feature is not yet in its final state and should be considered an internal part of HAPI for now - use with caution
|
||||
*/
|
||||
public class HapiLocalizer {
|
||||
|
||||
public static final String UNKNOWN_I18N_KEY_MESSAGE = "!MESSAGE!";
|
||||
private static boolean ourFailOnMissingMessage;
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(HapiLocalizer.class);
|
||||
private List<ResourceBundle> myBundle = new ArrayList<ResourceBundle>();
|
||||
public static final String UNKNOWN_I18N_KEY_MESSAGE = "!MESSAGE!";
|
||||
|
||||
private final Map<String, MessageFormat> myKeyToMessageFormat = new ConcurrentHashMap<String, MessageFormat>();
|
||||
private List<ResourceBundle> myBundle = new ArrayList<ResourceBundle>();
|
||||
private String[] myBundleNames;
|
||||
private final Map<String, MessageFormat> myKeyToMessageFormat = new ConcurrentHashMap<String, MessageFormat>();
|
||||
|
||||
public HapiLocalizer() {
|
||||
this(HapiLocalizer.class.getPackage().getName() + ".hapi-messages");
|
||||
|
@ -53,12 +56,6 @@ public class HapiLocalizer {
|
|||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
for (String nextName : myBundleNames) {
|
||||
myBundle.add(ResourceBundle.getBundle(nextName));
|
||||
}
|
||||
}
|
||||
|
||||
private String findFormatString(String theQualifiedKey) {
|
||||
String formatString = null;
|
||||
for (ResourceBundle nextBundle : myBundle) {
|
||||
|
@ -72,11 +69,25 @@ public class HapiLocalizer {
|
|||
|
||||
if (formatString == null) {
|
||||
ourLog.warn("Unknown localization key: {}", theQualifiedKey);
|
||||
if (ourFailOnMissingMessage) {
|
||||
throw new ConfigurationException("Unknown localization key: " + theQualifiedKey);
|
||||
}
|
||||
formatString = UNKNOWN_I18N_KEY_MESSAGE;
|
||||
}
|
||||
return formatString;
|
||||
}
|
||||
|
||||
public Set<String> getAllKeys(){
|
||||
HashSet<String> retVal = new HashSet<String>();
|
||||
for (ResourceBundle nextBundle : myBundle) {
|
||||
Enumeration<String> keysEnum = nextBundle.getKeys();
|
||||
while (keysEnum.hasMoreElements()) {
|
||||
retVal.add(keysEnum.nextElement());
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public String getMessage(Class<?> theType, String theKey, Object... theParameters) {
|
||||
return getMessage(theType.getName() + '.' + theKey, theParameters);
|
||||
}
|
||||
|
@ -97,16 +108,20 @@ public class HapiLocalizer {
|
|||
String retVal = findFormatString(theQualifiedKey);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public Set<String> getAllKeys(){
|
||||
HashSet<String> retVal = new HashSet<String>();
|
||||
for (ResourceBundle nextBundle : myBundle) {
|
||||
Enumeration<String> keysEnum = nextBundle.getKeys();
|
||||
while (keysEnum.hasMoreElements()) {
|
||||
retVal.add(keysEnum.nextElement());
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
for (String nextName : myBundleNames) {
|
||||
myBundle.add(ResourceBundle.getBundle(nextName));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* This <b>global setting</b> causes the localizer to fail if any attempts
|
||||
* are made to retrieve a key that does not exist. This method is primarily for
|
||||
* unit tests.
|
||||
*/
|
||||
public static void setOurFailOnMissingMessage(boolean ourFailOnMissingMessage) {
|
||||
HapiLocalizer.ourFailOnMissingMessage = ourFailOnMissingMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,453 +0,0 @@
|
|||
package ca.uhn.fhir.model.api;
|
||||
|
||||
/*
|
||||
* #%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 static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.base.resource.ResourceMetadataMap;
|
||||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.IntegerDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
public class Bundle extends BaseBundle /* implements IBase implements IElement */{
|
||||
|
||||
private static final long serialVersionUID = 5811989173275366745L;
|
||||
private ResourceMetadataMap myResourceMetadata;
|
||||
private BoundCodeDt<BundleTypeEnum> myType;
|
||||
private StringDt myBundleId;
|
||||
private TagList myCategories;
|
||||
private List<BundleEntry> myEntries;
|
||||
private volatile transient Map<IdDt, IResource> myIdToEntries;
|
||||
private StringDt myLinkBase;
|
||||
private StringDt myLinkFirst;
|
||||
private StringDt myLinkLast;
|
||||
private StringDt myLinkNext;
|
||||
private StringDt myLinkPrevious;
|
||||
private StringDt myLinkSelf;
|
||||
private StringDt myTitle;
|
||||
private IntegerDt myTotalResults;
|
||||
|
||||
/**
|
||||
* @deprecated Tags wil become immutable in a future release of HAPI, so
|
||||
* {@link #addCategory(String, String, String)} should be used instead
|
||||
*/
|
||||
@Deprecated
|
||||
public Tag addCategory() {
|
||||
Tag retVal = new Tag();
|
||||
getCategories().add(retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public void addCategory(String theScheme, String theTerm, String theLabel) {
|
||||
getCategories().add(new Tag(theScheme, theTerm, theLabel));
|
||||
}
|
||||
|
||||
public void addCategory(Tag theTag) {
|
||||
getCategories().add(theTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds and returns a new bundle entry
|
||||
*/
|
||||
public BundleEntry addEntry() {
|
||||
BundleEntry retVal = new BundleEntry();
|
||||
getEntries().add(retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new entry
|
||||
*
|
||||
* @param theBundleEntry
|
||||
* The entry to add
|
||||
*/
|
||||
public void addEntry(BundleEntry theBundleEntry) {
|
||||
Validate.notNull(theBundleEntry, "theBundleEntry can not be null");
|
||||
getEntries().add(theBundleEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new entry using the given resource and populates it accordingly
|
||||
*
|
||||
* @param theResource
|
||||
* The resource to add
|
||||
* @return Returns the newly created bundle entry that was added to the bundle
|
||||
*/
|
||||
public BundleEntry addResource(IResource theResource, FhirContext theContext, String theServerBase) {
|
||||
BundleEntry entry = addEntry();
|
||||
entry.setResource(theResource);
|
||||
|
||||
RuntimeResourceDefinition def = theContext.getResourceDefinition(theResource);
|
||||
|
||||
String title = ResourceMetadataKeyEnum.TITLE.get(theResource);
|
||||
if (title != null) {
|
||||
entry.getTitle().setValue(title);
|
||||
} else {
|
||||
entry.getTitle().setValue(def.getName() + " " + StringUtils.defaultString(theResource.getId().getValue(), "(no ID)"));
|
||||
}
|
||||
|
||||
if (theResource.getId() != null) {
|
||||
if (theResource.getId().isAbsolute()) {
|
||||
|
||||
entry.getLinkSelf().setValue(theResource.getId().getValue());
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
entry.getId().setValue(theResource.getId().toVersionless().getValue());
|
||||
|
||||
} else if (StringUtils.isNotBlank(theResource.getId().getValue())) {
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(theServerBase);
|
||||
if (b.length() > 0 && b.charAt(b.length() - 1) != '/') {
|
||||
b.append('/');
|
||||
}
|
||||
b.append(def.getName());
|
||||
b.append('/');
|
||||
String resId = theResource.getId().getIdPart();
|
||||
b.append(resId);
|
||||
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
entry.getId().setValue(b.toString());
|
||||
|
||||
if (isNotBlank(theResource.getId().getVersionIdPart())) {
|
||||
b.append('/');
|
||||
b.append(Constants.PARAM_HISTORY);
|
||||
b.append('/');
|
||||
b.append(theResource.getId().getVersionIdPart());
|
||||
} else {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
IdDt versionId = (IdDt) ResourceMetadataKeyEnum.VERSION_ID.get(theResource);
|
||||
if (versionId != null) {
|
||||
b.append('/');
|
||||
b.append(Constants.PARAM_HISTORY);
|
||||
b.append('/');
|
||||
b.append(versionId.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
String qualifiedId = b.toString();
|
||||
entry.getLinkSelf().setValue(qualifiedId);
|
||||
|
||||
// String resourceType = theContext.getResourceDefinition(theResource).getName();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
InstantDt published = ResourceMetadataKeyEnum.PUBLISHED.get(theResource);
|
||||
if (published == null) {
|
||||
entry.getPublished().setToCurrentTimeInLocalTimeZone();
|
||||
} else {
|
||||
entry.setPublished(published);
|
||||
}
|
||||
|
||||
InstantDt updated = ResourceMetadataKeyEnum.UPDATED.get(theResource);
|
||||
if (updated != null) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
entry.setUpdated(updated);
|
||||
}
|
||||
|
||||
InstantDt deleted = ResourceMetadataKeyEnum.DELETED_AT.get(theResource);
|
||||
if (deleted != null) {
|
||||
entry.setDeleted(deleted);
|
||||
}
|
||||
|
||||
IdDt previous = ResourceMetadataKeyEnum.PREVIOUS_ID.get(theResource);
|
||||
if (previous != null) {
|
||||
entry.getLinkAlternate().setValue(previous.withServerBase(theServerBase, def.getName()).getValue());
|
||||
}
|
||||
|
||||
TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(theResource);
|
||||
if (tagList != null) {
|
||||
for (Tag nextTag : tagList) {
|
||||
entry.addCategory(nextTag);
|
||||
}
|
||||
}
|
||||
|
||||
String linkSearch = ResourceMetadataKeyEnum.LINK_SEARCH.get(theResource);
|
||||
if (isNotBlank(linkSearch)) {
|
||||
if (!UrlUtil.isAbsolute(linkSearch)) {
|
||||
linkSearch = (theServerBase + "/" + linkSearch);
|
||||
}
|
||||
entry.getLinkSearch().setValue(linkSearch);
|
||||
}
|
||||
|
||||
String linkAlternate = ResourceMetadataKeyEnum.LINK_ALTERNATE.get(theResource);
|
||||
if (isNotBlank(linkAlternate)) {
|
||||
if (!UrlUtil.isAbsolute(linkAlternate)) {
|
||||
linkSearch = (theServerBase + "/" + linkAlternate);
|
||||
}
|
||||
entry.getLinkAlternate().setValue(linkSearch);
|
||||
}
|
||||
|
||||
BundleEntrySearchModeEnum entryStatus = ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(theResource);
|
||||
if (entryStatus != null) {
|
||||
entry.getSearchMode().setValueAsEnum(entryStatus);
|
||||
}
|
||||
|
||||
BundleEntryTransactionMethodEnum entryTransactionOperation = ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get(theResource);
|
||||
if (entryTransactionOperation != null) {
|
||||
entry.getTransactionMethod().setValueAsEnum(entryTransactionOperation);
|
||||
}
|
||||
|
||||
DecimalDt entryScore = ResourceMetadataKeyEnum.ENTRY_SCORE.get(theResource);
|
||||
if (entryScore != null) {
|
||||
entry.setScore(entryScore);
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
public StringDt getBundleId() {
|
||||
if (myBundleId == null) {
|
||||
myBundleId = new StringDt();
|
||||
}
|
||||
return myBundleId;
|
||||
}
|
||||
|
||||
public TagList getCategories() {
|
||||
if (myCategories == null) {
|
||||
myCategories = new TagList();
|
||||
}
|
||||
return myCategories;
|
||||
}
|
||||
|
||||
public List<BundleEntry> getEntries() {
|
||||
if (myEntries == null) {
|
||||
myEntries = new ArrayList<BundleEntry>();
|
||||
}
|
||||
return myEntries;
|
||||
}
|
||||
|
||||
public StringDt getLinkBase() {
|
||||
if (myLinkBase == null) {
|
||||
myLinkBase = new StringDt();
|
||||
}
|
||||
return myLinkBase;
|
||||
}
|
||||
|
||||
public StringDt getLinkFirst() {
|
||||
if (myLinkFirst == null) {
|
||||
myLinkFirst = new StringDt();
|
||||
}
|
||||
return myLinkFirst;
|
||||
}
|
||||
|
||||
public StringDt getLinkLast() {
|
||||
if (myLinkLast == null) {
|
||||
myLinkLast = new StringDt();
|
||||
}
|
||||
return myLinkLast;
|
||||
}
|
||||
|
||||
public StringDt getLinkNext() {
|
||||
if (myLinkNext == null) {
|
||||
myLinkNext = new StringDt();
|
||||
}
|
||||
return myLinkNext;
|
||||
}
|
||||
|
||||
public StringDt getLinkPrevious() {
|
||||
if (myLinkPrevious == null) {
|
||||
myLinkPrevious = new StringDt();
|
||||
}
|
||||
return myLinkPrevious;
|
||||
}
|
||||
|
||||
public StringDt getLinkSelf() {
|
||||
if (myLinkSelf == null) {
|
||||
myLinkSelf = new StringDt();
|
||||
}
|
||||
return myLinkSelf;
|
||||
}
|
||||
|
||||
/*
|
||||
public InstantDt getPublished() {
|
||||
InstantDt retVal = (InstantDt) getResourceMetadata().get(ResourceMetadataKeyEnum.PUBLISHED);
|
||||
if (retVal == null) {
|
||||
retVal= new InstantDt();
|
||||
getResourceMetadata().put(ResourceMetadataKeyEnum.PUBLISHED, retVal);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retrieves a resource from a bundle given its logical ID.
|
||||
* <p>
|
||||
* <b>Important usage notes</b>: This method ignores base URLs (so passing in an ID of
|
||||
* <code>http://foo/Patient/123</code> will return a resource if it has the logical ID of
|
||||
* <code>http://bar/Patient/123</code>. Also, this method is intended to be used for bundles which have already been
|
||||
* populated. It will cache its results for fast performance, but that means that modifications to the bundle after
|
||||
* this method is called may not be accurately reflected.
|
||||
* </p>
|
||||
*
|
||||
* @param theId
|
||||
* The resource ID
|
||||
* @return Returns the resource with the given ID, or <code>null</code> if none is found
|
||||
*/
|
||||
public IResource getResourceById(IdDt theId) {
|
||||
Map<IdDt, IResource> map = myIdToEntries;
|
||||
if (map == null) {
|
||||
map = new HashMap<IdDt, IResource>();
|
||||
for (BundleEntry next : this.getEntries()) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
if (next.getId().isEmpty() == false) {
|
||||
map.put(next.getId().toUnqualified(), next.getResource());
|
||||
}
|
||||
}
|
||||
myIdToEntries = map;
|
||||
}
|
||||
return map.get(theId.toUnqualified());
|
||||
}
|
||||
|
||||
public ResourceMetadataMap getResourceMetadata() {
|
||||
if (myResourceMetadata == null) {
|
||||
myResourceMetadata = new ResourceMetadataMap();
|
||||
}
|
||||
return myResourceMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing all resources of the given type from this bundle
|
||||
*/
|
||||
public <T extends IResource> List<T> getResources(Class<T> theClass) {
|
||||
ArrayList<T> retVal = new ArrayList<T>();
|
||||
for (BundleEntry next : getEntries()) {
|
||||
if (next.getResource() != null && theClass.isAssignableFrom(next.getResource().getClass())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T resource = (T) next.getResource();
|
||||
retVal.add(resource);
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public StringDt getTitle() {
|
||||
if (myTitle == null) {
|
||||
myTitle = new StringDt();
|
||||
}
|
||||
return myTitle;
|
||||
}
|
||||
|
||||
public IntegerDt getTotalResults() {
|
||||
if (myTotalResults == null) {
|
||||
myTotalResults = new IntegerDt();
|
||||
}
|
||||
return myTotalResults;
|
||||
}
|
||||
|
||||
public BoundCodeDt<BundleTypeEnum> getType() {
|
||||
if (myType == null) {
|
||||
myType = new BoundCodeDt<BundleTypeEnum>(BundleTypeEnum.VALUESET_BINDER);
|
||||
}
|
||||
return myType;
|
||||
}
|
||||
|
||||
public InstantDt getUpdated() {
|
||||
InstantDt retVal = (InstantDt) getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED);
|
||||
if (retVal == null) {
|
||||
retVal= new InstantDt();
|
||||
getResourceMetadata().put(ResourceMetadataKeyEnum.UPDATED, retVal);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this bundle contains zero entries
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return getEntries().isEmpty();
|
||||
}
|
||||
|
||||
public void setCategories(TagList theCategories) {
|
||||
myCategories = theCategories;
|
||||
}
|
||||
|
||||
/*
|
||||
public void setPublished(InstantDt thePublished) {
|
||||
getResourceMetadata().put(ResourceMetadataKeyEnum.PUBLISHED, thePublished);
|
||||
}
|
||||
*/
|
||||
|
||||
public void setType(BoundCodeDt<BundleTypeEnum> theType) {
|
||||
myType = theType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of entries in this bundle
|
||||
*/
|
||||
public int size() {
|
||||
return getEntries().size();
|
||||
}
|
||||
|
||||
public List<IResource> toListOfResources() {
|
||||
ArrayList<IResource> retVal = new ArrayList<IResource>();
|
||||
for (BundleEntry next : getEntries()) {
|
||||
if (next.getResource() != null) {
|
||||
retVal.add(next.getResource());
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
b.append(getEntries().size() + " entries");
|
||||
b.append("id", getId());
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public static Bundle withResources(List<IResource> theResources, FhirContext theContext, String theServerBase) {
|
||||
Bundle retVal = new Bundle();
|
||||
for (IResource next : theResources) {
|
||||
retVal.addResource(next, theContext, theServerBase);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static Bundle withSingleResource(IResource theResource) {
|
||||
Bundle retVal = new Bundle();
|
||||
retVal.addEntry().setResource(theResource);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,382 +0,0 @@
|
|||
package ca.uhn.fhir.model.api;
|
||||
|
||||
/*
|
||||
* #%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 org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
|
||||
import ca.uhn.fhir.util.ElementUtil;
|
||||
|
||||
public class BundleEntry extends BaseBundle {
|
||||
|
||||
private static final long serialVersionUID = 2635639739195593736L;
|
||||
//@formatter:off
|
||||
/* ****************************************************
|
||||
* NB: add any new fields to the isEmpty() method!!!
|
||||
*****************************************************/
|
||||
//@formatter:on
|
||||
private TagList myCategories;
|
||||
private InstantDt myDeletedAt;
|
||||
private StringDt myDeletedByEmail;
|
||||
private StringDt myDeletedByName;
|
||||
private StringDt myDeletedComment;
|
||||
private IdDt myDeletedResourceId;
|
||||
private CodeDt myDeletedResourceType;
|
||||
private StringDt myDeletedResourceVersion;
|
||||
private StringDt myLinkAlternate;
|
||||
private StringDt myLinkBase;
|
||||
private StringDt myLinkSearch;
|
||||
private StringDt myLinkSelf;
|
||||
private InstantDt myPublished;
|
||||
private IResource myResource;
|
||||
private DecimalDt myScore;
|
||||
private BoundCodeDt<BundleEntrySearchModeEnum> mySearchMode;
|
||||
private BoundCodeDt<BundleEntryTransactionMethodEnum> myTransactionOperation;
|
||||
private XhtmlDt mySummary;
|
||||
private StringDt myTitle;
|
||||
private InstantDt myUpdated;
|
||||
|
||||
/**
|
||||
* @deprecated Tags wil become immutable in a future release of HAPI, so
|
||||
* {@link #addCategory(String, String, String)} should be used instead
|
||||
*/
|
||||
@Deprecated
|
||||
public Tag addCategory() {
|
||||
Tag retVal = new Tag();
|
||||
getCategories().add(retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public void addCategory(String theScheme, String theTerm, String theLabel) {
|
||||
getCategories().add(new Tag(theScheme, theTerm, theLabel));
|
||||
}
|
||||
|
||||
public void addCategory(Tag theTag) {
|
||||
getCategories().add(theTag);
|
||||
}
|
||||
|
||||
public TagList getCategories() {
|
||||
if (myCategories == null) {
|
||||
myCategories = new TagList();
|
||||
}
|
||||
return myCategories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the date/time that thius entry was deleted.
|
||||
*/
|
||||
public InstantDt getDeletedAt() {
|
||||
if (myDeletedAt == null) {
|
||||
myDeletedAt = new InstantDt();
|
||||
}
|
||||
return myDeletedAt;
|
||||
}
|
||||
|
||||
public StringDt getDeletedByEmail() {
|
||||
if (myDeletedByEmail == null) {
|
||||
myDeletedByEmail = new StringDt();
|
||||
}
|
||||
return myDeletedByEmail;
|
||||
}
|
||||
|
||||
public StringDt getDeletedByName() {
|
||||
if (myDeletedByName == null) {
|
||||
myDeletedByName = new StringDt();
|
||||
}
|
||||
return myDeletedByName;
|
||||
}
|
||||
|
||||
public StringDt getDeletedComment() {
|
||||
if (myDeletedComment == null) {
|
||||
myDeletedComment = new StringDt();
|
||||
}
|
||||
return myDeletedComment;
|
||||
}
|
||||
|
||||
public IdDt getDeletedResourceId() {
|
||||
if (myDeletedResourceId == null) {
|
||||
myDeletedResourceId = new IdDt();
|
||||
}
|
||||
return myDeletedResourceId;
|
||||
}
|
||||
|
||||
public CodeDt getDeletedResourceType() {
|
||||
if (myDeletedResourceType == null) {
|
||||
myDeletedResourceType = new CodeDt();
|
||||
}
|
||||
return myDeletedResourceType;
|
||||
}
|
||||
|
||||
public StringDt getDeletedResourceVersion() {
|
||||
if (myDeletedResourceVersion == null) {
|
||||
myDeletedResourceVersion = new StringDt();
|
||||
}
|
||||
return myDeletedResourceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Setting IDs on bundle entries is redundant since resources already have an ID field. Instead of
|
||||
* providing an ID using this method, set the ID on the resource using {@link IResource#setId(IdDt)} or
|
||||
* if this entry represents a deleted resource, use {@link #setDeletedResourceId(IdDt)}.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public IdDt getId() {
|
||||
return super.getId();
|
||||
}
|
||||
|
||||
public StringDt getLinkAlternate() {
|
||||
if (myLinkAlternate == null) {
|
||||
myLinkAlternate = new StringDt();
|
||||
}
|
||||
return myLinkAlternate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use resource ID to determine base URL
|
||||
*/
|
||||
@Deprecated
|
||||
public StringDt getLinkBase() {
|
||||
if (myLinkBase == null) {
|
||||
myLinkBase = new StringDt();
|
||||
}
|
||||
return myLinkBase;
|
||||
}
|
||||
|
||||
public StringDt getLinkSearch() {
|
||||
if (myLinkSearch == null) {
|
||||
myLinkSearch = new StringDt();
|
||||
}
|
||||
return myLinkSearch;
|
||||
}
|
||||
|
||||
public StringDt getLinkSelf() {
|
||||
if (myLinkSelf == null) {
|
||||
myLinkSelf = new StringDt();
|
||||
}
|
||||
return myLinkSelf;
|
||||
}
|
||||
|
||||
public InstantDt getPublished() {
|
||||
if (myPublished == null) {
|
||||
myPublished = new InstantDt();
|
||||
}
|
||||
return myPublished;
|
||||
}
|
||||
|
||||
public IResource getResource() {
|
||||
return myResource;
|
||||
}
|
||||
|
||||
public DecimalDt getScore() {
|
||||
if (myScore == null) {
|
||||
myScore = new DecimalDt();
|
||||
}
|
||||
return myScore;
|
||||
}
|
||||
|
||||
|
||||
public XhtmlDt getSummary() {
|
||||
if (mySummary == null) {
|
||||
mySummary = new XhtmlDt();
|
||||
}
|
||||
return mySummary;
|
||||
}
|
||||
|
||||
public StringDt getTitle() {
|
||||
if (myTitle == null) {
|
||||
myTitle = new StringDt();
|
||||
}
|
||||
return myTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata
|
||||
* has been moved to the resource <meta/> element so it is redundant here). In preparation for
|
||||
* DSTU2, it is recommended that you migrate code away from using this method and over to using resource
|
||||
* metadata instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public InstantDt getUpdated() {
|
||||
if (myUpdated == null) {
|
||||
myUpdated = new InstantDt();
|
||||
}
|
||||
if (myUpdated.isEmpty() && myResource != null) {
|
||||
InstantDt resourceUpdated = ResourceMetadataKeyEnum.UPDATED.get(myResource);
|
||||
if (resourceUpdated != null && !resourceUpdated.isEmpty()) {
|
||||
return resourceUpdated;
|
||||
}
|
||||
}
|
||||
return myUpdated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
//@formatter:off
|
||||
return super.isEmpty() &&
|
||||
ElementUtil.isEmpty(
|
||||
myDeletedResourceId, myDeletedResourceType, myDeletedResourceVersion, myDeletedAt,
|
||||
myScore, mySearchMode, myTransactionOperation, myCategories,
|
||||
myLinkAlternate, myLinkSelf, myPublished, myResource, mySummary,
|
||||
myTitle, myUpdated, myDeletedByEmail, myDeletedByName, myDeletedComment);
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the date/time that this entry was deleted.
|
||||
*/
|
||||
public void setDeleted(InstantDt theDeletedAt) {
|
||||
myDeletedAt = theDeletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedByEmail(StringDt theDeletedByEmail) {
|
||||
myDeletedByEmail = theDeletedByEmail;
|
||||
}
|
||||
|
||||
public void setDeletedByName(StringDt theDeletedByName) {
|
||||
if (myDeletedByName == null) {
|
||||
myDeletedByName = new StringDt();
|
||||
}
|
||||
myDeletedByName = theDeletedByName;
|
||||
}
|
||||
|
||||
public void setDeletedComment(StringDt theDeletedComment) {
|
||||
myDeletedComment = theDeletedComment;
|
||||
}
|
||||
|
||||
public void setDeletedResourceId(IdDt theDeletedResourceId) {
|
||||
myDeletedResourceId = theDeletedResourceId;
|
||||
}
|
||||
|
||||
public void setDeletedResourceType(CodeDt theDeletedResourceType) {
|
||||
myDeletedResourceType = theDeletedResourceType;
|
||||
}
|
||||
|
||||
public void setDeletedResourceVersion(StringDt theDeletedResourceVersion) {
|
||||
myDeletedResourceVersion = theDeletedResourceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Bundle entries no longer have an ID in DSTU2, as ID is explicitly stated in the resource itself.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setId(IdDt theId) {
|
||||
super.setId(theId);
|
||||
}
|
||||
|
||||
public void setLinkAlternate(StringDt theLinkAlternate) {
|
||||
myLinkAlternate = theLinkAlternate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use resource ID to determine base URL
|
||||
*/
|
||||
@Deprecated
|
||||
public void setLinkBase(StringDt theLinkBase) {
|
||||
myLinkBase = theLinkBase;
|
||||
}
|
||||
|
||||
public void setLinkSearch(StringDt theLinkSearch) {
|
||||
myLinkSearch = theLinkSearch;
|
||||
}
|
||||
|
||||
public void setLinkSelf(StringDt theLinkSelf) {
|
||||
if (myLinkSelf == null) {
|
||||
myLinkSelf = new StringDt();
|
||||
}
|
||||
myLinkSelf = theLinkSelf;
|
||||
}
|
||||
|
||||
public void setPublished(InstantDt thePublished) {
|
||||
Validate.notNull(thePublished, "Published may not be null");
|
||||
myPublished = thePublished;
|
||||
}
|
||||
|
||||
public void setResource(IResource theResource) {
|
||||
myResource = theResource;
|
||||
}
|
||||
|
||||
public void setScore(DecimalDt theScore) {
|
||||
myScore = theScore;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated <b>DSTU2 Note:</b> As of DSTU2, bundle entries no longer have an updated time (this bit of metadata
|
||||
* has been moved to the resource <meta/> element so it is redundant here). In preparation for
|
||||
* DSTU2, it is recommended that you migrate code away from using this method and over to using resource
|
||||
* metadata instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setUpdated(InstantDt theUpdated) {
|
||||
Validate.notNull(theUpdated, "Updated may not be null");
|
||||
myUpdated = theUpdated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
if (getResource() != null) {
|
||||
b.append("type", getResource().getClass().getSimpleName());
|
||||
} else {
|
||||
b.append("No resource");
|
||||
}
|
||||
b.append("id", getId());
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public BoundCodeDt<BundleEntrySearchModeEnum> getSearchMode() {
|
||||
if (mySearchMode == null) {
|
||||
mySearchMode = new BoundCodeDt<BundleEntrySearchModeEnum>(BundleEntrySearchModeEnum.VALUESET_BINDER);
|
||||
}
|
||||
return mySearchMode;
|
||||
}
|
||||
|
||||
public void setSearchMode(BoundCodeDt<BundleEntrySearchModeEnum> theSearchMode) {
|
||||
mySearchMode = theSearchMode;
|
||||
}
|
||||
|
||||
public BoundCodeDt<BundleEntryTransactionMethodEnum> getTransactionMethod() {
|
||||
if (myTransactionOperation == null) {
|
||||
myTransactionOperation = new BoundCodeDt<BundleEntryTransactionMethodEnum>(BundleEntryTransactionMethodEnum.VALUESET_BINDER);
|
||||
}
|
||||
return myTransactionOperation;
|
||||
}
|
||||
|
||||
public void setTransactionMethod(BoundCodeDt<BundleEntryTransactionMethodEnum> theTransactionOperation) {
|
||||
myTransactionOperation = theTransactionOperation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ package ca.uhn.fhir.model.api;
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -23,29 +23,24 @@ package ca.uhn.fhir.model.api;
|
|||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.context.*;
|
||||
import ca.uhn.fhir.context.support.IContextValidationSupport;
|
||||
import ca.uhn.fhir.fluentpath.IFluentPath;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
|
||||
import ca.uhn.fhir.rest.server.IVersionSpecificBundleFactory;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
import ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory;
|
||||
|
||||
/**
|
||||
* Each structure version JAR will have an implementation of this interface.
|
||||
* This is used internally by HAPI and subject to change. Do not use this interface
|
||||
* directly in user code.
|
||||
*
|
||||
* See also IFhirVersionServer for the hapi-fhir-server equivalent.
|
||||
*/
|
||||
public interface IFhirVersion {
|
||||
|
||||
IFluentPath createFluentPathExecutor(FhirContext theFhirContext);
|
||||
|
||||
IServerConformanceProvider<? extends IBaseResource> createServerConformanceProvider(RestfulServer theRestfulServer);
|
||||
|
||||
IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer);
|
||||
|
||||
|
||||
IContextValidationSupport<?, ?, ?, ?, ?, ?> createValidationSupport();
|
||||
|
||||
IBaseResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase);
|
||||
|
@ -68,4 +63,11 @@ public interface IFhirVersion {
|
|||
|
||||
IIdType newIdType();
|
||||
|
||||
/**
|
||||
* Returns an instance of <code>IFhirVersionServer<code> for this version.
|
||||
* Note that this method may only be called if the <code>hapi-fhir-server</code>
|
||||
* JAR is on the classpath. Otherwise it will result in a {@link ClassNotFoundException}
|
||||
*/
|
||||
Object getServerVersion();
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.method.QualifiedParamList;
|
||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
|
||||
public interface IQueryParameterAnd<T extends IQueryParameterOr<?>> extends Serializable {
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.method.QualifiedParamList;
|
||||
import ca.uhn.fhir.rest.api.QualifiedParamList;
|
||||
|
||||
public interface IQueryParameterOr<T extends IQueryParameterType> extends Serializable {
|
||||
|
||||
|
|
|
@ -25,21 +25,14 @@ import java.math.BigDecimal;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.BaseIdentifiableElement;
|
||||
import ca.uhn.fhir.model.api.ICompositeDatatype;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
|
||||
import ca.uhn.fhir.model.primitive.BoundCodeDt;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.DecimalDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.model.api.*;
|
||||
import ca.uhn.fhir.model.primitive.*;
|
||||
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
||||
import ca.uhn.fhir.rest.param.QuantityParam;
|
||||
|
||||
public abstract class BaseQuantityDt extends BaseIdentifiableElement implements ICompositeDatatype, IQueryParameterType {
|
||||
|
||||
private static final long serialVersionUID = -925486613033086056L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Sets the value(s) for <b>value</b> (Numerical value (with implicit precision))
|
||||
|
@ -65,21 +58,21 @@ public abstract class BaseQuantityDt extends BaseIdentifiableElement implements
|
|||
}
|
||||
String[] parts = theValue.split("\\|");
|
||||
if (parts.length > 0 && StringUtils.isNotBlank(parts[0])) {
|
||||
if (parts[0].startsWith("<=")) {
|
||||
if (parts[0].startsWith("le")) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
getComparatorElement().setValue(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS.getCode());
|
||||
getComparatorElement().setValue(ParamPrefixEnum.LESSTHAN_OR_EQUALS.getValue());
|
||||
setValue(new BigDecimal(parts[0].substring(2)));
|
||||
} else if (parts[0].startsWith("<")) {
|
||||
} else if (parts[0].startsWith("lt")) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
getComparatorElement().setValue(QuantityCompararatorEnum.LESSTHAN.getCode());
|
||||
getComparatorElement().setValue(ParamPrefixEnum.LESSTHAN.getValue());
|
||||
setValue(new BigDecimal(parts[0].substring(1)));
|
||||
} else if (parts[0].startsWith(">=")) {
|
||||
} else if (parts[0].startsWith("ge")) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
getComparatorElement().setValue(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS.getCode());
|
||||
getComparatorElement().setValue(ParamPrefixEnum.GREATERTHAN_OR_EQUALS.getValue());
|
||||
setValue(new BigDecimal(parts[0].substring(2)));
|
||||
} else if (parts[0].startsWith(">")) {
|
||||
} else if (parts[0].startsWith("gt")) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
getComparatorElement().setValue(QuantityCompararatorEnum.GREATERTHAN.getCode());
|
||||
getComparatorElement().setValue(ParamPrefixEnum.GREATERTHAN.getValue());
|
||||
setValue(new BigDecimal(parts[0].substring(1)));
|
||||
} else {
|
||||
setValue(new BigDecimal(parts[0]));
|
||||
|
|
|
@ -1,159 +0,0 @@
|
|||
|
||||
package ca.uhn.fhir.model.dstu.valueset;
|
||||
|
||||
/*
|
||||
* #%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.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
|
||||
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
||||
import ca.uhn.fhir.util.CoverageIgnore;
|
||||
|
||||
/**
|
||||
* @deprecated This class has been replaced by {@link ParamPrefixEnum} in HAPI FHIR 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
@CoverageIgnore
|
||||
public enum QuantityCompararatorEnum {
|
||||
|
||||
/**
|
||||
* Code Value: <b><</b>
|
||||
*
|
||||
* The actual value is less than the given value.
|
||||
*/
|
||||
LESSTHAN("<", "http://hl7.org/fhir/quantity-comparator"),
|
||||
|
||||
/**
|
||||
* Code Value: <b><=</b>
|
||||
*
|
||||
* The actual value is less than or equal to the given value.
|
||||
*/
|
||||
LESSTHAN_OR_EQUALS("<=", "http://hl7.org/fhir/quantity-comparator"),
|
||||
|
||||
/**
|
||||
* Code Value: <b>>=</b>
|
||||
*
|
||||
* The actual value is greater than or equal to the given value.
|
||||
*/
|
||||
GREATERTHAN_OR_EQUALS(">=", "http://hl7.org/fhir/quantity-comparator"),
|
||||
|
||||
/**
|
||||
* Code Value: <b>></b>
|
||||
*
|
||||
* The actual value is greater than the given value.
|
||||
*/
|
||||
GREATERTHAN(">", "http://hl7.org/fhir/quantity-comparator"),
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Identifier for this Value Set:
|
||||
* http://hl7.org/fhir/vs/quantity-comparator
|
||||
*/
|
||||
public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/quantity-comparator";
|
||||
|
||||
/**
|
||||
* Name for this Value Set:
|
||||
* QuantityCompararator
|
||||
*/
|
||||
public static final String VALUESET_NAME = "QuantityCompararator";
|
||||
|
||||
private static Map<String, QuantityCompararatorEnum> CODE_TO_ENUM = new HashMap<String, QuantityCompararatorEnum>();
|
||||
private static Map<String, Map<String, QuantityCompararatorEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, QuantityCompararatorEnum>>();
|
||||
|
||||
private final String myCode;
|
||||
private final String mySystem;
|
||||
|
||||
static {
|
||||
for (QuantityCompararatorEnum next : QuantityCompararatorEnum.values()) {
|
||||
CODE_TO_ENUM.put(next.getCode(), next);
|
||||
|
||||
if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
|
||||
SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, QuantityCompararatorEnum>());
|
||||
}
|
||||
SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the code associated with this enumerated value
|
||||
*/
|
||||
public String getCode() {
|
||||
return myCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the code system associated with this enumerated value
|
||||
*/
|
||||
public String getSystem() {
|
||||
return mySystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumerated value associated with this code
|
||||
*/
|
||||
public static QuantityCompararatorEnum forCode(String theCode) {
|
||||
QuantityCompararatorEnum retVal = CODE_TO_ENUM.get(theCode);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts codes to their respective enumerated values
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public static final IValueSetEnumBinder<QuantityCompararatorEnum> VALUESET_BINDER = new IValueSetEnumBinder<QuantityCompararatorEnum>() {
|
||||
@Override
|
||||
public String toCodeString(QuantityCompararatorEnum theEnum) {
|
||||
return theEnum.getCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSystemString(QuantityCompararatorEnum theEnum) {
|
||||
return theEnum.getSystem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuantityCompararatorEnum fromCodeString(String theCodeString) {
|
||||
return CODE_TO_ENUM.get(theCodeString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuantityCompararatorEnum fromCodeString(String theCodeString, String theSystemString) {
|
||||
Map<String, QuantityCompararatorEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
return map.get(theCodeString);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
QuantityCompararatorEnum(String theCode, String theSystem) {
|
||||
myCode = theCode;
|
||||
mySystem = theSystem;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ import org.apache.commons.codec.binary.Base64;
|
|||
import ca.uhn.fhir.model.api.BasePrimitive;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
|
||||
@DatatypeDef(name = "base64Binary")
|
||||
public class Base64BinaryDt extends BasePrimitive<byte[]> {
|
||||
|
|
|
@ -26,19 +26,15 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.*;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
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.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
|
||||
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
/**
|
||||
|
@ -305,11 +301,16 @@ public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdTy
|
|||
b.append(myResourceType);
|
||||
}
|
||||
|
||||
if (b.length() > 0) {
|
||||
if (b.length() > 0 && isNotBlank(myUnqualifiedId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
if (isNotBlank(myUnqualifiedId)) {
|
||||
b.append(myUnqualifiedId);
|
||||
} else if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
b.append(myUnqualifiedId);
|
||||
if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
b.append(Constants.PARAM_HISTORY);
|
||||
|
@ -385,7 +386,7 @@ public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdTy
|
|||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return isBlank(getValue());
|
||||
return super.isBaseEmpty() && isBlank(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -527,7 +528,21 @@ public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdTy
|
|||
if (typeIndex == -1) {
|
||||
myResourceType = theValue.substring(0, idIndex);
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
if (typeIndex > 0 && '/' == theValue.charAt(typeIndex - 1)) {
|
||||
typeIndex = theValue.indexOf('/', typeIndex + 1);
|
||||
}
|
||||
if (typeIndex >= idIndex) {
|
||||
// e.g. http://example.org/foo
|
||||
// 'foo' was the id but we're making that the resource type. Nullify the id part because we don't have an id.
|
||||
// Also set null value to the super.setValue() and enable myHaveComponentParts so it forces getValue() to properly
|
||||
// recreate the url
|
||||
myResourceType = myUnqualifiedId;
|
||||
myUnqualifiedId = null;
|
||||
super.setValue(null);
|
||||
myHaveComponentParts = true;
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
}
|
||||
|
||||
if (typeIndex > 4) {
|
||||
myBaseUrl = theValue.substring(0, typeIndex);
|
||||
|
|
|
@ -21,17 +21,12 @@ package ca.uhn.fhir.narrative;
|
|||
*/
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.INarrative;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
import org.thymeleaf.IEngineConfiguration;
|
||||
import org.thymeleaf.TemplateEngine;
|
||||
import org.thymeleaf.cache.AlwaysValidCacheEntryValidity;
|
||||
|
@ -44,9 +39,7 @@ import org.thymeleaf.processor.IProcessor;
|
|||
import org.thymeleaf.processor.element.AbstractAttributeTagProcessor;
|
||||
import org.thymeleaf.processor.element.IElementTagStructureHandler;
|
||||
import org.thymeleaf.standard.StandardDialect;
|
||||
import org.thymeleaf.standard.expression.IStandardExpression;
|
||||
import org.thymeleaf.standard.expression.IStandardExpressionParser;
|
||||
import org.thymeleaf.standard.expression.StandardExpressions;
|
||||
import org.thymeleaf.standard.expression.*;
|
||||
import org.thymeleaf.templatemode.TemplateMode;
|
||||
import org.thymeleaf.templateresolver.DefaultTemplateResolver;
|
||||
import org.thymeleaf.templateresource.ITemplateResource;
|
||||
|
@ -56,7 +49,7 @@ import ca.uhn.fhir.context.ConfigurationException;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.IDatatype;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
|
||||
public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGenerator {
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ package ca.uhn.fhir.narrative;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
public class DefaultThymeleafNarrativeGenerator extends BaseThymeleafNarrativeGenerator implements INarrativeGenerator {
|
||||
|
||||
public static final String NARRATIVES_PROPERTIES = "classpath:ca/uhn/fhir/narrative/narratives.properties";
|
||||
|
|
|
@ -22,60 +22,19 @@ package ca.uhn.fhir.parser;
|
|||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
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.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.instance.model.api.IBaseElement;
|
||||
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||
import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions;
|
||||
import org.hl7.fhir.instance.model.api.IBaseMetaType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||
import ca.uhn.fhir.context.*;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition.ChildTypeEnum;
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeChildChoiceDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeChildContainedResources;
|
||||
import ca.uhn.fhir.context.RuntimeChildNarrativeDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IIdentifiableElement;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.api.Tag;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.model.api.*;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
|
@ -347,44 +306,20 @@ public abstract class BaseParser implements IParser {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean isOverrideResourceIdWithBundleEntryFullUrl() {
|
||||
Boolean overrideResourceIdWithBundleEntryFullUrl = myOverrideResourceIdWithBundleEntryFullUrl;
|
||||
if (overrideResourceIdWithBundleEntryFullUrl != null) {
|
||||
return overrideResourceIdWithBundleEntryFullUrl;
|
||||
}
|
||||
|
||||
|
||||
return myContext.getParserOptions().isOverrideResourceIdWithBundleEntryFullUrl();
|
||||
}
|
||||
|
||||
protected abstract void doEncodeBundleToWriter(Bundle theBundle, Writer theWriter) throws IOException, DataFormatException;
|
||||
|
||||
protected abstract void doEncodeResourceToWriter(IBaseResource theResource, Writer theWriter) throws IOException, DataFormatException;
|
||||
|
||||
protected abstract <T extends IBaseResource> T doParseResource(Class<T> theResourceType, Reader theReader) throws DataFormatException;
|
||||
|
||||
@Override
|
||||
public String encodeBundleToString(Bundle theBundle) throws DataFormatException {
|
||||
if (theBundle == null) {
|
||||
throw new NullPointerException("Bundle can not be null");
|
||||
}
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
try {
|
||||
encodeBundleToWriter(theBundle, stringWriter);
|
||||
} catch (IOException e) {
|
||||
throw new Error("Encountered IOException during write to string - This should not happen!");
|
||||
}
|
||||
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void encodeBundleToWriter(Bundle theBundle, Writer theWriter) throws IOException, DataFormatException {
|
||||
Validate.notNull(theBundle, "theBundle must not be null");
|
||||
Validate.notNull(theWriter, "theWriter must not be null");
|
||||
doEncodeBundleToWriter(theBundle, theWriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeResourceToString(IBaseResource theResource) throws DataFormatException {
|
||||
Writer stringWriter = new StringWriter();
|
||||
|
@ -409,17 +344,6 @@ public abstract class BaseParser implements IParser {
|
|||
doEncodeResourceToWriter(theResource, theWriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeTagListToString(TagList theTagList) {
|
||||
Writer stringWriter = new StringWriter();
|
||||
try {
|
||||
encodeTagListToWriter(theTagList, stringWriter);
|
||||
} catch (IOException e) {
|
||||
throw new Error("Encountered IOException during write to string - This should not happen!");
|
||||
}
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
private void filterCodingsWithNoCodeOrSystem(List<? extends IBaseCoding> tagList) {
|
||||
for (int i = 0; i < tagList.size(); i++) {
|
||||
if (isBlank(tagList.get(i).getCode()) && isBlank(tagList.get(i).getSystem())) {
|
||||
|
@ -555,27 +479,25 @@ public abstract class BaseParser implements IParser {
|
|||
break;
|
||||
}
|
||||
|
||||
if (myContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1)) {
|
||||
RuntimeResourceDefinition nextDef = myContext.getResourceDefinition(theResource);
|
||||
String profile = nextDef.getResourceProfile(myServerBaseUrl);
|
||||
if (isNotBlank(profile)) {
|
||||
for (T next : theProfiles) {
|
||||
if (profile.equals(next.getValue())) {
|
||||
return theProfiles;
|
||||
}
|
||||
RuntimeResourceDefinition nextDef = myContext.getResourceDefinition(theResource);
|
||||
String profile = nextDef.getResourceProfile(myServerBaseUrl);
|
||||
if (isNotBlank(profile)) {
|
||||
for (T next : theProfiles) {
|
||||
if (profile.equals(next.getValue())) {
|
||||
return theProfiles;
|
||||
}
|
||||
|
||||
List<T> newList = new ArrayList<T>();
|
||||
newList.addAll(theProfiles);
|
||||
|
||||
BaseRuntimeElementDefinition<?> idElement = myContext.getElementDefinition("id");
|
||||
@SuppressWarnings("unchecked")
|
||||
T newId = (T) idElement.newInstance();
|
||||
newId.setValue(profile);
|
||||
|
||||
newList.add(newId);
|
||||
return newList;
|
||||
}
|
||||
|
||||
List<T> newList = new ArrayList<T>();
|
||||
newList.addAll(theProfiles);
|
||||
|
||||
BaseRuntimeElementDefinition<?> idElement = myContext.getElementDefinition("id");
|
||||
@SuppressWarnings("unchecked")
|
||||
T newId = (T) idElement.newInstance();
|
||||
newId.setValue(profile);
|
||||
|
||||
newList.add(newId);
|
||||
return newList;
|
||||
}
|
||||
|
||||
return theProfiles;
|
||||
|
@ -606,7 +528,7 @@ public abstract class BaseParser implements IParser {
|
|||
public Boolean getStripVersionsFromReferences() {
|
||||
return myStripVersionsFromReferences;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean getOverrideResourceIdWithBundleEntryFullUrl() {
|
||||
return myOverrideResourceIdWithBundleEntryFullUrl;
|
||||
|
@ -627,20 +549,6 @@ public abstract class BaseParser implements IParser {
|
|||
return mySuppressNarratives;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle parseBundle(Reader theReader) {
|
||||
if (myContext.getVersion().getVersion() == FhirVersionEnum.DSTU2_HL7ORG) {
|
||||
throw new IllegalStateException("Can't parse DSTU1 (Atom) bundle in HL7.org DSTU2 mode. Use parseResource(Bundle.class, foo) instead.");
|
||||
}
|
||||
return parseBundle(null, theReader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle parseBundle(String theXml) throws ConfigurationException, DataFormatException {
|
||||
StringReader reader = new StringReader(theXml);
|
||||
return parseBundle(reader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IBaseResource> T parseResource(Class<T> theResourceType, Reader theReader) throws DataFormatException {
|
||||
|
||||
|
@ -715,10 +623,6 @@ public abstract class BaseParser implements IParser {
|
|||
return parseResource(null, theMessageString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagList parseTagList(String theString) {
|
||||
return parseTagList(new StringReader(theString));
|
||||
}
|
||||
|
||||
protected List<? extends IBase> preProcessValues(BaseRuntimeChildDefinition theMetaChildUncast, IBaseResource theResource, List<? extends IBase> theValues,
|
||||
CompositeChildElement theCompositeChildElement) {
|
||||
|
@ -892,7 +796,7 @@ public abstract class BaseParser implements IParser {
|
|||
myStripVersionsFromReferences = theStripVersionsFromReferences;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IParser setOverrideResourceIdWithBundleEntryFullUrl(Boolean theOverrideResourceIdWithBundleEntryFullUrl) {
|
||||
myOverrideResourceIdWithBundleEntryFullUrl = theOverrideResourceIdWithBundleEntryFullUrl;
|
||||
|
@ -968,10 +872,10 @@ public abstract class BaseParser implements IParser {
|
|||
return url;
|
||||
}
|
||||
|
||||
protected String getServerBaseUrl() {
|
||||
return myServerBaseUrl;
|
||||
protected String getServerBaseUrl() {
|
||||
return myServerBaseUrl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used for DSTU2 only
|
||||
*/
|
||||
|
|
|
@ -10,7 +10,7 @@ package ca.uhn.fhir.parser;
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -25,9 +25,7 @@ import java.io.IOException;
|
|||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeStructure;
|
||||
import ca.uhn.fhir.parser.json.JsonLikeWriter;
|
||||
|
||||
|
@ -41,27 +39,8 @@ import ca.uhn.fhir.parser.json.JsonLikeWriter;
|
|||
*/
|
||||
public interface IJsonLikeParser extends IParser {
|
||||
|
||||
void encodeBundleToJsonLikeWriter(Bundle theBundle, JsonLikeWriter theJsonLikeWriter) throws IOException, DataFormatException;
|
||||
|
||||
void encodeResourceToJsonLikeWriter(IBaseResource theResource, JsonLikeWriter theJsonLikeWriter) throws IOException, DataFormatException;
|
||||
|
||||
void encodeTagListToJsonLikeWriter(TagList theTagList, JsonLikeWriter theJsonLikeWriter) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Parse a DSTU1 style Atom Bundle. Note that as of DSTU2, Bundle is a resource so you should use
|
||||
* {@link #parseResource(Class, JsonLikeStructure)} with the Bundle class found in the
|
||||
* <code>ca.uhn.hapi.fhir.model.[version].resource</code> package instead.
|
||||
*/
|
||||
<T extends IBaseResource> Bundle parseBundle(Class<T> theResourceType, JsonLikeStructure theJsonLikeStructure);
|
||||
|
||||
/**
|
||||
* Parse a DSTU1 style Atom Bundle. Note that as of DSTU2, Bundle is a resource so you should use
|
||||
* {@link #parseResource(Class, JsonLikeStructure)} with the Bundle class found in the
|
||||
* <code>ca.uhn.hapi.fhir.model.[version].resource</code> package instead.
|
||||
*/
|
||||
Bundle parseBundle(JsonLikeStructure theJsonLikeStructure) throws DataFormatException;
|
||||
|
||||
/**
|
||||
* Parses a resource from a JSON-like data structure
|
||||
*
|
||||
|
@ -76,7 +55,6 @@ public interface IJsonLikeParser extends IParser {
|
|||
*/
|
||||
<T extends IBaseResource> T parseResource(Class<T> theResourceType, JsonLikeStructure theJsonLikeStructure) throws DataFormatException;
|
||||
|
||||
|
||||
/**
|
||||
* Parses a resource from a JSON-like data structure
|
||||
*
|
||||
|
@ -89,13 +67,4 @@ public interface IJsonLikeParser extends IParser {
|
|||
*/
|
||||
IBaseResource parseResource(JsonLikeStructure theJsonLikeStructure) throws DataFormatException;
|
||||
|
||||
/**
|
||||
* Parses a tag list from a JSON-like data structure
|
||||
*
|
||||
* @param theJsonLikeStructure
|
||||
* The JSON-like structure to parse
|
||||
* @return A parsed tag list
|
||||
*/
|
||||
TagList parseTagList(JsonLikeStructure theJsonLikeStructure);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ package ca.uhn.fhir.parser;
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -19,25 +19,14 @@ package ca.uhn.fhir.parser;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
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 ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.ParserOptions;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.context.*;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
|
||||
/**
|
||||
* A parser, which can be used to convert between HAPI FHIR model/structure objects, and their respective String wire
|
||||
|
@ -49,35 +38,10 @@ import ca.uhn.fhir.rest.server.EncodingEnum;
|
|||
*/
|
||||
public interface IParser {
|
||||
|
||||
String encodeBundleToString(Bundle theBundle) throws DataFormatException;
|
||||
|
||||
void encodeBundleToWriter(Bundle theBundle, Writer theWriter) throws IOException, DataFormatException;
|
||||
|
||||
String encodeResourceToString(IBaseResource theResource) throws DataFormatException;
|
||||
|
||||
void encodeResourceToWriter(IBaseResource theResource, Writer theWriter) throws IOException, DataFormatException;
|
||||
|
||||
/**
|
||||
* Encodes a tag list, as defined in the <a href="http://hl7.org/implement/standards/fhir/http.html#tags">FHIR
|
||||
* Specification</a>.
|
||||
*
|
||||
* @param theTagList
|
||||
* The tag list to encode. Must not be null.
|
||||
* @return An encoded tag list
|
||||
*/
|
||||
String encodeTagListToString(TagList theTagList);
|
||||
|
||||
/**
|
||||
* Encodes a tag list, as defined in the <a href="http://hl7.org/implement/standards/fhir/http.html#tags">FHIR
|
||||
* Specification</a>.
|
||||
*
|
||||
* @param theTagList
|
||||
* The tag list to encode. Must not be null.
|
||||
* @param theWriter
|
||||
* The writer to encode to
|
||||
*/
|
||||
void encodeTagListToWriter(TagList theTagList, Writer theWriter) throws IOException;
|
||||
|
||||
/**
|
||||
* See {@link #setEncodeElements(Set)}
|
||||
*/
|
||||
|
@ -128,7 +92,7 @@ public interface IParser {
|
|||
* @see ParserOptions
|
||||
*/
|
||||
Boolean getStripVersionsFromReferences();
|
||||
|
||||
|
||||
/**
|
||||
* If set to <code>true</code> (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
|
||||
* resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this
|
||||
|
@ -149,27 +113,6 @@ public interface IParser {
|
|||
*/
|
||||
boolean isSummaryMode();
|
||||
|
||||
/**
|
||||
* Parse a DSTU1 style Atom Bundle. Note that as of DSTU2, Bundle is a resource so you should use
|
||||
* {@link #parseResource(Class, Reader)} with the Bundle class found in the
|
||||
* <code>ca.uhn.hapi.fhir.model.[version].resource</code> package instead.
|
||||
*/
|
||||
<T extends IBaseResource> Bundle parseBundle(Class<T> theResourceType, Reader theReader);
|
||||
|
||||
/**
|
||||
* Parse a DSTU1 style Atom Bundle. Note that as of DSTU2, Bundle is a resource so you should use
|
||||
* {@link #parseResource(Class, Reader)} with the Bundle class found in the
|
||||
* <code>ca.uhn.hapi.fhir.model.[version].resource</code> package instead.
|
||||
*/
|
||||
Bundle parseBundle(Reader theReader);
|
||||
|
||||
/**
|
||||
* Parse a DSTU1 style Atom Bundle. Note that as of DSTU2, Bundle is a resource so you should use
|
||||
* {@link #parseResource(Class, String)} with the Bundle class found in the
|
||||
* <code>ca.uhn.hapi.fhir.model.[version].resource</code> package instead.
|
||||
*/
|
||||
Bundle parseBundle(String theMessageString) throws ConfigurationException, DataFormatException;
|
||||
|
||||
/**
|
||||
* Parses a resource
|
||||
*
|
||||
|
@ -222,26 +165,6 @@ public interface IParser {
|
|||
*/
|
||||
IBaseResource parseResource(String theMessageString) throws ConfigurationException, DataFormatException;
|
||||
|
||||
/**
|
||||
* Parses a tag list, as defined in the <a href="http://hl7.org/implement/standards/fhir/http.html#tags">FHIR
|
||||
* Specification</a>.
|
||||
*
|
||||
* @param theReader
|
||||
* A reader which will supply a tag list
|
||||
* @return A parsed tag list
|
||||
*/
|
||||
TagList parseTagList(Reader theReader);
|
||||
|
||||
/**
|
||||
* Parses a tag list, as defined in the <a href="http://hl7.org/implement/standards/fhir/http.html#tags">FHIR
|
||||
* Specification</a>.
|
||||
*
|
||||
* @param theString
|
||||
* A string containing a tag list
|
||||
* @return A parsed tag list
|
||||
*/
|
||||
TagList parseTagList(String theString);
|
||||
|
||||
/**
|
||||
* If provided, specifies the elements which should NOT be encoded. Valid values for this
|
||||
* field would include:
|
||||
|
@ -367,6 +290,7 @@ public interface IParser {
|
|||
* This method provides the ability to globally disable reference encoding. If finer-grained
|
||||
* control is needed, use {@link #setDontStripVersionsFromReferencesAtPaths(String...)}
|
||||
* </p>
|
||||
*
|
||||
* @param theStripVersionsFromReferences
|
||||
* Set this to <code>false<code> to prevent the parser from removing resource versions from references (or <code>null</code> to apply the default setting from the {@link ParserOptions}
|
||||
* @see #setDontStripVersionsFromReferencesAtPaths(String...)
|
||||
|
@ -374,7 +298,7 @@ public interface IParser {
|
|||
* @return Returns a reference to <code>this</code> parser so that method calls can be chained together
|
||||
*/
|
||||
IParser setStripVersionsFromReferences(Boolean theStripVersionsFromReferences);
|
||||
|
||||
|
||||
/**
|
||||
* If set to <code>true</code> (which is the default), the Bundle.entry.fullUrl will override the Bundle.entry.resource's
|
||||
* resource id if the fullUrl is defined. This behavior happens when parsing the source data into a Bundle object. Set this
|
||||
|
@ -426,7 +350,7 @@ public interface IParser {
|
|||
* @return Returns a reference to <code>this</code> parser so that method calls can be chained together
|
||||
*/
|
||||
IParser setDontStripVersionsFromReferencesAtPaths(String... thePaths);
|
||||
|
||||
|
||||
/**
|
||||
* If supplied value(s), any resource references at the specified paths will have their
|
||||
* resource versions encoded instead of being automatically stripped during the encoding
|
||||
|
@ -451,7 +375,7 @@ public interface IParser {
|
|||
|
||||
/**
|
||||
* Returns the value supplied to {@link IParser#setDontStripVersionsFromReferencesAtPaths(String...)}
|
||||
* or <code>null</code> if no value has been set for this parser (in which case the default from
|
||||
* or <code>null</code> if no value has been set for this parser (in which case the default from
|
||||
* the {@link ParserOptions} will be used}
|
||||
*
|
||||
* @see #setDontStripVersionsFromReferencesAtPaths(String...)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.parser;
|
||||
|
||||
/*
|
||||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
|
@ -19,85 +19,34 @@ package ca.uhn.fhir.parser;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.FactoryConfigurationError;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import javax.xml.stream.events.Characters;
|
||||
import javax.xml.stream.events.Comment;
|
||||
import javax.xml.stream.events.EntityReference;
|
||||
import javax.xml.stream.events.Namespace;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import javax.xml.stream.*;
|
||||
import javax.xml.stream.events.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBase;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
import org.hl7.fhir.instance.model.api.IBaseDatatype;
|
||||
import org.hl7.fhir.instance.model.api.IBaseExtension;
|
||||
import org.hl7.fhir.instance.model.api.IBaseHasExtensions;
|
||||
import org.hl7.fhir.instance.model.api.IBaseHasModifierExtensions;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseXhtml;
|
||||
import org.hl7.fhir.instance.model.api.IDomainResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.INarrative;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.*;
|
||||
|
||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeDeclaredChildDefinition;
|
||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.context.RuntimeChildContainedResources;
|
||||
import ca.uhn.fhir.context.RuntimeChildExtension;
|
||||
import ca.uhn.fhir.context.RuntimeChildNarrativeDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeChildUndeclaredExtensionDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.model.api.BaseBundle;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.BundleEntry;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.api.Tag;
|
||||
import ca.uhn.fhir.model.api.TagList;
|
||||
import ca.uhn.fhir.context.*;
|
||||
import ca.uhn.fhir.model.api.*;
|
||||
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||
import ca.uhn.fhir.model.primitive.*;
|
||||
import ca.uhn.fhir.narrative.INarrativeGenerator;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.util.ElementUtil;
|
||||
import ca.uhn.fhir.util.NonPrettyPrintWriterWrapper;
|
||||
import ca.uhn.fhir.util.PrettyPrintWriterWrapper;
|
||||
import ca.uhn.fhir.util.XmlUtil;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.util.*;
|
||||
|
||||
/**
|
||||
* This class is the FHIR XML parser/encoder. Users should not interact with this class directly, but should use
|
||||
* {@link FhirContext#newXmlParser()} to get an instance.
|
||||
*/
|
||||
public class XmlParser extends BaseParser /*implements IParser */{
|
||||
public class XmlParser extends BaseParser /* implements IParser */ {
|
||||
|
||||
static final String ATOM_NS = "http://www.w3.org/2005/Atom";
|
||||
static final String FHIR_NS = "http://hl7.org/fhir";
|
||||
|
@ -150,20 +99,6 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doEncodeBundleToWriter(Bundle theBundle, Writer theWriter) throws DataFormatException {
|
||||
try {
|
||||
XMLStreamWriter eventWriter = createXmlWriter(theWriter);
|
||||
if (myContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1)) {
|
||||
encodeBundleToWriterDstu2(theBundle, eventWriter);
|
||||
} else {
|
||||
encodeBundleToWriterDstu1(theBundle, eventWriter);
|
||||
}
|
||||
} catch (XMLStreamException e) {
|
||||
throw new ConfigurationException("Failed to initialize STaX event factory", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doEncodeResourceToWriter(IBaseResource theResource, Writer theWriter) throws DataFormatException {
|
||||
XMLStreamWriter eventWriter;
|
||||
|
@ -278,221 +213,6 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodeBundleToString(Bundle theBundle) throws DataFormatException {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
try {
|
||||
encodeBundleToWriter(theBundle, stringWriter);
|
||||
} catch (IOException e) {
|
||||
throw new InternalErrorException("IOException writing to StringWriter - Should not happen", e);
|
||||
}
|
||||
|
||||
return stringWriter.toString();
|
||||
}
|
||||
|
||||
private void encodeBundleToWriterDstu1(Bundle theBundle, XMLStreamWriter eventWriter) throws XMLStreamException {
|
||||
eventWriter.writeStartElement("feed");
|
||||
eventWriter.writeDefaultNamespace(ATOM_NS);
|
||||
|
||||
writeTagWithTextNode(eventWriter, "title", theBundle.getTitle());
|
||||
writeTagWithTextNode(eventWriter, "id", theBundle.getBundleId());
|
||||
|
||||
writeAtomLink(eventWriter, Constants.LINK_SELF, theBundle.getLinkSelf());
|
||||
writeAtomLink(eventWriter, Constants.LINK_FIRST, theBundle.getLinkFirst());
|
||||
writeAtomLink(eventWriter, Constants.LINK_PREVIOUS, theBundle.getLinkPrevious());
|
||||
writeAtomLink(eventWriter, Constants.LINK_NEXT, theBundle.getLinkNext());
|
||||
writeAtomLink(eventWriter, Constants.LINK_LAST, theBundle.getLinkLast());
|
||||
writeAtomLink(eventWriter, Constants.LINK_FHIR_BASE, theBundle.getLinkBase());
|
||||
|
||||
if (theBundle.getTotalResults().getValue() != null) {
|
||||
eventWriter.writeStartElement("os", "totalResults", OPENSEARCH_NS);
|
||||
eventWriter.writeNamespace("os", OPENSEARCH_NS);
|
||||
eventWriter.writeCharacters(theBundle.getTotalResults().getValue().toString());
|
||||
eventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
writeOptionalTagWithTextNode(eventWriter, "updated", theBundle.getUpdated());
|
||||
|
||||
writeAuthor(eventWriter, theBundle);
|
||||
|
||||
writeCategories(eventWriter, theBundle.getCategories());
|
||||
|
||||
for (BundleEntry nextEntry : theBundle.getEntries()) {
|
||||
boolean deleted = false;
|
||||
if (nextEntry.getDeletedAt() != null && nextEntry.getDeletedAt().isEmpty() == false) {
|
||||
deleted = true;
|
||||
eventWriter.writeStartElement("at", "deleted-entry", TOMBSTONES_NS);
|
||||
eventWriter.writeNamespace("at", TOMBSTONES_NS);
|
||||
|
||||
if (nextEntry.getDeletedResourceId().isEmpty()) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalAttribute(eventWriter, "ref", nextEntry.getId().getValueAsString());
|
||||
} else {
|
||||
writeOptionalAttribute(eventWriter, "ref", nextEntry.getDeletedResourceId().getValueAsString());
|
||||
}
|
||||
|
||||
writeOptionalAttribute(eventWriter, "when", nextEntry.getDeletedAt().getValueAsString());
|
||||
if (nextEntry.getDeletedByEmail().isEmpty() == false || nextEntry.getDeletedByName().isEmpty() == false) {
|
||||
eventWriter.writeStartElement(TOMBSTONES_NS, "by");
|
||||
if (nextEntry.getDeletedByName().isEmpty() == false) {
|
||||
eventWriter.writeStartElement(TOMBSTONES_NS, "name");
|
||||
eventWriter.writeCharacters(nextEntry.getDeletedByName().getValue());
|
||||
eventWriter.writeEndElement();
|
||||
}
|
||||
if (nextEntry.getDeletedByEmail().isEmpty() == false) {
|
||||
eventWriter.writeStartElement(TOMBSTONES_NS, "email");
|
||||
eventWriter.writeCharacters(nextEntry.getDeletedByEmail().getValue());
|
||||
eventWriter.writeEndElement();
|
||||
}
|
||||
eventWriter.writeEndElement();
|
||||
}
|
||||
if (nextEntry.getDeletedComment().isEmpty() == false) {
|
||||
eventWriter.writeStartElement(TOMBSTONES_NS, "comment");
|
||||
eventWriter.writeCharacters(nextEntry.getDeletedComment().getValue());
|
||||
eventWriter.writeEndElement();
|
||||
}
|
||||
} else {
|
||||
eventWriter.writeStartElement("entry");
|
||||
}
|
||||
|
||||
writeOptionalTagWithTextNode(eventWriter, "title", nextEntry.getTitle());
|
||||
if (!deleted) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
if (nextEntry.getId().isEmpty() == false) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeTagWithTextNode(eventWriter, "id", nextEntry.getId());
|
||||
} else {
|
||||
writeTagWithTextNode(eventWriter, "id", nextEntry.getResource().getId());
|
||||
}
|
||||
}
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalTagWithTextNode(eventWriter, "updated", nextEntry.getUpdated());
|
||||
writeOptionalTagWithTextNode(eventWriter, "published", nextEntry.getPublished());
|
||||
|
||||
writeAuthor(eventWriter, nextEntry);
|
||||
|
||||
writeCategories(eventWriter, nextEntry.getCategories());
|
||||
|
||||
if (!nextEntry.getLinkSelf().isEmpty()) {
|
||||
writeAtomLink(eventWriter, "self", nextEntry.getLinkSelf());
|
||||
}
|
||||
|
||||
if (!nextEntry.getLinkAlternate().isEmpty()) {
|
||||
writeAtomLink(eventWriter, "alternate", nextEntry.getLinkAlternate());
|
||||
}
|
||||
|
||||
if (!nextEntry.getLinkSearch().isEmpty()) {
|
||||
writeAtomLink(eventWriter, "search", nextEntry.getLinkSearch());
|
||||
}
|
||||
|
||||
IResource resource = nextEntry.getResource();
|
||||
if (resource != null && !resource.isEmpty() && !deleted) {
|
||||
eventWriter.writeStartElement("content");
|
||||
eventWriter.writeAttribute("type", "text/xml");
|
||||
encodeResourceToXmlStreamWriter(resource, eventWriter, false, true);
|
||||
eventWriter.writeEndElement(); // content
|
||||
} else {
|
||||
ourLog.debug("Bundle entry contains null resource");
|
||||
}
|
||||
|
||||
if (!nextEntry.getSummary().isEmpty()) {
|
||||
eventWriter.writeStartElement("summary");
|
||||
eventWriter.writeAttribute("type", "xhtml");
|
||||
encodeXhtml(nextEntry.getSummary(), eventWriter);
|
||||
eventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
eventWriter.writeEndElement(); // entry
|
||||
}
|
||||
|
||||
eventWriter.writeEndElement();
|
||||
eventWriter.close();
|
||||
}
|
||||
|
||||
private void encodeBundleToWriterDstu2(Bundle theBundle, XMLStreamWriter theEventWriter) throws XMLStreamException {
|
||||
theEventWriter.writeStartElement("Bundle");
|
||||
theEventWriter.writeDefaultNamespace(FHIR_NS);
|
||||
|
||||
writeOptionalTagWithValue(theEventWriter, "id", theBundle.getId().getIdPart());
|
||||
|
||||
InstantDt updated = (InstantDt) theBundle.getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED);
|
||||
IdDt bundleId = theBundle.getId();
|
||||
if (bundleId != null && isNotBlank(bundleId.getVersionIdPart()) || (updated != null && !updated.isEmpty())) {
|
||||
theEventWriter.writeStartElement("meta");
|
||||
//FIXME potential null acces bundleId may be null at this time due to the OR clause
|
||||
writeOptionalTagWithValue(theEventWriter, "versionId", bundleId.getVersionIdPart());
|
||||
if (updated != null) {
|
||||
writeOptionalTagWithValue(theEventWriter, "lastUpdated", updated.getValueAsString());
|
||||
}
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
writeOptionalTagWithValue(theEventWriter, "type", theBundle.getType().getValue());
|
||||
writeOptionalTagWithValue(theEventWriter, "total", theBundle.getTotalResults().getValueAsString());
|
||||
|
||||
writeBundleResourceLink(theEventWriter, "first", theBundle.getLinkFirst());
|
||||
writeBundleResourceLink(theEventWriter, "previous", theBundle.getLinkPrevious());
|
||||
writeBundleResourceLink(theEventWriter, "next", theBundle.getLinkNext());
|
||||
writeBundleResourceLink(theEventWriter, "last", theBundle.getLinkLast());
|
||||
writeBundleResourceLink(theEventWriter, "self", theBundle.getLinkSelf());
|
||||
|
||||
for (BundleEntry nextEntry : theBundle.getEntries()) {
|
||||
theEventWriter.writeStartElement("entry");
|
||||
|
||||
boolean deleted = false;
|
||||
if (nextEntry.getDeletedAt() != null && nextEntry.getDeletedAt().isEmpty() == false) {
|
||||
deleted = true;
|
||||
}
|
||||
|
||||
writeBundleResourceLink(theEventWriter, "alternate", nextEntry.getLinkAlternate());
|
||||
|
||||
if (nextEntry.getResource() != null && isNotBlank(nextEntry.getResource().getIdElement().getValue()) && (nextEntry.getResource().getId().getBaseUrl() != null || nextEntry.getResource().getId().getValueAsString().startsWith("urn:"))) {
|
||||
writeOptionalTagWithValue(theEventWriter, "fullUrl", nextEntry.getResource().getId().getValue());
|
||||
}
|
||||
|
||||
IResource resource = nextEntry.getResource();
|
||||
if (resource != null && !resource.isEmpty() && !deleted) {
|
||||
theEventWriter.writeStartElement("resource");
|
||||
encodeResourceToXmlStreamWriter(resource, theEventWriter, false, true);
|
||||
theEventWriter.writeEndElement(); // content
|
||||
} else {
|
||||
ourLog.debug("Bundle entry contains null resource");
|
||||
}
|
||||
|
||||
if (nextEntry.getSearchMode().isEmpty() == false || nextEntry.getScore().isEmpty() == false) {
|
||||
theEventWriter.writeStartElement("search");
|
||||
writeOptionalTagWithValue(theEventWriter, "mode", nextEntry.getSearchMode().getValueAsString());
|
||||
writeOptionalTagWithValue(theEventWriter, "score", nextEntry.getScore().getValueAsString());
|
||||
theEventWriter.writeEndElement();
|
||||
// IResource nextResource = nextEntry.getResource();
|
||||
}
|
||||
|
||||
if (nextEntry.getTransactionMethod().isEmpty() == false || nextEntry.getLinkSearch().isEmpty() == false) {
|
||||
theEventWriter.writeStartElement("request");
|
||||
writeOptionalTagWithValue(theEventWriter, "method", nextEntry.getTransactionMethod().getValue());
|
||||
writeOptionalTagWithValue(theEventWriter, "url", nextEntry.getLinkSearch().getValue());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
if (deleted) {
|
||||
theEventWriter.writeStartElement("deleted");
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalTagWithValue(theEventWriter, "type", nextEntry.getId().getResourceType());
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalTagWithValue(theEventWriter, "id", nextEntry.getId().getIdPart());
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
writeOptionalTagWithValue(theEventWriter, "versionId", nextEntry.getId().getVersionIdPart());
|
||||
writeOptionalTagWithValue(theEventWriter, "instant", nextEntry.getDeletedAt().getValueAsString());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
theEventWriter.writeEndElement(); // entry
|
||||
}
|
||||
|
||||
theEventWriter.writeEndElement();
|
||||
theEventWriter.close();
|
||||
}
|
||||
|
||||
private void encodeChildElementToStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, IBase theElement, String childName, BaseRuntimeElementDefinition<?> childDef,
|
||||
String theExtensionUrl, boolean theIncludedResource, CompositeChildElement theParent) throws XMLStreamException, DataFormatException {
|
||||
if (theElement == null || theElement.isEmpty()) {
|
||||
|
@ -507,13 +227,17 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
|
||||
switch (childDef.getChildType()) {
|
||||
case ID_DATATYPE: {
|
||||
IIdType value = IIdType.class.cast(theElement);
|
||||
String encodedValue = "id".equals(childName) ? value.getIdPart() : value.getValue();
|
||||
theEventWriter.writeStartElement(childName);
|
||||
theEventWriter.writeAttribute("value", encodedValue);
|
||||
encodeExtensionsIfPresent(theResource, theEventWriter, theElement, theIncludedResource);
|
||||
theEventWriter.writeEndElement();
|
||||
break;
|
||||
IIdType value = IIdType.class.cast(theElement);
|
||||
String encodedValue = "id".equals(childName) ? value.getIdPart() : value.getValue();
|
||||
if (StringUtils.isNotBlank(encodedValue) || super.hasExtensions(value)) {
|
||||
theEventWriter.writeStartElement(childName);
|
||||
if (StringUtils.isNotBlank(encodedValue)) {
|
||||
theEventWriter.writeAttribute("value", encodedValue);
|
||||
}
|
||||
encodeExtensionsIfPresent(theResource, theEventWriter, theElement, theIncludedResource);
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PRIMITIVE_DATATYPE: {
|
||||
IPrimitiveType<?> pd = IPrimitiveType.class.cast(theElement);
|
||||
|
@ -597,13 +321,13 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
|
||||
private void encodeCompositeElementToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, boolean theContainedResource, CompositeChildElement theParent)
|
||||
throws XMLStreamException, DataFormatException {
|
||||
|
||||
|
||||
for (CompositeChildElement nextChildElem : super.compositeChildIterator(theElement, theContainedResource, theParent)) {
|
||||
|
||||
BaseRuntimeChildDefinition nextChild = nextChildElem.getDef();
|
||||
|
||||
|
||||
if (nextChild.getElementName().equals("url") && theElement instanceof IBaseExtension) {
|
||||
/*
|
||||
/*
|
||||
* XML encoding is a one-off for extensions. The URL element goes in an attribute
|
||||
* instead of being encoded as a normal element, only for XML encoding
|
||||
*/
|
||||
|
@ -620,7 +344,7 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
} else {
|
||||
narr = null;
|
||||
}
|
||||
//FIXME potential null access on narr see line 623
|
||||
// FIXME potential null access on narr see line 623
|
||||
if (gen != null && narr.isEmpty()) {
|
||||
gen.generateNarrative(myContext, theResource, narr);
|
||||
}
|
||||
|
@ -647,22 +371,17 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
if ((nextValue == null || nextValue.isEmpty())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
BaseParser.ChildNameAndDef childNameAndDef = super.getChildNameAndDef(nextChild, nextValue);
|
||||
if (childNameAndDef == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
String childName = childNameAndDef.getChildName();
|
||||
BaseRuntimeElementDefinition<?> childDef = childNameAndDef.getChildDef();
|
||||
String extensionUrl = getExtensionUrl(nextChild.getExtensionUrl());
|
||||
|
||||
if (nextValue instanceof IBaseExtension && myContext.getVersion().getVersion() == FhirVersionEnum.DSTU1) {
|
||||
// This is called for the Query resource in DSTU1 only
|
||||
extensionUrl = getExtensionUrl(((IBaseExtension<?, ?>) nextValue).getUrl());
|
||||
encodeChildElementToStreamWriter(theResource, theEventWriter, nextValue, childName, childDef, extensionUrl, theContainedResource, nextChildElem);
|
||||
|
||||
} else if (extensionUrl != null && childName.equals("extension") == false) {
|
||||
if (extensionUrl != null && childName.equals("extension") == false) {
|
||||
encodeExtension(theResource, theEventWriter, theContainedResource, nextChildElem, nextChild, nextValue, childName, extensionUrl, childDef);
|
||||
} else if (nextChild instanceof RuntimeChildExtension) {
|
||||
IBaseExtension<?, ?> extension = (IBaseExtension<?, ?>) nextValue;
|
||||
|
@ -695,7 +414,7 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
if (isNotBlank(elementId)) {
|
||||
theEventWriter.writeAttribute("id", elementId);
|
||||
}
|
||||
|
||||
|
||||
theEventWriter.writeAttribute("url", extensionUrl);
|
||||
encodeChildElementToStreamWriter(theResource, theEventWriter, nextValue, childName, childDef, null, theContainedResource, nextChildElem);
|
||||
theEventWriter.writeEndElement();
|
||||
|
@ -725,9 +444,6 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
if (theResource.getIdElement().getValue().startsWith("urn:")) {
|
||||
resourceId = null;
|
||||
}
|
||||
if (myContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU1)) {
|
||||
resourceId = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!theIncludedResource) {
|
||||
|
@ -741,7 +457,6 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
encodeResourceToXmlStreamWriter(theResource, theEventWriter, theIncludedResource, resourceId);
|
||||
}
|
||||
|
||||
|
||||
private void encodeResourceToXmlStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, boolean theContainedResource, IIdType theResourceId) throws XMLStreamException {
|
||||
if (!theContainedResource) {
|
||||
super.containResourcesForEncoding(theResource);
|
||||
|
@ -756,98 +471,84 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
theEventWriter.writeDefaultNamespace(FHIR_NS);
|
||||
|
||||
if (theResource instanceof IAnyResource) {
|
||||
|
||||
// HL7.org Structures
|
||||
if (theResourceId != null) {
|
||||
writeCommentsPre(theEventWriter, theResourceId);
|
||||
writeOptionalTagWithValue(theEventWriter, "id", theResourceId.getIdPart());
|
||||
writeCommentsPost(theEventWriter, theResourceId);
|
||||
}
|
||||
if (theResourceId != null) {
|
||||
writeCommentsPre(theEventWriter, theResourceId);
|
||||
theEventWriter.writeStartElement("id");
|
||||
theEventWriter.writeAttribute("value", theResourceId.getIdPart());
|
||||
encodeExtensionsIfPresent(theResource, theEventWriter, theResourceId, false);
|
||||
theEventWriter.writeEndElement();
|
||||
writeCommentsPost(theEventWriter, theResourceId);
|
||||
}
|
||||
|
||||
encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter, theContainedResource, new CompositeChildElement(resDef));
|
||||
|
||||
} else {
|
||||
|
||||
if (myContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1)) {
|
||||
// DSTU2+
|
||||
|
||||
// DSTU2+
|
||||
IResource resource = (IResource) theResource;
|
||||
if (theResourceId != null) {
|
||||
/* writeCommentsPre(theEventWriter, theResourceId);
|
||||
writeOptionalTagWithValue(theEventWriter, "id", theResourceId.getIdPart());
|
||||
writeCommentsPost(theEventWriter, theResourceId);*/
|
||||
theEventWriter.writeStartElement("id");
|
||||
theEventWriter.writeAttribute("value", theResourceId.getIdPart());
|
||||
encodeExtensionsIfPresent(theResource, theEventWriter, theResourceId, false);
|
||||
theEventWriter.writeEndElement();
|
||||
writeCommentsPost(theEventWriter, theResourceId);
|
||||
}
|
||||
|
||||
IResource resource = (IResource) theResource;
|
||||
if (theResourceId != null) {
|
||||
writeCommentsPre(theEventWriter, theResourceId);
|
||||
writeOptionalTagWithValue(theEventWriter, "id", theResourceId.getIdPart());
|
||||
writeCommentsPost(theEventWriter, theResourceId);
|
||||
InstantDt updated = (InstantDt) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED);
|
||||
IdDt resourceId = resource.getId();
|
||||
String versionIdPart = resourceId.getVersionIdPart();
|
||||
if (isBlank(versionIdPart)) {
|
||||
versionIdPart = ResourceMetadataKeyEnum.VERSION.get(resource);
|
||||
}
|
||||
List<BaseCodingDt> securityLabels = extractMetadataListNotNull(resource, ResourceMetadataKeyEnum.SECURITY_LABELS);
|
||||
List<? extends IIdType> profiles = extractMetadataListNotNull(resource, ResourceMetadataKeyEnum.PROFILES);
|
||||
profiles = super.getProfileTagsForEncoding(resource, profiles);
|
||||
|
||||
TagList tags = getMetaTagsForEncoding((resource));
|
||||
|
||||
if (super.shouldEncodeResourceMeta(resource) && ElementUtil.isEmpty(versionIdPart, updated, securityLabels, tags, profiles) == false) {
|
||||
theEventWriter.writeStartElement("meta");
|
||||
writeOptionalTagWithValue(theEventWriter, "versionId", versionIdPart);
|
||||
if (updated != null) {
|
||||
writeOptionalTagWithValue(theEventWriter, "lastUpdated", updated.getValueAsString());
|
||||
}
|
||||
|
||||
InstantDt updated = (InstantDt) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED);
|
||||
IdDt resourceId = resource.getId();
|
||||
String versionIdPart = resourceId.getVersionIdPart();
|
||||
if (isBlank(versionIdPart)) {
|
||||
versionIdPart = ResourceMetadataKeyEnum.VERSION.get(resource);
|
||||
}
|
||||
List<BaseCodingDt> securityLabels = extractMetadataListNotNull(resource, ResourceMetadataKeyEnum.SECURITY_LABELS);
|
||||
List<? extends IIdType> profiles = extractMetadataListNotNull(resource, ResourceMetadataKeyEnum.PROFILES);
|
||||
profiles = super.getProfileTagsForEncoding(resource, profiles);
|
||||
|
||||
TagList tags = getMetaTagsForEncoding((resource));
|
||||
|
||||
if (super.shouldEncodeResourceMeta(resource) && ElementUtil.isEmpty(versionIdPart, updated, securityLabels, tags, profiles) == false) {
|
||||
theEventWriter.writeStartElement("meta");
|
||||
writeOptionalTagWithValue(theEventWriter, "versionId", versionIdPart);
|
||||
if (updated != null) {
|
||||
writeOptionalTagWithValue(theEventWriter, "lastUpdated", updated.getValueAsString());
|
||||
}
|
||||
|
||||
for (IIdType profile : profiles) {
|
||||
theEventWriter.writeStartElement("profile");
|
||||
theEventWriter.writeAttribute("value", profile.getValue());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
for (BaseCodingDt securityLabel : securityLabels) {
|
||||
theEventWriter.writeStartElement("security");
|
||||
encodeCompositeElementToStreamWriter(resource, securityLabel, theEventWriter, theContainedResource, null);
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
if (tags != null) {
|
||||
for (Tag tag : tags) {
|
||||
if (tag.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
theEventWriter.writeStartElement("tag");
|
||||
writeOptionalTagWithValue(theEventWriter, "system", tag.getScheme());
|
||||
writeOptionalTagWithValue(theEventWriter, "code", tag.getTerm());
|
||||
writeOptionalTagWithValue(theEventWriter, "display", tag.getLabel());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
}
|
||||
for (IIdType profile : profiles) {
|
||||
theEventWriter.writeStartElement("profile");
|
||||
theEventWriter.writeAttribute("value", profile.getValue());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
if (theResource instanceof IBaseBinary) {
|
||||
IBaseBinary bin = (IBaseBinary) theResource;
|
||||
writeOptionalTagWithValue(theEventWriter, "contentType", bin.getContentType());
|
||||
writeOptionalTagWithValue(theEventWriter, "content", bin.getContentAsBase64());
|
||||
} else {
|
||||
encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter, theContainedResource, new CompositeChildElement(resDef));
|
||||
for (BaseCodingDt securityLabel : securityLabels) {
|
||||
theEventWriter.writeStartElement("security");
|
||||
encodeCompositeElementToStreamWriter(resource, securityLabel, theEventWriter, theContainedResource, null);
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// DSTU1
|
||||
if (theResourceId != null && theContainedResource && theResourceId.hasIdPart()) {
|
||||
theEventWriter.writeAttribute("id", theResourceId.getIdPart());
|
||||
}
|
||||
|
||||
if (theResource instanceof IBaseBinary) {
|
||||
IBaseBinary bin = (IBaseBinary) theResource;
|
||||
if (bin.getContentType() != null) {
|
||||
theEventWriter.writeAttribute("contentType", bin.getContentType());
|
||||
if (tags != null) {
|
||||
for (Tag tag : tags) {
|
||||
if (tag.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
theEventWriter.writeStartElement("tag");
|
||||
writeOptionalTagWithValue(theEventWriter, "system", tag.getScheme());
|
||||
writeOptionalTagWithValue(theEventWriter, "code", tag.getTerm());
|
||||
writeOptionalTagWithValue(theEventWriter, "display", tag.getLabel());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
theEventWriter.writeCharacters(bin.getContentAsBase64());
|
||||
} else {
|
||||
encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter, theContainedResource, new CompositeChildElement(resDef));
|
||||
}
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
if (theResource instanceof IBaseBinary) {
|
||||
IBaseBinary bin = (IBaseBinary) theResource;
|
||||
writeOptionalTagWithValue(theEventWriter, "contentType", bin.getContentType());
|
||||
writeOptionalTagWithValue(theEventWriter, "content", bin.getContentAsBase64());
|
||||
} else {
|
||||
encodeCompositeElementToStreamWriter(theResource, theResource, theEventWriter, theContainedResource, new CompositeChildElement(resDef));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -855,39 +556,8 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void encodeTagListToWriter(TagList theTagList, Writer theWriter) throws IOException {
|
||||
try {
|
||||
XMLStreamWriter eventWriter = createXmlWriter(theWriter);
|
||||
|
||||
eventWriter.writeStartElement(TagList.ELEMENT_NAME_LC);
|
||||
eventWriter.writeDefaultNamespace(FHIR_NS);
|
||||
|
||||
for (Tag next : theTagList) {
|
||||
eventWriter.writeStartElement(TagList.ATTR_CATEGORY);
|
||||
|
||||
if (isNotBlank(next.getTerm())) {
|
||||
eventWriter.writeAttribute(Tag.ATTR_TERM, next.getTerm());
|
||||
}
|
||||
if (isNotBlank(next.getLabel())) {
|
||||
eventWriter.writeAttribute(Tag.ATTR_LABEL, next.getLabel());
|
||||
}
|
||||
if (isNotBlank(next.getScheme())) {
|
||||
eventWriter.writeAttribute(Tag.ATTR_SCHEME, next.getScheme());
|
||||
}
|
||||
|
||||
eventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
eventWriter.writeEndElement();
|
||||
eventWriter.close();
|
||||
} catch (XMLStreamException e) {
|
||||
throw new ConfigurationException("Failed to initialize STaX event factory", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theEventWriter, List<? extends IBaseExtension<?, ?>> theExtensions, String tagName, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
|
||||
private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theEventWriter, List<? extends IBaseExtension<?, ?>> theExtensions, String tagName, boolean theIncludedResource)
|
||||
throws XMLStreamException, DataFormatException {
|
||||
for (IBaseExtension<?, ?> next : theExtensions) {
|
||||
if (next == null || (ElementUtil.isEmpty(next.getValue()) && next.getExtension().isEmpty())) {
|
||||
continue;
|
||||
|
@ -914,7 +584,7 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
childDef = myContext.getElementDefinition(value.getClass());
|
||||
if (childDef == null) {
|
||||
throw new ConfigurationException("Unable to encode extension, unrecognized child element type: " + value.getClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
childName = RuntimeChildUndeclaredExtensionDefinition.createExtensionChildName(childDef);
|
||||
} else {
|
||||
childDef = extDef.getChildElementDefinitionByDatatype(value.getClass());
|
||||
|
@ -1033,31 +703,11 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
return EncodingEnum.XML;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IBaseResource> Bundle parseBundle(Class<T> theResourceType, Reader theReader) {
|
||||
XMLEventReader streamReader = createStreamReader(theReader);
|
||||
|
||||
return parseBundle(streamReader, theResourceType);
|
||||
}
|
||||
|
||||
private Bundle parseBundle(XMLEventReader theStreamReader, Class<? extends IBaseResource> theResourceType) {
|
||||
ParserState<Bundle> parserState = ParserState.getPreAtomInstance(this, myContext, theResourceType, false, getErrorHandler());
|
||||
return doXmlLoop(theStreamReader, parserState);
|
||||
}
|
||||
|
||||
private <T extends IBaseResource> T parseResource(Class<T> theResourceType, XMLEventReader theStreamReader) {
|
||||
ParserState<T> parserState = ParserState.getPreResourceInstance(this, theResourceType, myContext, false, getErrorHandler());
|
||||
return doXmlLoop(theStreamReader, parserState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagList parseTagList(Reader theReader) {
|
||||
XMLEventReader streamReader = createStreamReader(theReader);
|
||||
|
||||
ParserState<TagList> parserState = ParserState.getPreTagListInstance(this, myContext, false, getErrorHandler());
|
||||
return doXmlLoop(streamReader, parserState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParser setPrettyPrint(boolean thePrettyPrint) {
|
||||
myPrettyPrint = thePrettyPrint;
|
||||
|
@ -1075,49 +725,6 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
return retVal;
|
||||
}
|
||||
|
||||
private void writeAuthor(XMLStreamWriter theEventWriter, BaseBundle theBundle) throws XMLStreamException {
|
||||
if (StringUtils.isNotBlank(theBundle.getAuthorName().getValue())) {
|
||||
theEventWriter.writeStartElement("author");
|
||||
writeTagWithTextNode(theEventWriter, "name", theBundle.getAuthorName());
|
||||
writeOptionalTagWithTextNode(theEventWriter, "uri", theBundle.getAuthorUri());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeAtomLink(XMLStreamWriter theEventWriter, String theRel, StringDt theStringDt) throws XMLStreamException {
|
||||
if (StringUtils.isNotBlank(theStringDt.getValue())) {
|
||||
theEventWriter.writeStartElement("link");
|
||||
theEventWriter.writeAttribute("rel", theRel);
|
||||
theEventWriter.writeAttribute("href", theStringDt.getValue());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeBundleResourceLink(XMLStreamWriter theEventWriter, String theRel, StringDt theUrl) throws XMLStreamException {
|
||||
if (theUrl.isEmpty() == false) {
|
||||
theEventWriter.writeStartElement("link");
|
||||
theEventWriter.writeStartElement("relation");
|
||||
theEventWriter.writeAttribute("value", theRel);
|
||||
theEventWriter.writeEndElement();
|
||||
theEventWriter.writeStartElement("url");
|
||||
theEventWriter.writeAttribute("value", theUrl.getValue());
|
||||
theEventWriter.writeEndElement();
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeCategories(XMLStreamWriter eventWriter, TagList categories) throws XMLStreamException {
|
||||
if (categories != null) {
|
||||
for (Tag next : categories) {
|
||||
eventWriter.writeStartElement("category");
|
||||
eventWriter.writeAttribute("term", defaultString(next.getTerm()));
|
||||
eventWriter.writeAttribute("label", defaultString(next.getLabel()));
|
||||
eventWriter.writeAttribute("scheme", defaultString(next.getScheme()));
|
||||
eventWriter.writeEndElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeCommentsPost(XMLStreamWriter theEventWriter, IBase theElement) throws XMLStreamException {
|
||||
if (theElement != null && theElement.hasFormatComment()) {
|
||||
for (String next : theElement.getFormatCommentsPost()) {
|
||||
|
@ -1138,28 +745,6 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
}
|
||||
}
|
||||
|
||||
private void writeOptionalAttribute(XMLStreamWriter theEventWriter, String theName, String theValue) throws XMLStreamException {
|
||||
if (StringUtils.isNotBlank(theValue)) {
|
||||
theEventWriter.writeAttribute(theName, theValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeOptionalTagWithTextNode(XMLStreamWriter theEventWriter, String theTagName, InstantDt theInstantDt) throws XMLStreamException {
|
||||
if (theInstantDt.getValue() != null) {
|
||||
theEventWriter.writeStartElement(theTagName);
|
||||
theEventWriter.writeCharacters(theInstantDt.getValueAsString());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeOptionalTagWithTextNode(XMLStreamWriter theEventWriter, String theElementName, StringDt theTextValue) throws XMLStreamException {
|
||||
if (StringUtils.isNotBlank(theTextValue.getValue())) {
|
||||
theEventWriter.writeStartElement(theElementName);
|
||||
theEventWriter.writeCharacters(theTextValue.getValue());
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
private void writeOptionalTagWithValue(XMLStreamWriter theEventWriter, String theName, String theValue) throws XMLStreamException {
|
||||
if (StringUtils.isNotBlank(theValue)) {
|
||||
theEventWriter.writeStartElement(theName);
|
||||
|
@ -1168,20 +753,4 @@ public class XmlParser extends BaseParser /*implements IParser */{
|
|||
}
|
||||
}
|
||||
|
||||
private void writeTagWithTextNode(XMLStreamWriter theEventWriter, String theElementName, IdDt theIdDt) throws XMLStreamException {
|
||||
theEventWriter.writeStartElement(theElementName);
|
||||
if (StringUtils.isNotBlank(theIdDt.getValue())) {
|
||||
theEventWriter.writeCharacters(theIdDt.getValue());
|
||||
}
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
private void writeTagWithTextNode(XMLStreamWriter theEventWriter, String theElementName, StringDt theStringDt) throws XMLStreamException {
|
||||
theEventWriter.writeStartElement(theElementName);
|
||||
if (StringUtils.isNotBlank(theStringDt.getValue())) {
|
||||
theEventWriter.writeCharacters(theStringDt.getValue());
|
||||
}
|
||||
theEventWriter.writeEndElement();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ package ca.uhn.fhir.rest.annotation;
|
|||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
|
@ -44,7 +44,7 @@ public @interface Create {
|
|||
* for client implementations.
|
||||
*/
|
||||
// NB: Read, Search (maybe others) share this annotation, so update the javadocs everywhere
|
||||
Class<? extends IResource> type() default IResource.class;
|
||||
Class<? extends IBaseResource> type() default IBaseResource.class;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,85 +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;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
|
||||
/**
|
||||
* RESTful method annotation to be used for the FHIR <a
|
||||
* href="http://hl7.org/implement/standards/fhir/http.html#tags">Tag
|
||||
* Operations</a> which have to do with getting tags.
|
||||
* <ul>
|
||||
* <li>
|
||||
* To return a global list of all tags on the server, this annotation should not
|
||||
* contain a {@link #type()} attribute, and the method should not have an ID or
|
||||
* Version ID parameter. On server implementations, the method must be defined
|
||||
* in a <a href=
|
||||
* "http://jamesagnew.github.io/hapi-fhir/doc_rest_server.html#plain_providers"
|
||||
* >plain provider</a>.</li>
|
||||
* <li>
|
||||
* To return a list of all tags on the server <b>for the given resource
|
||||
* type</b>, this annotation should contain a {@link #type()} attribute
|
||||
* specifying the resource type, and the method should not have an ID or Version
|
||||
* ID parameter. Note that for a server implementation, the {@link #type()}
|
||||
* annotation is optional if the method is defined in a <a href=
|
||||
* "http://jamesagnew.github.io/hapi-fhir/doc_rest_server.html#resource_providers"
|
||||
* >resource provider</a>, since the type is implied.</li>
|
||||
* <li>
|
||||
* To return a list of all tags on the server <b>for the given resource
|
||||
* instance</b>, this annotation should contain a {@link #type()} attribute
|
||||
* specifying the resource type, and the method should have a parameter of type
|
||||
* {@link IdDt} annotated with the {@link IdParam} annotation. Note that for a
|
||||
* server implementation, the {@link #type()} annotation is optional if the
|
||||
* method is defined in a <a href=
|
||||
* "http://jamesagnew.github.io/hapi-fhir/doc_rest_server.html#resource_providers"
|
||||
* >resource provider</a>, since the type is implied.</li>
|
||||
* <li>
|
||||
* To return a list of all tags on the server <b>for the given version of the
|
||||
* resource instance</b>, this annotation should contain a {@link #type()}
|
||||
* attribute specifying the resource type, and the method should have a
|
||||
* parameter of type {@link IdDt} annotated with the {@link VersionIdParam}
|
||||
* annotation, <b>and</b> a parameter of type {@link IdDt} annotated with the
|
||||
* {@link IdParam} annotation. Note that for a server implementation, the
|
||||
* {@link #type()} annotation is optional if the method is defined in a <a href=
|
||||
* "http://jamesagnew.github.io/hapi-fhir/doc_rest_server.html#resource_providers"
|
||||
* >resource provider</a>, since the type is implied.</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Target(value= ElementType.METHOD)
|
||||
@Retention(value=RetentionPolicy.RUNTIME)
|
||||
public @interface GetTags {
|
||||
|
||||
/**
|
||||
* If set to a type other than the default (which is {@link IResource}
|
||||
* , this method is expected to return a TagList containing only tags which
|
||||
* are specific to the given resource type.
|
||||
*/
|
||||
Class<? extends IBaseResource> type() default IBaseResource.class;
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* A method annotated with this annotation will be treated as a GraphQL implementation
|
||||
* method
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(value= ElementType.METHOD)
|
||||
public @interface GraphQL {
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* This annotation should be placed on the parameter of a
|
||||
* {@link GraphQL @GraphQL} annotated method. The given
|
||||
* parameter will be populated with the specific graphQL
|
||||
* query being requested.
|
||||
*
|
||||
* <p>
|
||||
* This parameter should be of type {@link String}
|
||||
* </p>
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
public @interface GraphQLQuery {
|
||||
// ignore
|
||||
}
|
|
@ -79,5 +79,5 @@ public @interface Operation {
|
|||
* bundle type to set in the bundle.
|
||||
*/
|
||||
BundleTypeEnum bundleType() default BundleTypeEnum.COLLECTION;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,17 +19,12 @@ package ca.uhn.fhir.rest.annotation;
|
|||
* 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;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.rest.client.api.IBasicClient;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
|
||||
/**
|
||||
* RESTful method annotation to be used for the FHIR <a href="http://hl7.org/implement/standards/fhir/http.html#read">read</a> and <a
|
||||
|
@ -50,7 +45,7 @@ import ca.uhn.fhir.rest.server.IResourceProvider;
|
|||
public @interface Read {
|
||||
|
||||
/**
|
||||
* The return type for this method. This generally does not need to be populated for {@link IResourceProvider resource providers} in a server implementation, but often does need to be populated in
|
||||
* The return type for this method. This generally does not need to be populated for IResourceProvider in a server implementation, but often does need to be populated in
|
||||
* client implementations using {@link IBasicClient} or {@link IRestfulClient}, or in plain providers on a server.
|
||||
* <p>
|
||||
* This value also does not need to be populated if the return type for a method annotated with this annotation is sufficient to determine the type of resource provided. E.g. if the method returns
|
||||
|
|
|
@ -19,13 +19,7 @@ package ca.uhn.fhir.rest.annotation;
|
|||
* 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;
|
||||
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Denotes a parameter for a REST method which will contain the resource actually
|
||||
|
@ -37,7 +31,7 @@ import ca.uhn.fhir.rest.server.IResourceProvider;
|
|||
* <p>
|
||||
* Parameters with this annotation should typically be of the type of resource being
|
||||
* operated on (see below for an exception when raw data is required). For example, in a
|
||||
* {@link IResourceProvider} for Patient resources, the parameter annotated with this
|
||||
* IResourceProvider for Patient resources, the parameter annotated with this
|
||||
* annotation should be of type Patient.
|
||||
* </p>
|
||||
* <p>
|
||||
|
|
|
@ -29,8 +29,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
|
||||
import ca.uhn.fhir.rest.client.api.IBasicClient;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
import ca.uhn.fhir.rest.server.IDynamicSearchResourceProvider;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -66,7 +64,7 @@ public @interface Search {
|
|||
|
||||
/**
|
||||
* The return type for this method. This generally does not need
|
||||
* to be populated for {@link IResourceProvider resource providers} in a server implementation,
|
||||
* to be populated for IResourceProvider instances in a server implementation,
|
||||
* but often does need to be populated in client implementations using {@link IBasicClient} or
|
||||
* {@link IRestfulClient}, or in plain providers on a server.
|
||||
* <p>
|
||||
|
@ -82,8 +80,6 @@ public @interface Search {
|
|||
|
||||
/**
|
||||
* This is an experimental option - Use with caution
|
||||
*
|
||||
* @see IDynamicSearchResourceProvider
|
||||
*/
|
||||
boolean dynamic() default false;
|
||||
|
||||
|
|
|
@ -19,19 +19,13 @@ package ca.uhn.fhir.rest.annotation;
|
|||
* 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;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* RESTful method annotation to be used for the FHIR <a href="http://hl7.org/implement/standards/fhir/http.html#transaction">transaction</a> method.
|
||||
*
|
||||
* <p>
|
||||
* This method should have a parameter of type {@link Bundle} annotated with the {@link TransactionParam} annotation.
|
||||
* This method should have a parameter of type Bundle annotated with the {@link TransactionParam} annotation.
|
||||
* </p>
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
@ -19,19 +19,13 @@ package ca.uhn.fhir.rest.annotation;
|
|||
* 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;
|
||||
import java.lang.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
|
||||
/**
|
||||
* Parameter annotation for the "transaction" operation. The parameter annotated with this
|
||||
* annotation must be either of type <code>{@link Bundle}</code> or of type
|
||||
* <code>{@link List}<IResource></code>
|
||||
* annotation must be a Bundle resource type, or a type that implements
|
||||
* <code>{@link List}<IBaseResource></code>
|
||||
*/
|
||||
@Target(value=ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
@ -19,15 +19,11 @@ package ca.uhn.fhir.rest.annotation;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import java.lang.annotation.*;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.rest.api.ValidationModeEnum;
|
||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||
|
||||
/**
|
||||
* RESTful method annotation to be used for the FHIR
|
||||
|
@ -50,12 +46,12 @@ public @interface Validate {
|
|||
|
||||
/**
|
||||
* The return type for this method. This generally does not need
|
||||
* to be populated for a server implementation (using a {@link IResourceProvider},
|
||||
* to be populated for a server implementation (using an IResourceProvider,
|
||||
* since resource providers will return only one resource type per class,
|
||||
* but generally does need to be populated for client implementations.
|
||||
*/
|
||||
// NB: Read, Search (maybe others) share this annotation, so update the javadocs everywhere
|
||||
Class<? extends IResource> type() default IResource.class;
|
||||
Class<? extends IBaseResource> type() default IBaseResource.class;
|
||||
|
||||
/**
|
||||
* Validation mode parameter annotation for the validation mode parameter (only supported
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,252 @@
|
|||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
/*
|
||||
* #%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.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String CHARSET_NAME_UTF8 = "UTF-8";
|
||||
public static final Charset CHARSET_UTF8;
|
||||
public static final String CHARSET_UTF8_CTSUFFIX = "; charset=" + CHARSET_NAME_UTF8;
|
||||
public static final String CT_FHIR_JSON = "application/json+fhir";
|
||||
public static final String CT_FHIR_JSON_NEW = "application/fhir+json";
|
||||
public static final String CT_FHIR_XML = "application/xml+fhir";
|
||||
public static final String CT_FHIR_XML_NEW = "application/fhir+xml";
|
||||
public static final String CT_HTML = "text/html";
|
||||
public static final String CT_HTML_WITH_UTF8 = "text/html" + CHARSET_UTF8_CTSUFFIX;
|
||||
public static final String CT_JSON = "application/json";
|
||||
public static final String CT_JSON_PATCH = "application/json-patch+json";
|
||||
public static final String CT_OCTET_STREAM = "application/octet-stream";
|
||||
public static final String CT_TEXT = "text/plain";
|
||||
public static final String CT_TEXT_WITH_UTF8 = CT_TEXT + CHARSET_UTF8_CTSUFFIX;
|
||||
public static final String CT_X_FORM_URLENCODED = "application/x-www-form-urlencoded";
|
||||
public static final String CT_XML = "application/xml";
|
||||
public static final String CT_XML_PATCH = "application/xml-patch+xml";
|
||||
public static final String ENCODING_GZIP = "gzip";
|
||||
public static final String EXTOP_PROCESS_MESSAGE = "$process-message"; //Used in messaging
|
||||
public static final String EXTOP_VALIDATE = "$validate";
|
||||
public static final String EXTOP_VALIDATE_MODE = "mode";
|
||||
public static final String EXTOP_VALIDATE_PROFILE = "profile";
|
||||
public static final String EXTOP_VALIDATE_RESOURCE = "resource";
|
||||
public static final String FORMAT_HTML = "html";
|
||||
public static final String FORMAT_JSON = "json";
|
||||
public static final String FORMAT_XML = "xml";
|
||||
/**
|
||||
* "text/html" and "html"
|
||||
*/
|
||||
public static final Set<String> FORMATS_HTML;
|
||||
public static final String FORMATS_HTML_JSON = "html/json";
|
||||
public static final String FORMATS_HTML_XML = "html/xml";
|
||||
public static final String HEADER_ACCEPT = "Accept";
|
||||
public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding";
|
||||
public static final String HEADER_ACCEPT_VALUE_JSON_NON_LEGACY = CT_FHIR_JSON_NEW + ";q=1.0, " + CT_FHIR_JSON + ";q=0.9";
|
||||
public static final String HEADER_ACCEPT_VALUE_XML_NON_LEGACY = CT_FHIR_XML_NEW + ";q=1.0, " + CT_FHIR_XML + ";q=0.9";
|
||||
public static final String HEADER_ACCEPT_VALUE_XML_OR_JSON_LEGACY = CT_FHIR_XML + ";q=1.0, " + CT_FHIR_JSON + ";q=1.0";
|
||||
public static final String HEADER_ACCEPT_VALUE_XML_OR_JSON_NON_LEGACY = CT_FHIR_XML_NEW + ";q=1.0, " + CT_FHIR_JSON_NEW + ";q=1.0, " + HEADER_ACCEPT_VALUE_XML_OR_JSON_LEGACY.replace("1.0", "0.9");
|
||||
public static final String HEADER_ALLOW = "Allow";
|
||||
public static final String HEADER_AUTHORIZATION = "Authorization";
|
||||
public static final String HEADER_AUTHORIZATION_VALPREFIX_BASIC = "Basic ";
|
||||
public static final String HEADER_AUTHORIZATION_VALPREFIX_BEARER = "Bearer ";
|
||||
public static final String HEADER_CONTENT_DISPOSITION = "Content-Disposition";
|
||||
public static final String HEADER_CONTENT_ENCODING = "Content-Encoding";
|
||||
public static final String HEADER_CONTENT_LOCATION = "Content-Location";
|
||||
public static final String HEADER_CONTENT_LOCATION_LC = HEADER_CONTENT_LOCATION.toLowerCase();
|
||||
public static final String HEADER_CONTENT_TYPE = "Content-Type";
|
||||
public static final String HEADER_COOKIE = "Cookie";
|
||||
public static final String HEADER_CORS_ALLOW_METHODS = "Access-Control-Allow-Methods";
|
||||
public static final String HEADER_CORS_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
|
||||
public static final String HEADER_CORS_EXPOSE_HEADERS = "Access-Control-Expose-Headers";
|
||||
public static final String HEADER_ETAG = "ETag";
|
||||
public static final String HEADER_ETAG_LC = HEADER_ETAG.toLowerCase();
|
||||
public static final String HEADER_IF_MATCH = "If-Match";
|
||||
public static final String HEADER_IF_MATCH_LC = HEADER_IF_MATCH.toLowerCase();
|
||||
public static final String HEADER_IF_MODIFIED_SINCE = "If-Modified-Since";
|
||||
public static final String HEADER_IF_MODIFIED_SINCE_LC = HEADER_IF_MODIFIED_SINCE.toLowerCase();
|
||||
public static final String HEADER_IF_NONE_EXIST = "If-None-Exist";
|
||||
public static final String HEADER_IF_NONE_EXIST_LC = HEADER_IF_NONE_EXIST.toLowerCase();
|
||||
public static final String HEADER_IF_NONE_MATCH = "If-None-Match";
|
||||
public static final String HEADER_IF_NONE_MATCH_LC = HEADER_IF_NONE_MATCH.toLowerCase();
|
||||
public static final String HEADER_LAST_MODIFIED = "Last-Modified";
|
||||
public static final String HEADER_LAST_MODIFIED_LOWERCASE = HEADER_LAST_MODIFIED.toLowerCase();
|
||||
public static final String HEADER_LOCATION = "Location";
|
||||
public static final String HEADER_LOCATION_LC = HEADER_LOCATION.toLowerCase();
|
||||
public static final String HEADER_ORIGIN = "Origin";
|
||||
public static final String HEADER_PREFER = "Prefer";
|
||||
public static final String HEADER_PREFER_RETURN = "return";
|
||||
public static final String HEADER_PREFER_RETURN_MINIMAL = "minimal";
|
||||
public static final String HEADER_PREFER_RETURN_REPRESENTATION = "representation";
|
||||
public static final String HEADER_SUFFIX_CT_UTF_8 = "; charset=UTF-8";
|
||||
public static final String HEADERVALUE_CORS_ALLOW_METHODS_ALL = "GET, POST, PUT, DELETE, OPTIONS";
|
||||
public static final Map<Integer, String> HTTP_STATUS_NAMES;
|
||||
public static final String LINK_FHIR_BASE = "fhir-base";
|
||||
public static final String LINK_FIRST = "first";
|
||||
public static final String LINK_LAST = "last";
|
||||
public static final String LINK_NEXT = "next";
|
||||
public static final String LINK_PREVIOUS = "previous";
|
||||
public static final String LINK_SELF = "self";
|
||||
public static final String OPENSEARCH_NS_OLDER = "http://purl.org/atompub/tombstones/1.0";
|
||||
public static final String PARAM_ASYNC = "async"; //Used in messaging
|
||||
public static final String PARAM_AT = "_at";
|
||||
/**
|
||||
* Used in paging links
|
||||
*/
|
||||
public static final Object PARAM_BUNDLETYPE = "_bundletype";
|
||||
public static final String PARAM_CONTENT = "_content";
|
||||
public static final String PARAM_COUNT = "_count";
|
||||
public static final String PARAM_DELETE = "_delete";
|
||||
public static final String PARAM_ELEMENTS = "_elements";
|
||||
public static final String PARAM_FORMAT = "_format";
|
||||
public static final String PARAM_HAS = "_has";
|
||||
public static final String PARAM_HISTORY = "_history";
|
||||
public static final String PARAM_INCLUDE = "_include";
|
||||
public static final String PARAM_INCLUDE_QUALIFIER_RECURSE = ":recurse";
|
||||
public static final String PARAM_INCLUDE_RECURSE = "_include"+PARAM_INCLUDE_QUALIFIER_RECURSE;
|
||||
public static final String PARAM_LASTUPDATED = "_lastUpdated";
|
||||
public static final String PARAM_NARRATIVE = "_narrative";
|
||||
public static final String PARAM_PAGINGACTION = "_getpages";
|
||||
public static final String PARAM_PAGINGOFFSET = "_getpagesoffset";
|
||||
public static final String PARAM_PRETTY = "_pretty";
|
||||
public static final String PARAM_PRETTY_VALUE_FALSE = "false";
|
||||
public static final String PARAM_PRETTY_VALUE_TRUE = "true";
|
||||
public static final String PARAM_PROFILE = "_profile";
|
||||
public static final String PARAM_QUERY = "_query";
|
||||
public static final String PARAM_RESPONSE_URL = "response-url"; //Used in messaging
|
||||
public static final String PARAM_REVINCLUDE = "_revinclude";
|
||||
public static final String PARAM_REVINCLUDE_RECURSE = PARAM_REVINCLUDE+PARAM_INCLUDE_QUALIFIER_RECURSE;
|
||||
public static final String PARAM_SEARCH = "_search";
|
||||
public static final String PARAM_SECURITY = "_security";
|
||||
public static final String PARAM_SINCE = "_since";
|
||||
public static final String PARAM_SORT = "_sort";
|
||||
public static final String PARAM_SORT_ASC = "_sort:asc";
|
||||
public static final String PARAM_SORT_DESC = "_sort:desc";
|
||||
public static final String PARAM_SUMMARY = "_summary";
|
||||
public static final String PARAM_TAG = "_tag";
|
||||
public static final String PARAM_TAGS = "_tags";
|
||||
public static final String PARAM_TEXT = "_text";
|
||||
public static final String PARAM_VALIDATE = "_validate";
|
||||
public static final String PARAMQUALIFIER_MISSING = ":missing";
|
||||
public static final String PARAMQUALIFIER_MISSING_FALSE = "false";
|
||||
public static final String PARAMQUALIFIER_MISSING_TRUE = "true";
|
||||
public static final String PARAMQUALIFIER_STRING_CONTAINS = ":contains";
|
||||
public static final String PARAMQUALIFIER_STRING_EXACT = ":exact";
|
||||
public static final String PARAMQUALIFIER_TOKEN_TEXT = ":text";
|
||||
public static final int STATUS_HTTP_200_OK = 200;
|
||||
public static final int STATUS_HTTP_201_CREATED = 201;
|
||||
public static final int STATUS_HTTP_204_NO_CONTENT = 204;
|
||||
public static final int STATUS_HTTP_304_NOT_MODIFIED = 304;
|
||||
public static final int STATUS_HTTP_400_BAD_REQUEST = 400;
|
||||
public static final int STATUS_HTTP_401_CLIENT_UNAUTHORIZED = 401;
|
||||
public static final int STATUS_HTTP_403_FORBIDDEN = 403;
|
||||
|
||||
public static final int STATUS_HTTP_404_NOT_FOUND = 404;
|
||||
public static final int STATUS_HTTP_405_METHOD_NOT_ALLOWED = 405;
|
||||
public static final int STATUS_HTTP_409_CONFLICT = 409;
|
||||
public static final int STATUS_HTTP_410_GONE = 410;
|
||||
public static final int STATUS_HTTP_412_PRECONDITION_FAILED = 412;
|
||||
public static final int STATUS_HTTP_422_UNPROCESSABLE_ENTITY = 422;
|
||||
public static final int STATUS_HTTP_500_INTERNAL_ERROR = 500;
|
||||
public static final int STATUS_HTTP_501_NOT_IMPLEMENTED = 501;
|
||||
public static final String TAG_SUBSETTED_CODE = "SUBSETTED";
|
||||
public static final String TAG_SUBSETTED_SYSTEM = "http://hl7.org/fhir/v3/ObservationValue";
|
||||
public static final String URL_TOKEN_HISTORY = "_history";
|
||||
public static final String URL_TOKEN_METADATA = "metadata";
|
||||
public static final String OO_INFOSTATUS_PROCESSING = "processing";
|
||||
public static final String PARAM_GRAPHQL_QUERY = "query";
|
||||
|
||||
static {
|
||||
CHARSET_UTF8 = Charset.forName(CHARSET_NAME_UTF8);
|
||||
|
||||
HashMap<Integer, String> statusNames = new HashMap<Integer, String>();
|
||||
|
||||
statusNames.put(200, "OK");
|
||||
statusNames.put(201, "Created");
|
||||
statusNames.put(202, "Accepted");
|
||||
statusNames.put(203, "Non-Authoritative Information");
|
||||
statusNames.put(204, "No Content");
|
||||
statusNames.put(205, "Reset Content");
|
||||
statusNames.put(206, "Partial Content");
|
||||
statusNames.put(207, "Multi-Status");
|
||||
statusNames.put(208, "Already Reported");
|
||||
statusNames.put(226, "IM Used");
|
||||
statusNames.put(300, "Multiple Choices");
|
||||
statusNames.put(301, "Moved Permanently");
|
||||
statusNames.put(302, "Found");
|
||||
statusNames.put(302, "Moved Temporarily");
|
||||
statusNames.put(303, "See Other");
|
||||
statusNames.put(304, "Not Modified");
|
||||
statusNames.put(305, "Use Proxy");
|
||||
statusNames.put(307, "Temporary Redirect");
|
||||
statusNames.put(308, "Permanent Redirect");
|
||||
statusNames.put(400, "Bad Request");
|
||||
statusNames.put(401, "Unauthorized");
|
||||
statusNames.put(402, "Payment Required");
|
||||
statusNames.put(403, "Forbidden");
|
||||
statusNames.put(404, "Not Found");
|
||||
statusNames.put(405, "Method Not Allowed");
|
||||
statusNames.put(406, "Not Acceptable");
|
||||
statusNames.put(407, "Proxy Authentication Required");
|
||||
statusNames.put(408, "Request Timeout");
|
||||
statusNames.put(409, "Conflict");
|
||||
statusNames.put(410, "Gone");
|
||||
statusNames.put(411, "Length Required");
|
||||
statusNames.put(412, "Precondition Failed");
|
||||
statusNames.put(413, "Payload Too Large");
|
||||
statusNames.put(413, "Request Entity Too Large");
|
||||
statusNames.put(414, "URI Too Long");
|
||||
statusNames.put(414, "Request-URI Too Long");
|
||||
statusNames.put(415, "Unsupported Media Type");
|
||||
statusNames.put(416, "Requested range not satisfiable");
|
||||
statusNames.put(417, "Expectation Failed");
|
||||
statusNames.put(418, "I'm a teapot");
|
||||
statusNames.put(419, "Insufficient Space On Resource");
|
||||
statusNames.put(420, "Method Failure");
|
||||
statusNames.put(421, "Destination Locked");
|
||||
statusNames.put(422, "Unprocessable Entity");
|
||||
statusNames.put(423, "Locked");
|
||||
statusNames.put(424, "Failed Dependency");
|
||||
statusNames.put(426, "Upgrade Required");
|
||||
statusNames.put(428, "Precondition Required");
|
||||
statusNames.put(429, "Too Many Requests");
|
||||
statusNames.put(431, "Request Header Fields Too Large");
|
||||
statusNames.put(500, "Internal Server Error");
|
||||
statusNames.put(501, "Not Implemented");
|
||||
statusNames.put(502, "Bad Gateway");
|
||||
statusNames.put(503, "Service Unavailable");
|
||||
statusNames.put(504, "Gateway Timeout");
|
||||
statusNames.put(505, "HTTP Version not supported");
|
||||
statusNames.put(506, "Variant Also Negotiates");
|
||||
statusNames.put(507, "Insufficient Storage");
|
||||
statusNames.put(508, "Loop Detected");
|
||||
statusNames.put(509, "Bandwidth Limit Exceeded");
|
||||
statusNames.put(510, "Not Extended");
|
||||
statusNames.put(511, "Network Authentication Required");
|
||||
HTTP_STATUS_NAMES = Collections.unmodifiableMap(statusNames);
|
||||
|
||||
Set<String> formatsHtml = new HashSet<String>();
|
||||
formatsHtml.add(CT_HTML);
|
||||
formatsHtml.add(FORMAT_HTML);
|
||||
FORMATS_HTML = Collections.unmodifiableSet(formatsHtml);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
package ca.uhn.fhir.rest.server;
|
||||
|
||||
import java.util.Collections;
|
||||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
@ -21,23 +19,23 @@ import java.util.Collections;
|
|||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
import java.util.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
|
||||
public enum EncodingEnum {
|
||||
|
||||
JSON(Constants.CT_FHIR_JSON, Constants.CT_FHIR_JSON_NEW, Constants.CT_FHIR_JSON, Constants.FORMAT_JSON) {
|
||||
JSON(Constants.CT_FHIR_JSON, Constants.CT_FHIR_JSON_NEW, Constants.FORMAT_JSON) {
|
||||
@Override
|
||||
public IParser newParser(FhirContext theContext) {
|
||||
return theContext.newJsonParser();
|
||||
}
|
||||
},
|
||||
|
||||
XML(Constants.CT_FHIR_XML, Constants.CT_FHIR_XML_NEW, Constants.CT_ATOM_XML, Constants.FORMAT_XML) {
|
||||
XML(Constants.CT_FHIR_XML, Constants.CT_FHIR_XML_NEW, Constants.FORMAT_XML) {
|
||||
@Override
|
||||
public IParser newParser(FhirContext theContext) {
|
||||
return theContext.newXmlParser();
|
||||
|
@ -46,21 +44,20 @@ public enum EncodingEnum {
|
|||
|
||||
;
|
||||
|
||||
/** "xml" */
|
||||
public static final String XML_PLAIN_STRING = "xml";
|
||||
/** "json" */
|
||||
public static final String JSON_PLAIN_STRING = "json";
|
||||
|
||||
private static Map<String, EncodingEnum> ourContentTypeToEncoding;
|
||||
|
||||
private static Map<String, EncodingEnum> ourContentTypeToEncodingNonLegacy;
|
||||
private static Map<String, EncodingEnum> ourContentTypeToEncodingStrict;
|
||||
/** "xml" */
|
||||
public static final String XML_PLAIN_STRING = "xml";
|
||||
|
||||
static {
|
||||
ourContentTypeToEncoding = new HashMap<String, EncodingEnum>();
|
||||
ourContentTypeToEncodingNonLegacy = new HashMap<String, EncodingEnum>();
|
||||
|
||||
for (EncodingEnum next : values()) {
|
||||
ourContentTypeToEncoding.put(next.getBundleContentType(), next);
|
||||
ourContentTypeToEncoding.put(next.myResourceContentTypeNonLegacy, next);
|
||||
ourContentTypeToEncoding.put(next.myResourceContentTypeLegacy, next);
|
||||
ourContentTypeToEncodingNonLegacy.put(next.myResourceContentTypeNonLegacy, next);
|
||||
|
@ -96,22 +93,16 @@ public enum EncodingEnum {
|
|||
|
||||
}
|
||||
|
||||
private String myBundleContentType;
|
||||
private String myFormatContentType;
|
||||
private String myResourceContentTypeNonLegacy;
|
||||
private String myResourceContentTypeLegacy;
|
||||
private String myResourceContentTypeNonLegacy;
|
||||
|
||||
EncodingEnum(String theResourceContentTypeLegacy, String theResourceContentType, String theBundleContentType, String theFormatContentType) {
|
||||
EncodingEnum(String theResourceContentTypeLegacy, String theResourceContentType, String theFormatContentType) {
|
||||
myResourceContentTypeLegacy = theResourceContentTypeLegacy;
|
||||
myResourceContentTypeNonLegacy = theResourceContentType;
|
||||
myBundleContentType = theBundleContentType;
|
||||
myFormatContentType = theFormatContentType;
|
||||
}
|
||||
|
||||
public String getBundleContentType() {
|
||||
return myBundleContentType;
|
||||
}
|
||||
|
||||
public String getFormatContentType() {
|
||||
return myFormatContentType;
|
||||
}
|
||||
|
@ -136,6 +127,27 @@ public enum EncodingEnum {
|
|||
|
||||
public abstract IParser newParser(FhirContext theContext);
|
||||
|
||||
public static EncodingEnum detectEncoding(String theBody) {
|
||||
EncodingEnum retVal = detectEncodingNoDefault(theBody);
|
||||
retVal = ObjectUtils.defaultIfNull(retVal, EncodingEnum.XML);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static EncodingEnum detectEncodingNoDefault(String theBody) {
|
||||
EncodingEnum retVal = null;
|
||||
for (int i = 0; i < theBody.length() && retVal == null; i++) {
|
||||
switch (theBody.charAt(i)) {
|
||||
case '<':
|
||||
retVal = EncodingEnum.XML;
|
||||
break;
|
||||
case '{':
|
||||
retVal = EncodingEnum.JSON;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the encoding for a given content type, or <code>null</code> if no encoding
|
||||
* is found.
|
||||
|
@ -148,6 +160,7 @@ public enum EncodingEnum {
|
|||
return ourContentTypeToEncoding.get(theContentType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the encoding for a given content type, or <code>null</code> if no encoding
|
||||
* is found.
|
||||
|
@ -164,5 +177,5 @@ public enum EncodingEnum {
|
|||
return ourContentTypeToEncodingNonLegacy.containsKey(theFormat);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
/*
|
||||
* #%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.util.*;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.api.BundleInclusionRule;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
|
||||
|
||||
/**
|
||||
* This interface should be considered experimental and will likely change in future releases of HAPI. Use with caution!
|
||||
*/
|
||||
public interface IVersionSpecificBundleFactory {
|
||||
|
||||
void addResourcesToBundle(List<IBaseResource> theResult, BundleTypeEnum theBundleType, String theServerBase, BundleInclusionRule theBundleInclusionRule, Set<Include> theIncludes);
|
||||
|
||||
void addRootPropertiesToBundle(String theAuthor, String theServerBase, String theLinkSelf, String theLinkPrev, String theLinkNext, Integer theTotalResults, BundleTypeEnum theBundleType, IPrimitiveType<Date> theLastUpdated);
|
||||
|
||||
IBaseResource getResourceBundle();
|
||||
|
||||
void initializeBundleFromResourceList(String theAuthor, List<? extends IBaseResource> theResult, String theServerBase, String theCompleteUrl, int theTotalResults, BundleTypeEnum theBundleType);
|
||||
|
||||
void initializeWithBundleResource(IBaseResource theResource);
|
||||
|
||||
List<IBaseResource> toListOfResources();
|
||||
|
||||
}
|
|
@ -21,7 +21,6 @@ package ca.uhn.fhir.rest.api;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.rest.annotation.Patch;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
|
||||
/**
|
||||
* Parameter type for methods annotated with {@link Patch}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package ca.uhn.fhir.rest.method;
|
||||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
|
|
@ -37,6 +37,14 @@ public enum RestOperationTypeEnum {
|
|||
|
||||
GET_PAGE("get-page"),
|
||||
|
||||
/**
|
||||
* <b>
|
||||
* Use this value with caution, this may
|
||||
* change as the GraphQL interface matures
|
||||
* </b>
|
||||
*/
|
||||
GRAPHQL_REQUEST("graphql-request"),
|
||||
|
||||
/**
|
||||
* E.g. $everything, $validate, etc.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
package ca.uhn.fhir.rest.method;
|
||||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
/*
|
||||
* #%L
|
|
@ -1,4 +1,4 @@
|
|||
package ca.uhn.fhir.rest.method;
|
||||
package ca.uhn.fhir.rest.api;
|
||||
|
||||
/*
|
||||
* #%L
|
|
@ -0,0 +1,35 @@
|
|||
package ca.uhn.fhir.rest.api.server;
|
||||
|
||||
/*-
|
||||
* #%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.util.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
||||
public interface IRequestDetails {
|
||||
|
||||
Map<String, String[]> getParameters();
|
||||
|
||||
Map<String, List<String>> getUnqualifiedToQualifiedNames();
|
||||
|
||||
FhirContext getFhirContext();
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package ca.uhn.fhir.rest.api.server;
|
||||
|
||||
/*-
|
||||
* #%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%
|
||||
*/
|
||||
|
||||
public interface IServerMethodBinding {
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,400 +0,0 @@
|
|||
package ca.uhn.fhir.rest.client;
|
||||
|
||||
/*
|
||||
* #%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.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseConformance;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerException;
|
||||
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
|
||||
import ca.uhn.fhir.rest.gclient.*;
|
||||
|
||||
public interface IGenericClient extends IRestfulClient {
|
||||
|
||||
/**
|
||||
* Retrieves and returns the server conformance statement
|
||||
*
|
||||
* @deprecated Use {@link #fetchConformance()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
IBaseConformance conformance();
|
||||
|
||||
/**
|
||||
* Fluent method for the "create" operation, which creates a new resource instance on the server
|
||||
*/
|
||||
ICreate create();
|
||||
|
||||
/**
|
||||
* Implementation of the "type create" method.
|
||||
*
|
||||
* @param theResource
|
||||
* The resource to create
|
||||
* @return An outcome
|
||||
* @deprecated Use {@link #create() fluent method instead}. This method will be removed.
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
MethodOutcome create(IBaseResource theResource);
|
||||
|
||||
/**
|
||||
* Fluent method for the "delete" operation, which performs a logical delete on a server resource
|
||||
*/
|
||||
IDelete delete();
|
||||
|
||||
/**
|
||||
* Implementation of the "delete instance" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to delete
|
||||
* @param theId
|
||||
* the ID of the resource to delete
|
||||
* @return An outcome
|
||||
* @deprecated Use {@link #delete()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
MethodOutcome delete(Class<? extends IBaseResource> theType, IdDt theId);
|
||||
|
||||
/**
|
||||
* Implementation of the "delete instance" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to delete
|
||||
* @param theId
|
||||
* the ID of the resource to delete
|
||||
* @return An outcome
|
||||
* @deprecated Use {@link #delete()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
MethodOutcome delete(Class<? extends IBaseResource> theType, String theId);
|
||||
|
||||
/**
|
||||
* Retrieves the server's conformance statement
|
||||
*/
|
||||
IFetchConformanceUntyped fetchConformance();
|
||||
|
||||
/**
|
||||
* Force the client to fetch the server's conformance statement and validate that it is appropriate for this client.
|
||||
*
|
||||
* @throws FhirClientConnectionException
|
||||
* if the conformance statement cannot be read, or if the client
|
||||
* @throws FhirClientInappropriateForServerException
|
||||
* If the conformance statement indicates that the server is inappropriate for this client (e.g. it implements the wrong version of FHIR)
|
||||
*/
|
||||
void forceConformanceCheck() throws FhirClientConnectionException;
|
||||
|
||||
/**
|
||||
* Fluent method for the "get tags" operation
|
||||
*/
|
||||
IGetTags getTags();
|
||||
|
||||
/**
|
||||
* Implementation of the "history" method
|
||||
*/
|
||||
IHistory history();
|
||||
|
||||
/**
|
||||
* Implementation of the "history instance" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to return the history for, or <code>null</code> to search for history across all resources
|
||||
* @param theId
|
||||
* The ID of the resource to return the history for, or <code>null</code> to search for all resource instances. Note that if this param is not null, <code>theType</code> must also not
|
||||
* be null
|
||||
* @param theSince
|
||||
* If not null, request that the server only return resources updated since this time
|
||||
* @param theLimit
|
||||
* If not null, request that the server return no more than this number of resources. Note that the server may return less even if more are available, but should not return more
|
||||
* according to the FHIR specification.
|
||||
* @return A bundle containing returned resources
|
||||
* @deprecated As of 0.9, use the fluent {@link #history()} method instead
|
||||
*/
|
||||
@Deprecated
|
||||
<T extends IBaseResource> Bundle history(Class<T> theType, IdDt theId, DateTimeDt theSince, Integer theLimit);
|
||||
|
||||
/**
|
||||
* Implementation of the "history instance" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to return the history for, or <code>null</code> to search for history across all resources
|
||||
* @param theId
|
||||
* The ID of the resource to return the history for, or <code>null</code> to search for all resource instances. Note that if this param is not null, <code>theType</code> must also not
|
||||
* be null
|
||||
* @param theSince
|
||||
* If not null, request that the server only return resources updated since this time
|
||||
* @param theLimit
|
||||
* If not null, request that the server return no more than this number of resources. Note that the server may return less even if more are available, but should not return more
|
||||
* according to the FHIR specification.
|
||||
* @return A bundle containing returned resources
|
||||
* @deprecated As of 0.9, use the fluent {@link #history()} method instead
|
||||
*/
|
||||
@Deprecated
|
||||
<T extends IBaseResource> Bundle history(Class<T> theType, String theId, DateTimeDt theSince, Integer theLimit);
|
||||
|
||||
/**
|
||||
* Loads the previous/next bundle of resources from a paged set, using the link specified in the "link type=next" tag within the atom bundle.
|
||||
*
|
||||
* @see Bundle#getLinkNext()
|
||||
*/
|
||||
IGetPage loadPage();
|
||||
|
||||
// /**
|
||||
// * Implementation of the "instance read" method. This method will only ever do a "read" for the latest version of a
|
||||
// * given resource instance, even if the ID passed in contains a version. If you wish to request a specific version
|
||||
// * of a resource (the "vread" operation), use {@link #vread(Class, IdDt)} instead.
|
||||
// * <p>
|
||||
// * Note that if an absolute resource ID is passed in (i.e. a URL containing a protocol and host as well as the
|
||||
// * resource type and ID) the server base for the client will be ignored, and the URL passed in will be queried.
|
||||
// * </p>
|
||||
// *
|
||||
// * @param theType
|
||||
// * The type of resource to load
|
||||
// * @param theId
|
||||
// * The ID to load, including the resource ID and the resource version ID. Valid values include
|
||||
// * "Patient/123/_history/222", or "http://example.com/fhir/Patient/123/_history/222"
|
||||
// * @return The resource
|
||||
// */
|
||||
// <T extends IBaseResource> T read(Class<T> theType, IdDt theId);
|
||||
|
||||
/**
|
||||
* Fluent method for the "meta" operations, which can be used to get, add and remove tags and other
|
||||
* Meta elements from a resource or across the server.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
IMeta meta();
|
||||
|
||||
/**
|
||||
* Implementation of the FHIR "extended operations" action
|
||||
*/
|
||||
IOperation operation();
|
||||
|
||||
/**
|
||||
* Fluent method for "read" and "vread" methods.
|
||||
*/
|
||||
IRead read();
|
||||
|
||||
/**
|
||||
* Implementation of the "instance read" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to load
|
||||
* @param theId
|
||||
* The ID to load
|
||||
* @return The resource
|
||||
*/
|
||||
<T extends IBaseResource> T read(Class<T> theType, String theId);
|
||||
|
||||
/**
|
||||
* Perform the "read" operation (retrieve the latest version of a resource instance by ID) using an absolute URL.
|
||||
*
|
||||
* @param theType
|
||||
* The resource type that is being retrieved
|
||||
* @param theUrl
|
||||
* The absolute URL, e.g. "http://example.com/fhir/Patient/123"
|
||||
* @return The returned resource from the server
|
||||
*/
|
||||
<T extends IBaseResource> T read(Class<T> theType, UriDt theUrl);
|
||||
|
||||
/**
|
||||
* Perform the "read" operation (retrieve the latest version of a resource instance by ID) using an absolute URL.
|
||||
*
|
||||
* @param theUrl
|
||||
* The absolute URL, e.g. "http://example.com/fhir/Patient/123"
|
||||
* @return The returned resource from the server
|
||||
*/
|
||||
IBaseResource read(UriDt theUrl);
|
||||
|
||||
/**
|
||||
* Register a new interceptor for this client. An interceptor can be used to add additional logging, or add security headers, or pre-process responses, etc.
|
||||
*/
|
||||
@Override
|
||||
void registerInterceptor(IClientInterceptor theInterceptor);
|
||||
|
||||
/**
|
||||
* Fluent method for the "patch" operation, which performs a logical patch on a server resource
|
||||
*/
|
||||
IPatch patch();
|
||||
|
||||
/**
|
||||
* Search for resources matching a given set of criteria. Searching is a very powerful
|
||||
* feature in FHIR with many features for specifying exactly what should be seaerched for
|
||||
* and how it should be returned. See the <a href="http://www.hl7.org/fhir/search.html">specification on search</a>
|
||||
* for more information.
|
||||
*/
|
||||
IUntypedQuery search();
|
||||
|
||||
/**
|
||||
* Implementation of the "instance search" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to load
|
||||
* @param theParams
|
||||
*/
|
||||
<T extends IBaseResource> Bundle search(Class<T> theType, Map<String, List<IQueryParameterType>> theParams);
|
||||
|
||||
/**
|
||||
* Perform the "search" operation using an absolute URL.
|
||||
*
|
||||
* @param theType
|
||||
* The primary resource type that is being retrieved
|
||||
* @param theUrl
|
||||
* The absolute URL, e.g. "http://example.com/fhir/Patient/123"
|
||||
* @return The returned bundle from the server
|
||||
*/
|
||||
<T extends IBaseResource> Bundle search(Class<T> theType, UriDt theUrl);
|
||||
|
||||
Bundle search(UriDt theUrl);
|
||||
|
||||
/**
|
||||
* If set to <code>true</code>, the client will log all requests and all responses. This is probably not a good production setting since it will result in a lot of extra logging, but it can be
|
||||
* useful for troubleshooting.
|
||||
*
|
||||
* @param theLogRequestAndResponse
|
||||
* Should requests and responses be logged
|
||||
* @deprecated Use {@link LoggingInterceptor} as a client interceptor registered to your
|
||||
* client instead, as this provides much more fine-grained control over what is logged. This
|
||||
* method will be removed at some point (deprecated in HAPI 1.6 - 2016-06-16)
|
||||
*/
|
||||
@Deprecated
|
||||
void setLogRequestAndResponse(boolean theLogRequestAndResponse);
|
||||
|
||||
/**
|
||||
* Send a transaction (collection of resources) to the server to be executed as a single unit
|
||||
*/
|
||||
ITransaction transaction();
|
||||
|
||||
/**
|
||||
* Implementation of the "transaction" method.
|
||||
*
|
||||
* @param theResources
|
||||
* The resources to create/update in a single transaction
|
||||
* @return A list of resource stubs (<b>these will not be fully populated</b>) containing IDs and other {@link IResource#getResourceMetadata() metadata}
|
||||
* @deprecated Use {@link #transaction()}
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
List<IBaseResource> transaction(List<IBaseResource> theResources);
|
||||
|
||||
/**
|
||||
* Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(IClientInterceptor)}
|
||||
*/
|
||||
@Override
|
||||
void unregisterInterceptor(IClientInterceptor theInterceptor);
|
||||
|
||||
/**
|
||||
* Fluent method for the "update" operation, which performs a logical delete on a server resource
|
||||
*/
|
||||
IUpdate update();
|
||||
|
||||
/**
|
||||
* Implementation of the "instance update" method.
|
||||
*
|
||||
* @param theId
|
||||
* The ID to update
|
||||
* @param theResource
|
||||
* The new resource body
|
||||
* @return An outcome containing the results and possibly the new version ID
|
||||
*/
|
||||
MethodOutcome update(IdDt theId, IBaseResource theResource);
|
||||
|
||||
/**
|
||||
* Implementation of the "instance update" method.
|
||||
*
|
||||
* @param theId
|
||||
* The ID to update
|
||||
* @param theResource
|
||||
* The new resource body
|
||||
* @return An outcome containing the results and possibly the new version ID
|
||||
*/
|
||||
MethodOutcome update(String theId, IBaseResource theResource);
|
||||
|
||||
/**
|
||||
* Validate a resource
|
||||
*/
|
||||
IValidate validate();
|
||||
|
||||
/**
|
||||
* Implementation of the "type validate" method.
|
||||
*
|
||||
* @param theResource
|
||||
* The resource to validate
|
||||
* @return An outcome containing any validation issues
|
||||
*/
|
||||
MethodOutcome validate(IBaseResource theResource);
|
||||
|
||||
/**
|
||||
* Implementation of the "instance vread" method. Note that this method expects <code>theId</code> to contain a resource ID as well as a version ID, and will fail if it does not.
|
||||
* <p>
|
||||
* Note that if an absolute resource ID is passed in (i.e. a URL containing a protocol and host as well as the resource type and ID) the server base for the client will be ignored, and the URL
|
||||
* passed in will be queried.
|
||||
* </p>
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to load
|
||||
* @param theId
|
||||
* The ID to load, including the resource ID and the resource version ID. Valid values include "Patient/123/_history/222", or "http://example.com/fhir/Patient/123/_history/222"
|
||||
* @return The resource
|
||||
*/
|
||||
<T extends IBaseResource> T vread(Class<T> theType, IdDt theId);
|
||||
|
||||
/**
|
||||
* Implementation of the "instance vread" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to load
|
||||
* @param theId
|
||||
* The ID to load
|
||||
* @param theVersionId
|
||||
* The version ID
|
||||
* @return The resource
|
||||
* @deprecated Deprecated in 0.7 - IdDt can contain an ID and a version, so this class doesn't make a lot of sense
|
||||
*/
|
||||
@Deprecated
|
||||
<T extends IBaseResource> T vread(Class<T> theType, IdDt theId, IdDt theVersionId);
|
||||
|
||||
/**
|
||||
* Implementation of the "instance vread" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to load
|
||||
* @param theId
|
||||
* The ID to load
|
||||
* @param theVersionId
|
||||
* The version ID
|
||||
* @return The resource
|
||||
*/
|
||||
<T extends IBaseResource> T vread(Class<T> theType, String theId, String theVersionId);
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package ca.uhn.fhir.rest.client.api;
|
||||
|
||||
/*
|
||||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
* %%
|
||||
|
@ -20,7 +20,8 @@ package ca.uhn.fhir.rest.client.api;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.model.base.resource.BaseConformance;
|
||||
import org.hl7.fhir.instance.model.api.IBaseConformance;
|
||||
|
||||
import ca.uhn.fhir.rest.annotation.Metadata;
|
||||
|
||||
/**
|
||||
|
@ -36,6 +37,6 @@ public interface IBasicClient extends IRestfulClient {
|
|||
* for more information.
|
||||
*/
|
||||
@Metadata
|
||||
BaseConformance getServerConformanceStatement();
|
||||
IBaseConformance getServerConformanceStatement();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package ca.uhn.fhir.rest.client;
|
||||
package ca.uhn.fhir.rest.client.api;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
@ -22,9 +22,6 @@ package ca.uhn.fhir.rest.client;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import ca.uhn.fhir.rest.client.api.IHttpRequest;
|
||||
import ca.uhn.fhir.rest.client.api.IHttpResponse;
|
||||
|
||||
/**
|
||||
* This interface represents an interceptor which can be used to access (and optionally change or take actions upon)
|
||||
* requests that are being sent by the HTTP client, and responses received by it.
|
|
@ -0,0 +1,255 @@
|
|||
package ca.uhn.fhir.rest.client.api;
|
||||
|
||||
/*-
|
||||
* #%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 org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerException;
|
||||
import ca.uhn.fhir.rest.gclient.*;
|
||||
|
||||
public interface IGenericClient extends IRestfulClient {
|
||||
|
||||
/**
|
||||
* Fetch the capability statement for the server
|
||||
*/
|
||||
IFetchConformanceUntyped capabilities();
|
||||
|
||||
/**
|
||||
* Fluent method for the "create" operation, which creates a new resource instance on the server
|
||||
*/
|
||||
ICreate create();
|
||||
|
||||
/**
|
||||
* Fluent method for the "delete" operation, which performs a logical delete on a server resource
|
||||
*/
|
||||
IDelete delete();
|
||||
|
||||
/**
|
||||
* Retrieves the server's conformance statement
|
||||
*
|
||||
* @deprecated As of HAPI 3.0.0 this method has been deprecated, as the operation is now called "capabilities". Use {@link #capabilities()} instead
|
||||
*/
|
||||
IFetchConformanceUntyped fetchConformance();
|
||||
|
||||
/**
|
||||
* Force the client to fetch the server's conformance statement and validate that it is appropriate for this client.
|
||||
*
|
||||
* @throws FhirClientConnectionException
|
||||
* if the conformance statement cannot be read, or if the client
|
||||
* @throws FhirClientInappropriateForServerException
|
||||
* If the conformance statement indicates that the server is inappropriate for this client (e.g. it implements the wrong version of FHIR)
|
||||
*/
|
||||
void forceConformanceCheck() throws FhirClientConnectionException;
|
||||
|
||||
/**
|
||||
* Implementation of the "history" method
|
||||
*/
|
||||
IHistory history();
|
||||
|
||||
/**
|
||||
* Loads the previous/next bundle of resources from a paged set, using the link specified in the "link type=next" tag within the atom bundle.
|
||||
*/
|
||||
IGetPage loadPage();
|
||||
|
||||
/**
|
||||
* Fluent method for the "meta" operations, which can be used to get, add and remove tags and other
|
||||
* Meta elements from a resource or across the server.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
IMeta meta();
|
||||
|
||||
/**
|
||||
* Implementation of the FHIR "extended operations" action
|
||||
*/
|
||||
IOperation operation();
|
||||
|
||||
/**
|
||||
* Fluent method for the "patch" operation, which performs a logical patch on a server resource
|
||||
*/
|
||||
IPatch patch();
|
||||
|
||||
/**
|
||||
* Fluent method for "read" and "vread" methods.
|
||||
*/
|
||||
IRead read();
|
||||
|
||||
/**
|
||||
* Implementation of the "instance read" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to load
|
||||
* @param theId
|
||||
* The ID to load
|
||||
* @return The resource
|
||||
*
|
||||
* @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
|
||||
*/
|
||||
@Deprecated
|
||||
<T extends IBaseResource> T read(Class<T> theType, String theId);
|
||||
|
||||
/**
|
||||
* Perform the "read" operation (retrieve the latest version of a resource instance by ID) using an absolute URL.
|
||||
*
|
||||
* @param theType
|
||||
* The resource type that is being retrieved
|
||||
* @param theUrl
|
||||
* The absolute URL, e.g. "http://example.com/fhir/Patient/123"
|
||||
* @return The returned resource from the server
|
||||
* @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
|
||||
*/
|
||||
@Deprecated
|
||||
<T extends IBaseResource> T read(Class<T> theType, UriDt theUrl);
|
||||
|
||||
/**
|
||||
* Perform the "read" operation (retrieve the latest version of a resource instance by ID) using an absolute URL.
|
||||
*
|
||||
* @param theUrl
|
||||
* The absolute URL, e.g. "http://example.com/fhir/Patient/123"
|
||||
* @return The returned resource from the server
|
||||
* @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
|
||||
*/
|
||||
@Deprecated
|
||||
IBaseResource read(UriDt theUrl);
|
||||
|
||||
/**
|
||||
* Register a new interceptor for this client. An interceptor can be used to add additional logging, or add security headers, or pre-process responses, etc.
|
||||
*/
|
||||
@Override
|
||||
void registerInterceptor(IClientInterceptor theInterceptor);
|
||||
|
||||
/**
|
||||
* Search for resources matching a given set of criteria. Searching is a very powerful
|
||||
* feature in FHIR with many features for specifying exactly what should be seaerched for
|
||||
* and how it should be returned. See the <a href="http://www.hl7.org/fhir/search.html">specification on search</a>
|
||||
* for more information.
|
||||
*/
|
||||
<T extends IBaseBundle> IUntypedQuery<T> search();
|
||||
|
||||
/**
|
||||
* If set to <code>true</code>, the client will log all requests and all responses. This is probably not a good production setting since it will result in a lot of extra logging, but it can be
|
||||
* useful for troubleshooting.
|
||||
*
|
||||
* @param theLogRequestAndResponse
|
||||
* Should requests and responses be logged
|
||||
* @deprecated Use LoggingInterceptor as a client interceptor registered to your
|
||||
* client instead, as this provides much more fine-grained control over what is logged. This
|
||||
* method will be removed at some point (deprecated in HAPI 1.6 - 2016-06-16)
|
||||
*/
|
||||
@Deprecated
|
||||
void setLogRequestAndResponse(boolean theLogRequestAndResponse);
|
||||
|
||||
/**
|
||||
* Send a transaction (collection of resources) to the server to be executed as a single unit
|
||||
*/
|
||||
ITransaction transaction();
|
||||
|
||||
/**
|
||||
* Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(IClientInterceptor)}
|
||||
*/
|
||||
@Override
|
||||
void unregisterInterceptor(IClientInterceptor theInterceptor);
|
||||
|
||||
/**
|
||||
* Fluent method for the "update" operation, which performs a logical delete on a server resource
|
||||
*/
|
||||
IUpdate update();
|
||||
|
||||
/**
|
||||
* Implementation of the "instance update" method.
|
||||
*
|
||||
* @param theId
|
||||
* The ID to update
|
||||
* @param theResource
|
||||
* The new resource body
|
||||
* @return An outcome containing the results and possibly the new version ID
|
||||
* @deprecated Use {@link #update() update() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
|
||||
*/
|
||||
@Deprecated
|
||||
MethodOutcome update(IdDt theId, IBaseResource theResource);
|
||||
|
||||
/**
|
||||
* Implementation of the "instance update" method.
|
||||
*
|
||||
* @param theId
|
||||
* The ID to update
|
||||
* @param theResource
|
||||
* The new resource body
|
||||
* @return An outcome containing the results and possibly the new version ID
|
||||
* @deprecated Use {@link #update() update() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
|
||||
*/
|
||||
@Deprecated
|
||||
MethodOutcome update(String theId, IBaseResource theResource);
|
||||
|
||||
/**
|
||||
* Validate a resource
|
||||
*/
|
||||
IValidate validate();
|
||||
|
||||
/**
|
||||
* Implementation of the "type validate" method.
|
||||
*
|
||||
* @param theResource
|
||||
* The resource to validate
|
||||
* @return An outcome containing any validation issues
|
||||
* @deprecated Use {@link #validate() validate() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
|
||||
*/
|
||||
@Deprecated
|
||||
MethodOutcome validate(IBaseResource theResource);
|
||||
|
||||
/**
|
||||
* Implementation of the "instance vread" method. Note that this method expects <code>theId</code> to contain a resource ID as well as a version ID, and will fail if it does not.
|
||||
* <p>
|
||||
* Note that if an absolute resource ID is passed in (i.e. a URL containing a protocol and host as well as the resource type and ID) the server base for the client will be ignored, and the URL
|
||||
* passed in will be queried.
|
||||
* </p>
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to load
|
||||
* @param theId
|
||||
* The ID to load, including the resource ID and the resource version ID. Valid values include "Patient/123/_history/222", or "http://example.com/fhir/Patient/123/_history/222"
|
||||
* @return The resource
|
||||
* @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
|
||||
*/
|
||||
@Deprecated
|
||||
<T extends IBaseResource> T vread(Class<T> theType, IdDt theId);
|
||||
|
||||
/**
|
||||
* Implementation of the "instance vread" method.
|
||||
*
|
||||
* @param theType
|
||||
* The type of resource to load
|
||||
* @param theId
|
||||
* The ID to load
|
||||
* @param theVersionId
|
||||
* The version ID
|
||||
* @return The resource
|
||||
* @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0)
|
||||
*/
|
||||
@Deprecated
|
||||
<T extends IBaseResource> T vread(Class<T> theType, String theId, String theVersionId);
|
||||
|
||||
}
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||
import org.hl7.fhir.instance.model.api.IBaseBinary;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
|
||||
/**
|
||||
* A HTTP Client interface.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ca.uhn.fhir.rest.client.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
* HAPI FHIR - Core Library
|
||||
|
@ -10,7 +12,7 @@ package ca.uhn.fhir.rest.client.api;
|
|||
* 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
|
||||
* 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,
|
||||
|
@ -20,13 +22,11 @@ package ca.uhn.fhir.rest.client.api;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.api.SummaryEnum;
|
||||
import ca.uhn.fhir.rest.client.IClientInterceptor;
|
||||
import ca.uhn.fhir.rest.server.EncodingEnum;
|
||||
|
||||
public interface IRestfulClient {
|
||||
|
||||
|
@ -35,51 +35,66 @@ public interface IRestfulClient {
|
|||
* method could be used as a low level implementation of a read/vread/search
|
||||
* operation.
|
||||
*
|
||||
* @param theResourceType The resource type to parse
|
||||
* @param theUrl The URL to load
|
||||
* @param theResourceType
|
||||
* The resource type to parse
|
||||
* @param theUrl
|
||||
* The URL to load
|
||||
* @return The parsed resource
|
||||
*/
|
||||
<T extends IBaseResource> T fetchResourceFromUrl(Class<T> theResourceType, String theUrl);
|
||||
|
||||
|
||||
/**
|
||||
* Returns the encoding that will be used on requests. Default is <code>null</code>, which means the client will not
|
||||
* explicitly request an encoding. (This is standard behaviour according to the FHIR specification)
|
||||
*/
|
||||
EncodingEnum getEncoding();
|
||||
|
||||
/**
|
||||
* Returns the FHIR context associated with this client
|
||||
*/
|
||||
FhirContext getFhirContext();
|
||||
|
||||
|
||||
/**
|
||||
* Do not call this method in client code. It is a part of the internal HAPI API and
|
||||
* Do not call this method in client code. It is a part of the internal HAPI API and
|
||||
* is subject to change!
|
||||
*/
|
||||
IHttpClient getHttpClient();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the client interceptors that have been registered with this client
|
||||
*/
|
||||
List<IClientInterceptor> getInterceptors();
|
||||
|
||||
/**
|
||||
* Base URL for the server, with no trailing "/"
|
||||
*/
|
||||
String getServerBase();
|
||||
|
||||
|
||||
/**
|
||||
* Register a new interceptor for this client. An interceptor can be used to add additional
|
||||
* logging, or add security headers, or pre-process responses, etc.
|
||||
* logging, or add security headers, or pre-process responses, etc.
|
||||
*/
|
||||
void registerInterceptor(IClientInterceptor theInterceptor);
|
||||
|
||||
/**
|
||||
* Specifies that the client should use the given encoding to do its
|
||||
* Specifies that the client should use the given encoding to do its
|
||||
* queries. This means that the client will append the "_format" param
|
||||
* to GET methods (read/search/etc), and will add an appropriate header for
|
||||
* write methods.
|
||||
* write methods.
|
||||
*
|
||||
* @param theEncoding The encoding to use in the request, or <code>null</code> not specify
|
||||
* an encoding (which generally implies the use of XML). The default is <code>null</code>.
|
||||
* @param theEncoding
|
||||
* The encoding to use in the request, or <code>null</code> not specify
|
||||
* an encoding (which generally implies the use of XML). The default is <code>null</code>.
|
||||
*/
|
||||
void setEncoding(EncodingEnum theEncoding);
|
||||
|
||||
|
||||
/**
|
||||
* Specifies that the client should request that the server respond with "pretty printing"
|
||||
* enabled. Note that this is a non-standard parameter, not all servers will
|
||||
* support it.
|
||||
*
|
||||
* @param thePrettyPrint The pretty print flag to use in the request (default is <code>false</code>)
|
||||
* @param thePrettyPrint
|
||||
* The pretty print flag to use in the request (default is <code>false</code>)
|
||||
*/
|
||||
void setPrettyPrint(Boolean thePrettyPrint);
|
||||
|
||||
|
@ -88,10 +103,10 @@ public interface IRestfulClient {
|
|||
* to be applied globally on this client.
|
||||
*/
|
||||
void setSummary(SummaryEnum theSummary);
|
||||
|
||||
|
||||
/**
|
||||
* Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(IClientInterceptor)}
|
||||
*/
|
||||
void unregisterInterceptor(IClientInterceptor theInterceptor);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package ca.uhn.fhir.rest.client;
|
||||
package ca.uhn.fhir.rest.client.api;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
@ -25,9 +25,6 @@ import java.util.Map;
|
|||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.rest.api.RequestTypeEnum;
|
||||
import ca.uhn.fhir.rest.client.api.Header;
|
||||
import ca.uhn.fhir.rest.client.api.IHttpClient;
|
||||
import ca.uhn.fhir.rest.client.api.IRestfulClient;
|
||||
|
||||
public interface IRestfulClientFactory {
|
||||
|
||||
|
@ -252,11 +249,11 @@ public interface IRestfulClientFactory {
|
|||
*/
|
||||
void setPoolMaxPerRoute(int thePoolMaxPerRoute);
|
||||
|
||||
void validateServerBase(String theServerBase, IHttpClient theHttpClient, BaseClient theClient);
|
||||
void validateServerBase(String theServerBase, IHttpClient theHttpClient, IRestfulClient theClient);
|
||||
|
||||
/**
|
||||
* This method is internal to HAPI - It may change in future versions, use with caution.
|
||||
*/
|
||||
void validateServerBaseIfConfiguredToDoSo(String theServerBase, IHttpClient theHttpClient, BaseClient theClient);
|
||||
void validateServerBaseIfConfiguredToDoSo(String theServerBase, IHttpClient theHttpClient, IRestfulClient theClient);
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package ca.uhn.fhir.rest.client;
|
||||
package ca.uhn.fhir.rest.client.api;
|
||||
|
||||
/*
|
||||
* #%L
|
|
@ -1,218 +0,0 @@
|
|||
package ca.uhn.fhir.rest.client.interceptor;
|
||||
|
||||
/*
|
||||
* #%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.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import ca.uhn.fhir.rest.client.IClientInterceptor;
|
||||
import ca.uhn.fhir.rest.client.api.IHttpRequest;
|
||||
import ca.uhn.fhir.rest.client.api.IHttpResponse;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
||||
public class LoggingInterceptor implements IClientInterceptor {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(LoggingInterceptor.class);
|
||||
|
||||
private Logger myLog = ourLog;
|
||||
private boolean myLogRequestBody = false;
|
||||
private boolean myLogRequestHeaders = false;
|
||||
private boolean myLogRequestSummary = true;
|
||||
private boolean myLogResponseBody = false;
|
||||
private boolean myLogResponseHeaders = false;
|
||||
private boolean myLogResponseSummary = true;
|
||||
|
||||
/**
|
||||
* Constructor for client logging interceptor
|
||||
*/
|
||||
public LoggingInterceptor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for client logging interceptor
|
||||
*
|
||||
* @param theVerbose
|
||||
* If set to true, all logging is enabled
|
||||
*/
|
||||
public LoggingInterceptor(boolean theVerbose) {
|
||||
if (theVerbose) {
|
||||
setLogRequestBody(true);
|
||||
setLogRequestSummary(true);
|
||||
setLogResponseBody(true);
|
||||
setLogResponseSummary(true);
|
||||
setLogRequestHeaders(true);
|
||||
setLogResponseHeaders(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interceptRequest(IHttpRequest theRequest) {
|
||||
if (myLogRequestSummary) {
|
||||
myLog.info("Client request: {}", theRequest);
|
||||
}
|
||||
|
||||
if (myLogRequestHeaders) {
|
||||
StringBuilder b = headersToString(theRequest.getAllHeaders());
|
||||
myLog.info("Client request headers:\n{}", b.toString());
|
||||
}
|
||||
|
||||
if (myLogRequestBody) {
|
||||
try {
|
||||
String content = theRequest.getRequestBodyFromStream();
|
||||
if (content != null) {
|
||||
myLog.info("Client request body:\n{}", content);
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
myLog.warn("Failed to replay request contents (during logging attempt, actual FHIR call did not fail)", e);
|
||||
} catch (IOException e) {
|
||||
myLog.warn("Failed to replay request contents (during logging attempt, actual FHIR call did not fail)", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interceptResponse(IHttpResponse theResponse) throws IOException {
|
||||
if (myLogResponseSummary) {
|
||||
String message = "HTTP " + theResponse.getStatus() + " " + theResponse.getStatusInfo();
|
||||
myLog.info("Client response: {}", message);
|
||||
}
|
||||
|
||||
if (myLogResponseHeaders) {
|
||||
StringBuilder b = headersToString(theResponse.getAllHeaders());
|
||||
// if (theResponse.getEntity() != null && theResponse.getEntity().getContentEncoding() != null) {
|
||||
// Header next = theResponse.getEntity().getContentEncoding();
|
||||
// b.append(next.getName() + ": " + next.getValue());
|
||||
// }
|
||||
// if (theResponse.getEntity() != null && theResponse.getEntity().getContentType() != null) {
|
||||
// Header next = theResponse.getEntity().getContentType();
|
||||
// b.append(next.getName() + ": " + next.getValue());
|
||||
// }
|
||||
if (b.length() == 0) {
|
||||
myLog.info("Client response headers: (none)");
|
||||
} else {
|
||||
myLog.info("Client response headers:\n{}", b.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (myLogResponseBody) {
|
||||
//TODO: Use of a deprecated method should be resolved.
|
||||
theResponse.bufferEntitity();
|
||||
InputStream respEntity = null;
|
||||
try {
|
||||
respEntity = theResponse.readEntity();
|
||||
if (respEntity != null) {
|
||||
final byte[] bytes;
|
||||
try {
|
||||
bytes = IOUtils.toByteArray(respEntity);
|
||||
} catch (IllegalStateException e) {
|
||||
throw new InternalErrorException(e);
|
||||
}
|
||||
myLog.info("Client response body:\n{}", new String(bytes, "UTF-8"));
|
||||
} else {
|
||||
myLog.info("Client response body: (none)");
|
||||
}
|
||||
} finally {
|
||||
IOUtils.closeQuietly(respEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private StringBuilder headersToString(Map<String, List<String>> theHeaders) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
if (theHeaders != null && !theHeaders.isEmpty()) {
|
||||
Iterator<String> nameEntries = theHeaders.keySet().iterator();
|
||||
while(nameEntries.hasNext()) {
|
||||
String key = nameEntries.next();
|
||||
Iterator<String> values = theHeaders.get(key).iterator();
|
||||
while(values.hasNext()) {
|
||||
String value = values.next();
|
||||
b.append(key + ": " + value);
|
||||
if (nameEntries.hasNext() || values.hasNext()) {
|
||||
b.append('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a logger to use to log messages (default is a logger with this class' name). This can be used to redirect
|
||||
* logs to a differently named logger instead.
|
||||
*
|
||||
* @param theLogger
|
||||
* The logger to use. Must not be null.
|
||||
*/
|
||||
public void setLogger(Logger theLogger) {
|
||||
Validate.notNull(theLogger, "theLogger can not be null");
|
||||
myLog = theLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should a summary (one line) for each request be logged, containing the URL and other information
|
||||
*/
|
||||
public void setLogRequestBody(boolean theValue) {
|
||||
myLogRequestBody = theValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should headers for each request be logged, containing the URL and other information
|
||||
*/
|
||||
public void setLogRequestHeaders(boolean theValue) {
|
||||
myLogRequestHeaders = theValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should a summary (one line) for each request be logged, containing the URL and other information
|
||||
*/
|
||||
public void setLogRequestSummary(boolean theValue) {
|
||||
myLogRequestSummary = theValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should a summary (one line) for each request be logged, containing the URL and other information
|
||||
*/
|
||||
public void setLogResponseBody(boolean theValue) {
|
||||
myLogResponseBody = theValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should headers for each request be logged, containing the URL and other information
|
||||
*/
|
||||
public void setLogResponseHeaders(boolean theValue) {
|
||||
myLogResponseHeaders = theValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should a summary (one line) for each request be logged, containing the URL and other information
|
||||
*/
|
||||
public void setLogResponseSummary(boolean theValue) {
|
||||
myLogResponseSummary = theValue;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package ca.uhn.fhir.rest.client.interceptor;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
/*
|
||||
* #%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.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import ca.uhn.fhir.rest.client.IClientInterceptor;
|
||||
import ca.uhn.fhir.rest.client.api.IHttpRequest;
|
||||
import ca.uhn.fhir.rest.client.api.IHttpResponse;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
||||
/**
|
||||
* This interceptor adds an arbitrary header to requests made by this client. Both the
|
||||
* header name and the header value are specified by the calling code.
|
||||
*/
|
||||
public class SimpleRequestHeaderInterceptor implements IClientInterceptor {
|
||||
|
||||
private String myHeaderName;
|
||||
private String myHeaderValue;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SimpleRequestHeaderInterceptor() {
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SimpleRequestHeaderInterceptor(String theHeaderName, String theHeaderValue) {
|
||||
super();
|
||||
myHeaderName = theHeaderName;
|
||||
myHeaderValue = theHeaderValue;
|
||||
}
|
||||
|
||||
public String getHeaderName() {
|
||||
return myHeaderName;
|
||||
}
|
||||
|
||||
public String getHeaderValue() {
|
||||
return myHeaderValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interceptRequest(IHttpRequest theRequest) {
|
||||
if (isNotBlank(getHeaderName())) {
|
||||
theRequest.addHeader(getHeaderName(), getHeaderValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interceptResponse(IHttpResponse theResponse) throws IOException {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void setHeaderName(String theHeaderName) {
|
||||
myHeaderName = theHeaderName;
|
||||
}
|
||||
|
||||
public void setHeaderValue(String theHeaderValue) {
|
||||
myHeaderValue = theHeaderValue;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue