@Override public Response delete(Long id, boolean cascade) throws ConflictRestEx, NotFoundRestEx, InternalErrorRestEx { try { if ( cascade ) { ruleAdminService.deleteRulesByInstance(id); } else { RuleFilter filter = new RuleFilter(SpecialFilterType.ANY); filter.setInstance(id); filter.getInstance().setIncludeDefault(false); long cnt = ruleAdminService.count(filter); if ( cnt > 0 ) { throw new ConflictRestEx("Existing rules reference the GSInstance " + id); } } if ( ! instanceAdminService.delete(id)) { LOGGER.warn("GSInstance not found: " + id); throw new NotFoundRestEx("GSInstance not found: " + id); } return Response.status(Status.OK).entity("OK\n").build(); } catch (GeoFenceRestEx ex) { // already handled throw ex; } catch (NotFoundServiceEx ex) { LOGGER.warn("GSInstance not found: " + id); throw new NotFoundRestEx("GSInstance not found: " + id); } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } }