Class ValidationContext
- java.lang.Object
-
- de.captaingoldfish.scim.sdk.server.endpoints.validation.ValidationContext
-
public class ValidationContext extends Object
- Since:
- 07.04.2021
- Author:
- Pascal Knueppel
-
-
Constructor Summary
Constructors Constructor Description ValidationContext(ResourceType resourceType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddError(String errorMessage)adds an error that is not bound to a specific resource fieldvoidaddError(String fieldName, String errorMessage)adds an error that is bound to a specific resource fieldvoidaddExceptionMessages(ScimException ex)adds other more unspecific error messages to the context that are not directly related to any fieldsvoidaddExceptionMessages(AttributeValidationException ex)adds specific field errors to the validation contextList<String>getErrors()contains errors that are not bound to any specific fieldsMap<String,List<String>>getFieldErrors()contains all error messages that are bound to a specific fieldintgetHttpResponseStatus()the response status that should be returned to the client.ResourceTypegetResourceType()the endpoint definition of the resource to validateMap<String,String>getResponseHttpHeaders()additional headers that may be returned in case of validation errorbooleanhasErrors()voidlogErrors()logs all reported errors on debug levelvoidsetHttpResponseStatus(int httpResponseStatus)the response status that should be returned to the client.voidwriteToErrorResponse(ErrorResponse errorResponse)adds the current errors of this validation context to the given error response
-
-
-
Constructor Detail
-
ValidationContext
public ValidationContext(ResourceType resourceType)
-
-
Method Detail
-
hasErrors
public boolean hasErrors()
- Returns:
- true if any errors have been set, false else
-
logErrors
public void logErrors()
logs all reported errors on debug level
-
addError
public void addError(String errorMessage)
adds an error that is not bound to a specific resource field- Parameters:
errorMessage- the error message
-
addError
public void addError(String fieldName, String errorMessage)
adds an error that is bound to a specific resource field- Parameters:
fieldName- the name of the field to which the error is bounderrorMessage- the error message
-
addExceptionMessages
public void addExceptionMessages(AttributeValidationException ex)
adds specific field errors to the validation context- Parameters:
ex- the definition of the error that occurred
-
addExceptionMessages
public void addExceptionMessages(ScimException ex)
adds other more unspecific error messages to the context that are not directly related to any fields- Parameters:
ex- the definition of the error that occurred
-
writeToErrorResponse
public void writeToErrorResponse(ErrorResponse errorResponse)
adds the current errors of this validation context to the given error response
-
getFieldErrors
public Map<String,List<String>> getFieldErrors()
contains all error messages that are bound to a specific field
-
getResourceType
public ResourceType getResourceType()
the endpoint definition of the resource to validate
-
getResponseHttpHeaders
public Map<String,String> getResponseHttpHeaders()
additional headers that may be returned in case of validation error
-
getHttpResponseStatus
public int getHttpResponseStatus()
the response status that should be returned to the client. Is bad request (400) by default
-
setHttpResponseStatus
public void setHttpResponseStatus(int httpResponseStatus)
the response status that should be returned to the client. Is bad request (400) by default
-
-