@POST @Path("/delete") @ApiOperation(value = "Delete a category", notes = "Delete an existing feed category") public Response deleteCategory(@ApiParam(required = true) IDRequest req) { Preconditions.checkNotNull(req); Preconditions.checkNotNull(req.getId()); FeedCategory cat = feedCategoryDAO.findById(getUser(), req.getId()); if (cat != null) { List<FeedSubscription> subs = feedSubscriptionDAO.findByCategory(getUser(), cat); for (FeedSubscription sub : subs) { sub.setCategory(null); } feedSubscriptionDAO.saveOrUpdate(subs); List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(getUser(), cat); for (FeedCategory child : categories) { if (!child.getId().equals(cat.getId()) && child.getParent().getId().equals(cat.getId())) { child.setParent(null); } } feedCategoryDAO.saveOrUpdate(categories); feedCategoryDAO.delete(cat); cache.invalidateUserRootCategory(getUser()); return Response.ok().build(); } else { return Response.status(Status.NOT_FOUND).build(); } }
public void unregister(User user) { feedEntryStatusDAO.delete(feedEntryStatusDAO.findAll(user, false, ReadingOrder.desc, false)); feedSubscriptionDAO.delete(feedSubscriptionDAO.findAll(user)); feedCategoryDAO.delete(feedCategoryDAO.findAll(user)); userSettingsDAO.delete(userSettingsDAO.findByUser(user)); userRoleDAO.delete(userRoleDAO.findAll(user)); userDAO.delete(user); }