本文整理汇总了Java中com.rometools.rome.feed.atom.Feed.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java Feed.getEntries方法的具体用法?Java Feed.getEntries怎么用?Java Feed.getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rometools.rome.feed.atom.Feed
的用法示例。
在下文中一共展示了Feed.getEntries方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
}
示例2: 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);
}
示例3: 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");
}
}
示例4: 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());
}
示例5: poll
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
@Scheduled(fixedDelay = 15000)
public void poll() {
HttpHeaders requestHeaders = new HttpHeaders();
if (lastModified != null) {
requestHeaders.set("If-Modified-Since", DateUtils.formatDate(lastModified));
}
HttpEntity<?> requestEntity = new HttpEntity(requestHeaders);
ResponseEntity<Feed> response = restTemplate.exchange(creditDecisionFeed, HttpMethod.GET, requestEntity, Feed.class);
if (response.getStatusCode() != HttpStatus.NOT_MODIFIED) {
Feed feed = response.getBody();
Date lastUpdateInFeed = null;
for (Entry entry : feed.getEntries()) {
String applicationNumber = entry.getSummary().getValue();
if ((lastModified == null) || (entry.getUpdated().after(lastModified))) {
log.info(applicationNumber + " is new, updating the status");
CreditApplicationStatus applicationStatus = repository.findByApplicationNumber(applicationNumber);
if (applicationStatus != null) {
applicationStatus.setApproved(true);
repository.save(applicationStatus);
}
if ((lastUpdateInFeed == null) || (entry.getUpdated().after(lastUpdateInFeed))) {
lastUpdateInFeed = entry.getUpdated();
}
}
}
if (response.getHeaders().getFirst("Last-Modified") != null) {
lastModified = DateUtils.parseDate(response.getHeaders().getFirst("Last-Modified"));
log.info("LastModified header {}", lastModified);
} else {
if (lastUpdateInFeed != null) {
lastModified = lastUpdateInFeed;
log.info("Last in feed {}", lastModified);
}
}
}
}
示例6: addEntries
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
protected void addEntries(final Feed feed, final Element parent) throws FeedException {
final List<Entry> entries = feed.getEntries();
for (final Entry entry : entries) {
addEntry(entry, parent);
}
checkEntriesConstraints(parent);
}
示例7: addEntries
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
protected void addEntries(final Feed feed, final Element parent) throws FeedException {
final List<Entry> items = feed.getEntries();
for (final Entry entry : items) {
addEntry(entry, parent);
}
checkEntriesConstraints(parent);
}
示例8: findEntry
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
private Entry findEntry(final String id, final Feed feed) {
for (final Entry entry : feed.getEntries()) {
if (id.equals(entry.getId())) {
return entry;
}
}
return null;
}
示例9: addEntries
import com.rometools.rome.feed.atom.Feed; //导入方法依赖的package包/类
private void addEntries(final Feed feed, final Element parent) throws FeedException {
final List<Entry> items = feed.getEntries();
for (final Entry entry : items) {
addEntry(entry, parent);
}
}