private final FeedCategoryDAO feedCategoryDAO;
private final FeedSubscriptionDAO feedSubscriptionDAO;
public Opml export(User user) {
Opml opml = new Opml();
opml.setFeedType("opml_1.1");
opml.setTitle(String.format("%s subscriptions in CommaFeed", user.getName()));
opml.setCreated(new Date());
List<FeedCategory> categories = feedCategoryDAO.findAll(user);
List<FeedSubscription> subscriptions = feedSubscriptionDAO.findAll(user);
// export root categories
for (FeedCategory cat : categories) {
if (cat.getParent() == null) {
opml.getOutlines().add(buildCategoryOutline(cat, subscriptions));
}
}
// export root subscriptions
for (FeedSubscription sub : subscriptions) {
if (sub.getCategory() == null) {
opml.getOutlines().add(buildSubscriptionOutline(sub));
}
}
return opml;