@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()); } }
private void setFilter(IdNameFilter filter, Long id, String name, Boolean includeDefault) { if (id != null && name != null) { throw new IllegalArgumentException( "Id and name can't be both defined (id:" + id + " name:" + name + ")"); } if (id != null) { filter.setId(id); if (includeDefault != null) { filter.setIncludeDefault(includeDefault); } } else if (name != null) { filter.setName(name); if (includeDefault != null) { filter.setIncludeDefault(includeDefault); } } else { if (includeDefault != null && includeDefault) { filter.setType(SpecialFilterType.DEFAULT); } else { filter.setType(SpecialFilterType.ANY); } } }
private void setFilter(IdNameFilter filter, Long id, String name, Boolean includeDefault) throws BadRequestRestEx { if (id != null && name != null) { throw new BadRequestRestEx("Id and name can't be both defined (id:" + id + " name:" + name + ")"); } if (id != null) { filter.setId(id); if (includeDefault != null) { filter.setIncludeDefault(includeDefault); } } else if (name != null) { filter.setName(name); if (includeDefault != null) { filter.setIncludeDefault(includeDefault); } } else { if (includeDefault != null && includeDefault) { filter.setType(SpecialFilterType.DEFAULT); } else { filter.setType(SpecialFilterType.ANY); } } }
private void setFilter(IdNameFilter filter, Long id, String name, Boolean includeDefault) throws BadRequestRestEx { if (id != null && name != null) { throw new BadRequestRestEx("Id and name can't be both defined (id:" + id + " name:" + name + ")"); } if (id != null) { filter.setId(id); if (includeDefault != null) { filter.setIncludeDefault(includeDefault); } } else if (name != null) { filter.setName(name); if (includeDefault != null) { filter.setIncludeDefault(includeDefault); } } else { if (includeDefault != null && includeDefault) { filter.setType(SpecialFilterType.DEFAULT); } else { filter.setType(SpecialFilterType.ANY); } } }