Package org.dspace.app.rest.exception
Class DSpaceApiExceptionControllerAdvice
- java.lang.Object
-
- org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
-
- org.dspace.app.rest.exception.DSpaceApiExceptionControllerAdvice
-
@ControllerAdvice public class DSpaceApiExceptionControllerAdvice extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandlerThis Controller advice will handle default exceptions thrown by the DSpace REST API module.Keep in mind some specialized handlers exist for specific message types, e.g. DSpaceAccessDeniedHandler
- Author:
- Tom Desair (tom dot desair at atmire dot com), Frederic Van Reet (frederic dot vanreet at atmire dot com), Andrea Bollini (andrea.bollini at 4science.it), Pasquale Cavallo (pasquale.cavallo at 4science dot it)
- See Also:
DSpaceAccessDeniedHandler
-
-
Constructor Summary
Constructors Constructor Description DSpaceApiExceptionControllerAdvice()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcsrfTokenException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)protected voidhandleAuthorizeException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)protected voidhandleCustomUnprocessableEntityException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, TranslatableException ex)Add user-friendly error messages to the response body for selected errors.protected voidhandleGenericException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)protected voidhandleIOException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)protected org.springframework.http.ResponseEntity<Object>handleMissingServletRequestParameter(org.springframework.web.bind.MissingServletRequestParameterException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)protected voidhandleSQLException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)protected org.springframework.http.ResponseEntity<Object>handleTypeMismatch(org.springframework.beans.TypeMismatchException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)protected voidhandleUnprocessableEntityException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)protected voidhandleWrongRequestException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)protected voidmethodNotAllowedException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)protected voidMissingParameterException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)protected voidParameterConversionException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex)-
Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
handleAsyncRequestTimeoutException, handleBindException, handleConversionNotSupported, handleException, handleExceptionInternal, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMethodArgumentNotValid, handleMissingPathVariable, handleMissingServletRequestPart, handleNoHandlerFoundException, handleServletRequestBindingException
-
-
-
-
Method Detail
-
handleAuthorizeException
@ExceptionHandler({org.dspace.authorize.AuthorizeException.class,RESTAuthorizationException.class,org.springframework.security.access.AccessDeniedException.class}) protected void handleAuthorizeException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException- Throws:
IOException
-
csrfTokenException
@ExceptionHandler({org.springframework.security.web.csrf.InvalidCsrfTokenException.class,org.springframework.security.web.csrf.MissingCsrfTokenException.class}) protected void csrfTokenException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException- Throws:
IOException
-
handleWrongRequestException
@ExceptionHandler({java.lang.IllegalArgumentException.class,org.springframework.web.multipart.MultipartException.class}) protected void handleWrongRequestException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException- Throws:
IOException
-
handleSQLException
@ExceptionHandler(java.sql.SQLException.class) protected void handleSQLException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException
- Throws:
IOException
-
handleIOException
@ExceptionHandler(java.io.IOException.class) protected void handleIOException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException
- Throws:
IOException
-
methodNotAllowedException
@ExceptionHandler(MethodNotAllowedException.class) protected void methodNotAllowedException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException
- Throws:
IOException
-
handleUnprocessableEntityException
@ExceptionHandler(UnprocessableEntityException.class) protected void handleUnprocessableEntityException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException
- Throws:
IOException
-
handleCustomUnprocessableEntityException
@ExceptionHandler({RESTEmptyWorkflowGroupException.class,EPersonNameNotProvidedException.class,GroupNameNotProvidedException.class}) protected void handleCustomUnprocessableEntityException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, TranslatableException ex) throws IOExceptionAdd user-friendly error messages to the response body for selected errors. Since the error messages will be exposed to the API user, the exception classes are expected to implementTranslatableExceptionsuch that the error messages can be translated.- Throws:
IOException
-
ParameterConversionException
@ExceptionHandler(org.springframework.data.repository.support.QueryMethodParameterConversionException.class) protected void ParameterConversionException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException- Throws:
IOException
-
MissingParameterException
@ExceptionHandler(MissingParameterException.class) protected void MissingParameterException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException
- Throws:
IOException
-
handleMissingServletRequestParameter
protected org.springframework.http.ResponseEntity<Object> handleMissingServletRequestParameter(org.springframework.web.bind.MissingServletRequestParameterException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)
- Overrides:
handleMissingServletRequestParameterin classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
-
handleTypeMismatch
protected org.springframework.http.ResponseEntity<Object> handleTypeMismatch(org.springframework.beans.TypeMismatchException ex, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)
- Overrides:
handleTypeMismatchin classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
-
handleGenericException
@ExceptionHandler(java.lang.Exception.class) protected void handleGenericException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception ex) throws IOException
- Throws:
IOException
-
-