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


Java Feed类代码示例

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


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

示例1: buildFeedMetadata

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
@Override
protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
	feed.setId("https://github.com/mploed/event-driven-spring-boot/customer");
	feed.setTitle("Customer");
	List<Link> alternateLinks = new ArrayList<>();
	Link link = new Link();
	link.setRel("self");
	link.setHref(baseUrl(request) + "feed");
	alternateLinks.add(link);
	List<SyndPerson> authors = new ArrayList<SyndPerson>();
	Person person = new Person();
	person.setName("Big Pug Bank");
	authors.add(person);
	feed.setAuthors(authors);

	feed.setAlternateLinks(alternateLinks);
	feed.setUpdated(customerRepository.lastUpdate());
	Content subtitle = new Content();
	subtitle.setValue("List of all customers");
	feed.setSubtitle(subtitle);
}
 
开发者ID:mploed,项目名称:event-driven-spring-boot,代码行数:22,代码来源:CustomerAtomFeedView.java

示例2: pollInternal

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
public void pollInternal() {
	HttpHeaders requestHeaders = new HttpHeaders();
	if (lastModified != null) {
		requestHeaders.set(HttpHeaders.IF_MODIFIED_SINCE, DateUtils.formatDate(lastModified));
	}
	HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
	ResponseEntity<Feed> response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, Feed.class);

	if (response.getStatusCode() != HttpStatus.NOT_MODIFIED) {
		log.trace("data has been modified");
		Feed feed = response.getBody();
		for (Entry entry : feed.getEntries()) {
			if ((lastModified == null) || (entry.getUpdated().after(lastModified))) {
				Invoice invoice = restTemplate
						.getForEntity(entry.getContents().get(0).getSrc(), Invoice.class).getBody();
				log.trace("saving invoice {}", invoice.getId());
				invoiceService.generateInvoice(invoice);
			}
		}
		if (response.getHeaders().getFirst(HttpHeaders.LAST_MODIFIED) != null) {
			lastModified = DateUtils.parseDate(response.getHeaders().getFirst(HttpHeaders.LAST_MODIFIED));
			log.trace("Last-Modified header {}", lastModified);
		}
	} else {
		log.trace("no new data");
	}
}
 
开发者ID:ewolff,项目名称:microservice-atom,代码行数:28,代码来源:InvoicePoller.java

示例3: buildFeedMetadata

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
@Override
protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
	feed.setId("tag:ewolff.com/microservice-atom/order");
	feed.setTitle("Order");
	List<Link> alternateLinks = new ArrayList<>();
	Link link = new Link();
	link.setRel("self");
	link.setHref(baseUrl(request) + "feed");
	alternateLinks.add(link);
	List<SyndPerson> authors = new ArrayList<SyndPerson>();
	Person person = new Person();
	person.setName("Big Money Online Commerce Inc.");
	authors.add(person);
	feed.setAuthors(authors);

	feed.setAlternateLinks(alternateLinks);
	feed.setUpdated(orderRepository.lastUpdate());
	Content subtitle = new Content();
	subtitle.setValue("List of all orders");
	feed.setSubtitle(subtitle);
}
 
开发者ID:ewolff,项目名称:microservice-atom,代码行数:22,代码来源:OrderAtomFeedView.java

示例4: requestWithLastModifiedReturns304

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
@Test
public void requestWithLastModifiedReturns304() {
	Order order = new Order();
	order.setCustomer(customerRepository.findAll().iterator().next());
	orderRepository.save(order);
	ResponseEntity<Feed> response = restTemplate.exchange(feedUrl(), HttpMethod.GET, new HttpEntity(null),
			Feed.class);

	Date lastModified = DateUtils.parseDate(response.getHeaders().getFirst("Last-Modified"));

	HttpHeaders requestHeaders = new HttpHeaders();
	requestHeaders.set("If-Modified-Since", DateUtils.formatDate(lastModified));
	HttpEntity requestEntity = new HttpEntity(requestHeaders);

	response = restTemplate.exchange(feedUrl(), HttpMethod.GET, requestEntity, Feed.class);

	assertEquals(HttpStatus.NOT_MODIFIED, response.getStatusCode());
}
 
开发者ID:ewolff,项目名称:microservice-atom,代码行数:19,代码来源:AtomClientTest.java

