@Override public List<UpdateNotificationDto<EndpointGroupDto>> removeTopicById(String id) { validateId(id, "Can't remove topic. Invalid topic id " + id); TopicDto topic = findTopicById(id); List<UpdateNotificationDto<EndpointGroupDto>> notificationList = new LinkedList<>(); if (topic != null) { List<EndpointGroup> groups = endpointGroupDao.findEndpointGroupsByTopicIdAndAppId( topic.getApplicationId(), id); if (groups != null && !groups.isEmpty()) { for (EndpointGroup eg : groups) { notificationList.add(endpointService.removeTopicFromEndpointGroup(eg.getId().toString(), id)); } } topicDao.removeById(id); notificationDao.removeNotificationsByTopicId(id); } return notificationList; }