Package com.ibm.fhir.server.util
Class FHIRRestHelper
- java.lang.Object
-
- com.ibm.fhir.server.util.FHIRRestHelper
-
- All Implemented Interfaces:
FHIRResourceHelpers
public class FHIRRestHelper extends Object implements FHIRResourceHelpers
Helper methods for performing the "heavy lifting" with respect to implementing FHIR interactions.
-
-
Field Summary
Fields Modifier and Type Field Description static DateTimeFormatter
PARSER_FORMATTER
-
Fields inherited from interface com.ibm.fhir.server.operation.spi.FHIRResourceHelpers
DO_VALIDATION
-
-
Constructor Summary
Constructors Constructor Description FHIRRestHelper(FHIRPersistence persistence)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bundle
doBundle(Bundle inputBundle, Map<String,String> requestProperties)
Processes a bundled request.FHIRRestOperationResponse
doCreate(String type, Resource resource, String ifNoneExist, Map<String,String> requestProperties, boolean doValidation)
Performs the heavy lifting associated with a 'create' interaction.FHIRRestOperationResponse
doDelete(String type, String id, String searchQueryString, Map<String,String> requestProperties)
Performs a 'delete' operation on the specified resource.Bundle
doHistory(String type, String id, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri, Map<String,String> requestProperties)
Performs the work of retrieving versions of a Resource.Resource
doInvoke(FHIROperationContext operationContext, String resourceTypeName, String logicalId, String versionId, String operationName, Resource resource, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, Map<String,String> requestProperties)
Helper method which invokes a custom operation.FHIRRestOperationResponse
doPatch(String type, String id, FHIRPatch patch, String ifMatchValue, String searchQueryString, Map<String,String> requestProperties)
Performs a patch operation (a new version of the Resource will be stored).Resource
doRead(String type, String id, boolean throwExcOnNull, boolean includeDeleted, Map<String,String> requestProperties, Resource contextResource)
Performs a 'read' operation to retrieve a Resource.Resource
doRead(String type, String id, boolean throwExcOnNull, boolean includeDeleted, Map<String,String> requestProperties, Resource contextResource, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters)
Performs a 'read' operation to retrieve a Resource.Bundle
doSearch(String type, String compartment, String compartmentId, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri, Map<String,String> requestProperties, Resource contextResource)
Performs heavy lifting associated with a 'search' operation.FHIRRestOperationResponse
doUpdate(String type, String id, Resource newResource, String ifMatchValue, String searchQueryString, Map<String,String> requestProperties, boolean doValidation)
Performs an update operation (a new version of the Resource will be stored).Resource
doVRead(String type, String id, String versionId, Map<String,String> requestProperties)
Performs a 'vread' operation by retrieving the specified version of a Resource.FHIRPersistenceTransaction
getTransaction()
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.fhir.server.operation.spi.FHIRResourceHelpers
doCreate, doUpdate
-
-
-
-
Field Detail
-
PARSER_FORMATTER
public static final DateTimeFormatter PARSER_FORMATTER
-
-
Constructor Detail
-
FHIRRestHelper
public FHIRRestHelper(FHIRPersistence persistence)
-
-
Method Detail
-
doCreate
public FHIRRestOperationResponse doCreate(String type, Resource resource, String ifNoneExist, Map<String,String> requestProperties, boolean doValidation) throws Exception
Description copied from interface:FHIRResourceHelpers
Performs the heavy lifting associated with a 'create' interaction.- Specified by:
doCreate
in interfaceFHIRResourceHelpers
- Parameters:
type
- the resource type specified as part of the request URLresource
- the Resource to be stored.ifNoneExist
- whether to create the resource if none existsrequestProperties
- additional request properties which supplement the HTTP headers associated with this requestdoValidation
- if true, validate the resource; if false, assume the resource has already been validated- Returns:
- a FHIRRestOperationResponse object containing the results of the operation
- Throws:
Exception
-
doPatch
public FHIRRestOperationResponse doPatch(String type, String id, FHIRPatch patch, String ifMatchValue, String searchQueryString, Map<String,String> requestProperties) throws Exception
Description copied from interface:FHIRResourceHelpers
Performs a patch operation (a new version of the Resource will be stored).- Specified by:
doPatch
in interfaceFHIRResourceHelpers
- Parameters:
type
- the type of the resource to be updatedid
- the id of the Resource being updatedpatch
- the patch to applyifMatchValue
- an optional "If-Match" header value to request a version-aware updatesearchQueryString
- an optional search query string to request a conditional update- Returns:
- a FHIRRestOperationResponse that contains the results of the operation
- Throws:
Exception
-
doUpdate
public FHIRRestOperationResponse doUpdate(String type, String id, Resource newResource, String ifMatchValue, String searchQueryString, Map<String,String> requestProperties, boolean doValidation) throws Exception
Description copied from interface:FHIRResourceHelpers
Performs an update operation (a new version of the Resource will be stored).- Specified by:
doUpdate
in interfaceFHIRResourceHelpers
- Parameters:
type
- the type of the resource to be updatedid
- the id of the Resource being updatednewResource
- the new resource to be storedifMatchValue
- an optional "If-Match" header value to request a version-aware updatesearchQueryString
- an optional search query string to request a conditional updatedoValidation
- if true, validate the resource; if false, assume the resource has already been validated- Returns:
- a FHIRRestOperationResponse that contains the results of the operation
- Throws:
Exception
-
doDelete
public FHIRRestOperationResponse doDelete(String type, String id, String searchQueryString, Map<String,String> requestProperties) throws Exception
Performs a 'delete' operation on the specified resource.- Specified by:
doDelete
in interfaceFHIRResourceHelpers
- Parameters:
type
- the resource type associated with the Resource to be deletedid
- the id of the Resource to be deletedrequestProperties
- additional request properties which supplement the HTTP headers associated with this request- Returns:
- a FHIRRestOperationResponse that contains the results of the operation
- Throws:
Exception
-
doRead
public Resource doRead(String type, String id, boolean throwExcOnNull, boolean includeDeleted, Map<String,String> requestProperties, Resource contextResource) throws Exception
Description copied from interface:FHIRResourceHelpers
Performs a 'read' operation to retrieve a Resource.- Specified by:
doRead
in interfaceFHIRResourceHelpers
- Parameters:
type
- the resource type associated with the Resource to be retrievedid
- the id of the Resource to be retrieved- Returns:
- the Resource
- Throws:
Exception
-
doRead
public Resource doRead(String type, String id, boolean throwExcOnNull, boolean includeDeleted, Map<String,String> requestProperties, Resource contextResource, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters) throws Exception
Performs a 'read' operation to retrieve a Resource.- Specified by:
doRead
in interfaceFHIRResourceHelpers
- Parameters:
type
- the resource type associated with the Resource to be retrievedid
- the id of the Resource to be retrievedrequestProperties
- additional request properties which supplement the HTTP headers associated with this requestqueryParameters
- for supporting _summary for resource read- Returns:
- the Resource
- Throws:
Exception
-
doVRead
public Resource doVRead(String type, String id, String versionId, Map<String,String> requestProperties) throws Exception
Performs a 'vread' operation by retrieving the specified version of a Resource.- Specified by:
doVRead
in interfaceFHIRResourceHelpers
- Parameters:
type
- the resource type associated with the Resource to be retrievedid
- the id of the Resource to be retrievedversionId
- the version id of the Resource to be retrievedrequestProperties
- additional request properties which supplement the HTTP headers associated with this request- Returns:
- the Resource
- Throws:
Exception
-
doHistory
public Bundle doHistory(String type, String id, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri, Map<String,String> requestProperties) throws Exception
Performs the work of retrieving versions of a Resource.- Specified by:
doHistory
in interfaceFHIRResourceHelpers
- Parameters:
type
- the resource type associated with the Resource to be retrievedid
- the id of the Resource to be retrievedqueryParameters
- a Map containing the query parameters from the request URLrequestUri
- the URI from the requestrequestProperties
- additional request properties which supplement the HTTP headers associated with this request- Returns:
- a Bundle containing the history of the specified Resource
- Throws:
Exception
-
doSearch
public Bundle doSearch(String type, String compartment, String compartmentId, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri, Map<String,String> requestProperties, Resource contextResource) throws Exception
Performs heavy lifting associated with a 'search' operation.- Specified by:
doSearch
in interfaceFHIRResourceHelpers
- Parameters:
type
- the resource type associated with the searchqueryParameters
- a Map containing the query parameters from the request URLrequestProperties
- additional request properties which supplement the HTTP headers associated with this request- Returns:
- a Bundle containing the search result set
- Throws:
Exception
-
doInvoke
public Resource doInvoke(FHIROperationContext operationContext, String resourceTypeName, String logicalId, String versionId, String operationName, Resource resource, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, Map<String,String> requestProperties) throws Exception
Helper method which invokes a custom operation.- Specified by:
doInvoke
in interfaceFHIRResourceHelpers
- Parameters:
operationContext
- the FHIROperationContext associated with the requestresourceTypeName
- the resource type associated with the requestlogicalId
- the resource logical id associated with the requestversionId
- the resource version id associated with the requestoperationName
- the name of the custom operation to be invokedresource
- the input resource associated with the custom operation to be invokedqueryParameters
- query parameters may be passed instead of a Parameters resource for certain custom operations invoked via GETrequestProperties
- additional request properties which supplement the HTTP headers associated with this request- Returns:
- a Resource that represents the response to the custom operation
- Throws:
Exception
-
doBundle
public Bundle doBundle(Bundle inputBundle, Map<String,String> requestProperties) throws Exception
Processes a bundled request.- Specified by:
doBundle
in interfaceFHIRResourceHelpers
- Parameters:
bundleResource
- the request BundlerequestProperties
- additional request properties which supplement the HTTP headers associated with this request- Returns:
- the response Bundle
- Throws:
Exception
-
getTransaction
public FHIRPersistenceTransaction getTransaction() throws Exception
- Specified by:
getTransaction
in interfaceFHIRResourceHelpers
- Throws:
Exception
-
-