示例5: feedReturnsNewlyCreatedOrder

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
@Test
public void feedReturnsNewlyCreatedOrder() {
	Order order = new Order();
	order.setCustomer(customerRepository.findAll().iterator().next());
	orderRepository.save(order);
	Feed feed = retrieveFeed();
	boolean foundLinkToCreatedOrder = false;
	List<Entry> entries = feed.getEntries();
	for (Entry entry : entries) {
		for (Content content : entry.getContents()) {
			if (content.getSrc().contains(Long.toString(order.getId()))) {
				foundLinkToCreatedOrder = true;
			}
		}
	}
	assertTrue(foundLinkToCreatedOrder);
}
 
开发者ID:ewolff,项目名称:microservice-atom,代码行数:18,代码来源:AtomClientTest.java

示例6: pollInternal

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
public void pollInternal() {
	HttpHeaders requestHeaders = new HttpHeaders();
	if (lastModified != null) {
		requestHeaders.set(HttpHeaders.IF_MODIFIED_SINCE, DateUtils.formatDate(lastModified));
	}
	HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
	ResponseEntity<Feed> response = restTemplate.exchange(url, HttpMethod.GET, requestEntity, Feed.class);

	if (response.getStatusCode() != HttpStatus.NOT_MODIFIED) {
		log.trace("data has been modified");
		Feed feed = response.getBody();
		for (Entry entry : feed.getEntries()) {
			if ((lastModified == null) || (entry.getUpdated().after(lastModified))) {
				Shipment shipping = restTemplate
						.getForEntity(entry.getContents().get(0).getSrc(), Shipment.class).getBody();
				log.trace("saving shipping {}", shipping.getId());
				shipmentService.ship(shipping);
			}
		}
		if (response.getHeaders().getFirst("Last-Modified") != null) {
			lastModified = DateUtils.parseDate(response.getHeaders().getFirst(HttpHeaders.LAST_MODIFIED));
			log.trace("Last-Modified header {}", lastModified);
		}
	} else {
		log.trace("no new data");
	}
}
 
开发者ID:ewolff,项目名称:microservice-atom,代码行数:28,代码来源:ShippingPoller.java

示例7: read

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
@Test
public void read() throws IOException {
	InputStream is = getClass().getResourceAsStream("atom.xml");
	MockHttpInputMessage inputMessage = new MockHttpInputMessage(is);
	inputMessage.getHeaders().setContentType(new MediaType("application", "atom+xml", utf8));
	Feed result = converter.read(Feed.class, inputMessage);
	assertEquals("title", result.getTitle());
	assertEquals("subtitle", result.getSubtitle().getValue());
	List<?> entries = result.getEntries();
	assertEquals(2, entries.size());

	Entry entry1 = (Entry) entries.get(0);
	assertEquals("id1", entry1.getId());
	assertEquals("title1", entry1.getTitle());

	Entry entry2 = (Entry) entries.get(1);
	assertEquals("id2", entry2.getId());
	assertEquals("title2", entry2.getTitle());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:AtomFeedHttpMessageConverterTests.java

示例8: buildFeedMetadata

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
@Override
protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
    ZUser user = userService.getCurrentUser();
    ZUserConfig userConfig = user.getUserConfig();
    Locale locale;
    if (userConfig != null) {
        locale = userConfig.getLocale();
    } else {
        locale = Locale.getDefault();
    }
    super.buildFeedMetadata(model, feed, request);
    OPDSMetadata metadata = (OPDSMetadata) model.get(OPDS_METADATA);
    Res title = metadata.getTitle();
    feed.setTitle(res.get(locale, title.getKey(), title.getObjs()));
    feed.setId(metadata.getId());
    feed.setUpdated(metadata.getUpdated());
    feed.setIcon("favicon.ico");
    feed.setEncoding("utf-8");
    //noinspection unchecked
    feed.setOtherLinks(metadata.getOtherLinks());
}
 
开发者ID:patexoid,项目名称:ZombieLib2,代码行数:22,代码来源:OpdsView.java

示例9: testGenerator

import com.rometools.rome.feed.atom.Feed; //导入依赖的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

示例10: parseEntry

import com.rometools.rome.feed.atom.Feed; //导入依赖的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

示例11: serializeEntry

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
/**
 * Utility method to serialize an entry to writer.
 */
