Class IpfFhirServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
ca.uhn.fhir.rest.server.RestfulServer
org.openehealth.ipf.commons.ihe.fhir.IpfFhirServlet
All Implemented Interfaces:
IRestfulServer<ServletRequestDetails>, IRestfulServerDefaults, Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
IpfBootFhirServlet

public class IpfFhirServlet extends RestfulServer
HAPI FHIR RestfulServer implementation, adding a few configuration bits using servlet init parameters:
  • logging (boolean): add global logging interceptor
  • highlight (boolean): add response formatting if request was issued from a browser
  • pretty (boolean): pretty-print the response
  • pagingProviderSize (integer): maximum number of concurrent paging requests
  • strict (boolean): strict parsing, i.e. return error on invalid resources
Since:
3.2
Author:
Christian Ohr
See Also:
  • Field Details

  • Constructor Details

    • IpfFhirServlet

      public IpfFhirServlet()
    • IpfFhirServlet

      public IpfFhirServlet(FhirVersionEnum fhirVersion)
      Initialize the servlet with a FHIR version. During initialization, a new FHIR Context is created and initialized with strictErrorHandler and narrativeGenerator.
      Parameters:
      fhirVersion - FHIR version
    • IpfFhirServlet

      public IpfFhirServlet(FhirContext fhirContext)
      Initializes the servlet with a pre-instantiated FHIR Context. No further changes are done to this FHIRContext instance.
      Parameters:
      fhirContext - FHIR Context
  • Method Details

    • init

      public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
      RestfulServer assumes that all resource providers are known at init time, which is not the case here.
      Specified by:
      init in interface javax.servlet.Servlet
      Overrides:
      init in class javax.servlet.GenericServlet
      Parameters:
      config - servlet config
      Throws:
      javax.servlet.ServletException - servlet exception
    • destroy

      public void destroy()
      Specified by:
      destroy in interface javax.servlet.Servlet
      Overrides:
      destroy in class RestfulServer
    • getDefaultPagingProvider

      protected IPagingProvider getDefaultPagingProvider(int pagingProviderSize)
      Returns the instance of IPagingProvider to be used. This implementation returns FifoMemoryPagingProvider, you may overwrite this e.g. to add a provider backed by a decent Cache implementation. In this case, not forget to set the paging parameters accessible via getPagingProviderSize(), getDefaultPageSize() and getMaximumPageSize().

      You can also return null in order to disable paging.

      The way how paging is actually implemented depends on the respective FHIR consumer endpoints

      Parameters:
      pagingProviderSize - maximum number of parallel paged requests. Note that each request may have an arbitrary number of result resources though.
      Returns:
      implementation of IPagingProvider
      See Also:
    • getDefaultNarrativeGenerator

      protected INarrativeGenerator getDefaultNarrativeGenerator()
      Returns:
      the narrative generator, null by default
    • getLoggingInterceptor

      protected Object getLoggingInterceptor()
      Returns:
      the logging interceptor if logging is true
    • setFhirContext

      public void setFhirContext(FhirContext fhirContext)
      Overrides:
      setFhirContext in class RestfulServer
    • initialize

      protected void initialize()
      Called upon initialization of the servlet, which is too early to know about the existing FHIR consumers initialization of Camel routes and endpoints.
      Overrides:
      initialize in class RestfulServer
    • getServletName

      public String getServletName()
      Specified by:
      getServletName in interface javax.servlet.ServletConfig
      Overrides:
      getServletName in class javax.servlet.GenericServlet
    • setServletName

      public void setServletName(String servletName)
    • isLogging

      public boolean isLogging()
    • setLogging

      public void setLogging(boolean logging)
    • getFhirVersion

      public FhirVersionEnum getFhirVersion()
    • setFhirVersion

      public void setFhirVersion(FhirVersionEnum fhirVersion)
    • isResponseHighlighting

      public boolean isResponseHighlighting()
    • setResponseHighlighting

      public void setResponseHighlighting(boolean responseHighlighting)
    • isPrettyPrint

      public boolean isPrettyPrint()
    • setPrettyPrint

      public void setPrettyPrint(boolean prettyPrint)
    • getPagingProviderSize

      public int getPagingProviderSize()
    • setPagingProviderSize

      public void setPagingProviderSize(int pagingProviderSize)
    • getDefaultPageSize

      public Integer getDefaultPageSize()
      Specified by:
      getDefaultPageSize in interface IRestfulServerDefaults
      Overrides:
      getDefaultPageSize in class RestfulServer
    • setDefaultPageSize

      public void setDefaultPageSize(Integer defaultPageSize)
      Overrides:
      setDefaultPageSize in class RestfulServer
    • getMaximumPageSize

      public Integer getMaximumPageSize()
      Specified by:
      getMaximumPageSize in interface IRestfulServerDefaults
      Overrides:
      getMaximumPageSize in class RestfulServer
    • setMaximumPageSize

      public void setMaximumPageSize(Integer maximumPageSize)
      Overrides:
      setMaximumPageSize in class RestfulServer
    • isStrictErrorHandler

      public boolean isStrictErrorHandler()
    • setStrictErrorHandler

      public void setStrictErrorHandler(boolean strictErrorHandler)
    • getNarrativeGenerator

      public INarrativeGenerator getNarrativeGenerator()
    • setNarrativeGenerator

      public void setNarrativeGenerator(INarrativeGenerator narrativeGenerator)