com.rometools.rome.feed.atom.Entry Java Examples

The following examples show how to use com.rometools.rome.feed.atom.Entry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileBasedCollection.java    From rome with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: VetsAtomView.java    From docker-workflow-plugin with MIT License 6 votes vote down vote up
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model,
                                       HttpServletRequest request, HttpServletResponse response) throws Exception {

    Vets vets = (Vets) model.get("vets");
    List<Vet> vetList = vets.getVetList();
    List<Entry> entries = new ArrayList<Entry>(vetList.size());

    for (Vet vet : vetList) {
        Entry entry = new Entry();
        // see http://diveintomark.org/archives/2004/05/28/howto-atom-id#other
        entry.setId(String.format("tag:springsource.org,%s", vet.getId()));
        entry.setTitle(String.format("Vet: %s %s", vet.getFirstName(), vet.getLastName()));
        //entry.setUpdated(visit.getDate().toDate());

        Content summary = new Content();
        summary.setValue(vet.getSpecialties().toString());
        entry.setSummary(summary);

        entries.add(entry);
    }
    response.setContentType("blabla");
    return entries;

}
 
Example #3
Source File: Atom10Generator.java    From rome with Apache License 2.0 6 votes vote down vote up
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);

    }
 
Example #4
Source File: AtomFeedHttpMessageConverterTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #5
Source File: VetsAtomView.java    From activejpa with Apache License 2.0 6 votes vote down vote up
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model,
                                       HttpServletRequest request, HttpServletResponse response) throws Exception {

    Vets vets = (Vets) model.get("vets");
    List<Vet> vetList = vets.getVetList();
    List<Entry> entries = new ArrayList<Entry>(vetList.size());

    for (Vet vet : vetList) {
        Entry entry = new Entry();
        // see http://diveintomark.org/archives/2004/05/28/howto-atom-id#other
        entry.setId(String.format("tag:springsource.org,%s", vet.getId()));
        entry.setTitle(String.format("Vet: %s %s", vet.getFirstName(), vet.getLastName()));
        //entry.setUpdated(visit.getDate().toDate());

        Content summary = new Content();
        summary.setValue(vet.getSpecialties().toString());
        entry.setSummary(summary);

        entries.add(entry);
    }
    response.setContentType("blabla");
    return entries;

}
 
Example #6
Source File: VetsAtomView.java    From audit4j-demo with Apache License 2.0 6 votes vote down vote up
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model,
                                       HttpServletRequest request, HttpServletResponse response) throws Exception {

    Vets vets = (Vets) model.get("vets");
    List<Vet> vetList = vets.getVetList();
    List<Entry> entries = new ArrayList<Entry>(vetList.size());

    for (Vet vet : vetList) {
        Entry entry = new Entry();
        // see http://diveintomark.org/archives/2004/05/28/howto-atom-id#other
        entry.setId(String.format("tag:springsource.org,%s", vet.getId()));
        entry.setTitle(String.format("Vet: %s %s", vet.getFirstName(), vet.getLastName()));
        //entry.setUpdated(visit.getDate().toDate());

        Content summary = new Content();
        summary.setValue(vet.getSpecialties().toString());
        entry.setSummary(summary);

        entries.add(entry);
    }
    response.setContentType("blabla");
    return entries;

}
 
Example #7
Source File: ClientCollection.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Get full entry specified by entry edit URI. Note that entry may or may not be associated with
 * this collection.
 *
 * @return ClientEntry or ClientMediaEntry specified by URI.
 */
public ClientEntry getEntry(final String uri) throws ProponoException {
    final GetMethod method = new GetMethod(uri);
    authStrategy.addAuthentication(httpClient, method);
    try {
        httpClient.executeMethod(method);
        if (method.getStatusCode() != 200) {
            throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
        }
        final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri, Locale.US);
        if (!romeEntry.isMediaEntry()) {
            return new ClientEntry(service, this, romeEntry, false);
        } else {
            return new ClientMediaEntry(service, this, romeEntry, false);
        }
    } catch (final Exception e) {
        throw new ProponoException("ERROR: getting or parsing entry/media, HTTP code: ", e);
    } finally {
        method.releaseConnection();
    }
}
 
Example #8
Source File: EntryIterator.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Get next entry in collection.
 */
@Override
public ClientEntry next() {
    if (hasNext()) {
        final Entry romeEntry = members.next();
        try {
            if (!romeEntry.isMediaEntry()) {
                return new ClientEntry(null, collection, romeEntry, true);
            } else {
                return new ClientMediaEntry(null, collection, romeEntry, true);
            }
        } catch (final ProponoException e) {
            throw new RuntimeException("Unexpected exception creating ClientEntry or ClientMedia", e);
        }
    }
    throw new NoSuchElementException();
}
 
Example #9
Source File: ClientAtomService.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Get full entry from service by entry edit URI.
 */
public ClientEntry getEntry(final String uri) throws ProponoException {
    final GetMethod method = new GetMethod(uri);
    authStrategy.addAuthentication(httpClient, method);
    try {
        httpClient.executeMethod(method);
        if (method.getStatusCode() != 200) {
            throw new ProponoException("ERROR HTTP status code=" + method.getStatusCode());
        }
        final Entry romeEntry = Atom10Parser.parseEntry(new InputStreamReader(method.getResponseBodyAsStream()), uri, Locale.US);
        if (!romeEntry.isMediaEntry()) {
            return new ClientEntry(this, null, romeEntry, false);
        } else {
            return new ClientMediaEntry(this, null, romeEntry, false);
        }
    } catch (final Exception e) {
        throw new ProponoException("ERROR: getting or parsing entry/media", e);
    } finally {
        method.releaseConnection();
    }
}
 
Example #10
Source File: AtomClientTest.java    From microservice-atom with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #11
Source File: OrderAtomFeedView.java    From microservice-atom with Apache License 2.0 6 votes vote down vote up
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request,
		HttpServletResponse response) throws Exception {

	List<Entry> entries = new ArrayList<Entry>();
	List<Order> orderlist = (List<Order>) model.get("orders");

	for (Order o : orderlist) {
		Entry entry = new Entry();
		entry.setId("tag:ewolff.com/microservice-atom/order/" + Long.toString(o.getId()));
		entry.setUpdated(o.getUpdated());
		entry.setTitle("Order " + o.getId());
		List<Content> contents = new ArrayList<Content>();
		Content content = new Content();
		content.setSrc(baseUrl(request) + "order/" + Long.toString(o.getId()));
		content.setType("application/json");
		contents.add(content);
		entry.setContents(contents);
		Content summary = new Content();
		summary.setValue("This is the order " + o.getId());
		entry.setSummary(summary);
		entries.add(entry);
	}

	return entries;
}
 
Example #12
Source File: Atom10Parser.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #13
Source File: FileBasedCollection.java    From rome with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #14
Source File: FileBasedAtomHandler.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new entry specified by pathInfo and posted entry. We save the submitted Atom entry
 * verbatim, but we do set the id and reset the update time.
 *
 * @param entry Entry to be added to collection.
 * @param areq Details of HTTP request
 * @throws com.rometools.rome.propono.atom.server.AtomException On invalid collection or other
 *             error.
 * @return Entry as represented on server.
 */
@Override
public Entry postEntry(final AtomRequest areq, final Entry entry) throws AtomException {
    LOG.debug("postEntry");

    final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
    final String handle = pathInfo[0];
    final String collection = pathInfo[1];
    final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
    try {
        return col.addEntry(entry);

    } catch (final Exception fe) {
        fe.printStackTrace();
        throw new AtomException(fe);
    }
}
 
Example #15
Source File: CustomerAtomFeedView.java    From event-driven-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request,
                                       HttpServletResponse response) throws Exception {

	List<Entry> entries = new ArrayList<Entry>();
	List<Customer> customerlist = (List<Customer>) model.get("customers");

	for (Customer o : customerlist) {
		Entry entry = new Entry();
		entry.setId("https://github.com/mploed/event-driven-spring-boot/customer/" + Long.toString(o.getId()));
		entry.setUpdated(o.getUpdated());
		entry.setTitle("Customer " + o.getId());
		List<Content> contents = new ArrayList<Content>();
		Content content = new Content();
		content.setSrc(baseUrl(request) + "customer/rest/" + Long.toString(o.getId()));
		content.setType("application/json");
		contents.add(content);
		entry.setContents(contents);
		Content summary = new Content();
		summary.setValue("This is the customer " + o.getId());
		entry.setSummary(summary);
		entries.add(entry);
	}

	return entries;
}
 
Example #16
Source File: FileBasedAtomHandler.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Get entry specified by pathInfo.
 *
 * @param areq Details of HTTP request
 * @throws com.rometools.rome.propono.atom.server.AtomException On invalid pathinfo or other
 *             error.
 * @return ROME Entry object.
 */
@Override
public Entry getEntry(final AtomRequest areq) throws AtomException {
    LOG.debug("getEntry");
    final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
    final String handle = pathInfo[0];
    final String collection = pathInfo[1];
    final String fileName = pathInfo[2];
    final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
    try {
        return col.getEntry(fileName);

    } catch (final Exception re) {
        if (re instanceof AtomException) {
            throw (AtomException) re;
        }
        throw new AtomException("ERROR: getting entry", re);
    }
}
 
Example #17
Source File: FileBasedAtomHandler.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Update entry specified by pathInfo and posted entry.
 *
 * @param entry
 * @param areq Details of HTTP request
 * @throws com.rometools.rome.propono.atom.server.AtomException
 */
@Override
public void putEntry(final AtomRequest areq, final Entry entry) throws AtomException {
    LOG.debug("putEntry");
    final String[] pathInfo = StringUtils.split(areq.getPathInfo(), "/");
    final String handle = pathInfo[0];
    final String collection = pathInfo[1];
    final String fileName = pathInfo[2];
    final FileBasedCollection col = service.findCollectionByHandle(handle, collection);
    try {
        col.updateEntry(entry, fileName);

    } catch (final Exception fe) {
        throw new AtomException(fe);
    }
}
 
Example #18
Source File: AtomFeedHttpMessageConverterTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@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());
}
 
Example #19
Source File: AtomFeedView.java    From wallride with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected List<Entry> buildFeedEntries(
		Map<String, Object> model,
		HttpServletRequest request,
		HttpServletResponse response)
throws Exception {
	Set<Article> articles = (Set<Article>)model.get("articles");
	List<Entry> entries = new ArrayList<>(articles.size());
	for (Article article : articles) {
		Entry entry = new Entry();
		entry.setTitle(article.getTitle());
		entry.setPublished(Date.from(article.getDate().atZone(ZoneId.systemDefault()).toInstant()));
		Content content = new Content();
		content.setValue(article.getBody());
		entry.setSummary(content);

		Link link = new Link();
		link.setHref(link(article));
		List<Link> links = new ArrayList<Link>();
		links.add(link);
		entry.setAlternateLinks(links);
		entries.add(entry);
	}
	return entries;
}
 
Example #20
Source File: FileBasedCollection.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #21
Source File: Atom10Generator.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #22
Source File: FileBasedCollection.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * Get an entry from the collection.
 *
 * @param fsid Internal ID of entry to be returned
 * @throws java.lang.Exception On error
 * @return Entry specified by fileName/ID
 */
public Entry getEntry(String fsid) throws Exception {
    if (fsid.endsWith(".media-link")) {
        fsid = fsid.substring(0, fsid.length() - ".media-link".length());
    }

    final String entryPath = getEntryPath(fsid);

    checkExistence(entryPath);
    final InputStream in = FileStore.getFileStore().getFileInputStream(entryPath);

    final Entry entry;
    final File resource = new File(fsid);
    if (resource.exists()) {
        entry = loadAtomResourceEntry(in, resource);
        updateMediaEntryAppLinks(entry, fsid, true);
    } else {
        entry = loadAtomEntry(in);
        updateEntryAppLinks(entry, fsid, true);
    }
    return entry;
}
 
Example #23
Source File: AtomFeedHttpMessageConverterTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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());
}
 
