Package lib.containers

Examples of lib.containers.Feed


  public int limit = 5;

  public Object endpoint(String name, Params params) throws Exception {
    String url = params.get("url");
    String cacheKey = this.getClass().getName() + url;
    Feed out = Cache.get(cacheKey, Feed.class);
    if (out != null)
      return out;
    out = new Feed();
      URL source = new URL(url);
    SyndFeedInput raw = new SyndFeedInput();
    SyndFeed feed = raw.build(new XmlReader(source));
    Iterator<SyndEntry> itr = feed.getEntries().iterator();
    int i = 0;
    while( itr.hasNext() && i++ < limit) {
      SyndEntry s = itr.next();
      out.add(null, s.getTitle(), s.getLink());
    }
    Cache.set(cacheKey, out, "60s");
    return out;
  }
View Full Code Here


    if(params._contains("create")) {
      Shout s = new Shout(params.get("author"),params.get("text"));
      s.save();     
      return true;
    } else {
      Feed out = new Feed();
      List<Shout> shouts = Shout.find("order by posted desc").fetch(5);
      long limit = 1000 * 60 * 60 * 24 * 5; // 5 days in ms
      for(Shout s : shouts) {
        if( new Date().getTime() - s.posted.getTime() > limit)
          s.delete();
        else
          out.add(s.author, s.body, "");
      }
      return out; 
     
    }
  }
View Full Code Here

TOP

Related Classes of lib.containers.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.