@Override public Response toResponse(TransactionalException exception) { if (exception.getCause() instanceof InvalidTransactionException) { return Response.status(412).entity(INVALID_TRANSACTIONA_MESSAGE).build(); } else if (exception.getCause() instanceof TransactionRequiredException) { return Response.status(412).entity(TRANSACTIONA_REQUIRED_MESSAGE).build(); } throw exception; } }
@Override public <T> T doInTransaction(Callable<T> callable) { try { return impl.doInTransaction(callable); } catch (TransactionalException e) { // unwrap since not usable, cause more interesting // (validationException, etc.) Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } throw e; } } }
@Override public Response toResponse(final TransactionalException ejbException) { final Throwable cause = ejbException.getCause(); if (cause != null) { final Class causeClass = cause.getClass(); final ExceptionMapper exceptionMapper = providers.getExceptionMapper(causeClass); if (exceptionMapper == null) { return defaultResponse(cause); } return exceptionMapper.toResponse(cause); } return defaultResponse(ejbException); }