From 1ed7bc42993b3d23d92dfc38dfd34026a4619ae7 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Mon, 05 Dec 2016 15:23:22 +0000
Subject: [PATCH] #3410 #3411 fix - Fixed user roles and organizations and Pack date fields on saving action

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

diff --git a/securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java b/securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
index a794bc5..8578d51 100644
--- a/securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
+++ b/securis/src/main/java/net/curisit/securis/DefaultExceptionHandler.java
@@ -11,65 +11,65 @@
 import javax.ws.rs.ext.ExceptionMapper;
 import javax.ws.rs.ext.Provider;
 
-import net.curisit.securis.services.exception.SeCurisServiceException;
-import net.curisit.securis.services.exception.SeCurisServiceException.ErrorCodes;
-
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
+import net.curisit.securis.services.exception.SeCurisServiceException;
+import net.curisit.securis.services.exception.SeCurisServiceException.ErrorCodes;
+
 @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 int DEFAULT_APP_ERROR_STATUS_CODE = 418;
-    public static final String ERROR_MESSAGE_HEADER = "X-SECURIS-ERROR-MSG";
-    public static final String ERROR_CODE_MESSAGE_HEADER = "X-SECURIS-ERROR-CODE";
+	public static final int DEFAULT_APP_ERROR_STATUS_CODE = 418;
+	public static final String ERROR_MESSAGE_HEADER = "X-SECURIS-ERROR-MSG";
+	public static final String ERROR_CODE_MESSAGE_HEADER = "X-SECURIS-ERROR-CODE";
 
-    public DefaultExceptionHandler() {
-        LOG.info("Creating DefaultExceptionHandler ");
-    }
+	public DefaultExceptionHandler() {
+		LOG.info("Creating DefaultExceptionHandler ");
+	}
 
-    @Context
-    HttpServletRequest request;
-    @Context
-    SecurityContext bsc;
-    @Context
-    EntityManager em;
+	@Context
+	HttpServletRequest request;
+	@Context
+	SecurityContext bsc;
+	@Context
+	EntityManager em;
 
-    @Override
-    public Response toResponse(Exception e) {
-        releaseEntityManager();
-        if (e instanceof ForbiddenException) {
-            LOG.warn("ForbiddenException: {}", e);
-            return Response.status(Status.UNAUTHORIZED).header(ERROR_CODE_MESSAGE_HEADER, ErrorCodes.INVALID_CREDENTIALS)
-                    .header(ERROR_MESSAGE_HEADER, "Unathorized access to the application").type(MediaType.APPLICATION_JSON).build();
-        }
+	@Override
+	public Response toResponse(Exception e) {
+		releaseEntityManager();
+		if (e instanceof ForbiddenException) {
+			LOG.warn("ForbiddenException: {}", e.toString());
+			return Response.status(Status.UNAUTHORIZED).header(ERROR_CODE_MESSAGE_HEADER, ErrorCodes.INVALID_CREDENTIALS)
+					.header(ERROR_MESSAGE_HEADER, "Unathorized access to the application").type(MediaType.APPLICATION_JSON).build();
+		}
 
-        if (e instanceof SeCurisServiceException) {
-            LOG.warn("SeCurisServiceException: {}", e);
-            return Response.status(DEFAULT_APP_ERROR_STATUS_CODE).header(ERROR_CODE_MESSAGE_HEADER, ((SeCurisServiceException) e).getStatus())
-                    .header(ERROR_MESSAGE_HEADER, e.getMessage()).type(MediaType.APPLICATION_JSON).build();
-        }
+		if (e instanceof SeCurisServiceException) {
+			LOG.warn("SeCurisServiceException: {}", e.toString());
+			return Response.status(DEFAULT_APP_ERROR_STATUS_CODE).header(ERROR_CODE_MESSAGE_HEADER, ((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();
+	}
 
-    private void releaseEntityManager() {
-        try {
-            if (em != null && em.isOpen()) {
-                LOG.debug("CLOSING EM: {}, trans: {}", em, em.isJoinedToTransaction());
-                if (em.isJoinedToTransaction()) {
-                    em.getTransaction().rollback();
-                    LOG.info("ROLLBACK");
-                }
-                em.close();
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            LOG.error("Error closing EM: {}, {}", em, ex);
-        }
-    }
+	private void releaseEntityManager() {
+		try {
+			if (em != null && em.isOpen()) {
+				LOG.debug("CLOSING EM: {}, trans: {}", em, em.isJoinedToTransaction());
+				if (em.isJoinedToTransaction()) {
+					em.getTransaction().rollback();
+					LOG.info("ROLLBACK");
+				}
+				em.close();
+			}
+		} catch (Exception ex) {
+			ex.printStackTrace();
+			LOG.error("Error closing EM: {}, {}", em, ex);
+		}
+	}
 }

--
Gitblit v1.3.2