public static void serializeEntry(final Entry entry, final Writer writer) throws IllegalArgumentException, FeedException, IOException {

    // Build a feed containing only the entry
    final List<Entry> entries = new ArrayList<Entry>();
    entries.add(entry);
    final Feed feed1 = new Feed();
    feed1.setFeedType("atom_1.0");
    feed1.setEntries(entries);

    // Get Rome to output feed as a JDOM document
    final WireFeedOutput wireFeedOutput = new WireFeedOutput();
    final Document feedDoc = wireFeedOutput.outputJDom(feed1);

    // Grab entry element from feed and get JDOM to serialize it
    final Element entryElement = feedDoc.getRootElement().getChildren().get(0);

    final XMLOutputter outputter = new XMLOutputter();
    outputter.output(entryElement, writer);
}
 
开发者ID:rometools,项目名称:rome,代码行数:23,代码来源:Atom10Generator.java

示例12: getFeedDocument

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
/**
 * Get feed document representing collection.
 *
 * @throws com.rometools.rome.propono.atom.server.AtomException On error retrieving feed file.
 * @return Atom Feed representing collection.
 */
public Feed getFeedDocument() throws AtomException {
    InputStream in = null;
    synchronized (FileStore.getFileStore()) {
        in = FileStore.getFileStore().getFileInputStream(getFeedPath());
        if (in == null) {
            in = createDefaultFeedDocument(contextURI + servletPath + "/" + handle + "/" + collection);
        }
    }
    try {
        final WireFeedInput input = new WireFeedInput();
        final WireFeed wireFeed = input.build(new InputStreamReader(in, "UTF-8"));
        return (Feed) wireFeed;
    } catch (final Exception ex) {
        throw new AtomException(ex);
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:23,代码来源:FileBasedCollection.java

示例13: addEntry

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
/**
 * Add entry to collection.
 *
 * @param entry Entry to be added to collection. Entry will be saved to disk in a directory
 *            under the collection's directory and the path will follow the pattern
 *            [collection-plural]/[entryid]/entry.xml. The entry will be added to the
 *            collection's feed in [collection-plural]/feed.xml.
 * @throws java.lang.Exception On error.
 * @return Entry as it exists on the server.
 */
public Entry addEntry(final Entry entry) throws Exception {
    synchronized (FileStore.getFileStore()) {
        final Feed f = getFeedDocument();

        final String fsid = FileStore.getFileStore().getNextId();
        updateTimestamps(entry);

        // Save entry to file
        final String entryPath = getEntryPath(fsid);

        final OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
        updateEntryAppLinks(entry, fsid, true);
        Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
        os.flush();
        os.close();

        // Update feed file
        updateEntryAppLinks(entry, fsid, false);
        updateFeedDocumentWithNewEntry(f, entry);

        return entry;
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:34,代码来源:FileBasedCollection.java

示例14: updateEntry

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
/**
 * Update an entry in the collection.
 *
 * @param entry Updated entry to be stored
 * @param fsid Internal ID of entry
 * @throws java.lang.Exception On error
 */
public void updateEntry(final Entry entry, String fsid) throws Exception {
    synchronized (FileStore.getFileStore()) {

        final Feed f = getFeedDocument();

        if (fsid.endsWith(".media-link")) {
            fsid = fsid.substring(0, fsid.length() - ".media-link".length());
        }

        updateTimestamps(entry);

        updateEntryAppLinks(entry, fsid, false);
        updateFeedDocumentWithExistingEntry(f, entry);

        final String entryPath = getEntryPath(fsid);
        final OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
        updateEntryAppLinks(entry, fsid, true);
        Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
        os.flush();
        os.close();
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:30,代码来源:FileBasedCollection.java

示例15: deleteEntry

import com.rometools.rome.feed.atom.Feed; //导入依赖的package包/类
/**
 * Delete an entry and any associated media file.
 *
 * @param fsid Internal ID of entry
 * @throws java.lang.Exception On error
 */
public void deleteEntry(final String fsid) throws Exception {
    synchronized (FileStore.getFileStore()) {

        // Remove entry from Feed
        final Feed feed = getFeedDocument();
        updateFeedDocumentRemovingEntry(feed, fsid);

        final String entryFilePath = getEntryPath(fsid);
        FileStore.getFileStore().deleteFile(entryFilePath);

        final String entryMediaPath = getEntryMediaPath(fsid);
        if (entryMediaPath != null) {
            FileStore.getFileStore().deleteFile(entryMediaPath);
        }

        final String entryDirPath = getEntryDirPath(fsid);
        FileStore.getFileStore().deleteDirectory(entryDirPath);

        try {
            Thread.sleep(500L);
        } catch (final Exception ignored) {
        }
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:31,代码来源:FileBasedCollection.java


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