mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
catch potential exception (timeout) when subscribing
This commit is contained in:
@@ -6,6 +6,8 @@ import javax.ejb.ApplicationException;
|
|||||||
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.FeedEntryDAO;
|
import com.commafeed.backend.dao.FeedEntryDAO;
|
||||||
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
import com.commafeed.backend.dao.FeedEntryStatusDAO;
|
||||||
@@ -22,6 +24,8 @@ import com.google.api.client.util.Lists;
|
|||||||
|
|
||||||
public class FeedSubscriptionService {
|
public class FeedSubscriptionService {
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(FeedSubscriptionService.class);
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@ApplicationException
|
@ApplicationException
|
||||||
public static class FeedSubscriptionException extends RuntimeException {
|
public static class FeedSubscriptionException extends RuntimeException {
|
||||||
@@ -77,16 +81,20 @@ public class FeedSubscriptionService {
|
|||||||
feedSubscriptionDAO.saveOrUpdate(sub);
|
feedSubscriptionDAO.saveOrUpdate(sub);
|
||||||
|
|
||||||
if (newSubscription) {
|
if (newSubscription) {
|
||||||
List<FeedEntryStatus> statuses = Lists.newArrayList();
|
try {
|
||||||
List<FeedEntry> allEntries = feedEntryDAO.findByFeed(feed, 0, 10);
|
List<FeedEntryStatus> statuses = Lists.newArrayList();
|
||||||
for (FeedEntry entry : allEntries) {
|
List<FeedEntry> allEntries = feedEntryDAO.findByFeed(feed, 0, 10);
|
||||||
FeedEntryStatus status = new FeedEntryStatus();
|
for (FeedEntry entry : allEntries) {
|
||||||
status.setEntry(entry);
|
FeedEntryStatus status = new FeedEntryStatus();
|
||||||
status.setRead(false);
|
status.setEntry(entry);
|
||||||
status.setSubscription(sub);
|
status.setRead(false);
|
||||||
statuses.add(status);
|
status.setSubscription(sub);
|
||||||
|
statuses.add(status);
|
||||||
|
}
|
||||||
|
feedEntryStatusDAO.saveOrUpdate(statuses);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("could not fetch initial statuses when importing {} : {}", feed.getUrl(), e.getMessage());
|
||||||
}
|
}
|
||||||
feedEntryStatusDAO.saveOrUpdate(statuses);
|
|
||||||
}
|
}
|
||||||
taskGiver.add(feed);
|
taskGiver.add(feed);
|
||||||
return feed;
|
return feed;
|
||||||
|
|||||||
Reference in New Issue
Block a user