mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
import opml asynchronously
This commit is contained in:
@@ -3,9 +3,13 @@ package com.commafeed.backend.feeds;
|
|||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.ejb.Asynchronous;
|
||||||
|
import javax.ejb.Stateless;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.commafeed.backend.dao.FeedCategoryDAO;
|
import com.commafeed.backend.dao.FeedCategoryDAO;
|
||||||
import com.commafeed.backend.model.FeedCategory;
|
import com.commafeed.backend.model.FeedCategory;
|
||||||
@@ -13,11 +17,13 @@ import com.commafeed.backend.model.User;
|
|||||||
import com.commafeed.backend.services.FeedSubscriptionService;
|
import com.commafeed.backend.services.FeedSubscriptionService;
|
||||||
import com.sun.syndication.feed.opml.Opml;
|
import com.sun.syndication.feed.opml.Opml;
|
||||||
import com.sun.syndication.feed.opml.Outline;
|
import com.sun.syndication.feed.opml.Outline;
|
||||||
import com.sun.syndication.io.FeedException;
|
|
||||||
import com.sun.syndication.io.WireFeedInput;
|
import com.sun.syndication.io.WireFeedInput;
|
||||||
|
|
||||||
|
@Stateless
|
||||||
public class OPMLImporter {
|
public class OPMLImporter {
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(OPMLImporter.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
FeedSubscriptionService feedSubscriptionService;
|
FeedSubscriptionService feedSubscriptionService;
|
||||||
|
|
||||||
@@ -25,14 +31,20 @@ public class OPMLImporter {
|
|||||||
FeedCategoryDAO feedCategoryDAO;
|
FeedCategoryDAO feedCategoryDAO;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void importOpml(User user, String xml) throws FeedException {
|
@Asynchronous
|
||||||
|
public void importOpml(User user, String xml) {
|
||||||
|
|
||||||
WireFeedInput input = new WireFeedInput();
|
WireFeedInput input = new WireFeedInput();
|
||||||
|
try {
|
||||||
Opml feed = (Opml) input.build(new StringReader(xml));
|
Opml feed = (Opml) input.build(new StringReader(xml));
|
||||||
List<Outline> outlines = (List<Outline>) feed.getOutlines();
|
List<Outline> outlines = (List<Outline>) feed.getOutlines();
|
||||||
for (Outline outline : outlines) {
|
for (Outline outline : outlines) {
|
||||||
handleOutline(user, outline, null);
|
handleOutline(user, outline, null);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
Reference in New Issue
Block a user