public RangerServiceResource preDeleteServiceResource(Long id) throws Exception { RangerServiceResource existing = tagStore.getServiceResource(id); if (existing == null) { throw new Exception("Attempt to delete nonexistent resource, id=" + id); } List<RangerTagResourceMap> associations = tagStore.getTagResourceMapsForResourceId(existing.getId()); if (CollectionUtils.isNotEmpty(associations)) { throw new Exception( "Attempt to delete serviceResource which is associated with a tag, id=" + id); } return existing; }
public RangerServiceResource preDeleteServiceResourceByGuid(String guid, boolean deleteReferences) throws Exception { RangerServiceResource existing = tagStore.getServiceResourceByGuid(guid); if (existing == null) { throw new Exception("Attempt to delete nonexistent resource, guid=" + guid); } List<RangerTagResourceMap> associations = tagStore.getTagResourceMapsForResourceId(existing.getId()); if (CollectionUtils.isNotEmpty(associations) && !deleteReferences) { throw new Exception( "Attempt to delete serviceResource which is associated with a tag, guid=" + guid); } return existing; }