
Package ca.uhn.fhir.jaxrs.server
Class AbstractJaxRsResourceProvider<R extends org.hl7.fhir.instance.model.api.IBaseResource>
java.lang.Object
ca.uhn.fhir.jaxrs.server.AbstractJaxRsProvider
ca.uhn.fhir.jaxrs.server.AbstractJaxRsResourceProvider<R>
- All Implemented Interfaces:
ca.uhn.fhir.rest.api.server.IRestfulServer<JaxRsRequest>,ca.uhn.fhir.rest.server.IResourceProvider,ca.uhn.fhir.rest.server.IRestfulServerDefaults
@Produces({"application/json","application/xml","text/plain","application/json+fhir","application/xml+fhir"})
@Consumes({"application/x-www-form-urlencoded","application/json","application/json+fhir","application/xml+fhir","application/fhir+json","application/fhir+xml","application/octet-stream"})
public abstract class AbstractJaxRsResourceProvider<R extends org.hl7.fhir.instance.model.api.IBaseResource>
extends AbstractJaxRsProvider
implements ca.uhn.fhir.rest.api.server.IRestfulServer<JaxRsRequest>, ca.uhn.fhir.rest.server.IResourceProvider
This server is the abstract superclass for all resource providers. It exposes
a large amount of the fhir api functionality using JAXRS
- Author:
- Peter Van Houte | peter.vanhoute@agfa.com | Agfa Healthcare
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThe default constructor.protectedAbstractJaxRsResourceProvider(ca.uhn.fhir.context.FhirContext ctx) Provides the ability to specify theFhirContext.protectedAbstractJaxRsResourceProvider(ca.uhn.fhir.context.FhirContext ctx, Class<? extends AbstractJaxRsProvider> theProviderClass) This constructor takes in an explicit interface class.protectedAbstractJaxRsResourceProvider(Class<? extends AbstractJaxRsProvider> theProviderClass) This constructor takes in an explicit interface class. -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.core.ResponseconditionalUpdate(String resource) Update an existing resource based on the given conditionjakarta.ws.rs.core.ResponseCreate a new resource with a server assigned idprotected jakarta.ws.rs.core.ResponsecustomOperation(String resource, ca.uhn.fhir.rest.api.RequestTypeEnum requestType, String id, String operationName, ca.uhn.fhir.rest.api.RestOperationTypeEnum operationType) Execute a custom operationjakarta.ws.rs.core.Responsedelete()Delete a resource based on the given conditionjakarta.ws.rs.core.ResponseDelete a resourcejakarta.ws.rs.core.ResponseRead the current state of the resourcejakarta.ws.rs.core.ResponsefindCompartment(String id, String compartment) Compartment Based Accessjakarta.ws.rs.core.ResponsefindVersion(String id, String version) Retrieve a version of a resourceThe base for request for a resource provider has the following form:getBaseForServer()+ "/" +getResourceType().getSimpleName()protected ca.uhn.fhir.rest.server.method.BaseMethodBindinggetBinding(ca.uhn.fhir.rest.api.RestOperationTypeEnum restOperation, String theBindingKey) Return the method binding for the given rest operationReturn the bindings defined in this resource providerca.uhn.fhir.context.api.BundleInclusionRuleDefault: BundleInclusionRule.BASED_ON_INCLUDESca.uhn.fhir.rest.api.PreferReturnEnumca.uhn.fhir.rest.server.IPagingProviderDefault: no paging providerThe resource type should return conform to the generic resource included in the topicjakarta.ws.rs.core.ResponseRetrieve the update history for a particular resourcejakarta.ws.rs.core.ResponseRetrieve the update history for a particular typejakarta.ws.rs.core.Responsesearch()Search the resource type based on some filter criteriajakarta.ws.rs.core.ResponseSearch the resource type based on some filter criteriajakarta.ws.rs.core.ResponseUpdate an existing resource by its id (or create it if it is new)jakarta.ws.rs.core.ResponseMethods inherited from class ca.uhn.fhir.jaxrs.server.AbstractJaxRsProvider
getAddProfileTag, getBaseForServer, getDefaultResponseEncoding, getElementsSupport, getETagSupport, getFhirContext, getHeaders, getInterceptors_, getInterceptorService, getParameters, getRequest, getRequest, getServerAddressStrategy, getUriInfo, handleException, isDefaultPrettyPrint, setHeaders, setUriInfo, withStackTraceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ca.uhn.fhir.rest.api.server.IRestfulServer
canStoreSearchResultsMethods inherited from interface ca.uhn.fhir.rest.server.IRestfulServerDefaults
getAddProfileTag, getDefaultPageSize, getDefaultResponseEncoding, getElementsSupport, getETagSupport, getFhirContext, getInterceptors_, getInterceptorService, getMaximumPageSize, isDefaultPrettyPrint
-
Constructor Details
-
AbstractJaxRsResourceProvider
protected AbstractJaxRsResourceProvider()The default constructor. The method bindings are retrieved from the class being constructed. -
AbstractJaxRsResourceProvider
Provides the ability to specify theFhirContext.- Parameters:
ctx- theFhirContextinstance.
-
AbstractJaxRsResourceProvider
This constructor takes in an explicit interface class. This subclass should be identical to the class being constructed but is given explicitly in order to avoid issues with proxy classes in a jee environment.- Parameters:
theProviderClass- the interface of the class
-
AbstractJaxRsResourceProvider
protected AbstractJaxRsResourceProvider(ca.uhn.fhir.context.FhirContext ctx, Class<? extends AbstractJaxRsProvider> theProviderClass) This constructor takes in an explicit interface class. This subclass should be identical to the class being constructed but is given explicitly in order to avoid issues with proxy classes in a jee environment.- Parameters:
ctx- theFhirContextinstance.theProviderClass- the interface of the class
-
-
Method Details
-
getBaseForRequest
The base for request for a resource provider has the following form:getBaseForServer()+ "/" +getResourceType().getSimpleName()- Overrides:
getBaseForRequestin classAbstractJaxRsProvider- Returns:
- the ascii string for the base resource provider path
-
create
Create a new resource with a server assigned id- Parameters:
resource- the body of the post method containing resource being created in a xml/json form- Returns:
- the response
- Throws:
IOException- See Also:
-
searchWithPost
Search the resource type based on some filter criteria- Returns:
- the response
- Throws:
IOException- See Also:
-
search
Search the resource type based on some filter criteria- Returns:
- the response
- Throws:
IOException- See Also:
-
conditionalUpdate
Update an existing resource based on the given condition- Parameters:
resource- the body contents for the put method- Returns:
- the response
- Throws:
IOException- See Also:
-
update
@PUT @Path("/{id}") public jakarta.ws.rs.core.Response update(@PathParam("id") String id, String resource) throws IOException Update an existing resource by its id (or create it if it is new)- Parameters:
id- the id of the resourceresource- the body contents for the put method- Returns:
- the response
- Throws:
IOException- See Also:
-
delete
Delete a resource based on the given condition- Returns:
- the response
- Throws:
IOException- See Also:
-
delete
@DELETE @Path("/{id}") public jakarta.ws.rs.core.Response delete(@PathParam("id") String id) throws IOException Delete a resource- Parameters:
id- the id of the resource to delete- Returns:
- the response
- Throws:
IOException- See Also:
-
find
@GET @Path("/{id : ((?!_history).)*}") public jakarta.ws.rs.core.Response find(@PathParam("id") String id) throws IOException Read the current state of the resource- Parameters:
id- the id of the resource to read- Returns:
- the response
- Throws:
IOException- See Also:
-
customOperation
protected jakarta.ws.rs.core.Response customOperation(String resource, ca.uhn.fhir.rest.api.RequestTypeEnum requestType, String id, String operationName, ca.uhn.fhir.rest.api.RestOperationTypeEnum operationType) throws IOException Execute a custom operation- Parameters:
resource- the resource to createrequestType- the type of requestid- the id of the resource on which to perform the operationoperationName- the name of the operation to executeoperationType- the rest operation type- Returns:
- the response
- Throws:
IOException- See Also:
-
findVersion
@GET @Path("/{id}/_history/{version}") public jakarta.ws.rs.core.Response findVersion(@PathParam("id") String id, @PathParam("version") String version) throws IOException Retrieve a version of a resource- Parameters:
id- the id of the resourceversion- the version of the resource- Returns:
- the response
- Throws:
IOException- See Also:
-
historyForInstance
@GET @Path("/{id}/_history") public jakarta.ws.rs.core.Response historyForInstance(@PathParam("id") String id) throws IOException Retrieve the update history for a particular resource- Parameters:
id- the id of the resource- Returns:
- the response
- Throws:
IOException- See Also:
-
historyForType
Retrieve the update history for a particular type- Returns:
- the response
- Throws:
IOException- See Also:
-
findCompartment
@GET @Path("/{id}/{compartment : ((?!_history).)*}") public jakarta.ws.rs.core.Response findCompartment(@PathParam("id") String id, @PathParam("compartment") String compartment) throws IOException Compartment Based Access- Parameters:
id- the resource to which the compartment belongscompartment- the compartment- Returns:
- the repsonse
- Throws:
IOException- See Also:
-
validate
@POST @Path("/$validate") public jakarta.ws.rs.core.Response validate(String resource) throws IOException - Throws:
IOException
-
getBinding
protected ca.uhn.fhir.rest.server.method.BaseMethodBinding getBinding(ca.uhn.fhir.rest.api.RestOperationTypeEnum restOperation, String theBindingKey) Return the method binding for the given rest operation- Parameters:
restOperation- the rest operation to retrievetheBindingKey- the key determining the method to be executed (needed for e.g. custom operation)- Returns:
-
getPagingProvider
Default: no paging provider- Specified by:
getPagingProviderin interfaceca.uhn.fhir.rest.api.server.IRestfulServer<R extends org.hl7.fhir.instance.model.api.IBaseResource>- Specified by:
getPagingProviderin interfaceca.uhn.fhir.rest.server.IRestfulServerDefaults- Overrides:
getPagingProviderin classAbstractJaxRsProvider
-
getBundleInclusionRule
Default: BundleInclusionRule.BASED_ON_INCLUDES- Specified by:
getBundleInclusionRulein interfaceca.uhn.fhir.rest.api.server.IRestfulServer<R extends org.hl7.fhir.instance.model.api.IBaseResource>
-
getDefaultPreferReturn
- Specified by:
getDefaultPreferReturnin interfaceca.uhn.fhir.rest.api.server.IRestfulServer<R extends org.hl7.fhir.instance.model.api.IBaseResource>
-
getResourceType
The resource type should return conform to the generic resource included in the topic- Specified by:
getResourceTypein interfaceca.uhn.fhir.rest.server.IResourceProvider
-
getBindings
Return the bindings defined in this resource provider- Returns:
- the jax-rs method bindings
-