Class RequestDetails
- java.lang.Object
-
- ca.uhn.fhir.rest.api.server.RequestDetails
-
- Direct Known Subclasses:
ServletRequestDetails
public abstract class RequestDetails extends Object
-
-
Constructor Summary
Constructors Constructor Description RequestDetails(ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster theInterceptorBroadcaster)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddParameter(String theName, String[] theValues)abstract ObjectgetAttribute(String theAttributeName)Returns the attribute map for this request.protected abstract byte[]getByteStreamRequestContents()abstract CharsetgetCharset()Return the charset as defined by the header contenttype.StringgetCompartmentName()StringgetCompleteUrl()StringgetConditionalUrl(ca.uhn.fhir.rest.api.RestOperationTypeEnum theOperationType)Returns the conditional URL if this request has one, ornullotherwise.abstract ca.uhn.fhir.context.FhirContextgetFhirContext()Returns the HAPI FHIR Context associated with this requestStringgetFhirServerBase()The fhir server base url, independant of the query being executedStringgetFixedConditionalUrl()abstract StringgetHeader(String name)abstract List<String>getHeaders(String name)org.hl7.fhir.instance.model.api.IIdTypegetId()abstract InputStreamgetInputStream()Retrieves the body of the request as binary data.ca.uhn.fhir.interceptor.api.IInterceptorBroadcastergetInterceptorBroadcaster()Returns an invoker that can be called from user code to advise the server interceptors of any nested operations being invoked within operations.StringgetOperation()Map<String,String[]>getParameters()abstract ReadergetReader()Retrieves the body of the request as character data using aBufferedReader.StringgetRequestId()StringgetRequestPath()The part of the request URL that comes after the server base.ca.uhn.fhir.util.StopWatchgetRequestStopwatch()ca.uhn.fhir.rest.api.RequestTypeEnumgetRequestType()org.hl7.fhir.instance.model.api.IBaseResourcegetResource()Returns the request resource (as provided in the request body) if it has been parsed.StringgetResourceName()IRestfulResponsegetResponse()ca.uhn.fhir.rest.api.RestOperationTypeEnumgetRestOperationType()StringgetSecondaryOperation()abstract IRestfulServerDefaultsgetServer()abstract StringgetServerBaseForRequest()Returns the server base URL (with no trailing '/') for a given requestStringgetTenantId()Map<String,List<String>>getUnqualifiedToQualifiedNames()Map<Object,Object>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.booleanisRespondGzip()booleanisSubRequest()Is this request a sub-request (i.e.byte[]loadRequestContents()voidremoveParameter(String theName)abstract voidsetAttribute(String theAttributeName, Object theAttributeValue)Returns the attribute map for this request.voidsetCompartmentName(String theCompartmentName)voidsetCompleteUrl(String theCompleteUrl)voidsetFhirServerBase(String theFhirServerBase)voidsetFixedConditionalUrl(String theFixedConditionalUrl)voidsetId(org.hl7.fhir.instance.model.api.IIdType theId)voidsetOperation(String theOperation)voidsetParameters(Map<String,String[]> theParams)voidsetRequestContents(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.voidsetRequestId(String theRequestId)voidsetRequestPath(String theRequestPath)voidsetRequestType(ca.uhn.fhir.rest.api.RequestTypeEnum theRequestType)voidsetResource(org.hl7.fhir.instance.model.api.IBaseResource theResource)Sets the request resource (as provided in the request body) if it has been parsed.voidsetResourceName(String theResourceName)voidsetRespondGzip(boolean theRespondGzip)voidsetResponse(IRestfulResponse theResponse)voidsetRestOperationType(ca.uhn.fhir.rest.api.RestOperationTypeEnum theRestOperationType)voidsetSecondaryOperation(String theSecondaryOperation)voidsetSubRequest(boolean theSubRequest)Is this request a sub-request (i.e.voidsetTenantId(String theTenantId)voidstartDeferredOperationCallback()Sets thegetInterceptorBroadcaster()() interceptor broadcaster} handler in deferred mode, meaning that any notifications will be queued up for delivery, but won't be delivered untilstopDeferredRequestOperationCallbackAndRunDeferredItems()is called.voidstopDeferredRequestOperationCallbackAndRunDeferredItems()
-
-
-
Constructor Detail
-
RequestDetails
public RequestDetails(ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster theInterceptorBroadcaster)
Constructor
-
-
Method Detail
-
getFixedConditionalUrl
public String 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
public String getCompartmentName()
-
setCompartmentName
public void setCompartmentName(String theCompartmentName)
-
getCompleteUrl
public String 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, ornullotherwise. For an update or delete method, this is the part of the URL after the?. For a create, this is the value of theIf-None-Existheader.- Parameters:
theOperationType- The operation type to find the conditional URL for- Returns:
- Returns the conditional URL if this request has one, or
nullotherwise
-
getFhirContext
public abstract ca.uhn.fhir.context.FhirContext getFhirContext()
Returns the HAPI FHIR Context associated with this request
-
getFhirServerBase
public String getFhirServerBase()
The fhir server base url, independant of the query being executed- Returns:
- the fhir server base url
-
setFhirServerBase
public void setFhirServerBase(String theFhirServerBase)
-
getHeaders
public abstract List<String> getHeaders(String name)
-
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 orgetReader()may be called to read the body, not both.- Returns:
- a
InputStreamobject containing the body of the request - Throws:
IllegalStateException- if thegetReader()method has already been called for this requestIOException- if an input or output exception occurred
-
getOperation
public String getOperation()
-
setOperation
public void setOperation(String theOperation)
-
getParameters
public Map<String,String[]> 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 aBufferedReader. The reader translates the character data according to the character encoding used on the body. Either this method orgetInputStream()may be called to read the body, not both.- Returns:
- a
Readercontaining the body of the request - Throws:
UnsupportedEncodingException- if the character set encoding used is not supported and the text cannot be decodedIllegalStateException- ifgetInputStream()method has been called on this requestIOException- 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
public String 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
public String getResourceName()
-
setResourceName
public void setResourceName(String theResourceName)
-
getResponse
public IRestfulResponse 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
public String getSecondaryOperation()
-
setSecondaryOperation
public void setSecondaryOperation(String theSecondaryOperation)
-
getServer
public abstract IRestfulServerDefaults getServer()
-
getServerBaseForRequest
public abstract String getServerBaseForRequest()
Returns the server base URL (with no trailing '/') for a given request
-
getTenantId
public String getTenantId()
-
setTenantId
public void setTenantId(String theTenantId)
-
getUnqualifiedToQualifiedNames
public Map<String,List<String>> getUnqualifiedToQualifiedNames()
-
getUserData
public Map<Object,Object> 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 from an interceptor's
IServerInterceptor.incomingRequestPreHandled(RestOperationTypeEnum, ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails)method to theIServerInterceptor.outgoingResponse(RequestDetails, org.hl7.fhir.instance.model.api.IBaseResource, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)method.
-
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()
-
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
-
startDeferredOperationCallback
public void startDeferredOperationCallback()
Sets thegetInterceptorBroadcaster()() interceptor broadcaster} handler in deferred mode, meaning that any notifications will be queued up for delivery, but won't be delivered untilstopDeferredRequestOperationCallbackAndRunDeferredItems()is called.
-
stopDeferredRequestOperationCallbackAndRunDeferredItems
public void stopDeferredRequestOperationCallbackAndRunDeferredItems()
- See Also:
startDeferredOperationCallback()
-
-