Package com.sun.syndication.feed.synd

Examples of com.sun.syndication.feed.synd.SyndFeedImpl


        // Convert source element Feed into SyndFeed and assign as SyndEntry
        // source
        Feed source = entry.getSource();
        if (source != null) {
          SyndFeed syndSource = new SyndFeedImpl(source);
          syndEntry.setSource(syndSource);
        }

        return syndEntry;
    }
View Full Code Here


     * テスト用のRSSフィードを生成する。
     * @return テスト用のRSSフィード
     */
    @SuppressWarnings("unchecked")
    private SyndFeed createFeed() {
        SyndFeed feed = new SyndFeedImpl();
        feed.setModules(Arrays.asList(new NicoliveModule()));

        feed.setTitle("テストRSS");

        DateTime datetime = new DateTime(2011, 1, 1, 0, 0, 0, 0);
        DateTimeFormatter df = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
        List<SyndEntry> entries = new LinkedList<SyndEntry>();
        for (int i = 0; i < 9; i++) {
            SyndEntry entry = new SyndEntryImpl();
            entry.setTitle("テスト" + i);
            SyndContent description = new SyndContentImpl();
            description.setValue("テスト説明" + i);
            entry.setDescription(description);
            entry.setLink("http://ryu22e.org/" + i);

            NicoliveModule module = new NicoliveModule();
            module.setOpenTime(datetime.minusDays(i).toString(df));
            module.setStartTime(datetime
                .minusDays(i)
                .plusMinutes(10)
                .toString(df));
            module.setType("official");
            entry.getModules().add(module);

            entries.add(entry);
        }
        // NicoliveModuleなしのデータも含める。
        SyndEntry invalidEntry = new SyndEntryImpl();
        invalidEntry.setTitle("NicoliveModuleなしデータ");
        SyndContent description = new SyndContentImpl();
        description.setValue("テスト説明");
        invalidEntry.setDescription(description);
        invalidEntry.setLink("http://ryu22e.org/");
        entries.add(invalidEntry);

        feed.setEntries(entries);

        return feed;
    }
View Full Code Here

            link = "http://";
          }
        }       
       
        // Construct feed object.
        SyndFeed feed = new SyndFeedImpl();
       
        if (feedType.equals(FeedType.RSS)) {
            feed.setFeedType(RSS_2_0);
        } else {
            feed.setFeedType(ATOM_1_0);
        }
       
        feed.setTitle(title);
        feed.setDescription(description);
        feed.setLink(link);
       
        // Construct feed items.
        List<SyndEntry> entries = new ArrayList<SyndEntry>();

        for (Object feedItem : feedItems) {
            SyndEntry syndEntry = createFeedItem(feedItem);
           
            entries.add(syndEntry);
        }
       
        feed.setEntries(entries);
       
        // output the feed to the output stream
        SyndFeedOutput output = new SyndFeedOutput();
        output.output(feed, writer);
    }
View Full Code Here

     * Constructor.
     * @param ui either "xmlui" or "jspui"
     */
    public SyndicationFeed(String ui)
    {
        feed = new SyndFeedImpl();
        uiType = ui;
    }
View Full Code Here

    }
  }

  protected SyndFeed getFeed(HttpServletRequest req,String id,int numOfChanges,String feedId,ResourceBundle rb) //throws IOException, FeedException
  {
    SyndFeed feed = new SyndFeedImpl();

    //determine the directory uri
    //String servAddr =
    StringBuilder sb = new StringBuilder();
    //sb.append(SscfAjax.getServiceAddr(req)).append("/directory/").append(id);
    //id is now the whole uri
    String resUri = id;
    XfoafSscfResource xfsr = XfoafSscfResource.getXfoafSscfResource(resUri);
   
    if(xfsr!=null)
    {
      sb.setLength(0);
      String labelOfFeed = xfsr.getLabel();
      int type = 0; //1 for user feed;
     
      System.out.println(resUri);
     
      //in case we have top-level - user feed
      if(xfsr.getId().length()<=8)
      {
        Person p = PersonFactory.findPerson(resUri);
        if(p!=null) {
          System.out.println(p.getName());
          labelOfFeed = p.getName();
          type = 1;
        }
      }
     
      feed.setTitle(getFeedTitle(labelOfFeed, req.getLocalName(), rb, type));
   
      //TODO: - resUri may point to different server/system
      feed.setLink(resUri);
      feed.setDescription(getFeedTitle(labelOfFeed, req.getLocalName(), rb, type)); //TODO
 
      //get the changes
      ChangelogDbHandler cdh = ChangelogDbHandler.getInstance();
      List<ChangeBean> changes = new ArrayList<ChangeBean>();
      List<SyndEntry> entries = new ArrayList<SyndEntry>();
     
      if(cdh!=null)
      {
        changes = cdh.getLastChanges(resUri, numOfChanges);
      }
     
      for(ChangeBean change:changes)
      {
        SyndEntry entry;
        SyndContent description;
   
        entry = new SyndEntryImpl();
        XfoafSscfResource changeRes = null;
        XfoafSscfResource changedRes = null;
       
        changedRes = XfoafSscfResource.getXfoafSscfResource(change.getChangedUri());
        if((change.getChangeType()==ChangeTypes.ADDED.getChangeType()
            ||change.getChangeType()==ChangeTypes.REMOVED.getChangeType())
            &&change.getChangeUri()!=null)
        {
          changeRes = XfoafSscfResource.getXfoafSscfResource(change.getChangeUri());
        }
       
        entry.setTitle(ChangeContent.getTitle(change.getChangeType(), change.getDepth(),rb,changeRes));
        //TODO: generate unique link
        StringBuilder changeUri = new StringBuilder();
        changeUri.append(SscfAjax.getServiceAddr(req)).append('/').append(CH_DISP_SERVLET).append('/')
          .append(feedId).append('/').append(change.getId()).append("-").append(change.getDepth());
        entry.setLink(changeUri.toString());
        entry.setPublishedDate(change.getTimestamp());
       
        description = new SyndContentImpl();
        description.setType("text/html");

        description.setValue(ChangeContent.getMessage(change.getChangeType(), change.getDepth(),
          change.getChangeValue(), labelOfFeed, change.getChangedUri(),changedRes,changeRes,rb));
        entry.setDescription(description);
        entries.add(entry);
      }
 
      feed.setEntries(entries);
     
    }
    return feed;
  }
