Search in sources :

Example 1 with Feed

use of org.restlet.ext.atom.Feed in project qi4j-sdk by Qi4j.

the class EntitiesResource method representAtom.

private Representation representAtom() throws ResourceException {
    try {
        Feed feed = new Feed();
        feed.setTitle(new Text(MediaType.TEXT_PLAIN, "All entities"));
        List<Entry> entries = feed.getEntries();
        final Iterable<EntityReference> query = entityFinder.findEntities(EntityComposite.class, null, null, null, null, Collections.<String, Object>emptyMap());
        for (EntityReference entityReference : query) {
            Entry entry = new Entry();
            entry.setTitle(new Text(MediaType.TEXT_PLAIN, entityReference.toString()));
            Link link = new Link();
            link.setHref(getRequest().getResourceRef().clone().addSegment(entityReference.identity()));
            entry.getLinks().add(link);
            entries.add(entry);
        }
        return feed;
    } catch (Exception e) {
        throw new ResourceException(e);
    }
}
Also used : Entry(org.restlet.ext.atom.Entry) EntityReference(org.qi4j.api.entity.EntityReference) Text(org.restlet.ext.atom.Text) ResourceException(org.restlet.resource.ResourceException) Link(org.restlet.ext.atom.Link) ResourceException(org.restlet.resource.ResourceException) IOException(java.io.IOException) EntityFinderException(org.qi4j.spi.query.EntityFinderException) Feed(org.restlet.ext.atom.Feed)

Aggregations

IOException (java.io.IOException)1 EntityReference (org.qi4j.api.entity.EntityReference)1 EntityFinderException (org.qi4j.spi.query.EntityFinderException)1 Entry (org.restlet.ext.atom.Entry)1 Feed (org.restlet.ext.atom.Feed)1 Link (org.restlet.ext.atom.Link)1 Text (org.restlet.ext.atom.Text)1 ResourceException (org.restlet.resource.ResourceException)1