JAVA-Audit all incoming web requests

I have ExceptionhandlingController class annotated with @ControllerAdvice, they have methods annotated with @ExceptionHandler(ValidationException.class).I need to Audit the request in afterCompletion method of HandlerInterceptorAdapter class.My task is to get the exception from ExceptionhandlingController class using its response object as I am getting null value in Exception object of afterCompletion method.

I am not sure how to proceed on getting this done.

@ControllerAdvice

public class ExceptionHandlingController {

/**

* Resource not found.

*

* @param ex

* the ex

* @return the response entity

*/

@ExceptionHandler(ValidationException.class)

public ResponseEntity resourceNotFound(

ValidationException ex) {

ExceptionResponse response = new ExceptionResponse();

response.setErrorCode("Value not found");

response.setErrorMessage(messageByLocaleService.getMessage(ex

.getErrorCode()));

Map headers = new HashMap<>();

return new ResponseEntity<>(response,...

Read More »

By: StackOverFlow - 5 days ago

Related Posts