Class FHIRResource
- java.lang.Object
-
- org.linuxforhealth.fhir.server.resources.FHIRResource
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
AUDIT_LOGGING_ERR_MSG
protected javax.servlet.ServletContext
context
protected PropertyGroup
fhirConfig
static java.time.format.DateTimeFormatter
HTTP_DATETIME_FORMATTER
protected javax.servlet.http.HttpServletRequest
httpServletRequest
protected SearchHelper
searchHelper
protected javax.ws.rs.core.SecurityContext
securityContext
protected javax.ws.rs.core.UriInfo
uriInfo
UriInfo injected by the JAXRS framework.
-
Constructor Summary
Constructors Constructor Description FHIRResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.ws.rs.core.Response.ResponseBuilder
addETagAndLastModifiedHeaders(javax.ws.rs.core.Response.ResponseBuilder rb, Resource resource)
Adds the Etag and Last-Modified headers to the response from the specified resource (if possible).protected javax.ws.rs.core.Response.ResponseBuilder
addHeaders(javax.ws.rs.core.Response.ResponseBuilder rb, int fallbackETagVersion)
Adds the Etag header to the specified response object.protected javax.ws.rs.core.Response.ResponseBuilder
addHeaders(javax.ws.rs.core.Response.ResponseBuilder rb, java.net.URI locationURI)
Add the etag header using the version obtained from the locationURIprotected java.lang.String
buildAbsoluteUri(java.lang.String baseUri, java.lang.String relativeUri)
This function will build an absolute URI from the specified base URI and relative URI.protected OperationOutcome.Issue
buildOperationOutcomeIssue(IssueSeverity severity, IssueType type, java.lang.String msg)
Builds an OperationOutcomeIssue with the respective values for some of the fields.protected FHIROperationException
buildRestException(java.lang.String msg, IssueType issueType)
protected FHIROperationException
buildRestException(java.lang.String msg, IssueType issueType, IssueSeverity severity)
protected FHIROperationException
buildUnsupportedResourceTypeException(java.lang.String resourceTypeName)
protected void
checkInitComplete()
This method will do a quick check of the "initCompleted" flag in the servlet context.protected void
checkType(java.lang.String type)
This method will do a quick check of the {type} URL parameter.protected javax.ws.rs.core.Response
exceptionResponse(java.lang.Exception e, javax.ws.rs.core.Response.Status status)
protected javax.ws.rs.core.Response
exceptionResponse(FHIROperationException e, javax.ws.rs.core.Response.Status status)
protected javax.ws.rs.core.Response
exceptionResponse(OperationOutcome oo, javax.ws.rs.core.Response.Status status)
protected javax.ws.rs.core.Response
exceptionResponse(FHIRRestBundledRequestException e)
protected FHIRVersionParam
getFhirVersion()
The FHIRVersion to use for the current requestprotected FHIRPersistence
getPersistenceImpl()
Retrieves the persistence implementation to use for the current request.protected java.lang.String
getRequestUri()
Get the original request URI from either the HttpServletRequest or a configured Header (in case of re-writing proxies).protected SearchHelper
getSearchHelper()
Retrieves the shared persistence helper object from the servlet context.protected boolean
isDeleteSupported()
protected java.lang.Boolean
isUpdateCreateEnabled()
protected long
parseIfModifiedSince()
protected java.net.URI
toUri(java.lang.String uriString)
This method simply returns a URI object containing the specified URI string.
-
-
-
Field Detail
-
HTTP_DATETIME_FORMATTER
public static final java.time.format.DateTimeFormatter HTTP_DATETIME_FORMATTER
-
AUDIT_LOGGING_ERR_MSG
protected static final java.lang.String AUDIT_LOGGING_ERR_MSG
- See Also:
- Constant Field Values
-
context
@Context protected javax.servlet.ServletContext context
-
httpServletRequest
@Context protected javax.servlet.http.HttpServletRequest httpServletRequest
-
uriInfo
@Context protected javax.ws.rs.core.UriInfo uriInfo
UriInfo injected by the JAXRS framework.Use
getRequestUri()
instead to get the original request URI when constructing URIs that will be sent back to the end user.
-
securityContext
@Context protected javax.ws.rs.core.SecurityContext securityContext
-
searchHelper
protected SearchHelper searchHelper
-
fhirConfig
protected PropertyGroup fhirConfig
-
-
Method Detail
-
checkInitComplete
protected void checkInitComplete() throws FHIROperationException
This method will do a quick check of the "initCompleted" flag in the servlet context. If the flag is FALSE, then we'll throw an error to short-circuit the current in-progress REST API invocation.- Throws:
FHIROperationException
-
checkType
protected void checkType(java.lang.String type) throws FHIROperationException
This method will do a quick check of the {type} URL parameter. If the type is not a valid FHIR resource type, then we'll throw an error to short-circuit the current in-progress REST API invocation.- Throws:
FHIROperationException
-
buildRestException
protected FHIROperationException buildRestException(java.lang.String msg, IssueType issueType)
-
buildRestException
protected FHIROperationException buildRestException(java.lang.String msg, IssueType issueType, IssueSeverity severity)
-
parseIfModifiedSince
protected long parseIfModifiedSince()
-
buildOperationOutcomeIssue
protected OperationOutcome.Issue buildOperationOutcomeIssue(IssueSeverity severity, IssueType type, java.lang.String msg)
Builds an OperationOutcomeIssue with the respective values for some of the fields.
-
buildAbsoluteUri
protected java.lang.String buildAbsoluteUri(java.lang.String baseUri, java.lang.String relativeUri)
This function will build an absolute URI from the specified base URI and relative URI.- Parameters:
baseUri
- the base URI to be used; this will be of the form:// : / relativeUri
- the path and query parts- Returns:
- the full URI value as a String
-
addETagAndLastModifiedHeaders
protected javax.ws.rs.core.Response.ResponseBuilder addETagAndLastModifiedHeaders(javax.ws.rs.core.Response.ResponseBuilder rb, Resource resource)
Adds the Etag and Last-Modified headers to the response from the specified resource (if possible).- Parameters:
rb
-resource
-- Returns:
-
addHeaders
protected javax.ws.rs.core.Response.ResponseBuilder addHeaders(javax.ws.rs.core.Response.ResponseBuilder rb, int fallbackETagVersion)
Adds the Etag header to the specified response object.- Parameters:
rb
-fallbackETagVersion
-- Returns:
-
addHeaders
protected javax.ws.rs.core.Response.ResponseBuilder addHeaders(javax.ws.rs.core.Response.ResponseBuilder rb, java.net.URI locationURI)
Add the etag header using the version obtained from the locationURI- Parameters:
rb
-locationURI
-- Returns:
-
exceptionResponse
protected javax.ws.rs.core.Response exceptionResponse(FHIRRestBundledRequestException e)
-
exceptionResponse
protected javax.ws.rs.core.Response exceptionResponse(FHIROperationException e, javax.ws.rs.core.Response.Status status)
-
exceptionResponse
protected javax.ws.rs.core.Response exceptionResponse(java.lang.Exception e, javax.ws.rs.core.Response.Status status)
-
exceptionResponse
protected javax.ws.rs.core.Response exceptionResponse(OperationOutcome oo, javax.ws.rs.core.Response.Status status)
-
getSearchHelper
protected SearchHelper getSearchHelper()
Retrieves the shared persistence helper object from the servlet context.
-
getPersistenceImpl
protected FHIRPersistence getPersistenceImpl() throws FHIRPersistenceException
Retrieves the persistence implementation to use for the current request.- Throws:
FHIRPersistenceException
-
isDeleteSupported
protected boolean isDeleteSupported() throws FHIRPersistenceException
- Throws:
FHIRPersistenceException
-
isUpdateCreateEnabled
protected java.lang.Boolean isUpdateCreateEnabled()
-
getRequestUri
protected java.lang.String getRequestUri() throws java.lang.Exception
Get the original request URI from either the HttpServletRequest or a configured Header (in case of re-writing proxies).When the 'fhirServer/core/originalRequestUriHeaderName' property is empty, this method returns the equivalent of uriInfo.getRequestUri().toString(), except that uriInfo.getRequestUri() will throw an IllegalArgumentException when the query string portion contains a vertical bar | character. The vertical bar is one known case of a special character causing the exception. There could be others.
- Returns:
- String The complete request URI
- Throws:
java.lang.Exception
- if an error occurs while reading the config
-
toUri
protected java.net.URI toUri(java.lang.String uriString) throws java.net.URISyntaxException
This method simply returns a URI object containing the specified URI string.- Parameters:
uriString
- the URI string for which the URI object will be created- Throws:
java.net.URISyntaxException
-
buildUnsupportedResourceTypeException
protected FHIROperationException buildUnsupportedResourceTypeException(java.lang.String resourceTypeName)
-
getFhirVersion
protected FHIRVersionParam getFhirVersion()
The FHIRVersion to use for the current request- Returns:
- the corresponding FHIRVersion for the org.linuxforhealth.fhir.server.fhirVersion request context attribute
-
-