Package com.commafeed.frontend.model

Examples of com.commafeed.frontend.model.Entries


    List<FeedEntryKeyword> entryKeywords = FeedEntryKeyword.fromQueryString(keywords);

    limit = Math.min(limit, 1000);
    limit = Math.max(0, limit);

    Entries entries = new Entries();
    entries.setOffset(offset);
    entries.setLimit(limit);
    boolean unreadOnly = readType == ReadingMode.unread;
    if (StringUtils.isBlank(id)) {
      id = ALL;
    }

    Date newerThanDate = newerThan == null ? null : new Date(newerThan);

    List<Long> excludedIds = null;
    if (StringUtils.isNotEmpty(excludedSubscriptionIds)) {
      excludedIds = Lists.newArrayList();
      for (String excludedId : excludedSubscriptionIds.split(",")) {
        excludedIds.add(Long.valueOf(excludedId));
      }
    }

    if (ALL.equals(id)) {
      entries.setName(Optional.fromNullable(tag).or("All"));
      List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user);
      removeExcludedSubscriptions(subs, excludedIds);
      List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, subs, unreadOnly, entryKeywords, newerThanDate,
          offset, limit + 1, order, true, onlyIds, tag);

      for (FeedEntryStatus status : list) {
        entries.getEntries().add(
            Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
                .isImageProxyEnabled()));
      }

    } else if (STARRED.equals(id)) {
      entries.setName("Starred");
      List<FeedEntryStatus> starred = feedEntryStatusDAO.findStarred(user, newerThanDate, offset, limit + 1, order, !onlyIds);
      for (FeedEntryStatus status : starred) {
        entries.getEntries().add(
            Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
                .isImageProxyEnabled()));
      }
    } else {
      FeedCategory parent = feedCategoryDAO.findById(user, Long.valueOf(id));
      if (parent != null) {
        List<FeedCategory> categories = feedCategoryDAO.findAllChildrenCategories(user, parent);
        List<FeedSubscription> subs = feedSubscriptionDAO.findByCategories(user, categories);
        removeExcludedSubscriptions(subs, excludedIds);
        List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, subs, unreadOnly, entryKeywords, newerThanDate,
            offset, limit + 1, order, true, onlyIds, tag);

        for (FeedEntryStatus status : list) {
          entries.getEntries().add(
              Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
                  .isImageProxyEnabled()));
        }
        entries.setName(parent.getName());
      } else {
        return Response.status(Status.NOT_FOUND).entity("<message>category not found</message>").build();
      }
    }

    boolean hasMore = entries.getEntries().size() > limit;
    if (hasMore) {
      entries.setHasMore(true);
      entries.getEntries().remove(entries.getEntries().size() - 1);
    }

    entries.setTimestamp(System.currentTimeMillis());
    entries.setIgnoredReadStatus(STARRED.equals(id) || keywords != null || tag != null);
    FeedUtils.removeUnwantedFromSearch(entries.getEntries(), entryKeywords);
    return Response.ok(entries).build();
  }
View Full Code Here


    Response response = getCategoryEntries(user, id, readType, newerThan, offset, limit, order, keywords, onlyIds,
        excludedSubscriptionIds, tag);
    if (response.getStatus() != Status.OK.getStatusCode()) {
      return response;
    }
    Entries entries = (Entries) response.getEntity();

    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");
    feed.setTitle("CommaFeed - " + entries.getName());
    feed.setDescription("CommaFeed - " + entries.getName());
    String publicUrl = config.getApplicationSettings().getPublicUrl();
    feed.setLink(publicUrl);

    List<SyndEntry> children = Lists.newArrayList();
    for (Entry entry : entries.getEntries()) {
      children.add(entry.asRss());
    }
    feed.setEntries(children);

    SyndFeedOutput output = new SyndFeedOutput();
View Full Code Here

    List<FeedEntryKeyword> entryKeywords = FeedEntryKeyword.fromQueryString(keywords);

    limit = Math.min(limit, 1000);
    limit = Math.max(0, limit);

    Entries entries = new Entries();
    entries.setOffset(offset);
    entries.setLimit(limit);

    boolean unreadOnly = readType == ReadingMode.unread;

    Date newerThanDate = newerThan == null ? null : new Date(newerThan);

    FeedSubscription subscription = feedSubscriptionDAO.findById(user, Long.valueOf(id));
    if (subscription != null) {
      entries.setName(subscription.getTitle());
      entries.setMessage(subscription.getFeed().getMessage());
      entries.setErrorCount(subscription.getFeed().getErrorCount());
      entries.setFeedLink(subscription.getFeed().getLink());

      List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, Arrays.asList(subscription), unreadOnly,
          entryKeywords, newerThanDate, offset, limit + 1, order, true, onlyIds, null);

      for (FeedEntryStatus status : list) {
        entries.getEntries().add(
            Entry.build(status, config.getApplicationSettings().getPublicUrl(), config.getApplicationSettings()
                .isImageProxyEnabled()));
      }

      boolean hasMore = entries.getEntries().size() > limit;
      if (hasMore) {
        entries.setHasMore(true);
        entries.getEntries().remove(entries.getEntries().size() - 1);
      }
    } else {
      return Response.status(Status.NOT_FOUND).entity("<message>feed not found</message>").build();
    }

    entries.setTimestamp(System.currentTimeMillis());
    entries.setIgnoredReadStatus(keywords != null);
    FeedUtils.removeUnwantedFromSearch(entries.getEntries(), entryKeywords);
    return Response.ok(entries).build();
  }
View Full Code Here

    Response response = getFeedEntries(user, id, readType, newerThan, offset, limit, order, keywords, onlyIds);
    if (response.getStatus() != Status.OK.getStatusCode()) {
      return response;
    }
    Entries entries = (Entries) response.getEntity();

    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");
    feed.setTitle("CommaFeed - " + entries.getName());
    feed.setDescription("CommaFeed - " + entries.getName());
    String publicUrl = config.getApplicationSettings().getPublicUrl();
    feed.setLink(publicUrl);

    List<SyndEntry> children = Lists.newArrayList();
    for (Entry entry : entries.getEntries()) {
      children.add(entry.asRss());
    }
    feed.setEntries(children);

    SyndFeedOutput output = new SyndFeedOutput();
View Full Code Here

TOP

Related Classes of com.commafeed.frontend.model.Entries

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.