Class RequestDetails

java.lang.Object
ca.uhn.fhir.rest.api.server.RequestDetails
Direct Known Subclasses:
ServletRequestDetails, SystemRequestDetails

public abstract class RequestDetails extends Object
  • Field Details

  • Constructor Details

    • RequestDetails

      public RequestDetails(ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster theInterceptorBroadcaster)
      Constructor
    • RequestDetails

      public RequestDetails(RequestDetails theRequestDetails)
      Copy constructor
  • Method Details

    • getFixedConditionalUrl

    • setFixedConditionalUrl

      public void setFixedConditionalUrl(String theFixedConditionalUrl)
    • getRequestId

      public String getRequestId()
    • setRequestId

      public void setRequestId(String theRequestId)
    • getRequestStopwatch

      public ca.uhn.fhir.util.StopWatch getRequestStopwatch()
    • getResource

      public org.hl7.fhir.instance.model.api.IBaseResource getResource()
      Returns the request resource (as provided in the request body) if it has been parsed. Note that this value is only set fairly late in the processing pipeline, so it may not always be set, even for operations that take a resource as input.
      Since:
      4.0.0
    • setResource

      public void setResource(org.hl7.fhir.instance.model.api.IBaseResource theResource)
      Sets the request resource (as provided in the request body) if it has been parsed. Note that this value is only set fairly late in the processing pipeline, so it may not always be set, even for operations that take a resource as input.
      Since:
      4.0.0
    • addParameter

      public void addParameter(String theName, String[] theValues)
    • getByteStreamRequestContents

      protected abstract byte[] getByteStreamRequestContents()
    • getCharset

      public abstract Charset getCharset()
      Return the charset as defined by the header contenttype. Return null if it is not set.
    • getCompartmentName

    • setCompartmentName

      public void setCompartmentName(String theCompartmentName)
    • getCompleteUrl

    • setCompleteUrl

      public void setCompleteUrl(String theCompleteUrl)
    • getConditionalUrl

      public String getConditionalUrl(ca.uhn.fhir.rest.api.RestOperationTypeEnum theOperationType)
      Returns the conditional URL if this request has one, or null otherwise. For an update or delete method, this is the part of the URL after the ?. For a create, this is the value of the If-None-Exist header.
      Parameters:
      theOperationType - The operation type to find the conditional URL for
      Returns:
      Returns the conditional URL if this request has one, or null otherwise
    • getFhirContext

      public abstract ca.uhn.fhir.context.FhirContext getFhirContext()
      Returns the HAPI FHIR Context associated with this request
    • getFhirServerBase

      The fhir server base url, independant of the query being executed
      Returns:
      the fhir server base url
    • setFhirServerBase

      public void setFhirServerBase(String theFhirServerBase)
    • getHeader

      public abstract String getHeader(String name)
    • getHeaders

      public abstract List<String> getHeaders(String name)
    • addHeader

      public abstract void addHeader(String theName, String theValue)
      Adds a new header
      Parameters:
      theName - The header name
      theValue - The header value
      Since:
      7.2.0
    • setHeaders

      public abstract void setHeaders(String theName, List<String> theValue)
      Replaces any existing header(s) with the given name using a List of new header values
      Parameters:
      theName - The header name
      theValue - The header value
      Since:
      7.2.0
    • getId

      public org.hl7.fhir.instance.model.api.IIdType getId()
    • setId

      public void setId(org.hl7.fhir.instance.model.api.IIdType theId)
    • getAttribute

      public abstract Object getAttribute(String theAttributeName)
      Returns the attribute map for this request. Attributes are a place for user-supplied objects of any type to be attached to an individual request. They can be used to pass information between interceptor methods.
    • setAttribute

      public abstract void setAttribute(String theAttributeName, Object theAttributeValue)
      Returns the attribute map for this request. Attributes are a place for user-supplied objects of any type to be attached to an individual request. They can be used to pass information between interceptor methods.
    • getInputStream

      public abstract InputStream getInputStream() throws IOException
      Retrieves the body of the request as binary data. Either this method or getReader() may be called to read the body, not both.
      Returns:
      a InputStream object containing the body of the request
      Throws:
      IllegalStateException - if the getReader() method has already been called for this request
      IOException - if an input or output exception occurred
    • getOperation

      public String getOperation()
    • setOperation

      public void setOperation(String theOperation)
    • getParameters

    • setParameters

      public void setParameters(Map<String,String[]> theParams)
    • getReader

      public abstract Reader getReader() throws IOException
      Retrieves the body of the request as character data using a BufferedReader. The reader translates the character data according to the character encoding used on the body. Either this method or getInputStream() may be called to read the body, not both.
      Returns:
      a Reader containing the body of the request
      Throws:
      UnsupportedEncodingException - if the character set encoding used is not supported and the text cannot be decoded
      IllegalStateException - if getInputStream() method has been called on this request
      IOException - if an input or output exception occurred
      See Also:
      • ServletRequest.getInputStream()
    • getInterceptorBroadcaster

      public ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster getInterceptorBroadcaster()
      Returns an invoker that can be called from user code to advise the server interceptors of any nested operations being invoked within operations. This invoker acts as a proxy for all interceptors
    • getRequestPath

      The part of the request URL that comes after the server base.

      Will not contain a leading '/'

    • setRequestPath

      public void setRequestPath(String theRequestPath)
    • getRequestType

      public ca.uhn.fhir.rest.api.RequestTypeEnum getRequestType()
    • setRequestType

      public void setRequestType(ca.uhn.fhir.rest.api.RequestTypeEnum theRequestType)
    • getResourceName

    • setResourceName

      public void setResourceName(String theResourceName)
    • getResponse

    • setResponse

      public void setResponse(IRestfulResponse theResponse)
    • getRestOperationType

      public ca.uhn.fhir.rest.api.RestOperationTypeEnum getRestOperationType()
    • setRestOperationType

      public void setRestOperationType(ca.uhn.fhir.rest.api.RestOperationTypeEnum theRestOperationType)
    • getSecondaryOperation

    • setSecondaryOperation

      public void setSecondaryOperation(String theSecondaryOperation)
    • getServer

      public abstract IRestfulServerDefaults getServer()
    • getServerBaseForRequest

      Deprecated.
      Use getFhirServerBase() instead. Deprecated in HAPI FHIR 7.0.0
      Returns the server base URL (with no trailing '/') for a given request
    • getTenantId

      public String getTenantId()
      Gets the tenant ID associated with the request. Note that the tenant ID and the partition ID are not the same thing - Depending on the specific partition interceptors in use, the tenant ID might be used internally to derive the partition ID or it might not. Do not assume that it will be used for this purpose.
    • setTenantId

      public void setTenantId(String theTenantId)
      Sets the tenant ID associated with the request. Note that the tenant ID and the partition ID are not the same thing - Depending on the specific partition interceptors in use, the tenant ID might be used internally to derive the partition ID or it might not. Do not assume that it will be used for this purpose.
    • getUnqualifiedToQualifiedNames

    • getUserData

      Returns a map which can be used to hold any user specific data to pass it from one part of the request handling chain to another. Data in this map can use any key, although user code should try to use keys which are specific enough to avoid conflicts.

      A new map is created for each individual request that is handled by the server, so this map can be used (for example) to pass authorization details from an interceptor to the resource providers, or for example to pass data from a hook method on the Pointcut.SERVER_INCOMING_REQUEST_POST_PROCESSED to a later hook method on the Pointcut.SERVER_OUTGOING_RESPONSE pointcut.

    • isRespondGzip

      public boolean isRespondGzip()
    • setRespondGzip

      public void setRespondGzip(boolean theRespondGzip)
    • isSubRequest

      public boolean isSubRequest()
      Is this request a sub-request (i.e. a request within a batch or transaction)? This flag is used internally by hapi-fhir-jpaserver-base, but not used in the plain server library. You may use it in your client code as a hint when implementing transaction logic in the plain server.

      Defaults to false

    • setSubRequest

      public void setSubRequest(boolean theSubRequest)
      Is this request a sub-request (i.e. a request within a batch or transaction)? This flag is used internally by hapi-fhir-jpaserver-base, but not used in the plain server library. You may use it in your client code as a hint when implementing transaction logic in the plain server.

      Defaults to false

    • loadRequestContents

      public final byte[] loadRequestContents()
    • getRequestContentsIfLoaded

      public byte[] getRequestContentsIfLoaded()
      Returns the request contents if they were loaded, returns null otherwise
      See Also:
    • removeParameter

      public void removeParameter(String theName)
    • setRequestContents

      public void setRequestContents(byte[] theRequestContents)
      This method may be used to modify the contents of the incoming request by hardcoding a value which will be used instead of the value received by the client.

      This method is useful for modifying the request body prior to parsing within interceptors. It generally only has an impact when called in the IServerInterceptor.incomingRequestPostProcessed(RequestDetails, HttpServletRequest, HttpServletResponse) method

    • getTransactionGuid

    • setTransactionGuid

      public void setTransactionGuid(String theTransactionGuid)
    • isRewriteHistory

      public boolean isRewriteHistory()
    • setRewriteHistory

      public void setRewriteHistory(boolean theRewriteHistory)
    • getMaxRetries

      public int getMaxRetries()
    • setMaxRetries

      public void setMaxRetries(int theMaxRetries)
    • isRetry

      public boolean isRetry()
    • setRetry

      public void setRetry(boolean theRetry)