Package com.commafeed.backend.model

Examples of com.commafeed.backend.model.FeedSubscription


  private void removeExcludedSubscriptions(List<FeedSubscription> subs, List<Long> excludedIds) {
    if (CollectionUtils.isNotEmpty(excludedIds)) {
      Iterator<FeedSubscription> it = subs.iterator();
      while (it.hasNext()) {
        FeedSubscription sub = it.next();
        if (excludedIds.contains(sub.getId())) {
          it.remove();
        }
      }
    }
  }
View Full Code Here


  public static Entry build(FeedEntryStatus status, String publicUrl, boolean proxyImages) {
    Entry entry = new Entry();

    FeedEntry feedEntry = status.getEntry();
    FeedSubscription sub = status.getSubscription();
    FeedEntryContent content = feedEntry.getContent();

    entry.setId(String.valueOf(feedEntry.getId()));
    entry.setGuid(feedEntry.getGuid());
    entry.setRead(status.isRead());
    entry.setStarred(status.isStarred());
    entry.setMarkable(status.isMarkable());
    entry.setDate(feedEntry.getUpdated());
    entry.setInsertedDate(feedEntry.getInserted());
    entry.setUrl(feedEntry.getUrl());
    entry.setFeedName(sub.getTitle());
    entry.setFeedId(String.valueOf(sub.getId()));
    entry.setFeedUrl(sub.getFeed().getUrl());
    entry.setFeedLink(sub.getFeed().getLink());
    entry.setIconUrl(FeedUtils.getFaviconUrl(sub, publicUrl));

    List<String> tags = Lists.newArrayList();
    for (FeedEntryTag tag : status.getTags()) {
      tags.add(tag.getName());
View Full Code Here

    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) {
View Full Code Here

  public Response queueForRefresh(@SecurityCheck User user, @ApiParam(value = "Feed id") IDRequest req) {

    Preconditions.checkNotNull(req);
    Preconditions.checkNotNull(req.getId());

    FeedSubscription sub = feedSubscriptionDAO.findById(user, req.getId());
    if (sub != null) {
      Feed feed = sub.getFeed();
      queues.add(feed, true);
      return Response.ok().build();
    }
    return Response.ok(Status.NOT_FOUND).build();
  }
View Full Code Here

    Date olderThan = req.getOlderThan() == null ? null : new Date(req.getOlderThan());
    String keywords = req.getKeywords();
    List<FeedEntryKeyword> entryKeywords = FeedEntryKeyword.fromQueryString(keywords);

    FeedSubscription subscription = feedSubscriptionDAO.findById(user, Long.valueOf(req.getId()));
    if (subscription != null) {
      feedEntryService.markSubscriptionEntries(user, Arrays.asList(subscription), olderThan, entryKeywords);
    }
    return Response.ok().build();
  }
View Full Code Here

  @UnitOfWork
  @ApiOperation(value = "", notes = "")
  public Response get(@SecurityCheck User user, @ApiParam(value = "user id", required = true) @PathParam("id") Long id) {

    Preconditions.checkNotNull(id);
    FeedSubscription sub = feedSubscriptionDAO.findById(user, id);
    if (sub == null) {
      return Response.status(Status.NOT_FOUND).build();
    }
    UnreadCount unreadCount = feedSubscriptionService.getUnreadCount(user).get(id);
    return Response.ok(Subscription.build(sub, config.getApplicationSettings().getPublicUrl(), unreadCount)).build();
View Full Code Here

  @UnitOfWork
  @ApiOperation(value = "Fetch a feed's icon", notes = "Fetch a feed's icon")
  public Response getFavicon(@SecurityCheck User user, @ApiParam(value = "subscription id") @PathParam("id") Long id) {

    Preconditions.checkNotNull(id);
    FeedSubscription subscription = feedSubscriptionDAO.findById(user, id);
    if (subscription == null) {
      return Response.status(Status.NOT_FOUND).build();
    }
    Feed feed = subscription.getFeed();
    byte[] icon = feedService.fetchFavicon(feed);

    ResponseBuilder builder = Response.ok(icon, "image/x-icon");

    CacheControl cacheControl = new CacheControl();
View Full Code Here

    } catch (FeedEntryFilterException e) {
      Throwable root = Throwables.getRootCause(e);
      return Response.status(Status.BAD_REQUEST).entity(root.getMessage()).build();
    }

    FeedSubscription subscription = feedSubscriptionDAO.findById(user, req.getId());
    subscription.setFilter(req.getFilter());

    if (StringUtils.isNotBlank(req.getName())) {
      subscription.setTitle(req.getName());
    }

    FeedCategory parent = null;
    if (req.getCategoryId() != null && !CategoryREST.ALL.equals(req.getCategoryId())) {
      parent = feedCategoryDAO.findById(user, Long.valueOf(req.getCategoryId()));
    }
    subscription.setCategory(parent);

    if (req.getPosition() != null) {
      List<FeedSubscription> subs = feedSubscriptionDAO.findByCategory(user, parent);
      Collections.sort(subs, new Comparator<FeedSubscription>() {
        @Override
        public int compare(FeedSubscription o1, FeedSubscription o2) {
          return ObjectUtils.compare(o1.getPosition(), o2.getPosition());
        }
      });

      int existingIndex = -1;
      for (int i = 0; i < subs.size(); i++) {
        if (Objects.equals(subs.get(i).getId(), subscription.getId())) {
          existingIndex = i;
        }
      }
      if (existingIndex != -1) {
        subs.remove(existingIndex);
View Full Code Here

      throw new FeedSubscriptionException("Could not subscribe to a feed from this CommaFeed instance");
    }

    Feed feed = feedService.findOrCreate(url);

    FeedSubscription sub = feedSubscriptionDAO.findByFeed(user, feed);
    if (sub == null) {
      sub = new FeedSubscription();
      sub.setFeed(feed);
      sub.setUser(user);
    }
    sub.setCategory(category);
    sub.setPosition(0);
    sub.setTitle(FeedUtils.truncate(title, 128));
    feedSubscriptionDAO.saveOrUpdate(sub);

    queues.add(feed, false);
    cache.invalidateUserRootCategory(user);
    return feed;
View Full Code Here

    cache.invalidateUserRootCategory(user);
    return feed;
  }

  public boolean unsubscribe(User user, Long subId) {
    FeedSubscription sub = feedSubscriptionDAO.findById(user, subId);
    if (sub != null) {
      feedSubscriptionDAO.delete(sub);
      cache.invalidateUserRootCategory(user);
      return true;
    } else {
View Full Code Here

TOP

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

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.