Package com.commafeed.backend.model

Examples of com.commafeed.backend.model.Feed


    }

    @Override
    public void run() {
      boolean ok = true;
      final Feed feed = context.getFeed();
      List<FeedEntry> entries = context.getEntries();
      if (entries.isEmpty()) {
        feed.setMessage("Feed has no entries");
      } else {
        List<String> lastEntries = cache.getLastEntries(feed);
        List<String> currentEntries = Lists.newArrayList();

        List<FeedSubscription> subscriptions = null;
        for (FeedEntry entry : entries) {
          String cacheKey = cache.buildUniqueEntryKey(feed, entry);
          if (!lastEntries.contains(cacheKey)) {
            log.debug("cache miss for {}", entry.getUrl());
            if (subscriptions == null) {
              subscriptions = new UnitOfWork<List<FeedSubscription>>(sessionFactory) {
                @Override
                protected List<FeedSubscription> runInSession() throws Exception {
                  return feedSubscriptionDAO.findByFeed(feed);
                }
              }.run();
            }
            ok &= addEntry(feed, entry, subscriptions);
            entryCacheMiss.mark();
          } else {
            log.debug("cache hit for {}", entry.getUrl());
            entryCacheHit.mark();
          }

          currentEntries.add(cacheKey);
        }
        cache.setLastEntries(feed, currentEntries);

        if (subscriptions == null) {
          feed.setMessage("No new entries found");
        }

        if (CollectionUtils.isNotEmpty(subscriptions)) {
          List<User> users = Lists.newArrayList();
          for (FeedSubscription sub : subscriptions) {
            users.add(sub.getUser());
          }
          cache.invalidateUnreadCount(subscriptions.toArray(new FeedSubscription[0]));
          cache.invalidateUserRootCategory(users.toArray(new User[0]));
        }
      }

      if (config.getApplicationSettings().isPubsubhubbub()) {
        handlePubSub(feed);
      }
      if (!ok) {
        // requeue asap
        feed.setDisabledUntil(new Date(0));
      }
      feedUpdated.mark();
      queues.giveBack(feed);
    }
View Full Code Here


        && lastPublishedDate.getTime() == fetchedFeed.getFeed().getLastPublishedDate().getTime()) {
      log.debug("publishedDate not modified: {}", feedUrl);
      throw new NotModifiedException("publishedDate not modified");
    }

    Feed feed = fetchedFeed.getFeed();
    feed.setLastModifiedHeader(result.getLastModifiedSince());
    feed.setEtagHeader(FeedUtils.truncate(result.getETag(), 255));
    feed.setLastContentHash(hash);
    fetchedFeed.setFetchDuration(result.getDuration());
    fetchedFeed.setUrlAfterRedirect(result.getUrlAfterRedirect());
    return fetchedFeed;
  }
View Full Code Here

TOP

Related Classes of com.commafeed.backend.model.Feed

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.