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


Java FeedException类代码示例

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


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

示例1: doInBackground

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
@Override
protected Void doInBackground(final InputStream... ignored) {
    final String currentFeedUrl = SharedPrefUtils.getCurrentFeedUrl(mActivity);

    final InputStream feed = FeedDownloader.getInputStream(mActivity, currentFeedUrl);

    if (feed != null) {
        try {
            RomeFeedParser.parse(feed);
        } catch (final FeedException | IOException e) {
            ErrorHandler.setErrno(ErrorHandler.ERROR_PARSER, e);
        }
    }

    return null;
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:17,代码来源:LoadCurrentFeedFragment.java

示例2: parse

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
public static void parse(final InputStream in) throws IOException, FeedException {
    try (final XmlReader reader = new XmlReader(in)) {
        final SyndFeedInput input = new SyndFeedInput();

        final SyndFeed feed = input.build(reader);

        final String encoding = feed.getEncoding();

        if (!TextUtils.isEmpty(encoding) &&
                !encoding.equalsIgnoreCase(StandardCharsets.UTF_8.name())) {
            throw new IOException("Unsupported XML encoding");
        }

        CurrentFeed.set(feed);
    }
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:17,代码来源:RomeFeedParser.java

示例3: readInternal

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
		throws IOException, HttpMessageNotReadableException {

	WireFeedInput feedInput = new WireFeedInput();
	MediaType contentType = inputMessage.getHeaders().getContentType();
	Charset charset =
			(contentType != null && contentType.getCharSet() != null? contentType.getCharSet() : DEFAULT_CHARSET);
	try {
		Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
		return (T) feedInput.build(reader);
	}
	catch (FeedException ex) {
		throw new HttpMessageNotReadableException("Could not read WireFeed: " + ex.getMessage(), ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:AbstractWireFeedHttpMessageConverter.java

示例4: writeInternal

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
@Override
protected void writeInternal(T wireFeed, HttpOutputMessage outputMessage)
		throws IOException, HttpMessageNotWritableException {

	String wireFeedEncoding = wireFeed.getEncoding();
	if (!StringUtils.hasLength(wireFeedEncoding)) {
		wireFeedEncoding = DEFAULT_CHARSET.name();
	}
	MediaType contentType = outputMessage.getHeaders().getContentType();
	if (contentType != null) {
		Charset wireFeedCharset = Charset.forName(wireFeedEncoding);
		contentType = new MediaType(contentType.getType(), contentType.getSubtype(), wireFeedCharset);
		outputMessage.getHeaders().setContentType(contentType);
	}

	WireFeedOutput feedOutput = new WireFeedOutput();
	try {
		Writer writer = new OutputStreamWriter(outputMessage.getBody(), wireFeedEncoding);
		feedOutput.output(wireFeed, writer);
	}
	catch (FeedException ex) {
		throw new HttpMessageNotWritableException("Could not write WireFeed: " + ex.getMessage(), ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:AbstractWireFeedHttpMessageConverter.java

示例5: getStreamRssByUserName

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
@Override
public GetStreamRssByUserNameResponse getStreamRssByUserName(String userName) throws Exception {
  StreamingOutput rssOutput = outputStream -> {
    PageRequest pageable = new PageRequest(0, 30);

    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");

    feed.setTitle("PutPut RSS");
    feed.setLink("https://putput.org/api/stream/rss/"+userName);
    feed.setDescription("PutPut feed for @" + userName);

    feed.setEntries(rssEntries(userName, pageable));
    try {
      outputStream.write(new SyndFeedOutput().outputString(feed, true).getBytes("UTF-8"));
    } catch (FeedException e) {
      throw new RuntimeException(e);
    }
  };

  return GetStreamRssByUserNameResponse.withRssxmlOK(rssOutput);
}
 
开发者ID:adrobisch,项目名称:putput,代码行数:23,代码来源:StreamResource.java

示例6: run

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
@Scheduled(fixedRate=DateTimeConstants.MILLIS_PER_DAY)
public void run() {
    LocalDateTime lastImport = service.getLastImportDate(PublicationSource.ARXIV);
    for (String feedKey : FEEDS) {
        SyndFeedInput input = new SyndFeedInput();
        try {
            SyndFeed feed = input.build(new XmlReader(new URL(ROOT_RSS_URL + feedKey)));
            List<String> ids = new ArrayList<String>(feed.getEntries().size());
            for (SyndEntry entry : feed.getEntries()) {
                ids.add(entry.getLink().replace(URI_PREFIX, ""));
            }
            
            URL url = new URL("http://export.arxiv.org/api/query?id_list=" + joiner.join(ids) + "&max_results=100");
            try (InputStream inputStream = url.openStream()) {
                List<Publication> publications = extractPublications(inputStream, lastImport, ids.size());
                publications = publications.stream().filter(p -> p.getCreated().isAfter(lastImport)).collect(Collectors.toList());
                logger.info("Obtained publications from arxiv for category {}: {}", feedKey, publications.size());
                service.storePublication(publications);
            }
            
        } catch (IllegalArgumentException | FeedException | IOException e) {
            logger.error("Problem getting arxiv RSS feed", e);
        }
    }
}
 
开发者ID:Glamdring,项目名称:scientific-publishing,代码行数:26,代码来源:ArxivImporter.java

示例7: buildSyndFeed

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
/**
 * Feedを取得する.
 * @param uri 対象URL
 * @return 取得したSyndFeed
 * @throws IOException IO例外
 * @throws FeedException Feed解析失敗
 * @throws CrawlerException Crawler共通例外
 */
protected SyndFeed buildSyndFeed(URI uri) throws IOException, FeedException, CrawlerException {
    InputStream is = null;
    try {
        is = httpget(uri);
    } catch (UnknownHostException e) {
        log.warn("http request failure url : " + uri.toString());
        throw new CrawlerException();
    }
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = null;
    if (is != null) {
        InputStreamReader sr = new InputStreamReader(is, StandardCharsets.UTF_8);
        feed = input.build(sr);
    }
    return feed;
}
 
开发者ID:codefornamie,项目名称:namie-crawler,代码行数:25,代码来源:ArticleCrawler.java

示例8: setFeedInfo

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
/**
 * Add a SyndFeedInfo object to the cache
 *
 * @param feedUrl The url of the feed
 * @param feedInfo A SyndFeedInfo for the feed
 */
@Override
public synchronized void setFeedInfo(URL feedUrl, SyndFeedInfo feedInfo) {
    try {
        String url = FeedCacheUtils.urlToString(feedUrl);
        FeedRecord record = feedRecordDataService.findByURL(url);
        if (record != null) {
            SyndFeedInfo cachedFeedInfo = FeedCacheUtils.feedRecordToFeedInfo(record);
            if (sendMessagesForChangedEntries(url, cachedFeedInfo.getSyndFeed(), feedInfo.getSyndFeed())) {
                feedRecordDataService.delete(record);
                feedRecordDataService.create(FeedCacheUtils.recordFromFeed(url, feedInfo));
            }
        } else {
            sendMessagesForNewFeedData(url, feedInfo.getSyndFeed());
            feedRecordDataService.create(FeedCacheUtils.recordFromFeed(url, feedInfo));
        }
    } catch (IOException | FeedException | ClassNotFoundException ex) {
        LOGGER.error("Error writing FeedRecord to the database {}", ex.getMessage());
    }
}
 
开发者ID:motech,项目名称:modules,代码行数:26,代码来源:FeedCache.java

示例9: remove

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
/**
 * Removes the SyndFeedInfo identified by the url from the cache.
 *
 * @return The removed SyndFeedInfo
 */
@Override
public SyndFeedInfo remove(URL feedUrl) {
    try {
        String url = FeedCacheUtils.urlToString(feedUrl);
        FeedRecord record = feedRecordDataService.findByURL(url);
        if (record == null) {
            LOGGER.error("Trying to remove feedRecord for inexistent URL {}", feedUrl);
            return null;
        }
        LOGGER.debug("*** removing from cache *** {}", url);
        feedRecordDataService.delete(record);
        return FeedCacheUtils.feedRecordToFeedInfo(record);
    } catch (IOException | ClassNotFoundException | FeedException ex) {
        LOGGER.error("Error removing FeedRecord from the databaase {}", ex.getMessage());
        return null;
    }
}
 
开发者ID:motech,项目名称:modules,代码行数:23,代码来源:FeedCache.java

示例10: setFeedInfo

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
/**
 * Add a SyndFeedInfo object to the cache
 *
 * @param feedUrl The url of the feed
 * @param feedInfo A SyndFeedInfo for the feed
 */
@Override
public synchronized void setFeedInfo(URL feedUrl, SyndFeedInfo feedInfo) {
    try {
        String url = FeedCacheUtils.urlToString(feedUrl);
        String regex = atomClientConfigService.getRegexForFeedUrl(url);
        FeedRecord record = feedRecordDataService.findByURL(url);
        if (record != null) {
            SyndFeedInfo cachedFeedInfo = FeedCacheUtils.feedRecordToFeedInfo(record);
            if (sendMessagesForChangedEntries(url, cachedFeedInfo.getSyndFeed(), feedInfo.getSyndFeed(), regex)) {
                feedRecordDataService.delete(record);
                feedRecordDataService.create(FeedCacheUtils.recordFromFeed(url, feedInfo));
            }
        } else {
            sendMessagesForNewFeedData(url, feedInfo.getSyndFeed(), regex);
            feedRecordDataService.create(FeedCacheUtils.recordFromFeed(url, feedInfo));
        }
    } catch (IOException | FeedException | ClassNotFoundException ex) {
        LOGGER.error("Error writing FeedRecord to the database {}", ex.getMessage());
    }
}
 
开发者ID:motech,项目名称:modules,代码行数:27,代码来源:FeedCache.java

示例11: testGenerator

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
/**
 * Parser-Test (INSPIRE Service Feed)
 * @throws java.io.IOException
 * @throws org.jdom2.JDOMException
 * @throws com.rometools.rome.io.FeedException
 */
public void testGenerator() throws IOException, JDOMException, IllegalArgumentException, FeedException {

    final String file = "src/test/resources/dgm200.xml";        
    final Document xml = new SAXBuilder().build(new File(file));
    
    // parse Atom 
    Feed atomFeed = (Feed) new Atom10Parser().parse(xml, true, Locale.GERMAN);
    
    // get first Entry-Element
    Entry atomEntry = (Entry) atomFeed.getEntries().get(0);
    
    // get INSPIRE_DLS-Module
    InspireDlsModule inspireDlsModule = (InspireDlsModuleImpl) atomEntry.getModule(InspireDlsModule.URI);        
    assertTrue(inspireDlsModule.getSpatialDatasetIdentifier().getCode().equals("DEBY_1d4ab890-27e7-3ebb-95ba-2d2ab8071871"));
    assertTrue(inspireDlsModule.getSpatialDatasetIdentifier().getNamespace().equals("http://www.geodaten.bayern.de"));        
    System.out.println(inspireDlsModule.getSpatialDatasetIdentifier());                
}
 
开发者ID:JuergenWeichand,项目名称:inspire_dls-rome,代码行数:24,代码来源:ParserTest.java

示例12: compareFeedFiles

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
/**
 * @param expected original file
 * @param generated file for output
 * @throws IOException if file not found or not accessible
 * @throws FeedException when the feed can't be parsed
 */
private void compareFeedFiles(final File expected, final File generated) throws IOException, FeedException {
    final SyndFeed feed = getSyndFeed(expected);
    final List<SyndEntry> entries = feed.getEntries();
    final SyndFeedOutput output = new SyndFeedOutput();
    output.output(feed, generated);
    final SyndFeed feed2 = getSyndFeed(generated);
    for (int i = 0; i < entries.size(); i++) {
        BufferedWriter b = new BufferedWriter(new FileWriter(generated.getAbsolutePath() + ".a.txt"));
        b.write("" + entries.get(i).getModule(MediaModule.URI));
        b.close();
        b = new BufferedWriter(new FileWriter(generated.getAbsolutePath() + ".b.txt"));
        b.write("" + feed2.getEntries().get(i).getModule(MediaModule.URI));
        b.close();
        assertEquals(entries.get(i).getModule(MediaModule.URI), feed2.getEntries().get(i).getModule(MediaModule.URI));
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:23,代码来源:MediaModuleTest.java

示例13: testReadMainSpec

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
public void testReadMainSpec() throws IOException, FeedException {
    final SyndFeed feed = getSyndFeed("thr/threading-main.xml");
    List<SyndEntry> entries = feed.getEntries();
    SyndEntry parentEntry = entries.get(0);
    assertEquals("should be the parent entry", "My original entry", parentEntry.getTitle());
    assertNull(parentEntry.getModule(ThreadingModule.URI));

    SyndEntry replyEntry = entries.get(1);
    assertEquals("should be the reply entry", "A response to the original", replyEntry.getTitle());
    Module module = replyEntry.getModule(ThreadingModule.URI);
    assertNotNull(module);
    ThreadingModule threadingModule = (ThreadingModule) module;
    assertEquals("tag:example.org,2005:1", threadingModule.getRef());
    assertEquals("application/xhtml+xml", threadingModule.getType());
    assertEquals("http://www.example.org/entries/1", threadingModule.getHref());
    assertNull(threadingModule.getSource());
}
 
开发者ID:rometools,项目名称:rome-modules,代码行数:18,代码来源:ThreadingModuleTest.java

示例14: parseEntry

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
/**
 * Parse entry from reader.
 */
public static Entry parseEntry(final Reader rd, final String baseURI, final Locale locale) throws JDOMException, IOException, IllegalArgumentException,
        FeedException {

    // Parse entry into JDOM tree
    final SAXBuilder builder = new SAXBuilder();
    final Document entryDoc = builder.build(rd);
    final Element fetchedEntryElement = entryDoc.getRootElement();
    fetchedEntryElement.detach();

    // Put entry into a JDOM document with 'feed' root so that Rome can
    // handle it
    final Feed feed = new Feed();
    feed.setFeedType("atom_1.0");
    final WireFeedOutput wireFeedOutput = new WireFeedOutput();
    final Document feedDoc = wireFeedOutput.outputJDom(feed);
    feedDoc.getRootElement().addContent(fetchedEntryElement);

    if (baseURI != null) {
        feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE);
    }

    final WireFeedInput input = new WireFeedInput(false, locale);
    final Feed parsedFeed = (Feed) input.build(feedDoc);
    return parsedFeed.getEntries().get(0);
}
 
开发者ID:rometools,项目名称:rome,代码行数:29,代码来源:Atom10Parser.java

示例15: addEntry

import com.rometools.rome.io.FeedException; //导入依赖的package包/类
protected void addEntry(final Entry entry, final Element parent) throws FeedException {

        final Element eEntry = new Element("entry", getFeedNamespace());

        final String xmlBase = entry.getXmlBase();
        if (xmlBase != null) {
            eEntry.setAttribute("base", xmlBase, Namespace.XML_NAMESPACE);
        }

        populateEntry(entry, eEntry);
        generateForeignMarkup(eEntry, entry.getForeignMarkup());
        checkEntryConstraints(eEntry);
        generateItemModules(entry.getModules(), eEntry);
        parent.addContent(eEntry);

    }
 
开发者ID:rometools,项目名称:rome,代码行数:17,代码来源:Atom10Generator.java


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