当前位置: 首页>>代码示例>>Java>>正文


Java SyndFeed类代码示例

本文整理汇总了Java中com.sun.syndication.feed.synd.SyndFeed的典型用法代码示例。如果您正苦于以下问题:Java SyndFeed类的具体用法?Java SyndFeed怎么用?Java SyndFeed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SyndFeed类属于com.sun.syndication.feed.synd包,在下文中一共展示了SyndFeed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildChannelMap

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
private Map<Channel, List<Document>> buildChannelMap(long userId) {
    List<Source> sources;
    if (userId == PUB_USER_KEY) {
        sources = articleDao.getPublicSources();
    } else if (articleDao.hasSubscriptions(userId)) {
        sources = articleDao.getSources(userId);
    } else {
        return Collections.emptyMap();
    }

    List<RufusFeed> requests = sources.parallelStream().map(RufusFeed::generate).collect(Collectors.toList());

    Map<Channel, List<Document>> ret = new HashMap<>();
    requests.stream().filter(r -> r.getFeed() != null).forEach(r -> {
        Pair<SyndFeed, List<SyndEntry>> synd = feedPair(r);
        ret.put(Channel.of(
            synd.getKey().getTitle(),
            synd.getKey().getLanguage(),
            synd.getKey().getLink(),
            r.getSource()),
            extractDocuments(synd));
    });

    return ret;
}
 
开发者ID:jtanza,项目名称:rufus,代码行数:26,代码来源:FeedProcessorImpl.java

示例2: extractDocuments

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
private static List<Document> extractDocuments(Pair<SyndFeed, List<SyndEntry>> feedEntry) {
    List<Document> ret = new ArrayList<>();
    feedEntry.getRight().forEach(e -> {
        FeedUtils.mergeAuthors(e);
        String description = e.getDescription() != null ? FeedUtils.clean(e.getDescription().getValue()) : StringUtils.EMPTY;
        if (description.length() > FeedConstants.MAX_DESCRIP_LEN) {
            description = FeedUtils.truncate(description, FeedConstants.MAX_DESCRIP_LEN);
        }
        ret.add(Document.of(
            StringEscapeUtils.unescapeHtml4(e.getTitle()),
            e.getPublishedDate(),
            e.getAuthors(),
            description,
            e.getLink(),
            feedEntry.getLeft().getTitle()
        ));
    });
    return ret;
}
 
开发者ID:jtanza,项目名称:rufus,代码行数:20,代码来源:FeedProcessorImpl.java

