return null;
}
private ResponseBuilder processInvalidEntityExceptions(final Exception ex) {
InvalidEntityException iee = null;
if (ex instanceof InvalidEntityException) {
iee = (InvalidEntityException) ex;
}
if (ex instanceof TransactionSystemException && ex.getCause() instanceof RollbackException
&& ex.getCause().getCause() instanceof InvalidEntityException) {
iee = (InvalidEntityException) ex.getCause().getCause();
}
if (iee != null) {
ClientExceptionType exType =
iee.getEntityClassSimpleName().endsWith("Policy")
? ClientExceptionType.InvalidPolicy
: ClientExceptionType.valueOf("Invalid" + iee.getEntityClassSimpleName());
ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
builder.header(RESTHeaders.ERROR_CODE, exType.getHeaderValue());
ErrorTO error = new ErrorTO();
error.setStatus(exType.getResponseStatus().getStatusCode());
error.setType(exType);
for (Map.Entry<Class<?>, Set<EntityViolationType>> violation : iee.getViolations().entrySet()) {
for (EntityViolationType violationType : violation.getValue()) {
builder.header(RESTHeaders.ERROR_INFO,
exType.getInfoHeaderValue(violationType.name() + ": " + violationType.getMessage()));
error.getElements().add(violationType.name() + ": " + violationType.getMessage());
}