From 8d5386be38db25a2a41c3bf6c876adee21ca26cc Mon Sep 17 00:00:00 2001
From: Roberto Sánchez <roberto.sanchez@curisit.net>
Date: Fri, 19 Sep 2014 08:26:02 +0000
Subject: [PATCH] #396 fix - Fixed more SonarQube issues

---
 securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java |   50 ++++++++++++++++++++++++++------------------------
 1 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java b/securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
index b7c52bd..c933878 100644
--- a/securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
+++ b/securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
@@ -17,34 +17,36 @@
 
 @Provider
 public class DefaultExceptionHandler implements ExceptionMapper<Exception> {
-	private static final Logger LOG = LogManager.getLogger(DefaultExceptionHandler.class);
+    private static final Logger LOG = LogManager.getLogger(DefaultExceptionHandler.class);
 
-	public static final String ERROR_MESSAGE_HEADER = "X-SECURIS-ERROR";
+    public static final String ERROR_MESSAGE_HEADER = "X-SECURIS-ERROR";
 
-	public DefaultExceptionHandler() {
-		LOG.info("Creating DefaultExceptionHandler ");
-	}
+    public DefaultExceptionHandler() {
+        LOG.info("Creating DefaultExceptionHandler ");
+    }
 
-	@Context
-	HttpServletRequest request;
-	@Context
-	SecurityContext bsc;
+    @Context
+    HttpServletRequest request;
+    @Context
+    SecurityContext bsc;
 
-	@Override
-	public Response toResponse(Exception e) {
-		if (e instanceof ForbiddenException) {
-			LOG.warn("Unauthorized access to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal());
-			return Response.status(Status.UNAUTHORIZED).header(ERROR_MESSAGE_HEADER, "Unathorized access to the application").type(MediaType.APPLICATION_JSON).build();
-		}
+    @Override
+    public Response toResponse(Exception e) {
+        if (e instanceof ForbiddenException) {
+            LOG.warn("Unauthorized access to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal());
+            return Response.status(Status.UNAUTHORIZED).header(ERROR_MESSAGE_HEADER, "Unathorized access to the application")
+                    .type(MediaType.APPLICATION_JSON).build();
+        }
 
-		if (e instanceof SeCurisServiceException) {
-			LOG.warn("SeCurisServiceException accessing to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal());
-			return Response.status(Status.fromStatusCode(((SeCurisServiceException) e).getStatus())).header(ERROR_MESSAGE_HEADER, e.getMessage()).type(MediaType.APPLICATION_JSON).build();
-		}
+        if (e instanceof SeCurisServiceException) {
+            LOG.warn("SeCurisServiceException accessing to {}, user: {}", request.getPathInfo(), bsc.getUserPrincipal());
+            return Response.status(Status.fromStatusCode(((SeCurisServiceException) e).getStatus())).header(ERROR_MESSAGE_HEADER, e.getMessage())
+                    .type(MediaType.APPLICATION_JSON).build();
+        }
 
-		LOG.error("Unexpected error accesing to '{}' by user: {}", request.getPathInfo(), bsc.getUserPrincipal());
-		LOG.error("Request sent from {}, with User-Agent: {}", request.getRemoteHost(), request.getHeader("User-Agent"));
-		LOG.error("Request url: " + request.getRequestURL(), e);
-		return Response.serverError().header(ERROR_MESSAGE_HEADER, "Unexpected error: " + e.toString()).type(MediaType.APPLICATION_JSON).build();
-	}
+        LOG.error("Unexpected error accesing to '{}' by user: {}", request.getPathInfo(), bsc.getUserPrincipal());
+        LOG.error("Request sent from {}, with User-Agent: {}", request.getRemoteHost(), request.getHeader("User-Agent"));
+        LOG.error("Request url: " + request.getRequestURL(), e);
+        return Response.serverError().header(ERROR_MESSAGE_HEADER, "Unexpected error: " + e.toString()).type(MediaType.APPLICATION_JSON).build();
+    }
 }
\ No newline at end of file

--
Gitblit v1.3.2