示例3: copyInto

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
public void copyInto(WireFeed feed,SyndFeed syndFeed) {
    syndFeed.setModules(ModuleUtils.cloneModules(feed.getModules()));

    syndFeed.setEncoding(feed.getEncoding());
    Channel channel = (Channel) feed;
    syndFeed.setTitle(channel.getTitle());
    syndFeed.setLink(channel.getLink());
    syndFeed.setDescription(channel.getDescription());

    Image image = channel.getImage();
    if (image!=null) {
        syndFeed.setImage(createSyndImage(image));
    }

    List items = channel.getItems();
    if (items!=null) {
        syndFeed.setEntries(createSyndEntries(items));
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:ConverterForRSS090.java

示例4: createRealFeed

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
protected WireFeed createRealFeed(String type,SyndFeed syndFeed) {
    Channel channel = new Channel(type);
    channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules()));

    channel.setEncoding(syndFeed.getEncoding());

    channel.setTitle(syndFeed.getTitle());
    channel.setLink(syndFeed.getLink());
    channel.setDescription(syndFeed.getDescription());
    SyndImage sImage = syndFeed.getImage();
    if (sImage!=null) {
        channel.setImage(createRSSImage(sImage));
    }

    List sEntries = syndFeed.getEntries();
    if (sEntries!=null) {
        channel.setItems(createRSSItems(sEntries));
    }
    return channel;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:ConverterForRSS090.java

示例5: copyInto

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
public void copyInto(WireFeed feed,SyndFeed syndFeed) {
    Channel channel = (Channel) feed;
    super.copyInto(channel,syndFeed);
    syndFeed.setLanguage(channel.getLanguage());        //c
    syndFeed.setCopyright(channel.getCopyright());      //c
    Date pubDate = channel.getPubDate();
    if (pubDate!=null) {
        syndFeed.setPublishedDate(pubDate);     //c
    }

    String author = channel.getManagingEditor();
    if (author!=null) {    
        List creators = ((DCModule) syndFeed.getModule(DCModule.URI)).getCreators();
        if (!creators.contains(author)) {
            Set s = new HashSet(); // using a set to remove duplicates
            s.addAll(creators);    // DC creators
            s.add(author);         // feed native author
            creators.clear();
            creators.addAll(s);
        }
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:ConverterForRSS091Userland.java

示例6: main

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
public static void main(String[] args) {
    boolean ok = false;
    if (args.length==1) {
        try {
            URL feedUrl = new URL(args[0]);
            SyndFeedInput input = new SyndFeedInput();

            SyndFeed feed = input.build(new XmlReader(feedUrl));

            System.out.println(feed);

            ok = true;
        }
        catch (Exception ex) {
            ex.printStackTrace();
            System.out.println("ERROR: "+ex.getMessage());
        }
    }

    if (!ok) {
        System.out.println();
        System.out.println("FeedReader reads and prints any RSS/Atom feed type.");
        System.out.println("The first parameter must be the URL of the feed to read.");
        System.out.println();
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:FeedReader.java

示例7: getAllBuildsFeed

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
/**
 * Returns a feed for all builds that are allowed for a given user.
 *
 * @param userID for that to return feeds.
 *
 * @return a feed for all builds that are allowed for the given user.
 */
public SyndFeed getAllBuildsFeed(final int userID) {

  final List buildStatusList = org.parabuild.ci.security.SecurityManager.getInstance().getFeedBuildStatuses(userID);

  // traverse build statuses
  final List entries = new ArrayList(11);
  final BuildStatusURLGenerator urlGenerator = new BuildStatusURLGenerator();
  final ConfigurationManager cm = ConfigurationManager.getInstance();
  for (final Iterator i = buildStatusList.iterator(); i.hasNext();) {
    final int activeBuildID = ((BuildState)i.next()).getActiveBuildID();
    entries.addAll(getBuildEntries(cm, activeBuildID, urlGenerator));
  }

  // create feed and set collected entries
  final SyndFeed feed = new SyndFeedImpl();
  feed.setTitle("Parabuild Published Result Feed");
  feed.setLink(urlGenerator.makeBuildListURL());
  feed.setDescription("This feed provides information about published results at Parabuild server");
  feed.setEntries(entries);

  // return result
  return feed;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:PublishedResultFeedGenerator.java

示例8: getAllBuildsFeed

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
/**
 * Returns a feed for all builds that are allowed for a given user.
 *
 * @param userID for that to return feeds.
 * @return a feed for all builds that are allowed for the given user.
 */
public SyndFeed getAllBuildsFeed(final int userID) {

  final List buildStatusList = SecurityManager.getInstance().getFeedBuildStatuses(userID);

  // traverse build statuses
  final List entries = new ArrayList(1);
  final BuildStatusURLGenerator urlGenerator = new BuildStatusURLGenerator();
  final ConfigurationManager cm = ConfigurationManager.getInstance();
  for (final Iterator i = buildStatusList.iterator(); i.hasNext();) {
    final int activeBuildID = ((BuildState) i.next()).getActiveBuildID();
    entries.addAll(getBuildEntries(cm, activeBuildID, urlGenerator));
  }

  // create feed and set collected entries
  final SyndFeed feed = new SyndFeedImpl();
  feed.setTitle("Parabuild Feed");
  feed.setLink(urlGenerator.makeBuildListURL());
  feed.setDescription("This feed provides information about build statuses at Parabuild server");
  feed.setEntries(entries);

  // return result
  return feed;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:FeedGenerator.java

示例9: execute

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
    log.info("Start FetchAtomWorker job");

    EntityManagerFactory emf = (EntityManagerFactory) context.getMergedJobDataMap().get("emf");
    DataManager dm = new DataManager (emf);
    ServletContext scontext = (ServletContext) context.getMergedJobDataMap().get("scontext");

    Iterator it = dm.feeds.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry <String, String[]> pair = (Map.Entry)it.next();
        System.out.println(pair.getKey() + " = " + pair.getValue());

        try {
            URL feedUrl = new URL(pair.getValue()[1]);

            SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(feedUrl));
            for (SyndEntry entry : (List<SyndEntry>) feed.getEntries()) {
                dm.saveNewsItem(entry, pair.getKey());
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
 
开发者ID:juntao,项目名称:dwnewsbot,代码行数:26,代码来源:FetchAtomWorker.java

示例10: generateFeed

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
public SyndFeed generateFeed( String title, String description, List<RssFeedEntry> dataEntries )
{
    if( dataEntries.size() ==  0 )
    {
        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;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:21,代码来源:RssFeedGenerator.java

示例11: SyndEntryAdapter

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
public SyndEntryAdapter(SyndFeed feed, SyndEntry entry) {
    if (entry.getTitleEx() != null) {
        this.title = entry.getTitle();
        this.titleType = entry.getTitleEx().getType();
    }
    if (entry.getDescription() != null) {
        this.description = entry.getDescription().getValue();
        this.descriptionType = entry.getDescription().getType();
    }
    this.uri = entry.getUri();
    this.author = entry.getAuthor();
    this.link = entry.getLink();

    if (entry.getPublishedDate() != null)
        this.publishedDate = ISO_8601_DATE_FORMAT.format(entry.getPublishedDate());
    if (entry.getUpdatedDate() != null)
        this.updatedDate = ISO_8601_DATE_FORMAT.format(entry.getUpdatedDate());
    this.fetchDate = ISO_8601_DATE_FORMAT.format(new Date());

    this.sourceLink = feed.getLink();
    this.sourceUri = feed.getUri();
    this.sourceTitle = feed.getTitle();
    this.language = feed.getLanguage();
    this.sourceType = feed.getFeedType();
}
 
开发者ID:marozau,项目名称:expresso,代码行数:26,代码来源:SyndEntryAdapter.java

示例12: aggregate

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
    if (oldExchange == null) {
        return newExchange;
    }
    SyndFeed oldFeed = oldExchange.getIn().getBody(SyndFeed.class);
    SyndFeed newFeed = newExchange.getIn().getBody(SyndFeed.class);
    if (oldFeed != null && newFeed != null) {                
        List<SyndEntryImpl> oldEntries = CastUtils.cast(oldFeed.getEntries());                  
        List<SyndEntryImpl> newEntries = CastUtils.cast(newFeed.getEntries());
        List<SyndEntryImpl> mergedList = new ArrayList<SyndEntryImpl>(oldEntries.size() + newEntries.size());
        mergedList.addAll(oldEntries);
        mergedList.addAll(newEntries);
        oldFeed.setEntries(mergedList);    
    } else {
        log.debug("Could not merge exchanges. One body was null.");
    }
    return oldExchange;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:AggregateRssFeedStrategy.java

示例13: testGrabbingListOfEntries

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
@Test
public void testGrabbingListOfEntries() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    mock.assertIsSatisfied();

    Exchange exchange = mock.getExchanges().get(0);
    Message in = exchange.getIn();
    assertNotNull(in);
    assertTrue(in.getBody() instanceof SyndFeed);
    assertTrue(in.getHeader(RssConstants.RSS_FEED) instanceof SyndFeed);

    SyndFeed feed = in.getHeader(RssConstants.RSS_FEED, SyndFeed.class);
    assertTrue(feed.getAuthor().contains("Jonathan Anstey"));

    SyndFeed body = in.getBody(SyndFeed.class);
    assertEquals(10, body.getEntries().size());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:RssPollingConsumerTest.java

示例14: testCreateNullHeadlineAndLink

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testCreateNullHeadlineAndLink() throws Exception {
	String createdFeed = new String(createFeedCreator("feeds/valid_page/index.html")
			.createFeed(".headline,.article,.footer", null, null, null)
			.setTitle("Title")
			.build());
	SyndFeedInput input = new SyndFeedInput();
	SyndFeed feed = input.build(new XmlReader(new ByteArrayInputStream(createdFeed.getBytes())));
	assertEquals("Title", feed.getTitle());
	
	List<SyndEntry> entries = feed.getEntries();

	assertEquals(null, entries.get(0).getTitle());
	assertEquals(null, entries.get(0).getLink());
	assertEquals(EMPTY, entries.get(0).getAuthor());
	assertEquals(null, entries.get(1).getTitle());
	assertEquals(null, entries.get(1).getLink());
	assertEquals(EMPTY, entries.get(1).getAuthor());
}
 
开发者ID:rrauschenbach,项目名称:FeedExpander,代码行数:21,代码来源:FeedCreatorTest.java

示例15: getFeedContent

import com.sun.syndication.feed.synd.SyndFeed; //导入依赖的package包/类
/**
 * Get the feed content
 * @param request
 * @param response
 * @return Map of params or null if any required data is missing
 */
private SyndFeed getFeedContent(RenderRequest request, RenderResponse response) {
	
	SyndFeed feed;
	
	//check cache, otherwise get fresh
	//we use the feedUrl as the cacheKey
	String feedUrl = getConfiguredFeedUrl(request);
	if(StringUtils.isBlank(feedUrl)) {
		log.debug("No feed URL configured");
		doError("error.no.config", "error.heading.config", getPortletModeUrl(response, PortletMode.EDIT), request, response);
		return null;
	}
	
	String cacheKey = feedUrl;
	
	feed = feedCache.get(cacheKey);
	if(feed != null) {
		log.debug("Fetching data from feed cache for: " + cacheKey);
	} else {
		//get from remote
		feed = getRemoteFeed(feedUrl, request, response);
	}
	
	return feed;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:32,代码来源:SimpleRSSPortlet.java


注:本文中的com.sun.syndication.feed.synd.SyndFeed类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。