Example #24
Source File: FileBasedCollection.java    From rome with Apache License 2.0 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example #25
Source File: FileBasedCollection.java    From rome with Apache License 2.0 5 votes vote down vote up
/**
 * Add media entry to collection. Accepts a media file to be added to collection. The file will
 * be saved to disk in a directory under the collection's directory and the path will follow the
 * pattern <code>[collection-plural]/[entryid]/media/[entryid]</code>. An Atom entry will be
 * created to store metadata for the entry and it will exist at the path
 * <code>[collection-plural]/[entryid]/entry.xml</code>. The entry will be added to the
 * collection's feed in [collection-plural]/feed.xml.
 *
 * @param entry Entry object
 * @param slug String to be used in file-name
 * @param is Source of media data
 * @throws java.lang.Exception On Error
 * @return Location URI of entry
 */
public String addMediaEntry(final Entry entry, final String slug, final InputStream is) throws Exception {
    synchronized (FileStore.getFileStore()) {

        // Save media file temp file
        final Content content = entry.getContents().get(0);
        if (entry.getTitle() == null) {
            entry.setTitle(slug);
        }
        final String fileName = createFileName(slug != null ? slug : entry.getTitle(), content.getType());
        final File tempFile = File.createTempFile(fileName, "tmp");
        final FileOutputStream fos = new FileOutputStream(tempFile);
        Utilities.copyInputToOutput(is, fos);
        fos.close();

        // Save media file
        final FileInputStream fis = new FileInputStream(tempFile);
        saveMediaFile(fileName, content.getType(), tempFile.length(), fis);
        fis.close();
        final File resourceFile = new File(getEntryMediaPath(fileName));

        // Create media-link entry
        updateTimestamps(entry);

        // Save media-link entry
        final String entryPath = getEntryPath(fileName);
        final OutputStream os = FileStore.getFileStore().getFileOutputStream(entryPath);
        updateMediaEntryAppLinks(entry, resourceFile.getName(), true);
        Atom10Generator.serializeEntry(entry, new OutputStreamWriter(os, "UTF-8"));
        os.flush();
        os.close();

        // Update feed with new entry
        final Feed f = getFeedDocument();
        updateMediaEntryAppLinks(entry, resourceFile.getName(), false);
        updateFeedDocumentWithNewEntry(f, entry);

        return getEntryEditURI(fileName, false, true);
    }
}
 
Example #26
Source File: Atom10Parser.java    From rome with Apache License 2.0 5 votes vote down vote up
private List<Link> parseAlternateLinks(final Feed feed, final Entry entry, final String baseURI, final List<Element> eLinks) {

        final List<Link> links = new ArrayList<Link>();
        for (final Element eLink : eLinks) {
            final Link link = parseLink(feed, entry, baseURI, eLink);
            if (link.getRel() == null || "".equals(link.getRel().trim()) || "alternate".equals(link.getRel())) {
                links.add(link);
            }
        }

        return Lists.emptyToNull(links);

    }
 
Example #27
Source File: Atom10Generator.java    From rome with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #28
Source File: AbstractAtomFeedView.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Invokes {@link #buildFeedEntries(Map, HttpServletRequest, HttpServletResponse)}
 * to get a list of feed entries.
 */
@Override
protected final void buildFeedEntries(Map<String, Object> model, Feed feed,
		HttpServletRequest request, HttpServletResponse response) throws Exception {

	List<Entry> entries = buildFeedEntries(model, request, response);
	feed.setEntries(entries);
}
 
Example #29
Source File: Atom10Parser.java    From rome with Apache License 2.0 5 votes vote down vote up
private List<Link> parseOtherLinks(final Feed feed, final Entry entry, final String baseURI, final List<Element> eLinks) {

        final List<Link> links = new ArrayList<Link>();
        for (final Element eLink : eLinks) {
            final Link link = parseLink(feed, entry, baseURI, eLink);
            if (!"alternate".equals(link.getRel())) {
                links.add(link);
            }
        }

        return Lists.emptyToNull(links);

    }
 
Example #30
Source File: Atom03Generator.java    From rome with Apache License 2.0 5 votes vote down vote up
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);
}