Roberto Sánchez
2014-09-18 52ce72b22ef8d92a1f35b4993bcddaaa66d67350
securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
....@@ -17,12 +17,12 @@
1717
1818 @Provider
1919 public class DefaultExceptionHandler implements ExceptionMapper<Exception> {
20
- private static final Logger log = LogManager.getLogger(DefaultExceptionHandler.class);
20
+ private static final Logger LOG = LogManager.getLogger(DefaultExceptionHandler.class);
2121
2222 public static final String ERROR_MESSAGE_HEADER = "X-SECURIS-ERROR";
2323
2424 public DefaultExceptionHandler() {
25
- log.info("Creating DefaultExceptionHandler ");
25
+ LOG.info("Creating DefaultExceptionHandler ");
2626 }
2727
2828 @Context
....@@ -32,21 +32,19 @@
3232
3333 @Override
3434 public Response toResponse(Exception e) {
35
- // log.info("Creating DefaultExceptionHandler ");
36
- // e.printStackTrace();
3735 if (e instanceof ForbiddenException) {
38
- log.warn("Unauthorized access to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal());
36
+ LOG.warn("Unauthorized access to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal());
3937 return Response.status(Status.UNAUTHORIZED).header(ERROR_MESSAGE_HEADER, "Unathorized access to the application").type(MediaType.APPLICATION_JSON).build();
4038 }
4139
4240 if (e instanceof SeCurisServiceException) {
43
- log.warn("SeCurisServiceException accessing to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal());
41
+ LOG.warn("SeCurisServiceException accessing to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal());
4442 return Response.status(Status.fromStatusCode(((SeCurisServiceException) e).getStatus())).header(ERROR_MESSAGE_HEADER, e.getMessage()).type(MediaType.APPLICATION_JSON).build();
4543 }
4644
47
- log.error("Unexpected error accesing to '{}' by user: {}", request.getPathInfo(), bsc.getUserPrincipal());
48
- log.error("Request sent from {}, with User-Agent: {}", request.getRemoteHost(), request.getHeader("User-Agent"));
49
- log.error("Request url: " + request.getRequestURL(), e);
45
+ LOG.error("Unexpected error accesing to '{}' by user: {}", request.getPathInfo(), bsc.getUserPrincipal());
46
+ LOG.error("Request sent from {}, with User-Agent: {}", request.getRemoteHost(), request.getHeader("User-Agent"));
47
+ LOG.error("Request url: " + request.getRequestURL(), e);
5048 return Response.serverError().header(ERROR_MESSAGE_HEADER, "Unexpected error: " + e.toString()).type(MediaType.APPLICATION_JSON).build();
5149 }
5250 }