catch potential exception (timeout) when subscribing

This commit is contained in:
Athou
2013-07-02 10:14:47 +02:00
parent 31290aad8f
commit 761946d2a3

View File

@@ -6,6 +6,8 @@ import javax.ejb.ApplicationException;
import javax.inject.Inject;
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.FeedEntryStatusDAO;
@@ -22,6 +24,8 @@ import com.google.api.client.util.Lists;
public class FeedSubscriptionService {
private static Logger log = LoggerFactory.getLogger(FeedSubscriptionService.class);
@SuppressWarnings("serial")
@ApplicationException
public static class FeedSubscriptionException extends RuntimeException {
@@ -77,16 +81,20 @@ public class FeedSubscriptionService {
feedSubscriptionDAO.saveOrUpdate(sub);
if (newSubscription) {
List<FeedEntryStatus> statuses = Lists.newArrayList();
List<FeedEntry> allEntries = feedEntryDAO.findByFeed(feed, 0, 10);
for (FeedEntry entry : allEntries) {
FeedEntryStatus status = new FeedEntryStatus();
status.setEntry(entry);
status.setRead(false);
status.setSubscription(sub);
statuses.add(status);
try {
List<FeedEntryStatus> statuses = Lists.newArrayList();
List<FeedEntry> allEntries = feedEntryDAO.findByFeed(feed, 0, 10);
for (FeedEntry entry : allEntries) {
FeedEntryStatus status = new FeedEntryStatus();
status.setEntry(entry);
status.setRead(false);
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);
return feed;