queue feed for refresh after a subscription

This commit is contained in:
Athou
2013-04-25 14:41:56 +02:00
parent 8944687006
commit 735c2efb34
2 changed files with 11 additions and 0 deletions

View File

@@ -37,6 +37,13 @@ public class FeedRefreshTaskGiver {
.getBackgroundThreads();
}
@Lock(LockType.WRITE)
public void add(Feed feed) {
queue.add(feed);
feed.setLastUpdated(Calendar.getInstance().getTime());
feedDAO.update(feed);
}
@Lock(LockType.WRITE)
public Feed take() {
Feed feed = queue.poll();

View File

@@ -8,6 +8,7 @@ import javax.inject.Inject;
import com.commafeed.backend.dao.FeedEntryDAO;
import com.commafeed.backend.dao.FeedEntryStatusDAO;
import com.commafeed.backend.dao.FeedSubscriptionDAO;
import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.FeedEntry;
@@ -30,6 +31,8 @@ public class FeedSubscriptionService {
@Inject
FeedSubscriptionDAO feedSubscriptionDAO;
@Inject FeedRefreshTaskGiver taskGiver;
public Feed subscribe(User user, String url, String title,
FeedCategory category) {
@@ -60,6 +63,7 @@ public class FeedSubscriptionService {
}
feedEntryStatusDAO.save(statuses);
}
taskGiver.add(feed);
return feed;
}
}