public class RequestValidatingInterceptor extends InterceptorAdapter
HTTP 422 Unprocessable Entity.IServerInterceptor.ActionRequestDetails| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_RESPONSE_HEADER_NAME
X-HAPI-Request-Validation
|
static String |
DEFAULT_RESPONSE_HEADER_VALUE
Default value:
${row}:${col} ${severity} ${message} (${location})
|
| Constructor and Description |
|---|
RequestValidatingInterceptor() |
| Modifier and Type | Method and Description |
|---|---|
ca.uhn.fhir.rest.server.interceptor.BaseValidatingInterceptor<T> |
addValidatorModule(IValidatorModule theModule) |
protected void |
fail(RequestDetails theRequestDetails,
ValidationResult theValidationResult)
Fail the request by throwing an
UnprocessableEntityException as a result of a validation failure. |
ResultSeverityEnum |
getAddResponseOutcomeHeaderOnSeverity()
If the validation produces a result with at least the given severity, a header with the name
specified by
setResponseOutcomeHeaderName(String) will be added containing a JSON encoded
OperationOutcome resource containing the validation results. |
int |
getMaximumHeaderLength()
The maximum length for an individual header.
|
String |
getResponseOutcomeHeaderName()
The name of the header specified by
setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum) |
List<IValidatorModule> |
getValidatorModules() |
boolean |
incomingRequestPostProcessed(RequestDetails theRequestDetails,
javax.servlet.http.HttpServletRequest theRequest,
javax.servlet.http.HttpServletResponse theResponse)
This method is called just before the actual implementing server method is invoked.
|
void |
setAddResponseHeaderOnSeverity(ResultSeverityEnum theSeverity)
Sets the minimum severity at which an issue detected by the validator will result in a header being added to the
response.
|
void |
setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum theAddResponseOutcomeHeaderOnSeverity)
If the validation produces a result with at least the given severity, a header with the name
specified by
setResponseOutcomeHeaderName(String) will be added containing a JSON encoded
OperationOutcome resource containing the validation results. |
void |
setFailOnSeverity(ResultSeverityEnum theSeverity)
Sets the minimum severity at which an issue detected by the validator will fail/reject the request.
|
void |
setMaximumHeaderLength(int theMaximumHeaderLength)
The maximum length for an individual header.
|
void |
setResponseHeaderName(String theResponseHeaderName)
Sets the name of the response header to add validation failures to
|
void |
setResponseHeaderValue(String theResponseHeaderValue)
Sets the value to add to the response header with the name specified by
setResponseHeaderName(String)
when validation produces a message of severity equal to or greater than
setAddResponseHeaderOnSeverity(ResultSeverityEnum) |
void |
setResponseHeaderValueNoIssues(String theResponseHeaderValueNoIssues)
Sets the header value to add when no issues are found at or exceeding the
threshold specified by
setAddResponseHeaderOnSeverity(ResultSeverityEnum) |
void |
setResponseOutcomeHeaderName(String theResponseOutcomeHeaderName)
The name of the header specified by
setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum) |
void |
setValidatorModules(List<IValidatorModule> theValidatorModules) |
protected void |
validate(T theRequest,
RequestDetails theRequestDetails) |
handleException, incomingRequestPreHandled, incomingRequestPreProcessed, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, preProcessOutgoingExceptionpublic static final String DEFAULT_RESPONSE_HEADER_NAME
public static final String DEFAULT_RESPONSE_HEADER_VALUE
${row}:${col} ${severity} ${message} (${location})
public RequestValidatingInterceptor()
public boolean incomingRequestPostProcessed(RequestDetails theRequestDetails, javax.servlet.http.HttpServletRequest theRequest, javax.servlet.http.HttpServletResponse theResponse) throws AuthenticationException
IServerInterceptorNote about exceptions:
incomingRequestPostProcessed in interface IServerInterceptorincomingRequestPostProcessed in class InterceptorAdaptertheRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
pulled out of the servlet request.theRequest - The incoming requesttheResponse - The response. Note that interceptors may choose to provide a response (i.e. by calling
ServletResponse.getWriter()) but in that case it is important to return false
to indicate that the server itself should not also provide a response.true if processing should continue normally. This is generally the right thing to do.
If your interceptor is providing a response rather than letting HAPI handle the response normally, you
must return false. In this case, no further processing will occur and no further interceptors
will be called.AuthenticationException - This exception may be thrown to indicate that the interceptor has detected an unauthorized access
attempt. If thrown, processing will stop and an HTTP 401 will be returned to the client.public void setResponseHeaderName(String theResponseHeaderName)
public ca.uhn.fhir.rest.server.interceptor.BaseValidatingInterceptor<T> addValidatorModule(IValidatorModule theModule)
protected void fail(RequestDetails theRequestDetails, ValidationResult theValidationResult)
UnprocessableEntityException as a result of a validation failure.
Subclasses may change this behaviour by providing alternate behaviour.public ResultSeverityEnum getAddResponseOutcomeHeaderOnSeverity()
setResponseOutcomeHeaderName(String) will be added containing a JSON encoded
OperationOutcome resource containing the validation results.public int getMaximumHeaderLength()
public String getResponseOutcomeHeaderName()
setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum)public List<IValidatorModule> getValidatorModules()
public void setAddResponseHeaderOnSeverity(ResultSeverityEnum theSeverity)
ResultSeverityEnum.INFORMATION. Set to null to disable this behaviour.public void setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum theAddResponseOutcomeHeaderOnSeverity)
setResponseOutcomeHeaderName(String) will be added containing a JSON encoded
OperationOutcome resource containing the validation results.public void setFailOnSeverity(ResultSeverityEnum theSeverity)
ResultSeverityEnum.ERROR. Set to null to disable this behaviour.public void setMaximumHeaderLength(int theMaximumHeaderLength)
public void setResponseHeaderValue(String theResponseHeaderValue)
setResponseHeaderName(String)
when validation produces a message of severity equal to or greater than
setAddResponseHeaderOnSeverity(ResultSeverityEnum)
This field allows the following substitutions:
| Name | Value |
| ${line} | The line in the request |
| ${col} | The column in the request |
| ${location} | The location in the payload as a string (typically this will be a path) |
| ${severity} | The severity of the issue |
| ${message} | The validation message |
public void setResponseHeaderValueNoIssues(String theResponseHeaderValueNoIssues)
setAddResponseHeaderOnSeverity(ResultSeverityEnum)public void setResponseOutcomeHeaderName(String theResponseOutcomeHeaderName)
setAddResponseOutcomeHeaderOnSeverity(ResultSeverityEnum)public void setValidatorModules(List<IValidatorModule> theValidatorModules)
protected void validate(T theRequest, RequestDetails theRequestDetails)
Copyright © 2014–2016 University Health Network. All rights reserved.