@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", StandardCharsets.UTF_8)); 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()); }
private Entry findEntry(final String id, final Feed feed) { for (final Entry entry : feed.getEntries()) { if (id.equals(entry.getId())) { return entry; } } return null; }
private void updateFeedDocumentWithNewEntry(final Feed f, final Entry e) throws AtomException { boolean inserted = false; for (int i = 0; i < f.getEntries().size(); i++) { final Entry entry = f.getEntries().get(i); final AppModule mod = (AppModule) entry.getModule(AppModule.URI); final AppModule newMod = (AppModule) e.getModule(AppModule.URI); if (newMod.getEdited().before(mod.getEdited())) { f.getEntries().add(i, e); inserted = true; break; } } if (!inserted) { f.getEntries().add(0, e); } updateFeedDocument(f); }
private void updateFeedDocumentRemovingEntry(final Feed f, final String id) throws AtomException { final Entry e = findEntry("urn:uuid:" + id, f); f.getEntries().remove(e); updateFeedDocument(f); }
private void updateFeedDocumentWithExistingEntry(final Feed f, final Entry e) throws AtomException { final Entry old = findEntry(e.getId(), f); f.getEntries().remove(old); boolean inserted = false; for (int i = 0; i < f.getEntries().size(); i++) { final Entry entry = f.getEntries().get(i); final AppModule entryAppModule = (AppModule) entry.getModule(AppModule.URI); final AppModule eAppModule = (AppModule) entry.getModule(AppModule.URI); if (eAppModule.getEdited().before(entryAppModule.getEdited())) { f.getEntries().add(i, e); inserted = true; break; } } if (!inserted) { f.getEntries().add(0, e); } updateFeedDocument(f); }
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); }
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); }
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); }
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); }
Feed feed = response.getBody(); Date lastUpdateInFeed = null; for (Entry entry : feed.getEntries()) { String applicationNumber = entry.getSummary().getValue(); if ((lastModified == null) || (entry.getUpdated().after(lastModified))) {
private void getNextEntries() throws ProponoException { if (nextURI == null) { return; } final GetMethod colGet = new GetMethod(collection.getHrefResolved(nextURI)); collection.addAuthentication(colGet); try { collection.getHttpClient().executeMethod(colGet); final SAXBuilder builder = new SAXBuilder(); final Document doc = builder.build(colGet.getResponseBodyAsStream()); final WireFeedInput feedInput = new WireFeedInput(); col = (Feed) feedInput.build(doc); } catch (final Exception e) { throw new ProponoException("ERROR: fetching or parsing next entries, HTTP code: " + (colGet != null ? colGet.getStatusCode() : -1), e); } finally { colGet.releaseConnection(); } members = col.getEntries().iterator(); col.getEntries().size(); nextURI = null; final List<Link> altLinks = col.getOtherLinks(); if (altLinks != null) { for (final Link link : altLinks) { if ("next".equals(link.getRel())) { nextURI = link.getHref(); } } } }
Date lastUpdateInFeed = null; ObjectMapper mapper = new ObjectMapper(); for (Entry entry : feed.getEntries()) { String ratingAsJson = entry.getSummary().getValue(); if ((lastModified == null) || (entry.getUpdated().after(lastModified))) {
for (Entry entry : (List<Entry>)atomFeed.getEntries()) { String href = ""; for (Link link : (List<Link>)entry.getAlternateLinks()) {
/** * 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); }
/** * 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); }
final List<Entry> aEntries = aFeed.getEntries(); if (Lists.isNotEmpty(aEntries)) { syndFeed.setEntries(createSyndEntries(aEntries, syndFeed.isPreservingWireFeed()));
final List<Entry> aEntries = aFeed.getEntries(); if (aEntries != null) { syndFeed.setEntries(createSyndEntries(aFeed, aEntries, syndFeed.isPreservingWireFeed()));
final List<Entry> aEntries = aFeed.getEntries(); if (Lists.isNotEmpty(aEntries)) { syndFeed.setEntries(createSyndEntries(aEntries, syndFeed.isPreservingWireFeed()));
final List<Entry> aEntries = aFeed.getEntries(); if (aEntries != null) { syndFeed.setEntries(createSyndEntries(aFeed, aEntries, syndFeed.isPreservingWireFeed()));