try {
service.removeEntity(entityForm, getSectionCustomCriteria(), sectionCrumbs);
} catch (ServiceException e) {
if (e instanceof ValidationException) {
// Create a flash attribute for the unsuccessful delete
FlashMap fm = new FlashMap();
fm.put("headerFlash", e.getMessage());
fm.put("headerFlashAlert", true);
request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, fm);
// Make sure we have this error show up in our logs
LOG.error("Could not delete record", e);
// Refresh the page
return "redirect:/" + sectionKey + "/" + id;
}
if (e.containsCause(ConstraintViolationException.class)) {
// Create a flash attribute for the unsuccessful delete
FlashMap fm = new FlashMap();
fm.put("headerFlash", "delete.unsuccessful");
fm.put("headerFlashAlert", true);
request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, fm);
// Make sure we have this error show up in our logs
LOG.error("Could not delete record", e);