View Full Code Here

        {
            log.debug( "No updates found, feed not generated." );
            return null;
        }
       
        SyndFeed feed = new SyndFeedImpl();
        feed.setTitle( title );       
        feed.setDescription( description );
        feed.setLanguage( DEFAULT_LANGUAGE );
        feed.setPublishedDate( dataEntries.get( dataEntries.size() - 1 ).getPublishedDate() );
        feed.setFeedType( DEFAULT_FEEDTYPE );
        feed.setEntries( getEntries( dataEntries ) );

        log.debug( "Finished generating the feed \'{}\'.", title );
       
        return feed;
    }
View Full Code Here

        }
        return description;
    }

    protected SyndFeed createFeed(QueueBrowser browser, HttpServletRequest request) throws JMSException {
        SyndFeed feed = new SyndFeedImpl();
        feed.setFeedType(feedType);

        String title = browser.getQueue().toString();
        String selector = browser.getMessageSelector();
        if (selector != null) {
            title += " with selector: " + selector;
        }
        feed.setTitle(title);
        feed.setLink(request.getRequestURI());
        feed.setDescription(getDescription());
        return feed;
    }
View Full Code Here

        }
        return createFeed();
    }

    protected SyndFeed createFeed() {
        SyndFeed feed = new SyndFeedImpl();
        feed.setFeedType(feedType);

        feed.setTitle(getTitle());
        feed.setLink(getLink());
        feed.setDescription(getFeedDescription());
        return feed;
    }
View Full Code Here

     * Poll for updates
     */
    public void poll() {
        List list = getLastesEntries();
        if (list != null && !list.isEmpty()) {
            SyndFeed feed = new SyndFeedImpl();
            feed.setFeedType(outputType);
            feed.setTitle("Aggregated Feed");
            feed.setDescription("Anonymous Aggregated Feed");
            feed.setAuthor("servicemix");
            feed.setLink("http://www.servicemix.org");
            feed.setEntries(list);
            // send on to the nmr ...
            SyndFeedOutput output = new SyndFeedOutput();
            try {
                Source source = new DOMSource(output.outputW3CDom(feed));
                InOnly exchange = getExchangeFactory().createInOnlyExchange();
View Full Code Here

    try {
      final Map<String, String> params = getParameters(uriInfo);
      final List<FeedEvent> feedEvents = feedSource.getFeed(from, count, params);

      final SyndFeed feed = new SyndFeedImpl();
      feed.setTitle(feedSource.getFeedName());
      feed.setDescription(feedSource.getFeedDescription());
      feed.setAuthor("Nexus " + systemStatusProvider.get().getVersion());
      feed.setPublishedDate(new Date());
      feed.setLink(BaseUrlHolder.get() + "/service/siesta/feeds/" + feedSource.getFeedKey());


      final List<SyndEntry> entries = Lists.newArrayListWithCapacity(feedEvents.size());
      for (FeedEvent event : feedEvents) {
        final SyndEntry entry = new SyndEntryImpl();
        entry.setTitle(feedContentRenderer.getTitle(event));
        entry.setPublishedDate(event.getPublished());
        if (event.getAuthor() != null) {
          entry.setAuthor(event.getAuthor());
        }
        else {
          entry.setAuthor(feed.getAuthor());
        }
        if (event.getLink() != null) {
          if (event.getLink().startsWith("http:") || event.getLink().startsWith("https:")) {
            // this is full URL, use it as is
            entry.setLink(event.getLink());
          }
          else {
            entry.setLink(BaseUrlHolder.get() + event.getLink());
          }
        }
        final SyndContent content = new SyndContentImpl();
        content.setType(feedContentRenderer.getContentType(event));
        content.setValue(feedContentRenderer.getContent(event));
        entry.setDescription(content);
        entries.add(entry);
      }
      feed.setEntries(entries);
      return feed;
    }
    catch (Exception e) {
      log.error("Problem during feed creation", e);
      throw new WebApplicationException(e);
View Full Code Here

TOP

Related Classes of com.sun.syndication.feed.synd.SyndFeedImpl

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.