Search in sources :

Example 1 with Content

use of org.jboss.resteasy.plugins.providers.atom.Content in project wildfly-camel by wildfly-extras.

the class AtomFeed method getFeed.

@GET
@Produces("application/atom+xml")
public Feed getFeed() throws URISyntaxException {
    Feed feed = new Feed();
    feed.setId(new URI("http://test.com/1"));
    feed.setTitle("WildFly Camel Test Feed");
    feed.setUpdated(new Date());
    Link link = new Link();
    link.setHref(new URI("http://localhost"));
    link.setRel("edit");
    feed.getLinks().add(link);
    feed.getAuthors().add(new Person("WildFly Camel"));
    Entry entry = new Entry();
    entry.setTitle("Hello Kermit");
    Content content = new Content();
    content.setType(MediaType.TEXT_HTML_TYPE);
    content.setText("Greeting Kermit");
    entry.setContent(content);
    feed.getEntries().add(entry);
    return feed;
}
Also used : Entry(org.jboss.resteasy.plugins.providers.atom.Entry) Content(org.jboss.resteasy.plugins.providers.atom.Content) URI(java.net.URI) Person(org.jboss.resteasy.plugins.providers.atom.Person) Date(java.util.Date) Link(org.jboss.resteasy.plugins.providers.atom.Link) Feed(org.jboss.resteasy.plugins.providers.atom.Feed) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with Content

use of org.jboss.resteasy.plugins.providers.atom.Content in project candlepin by candlepin.

the class EventAdapterImpl method toFeed.

@Override
public Feed toFeed(List<Event> events, String path) {
    String url = config.getString(ConfigProperties.CANDLEPIN_URL) + path + "/";
    Feed feed = new Feed();
    feed.setUpdated(new Date());
    feed.getAuthors().add(new Person("Red Hat, Inc."));
    try {
        feed.setId(new URI(url));
    } catch (Exception e) {
    // ignore, shouldn't happen
    }
    if (events == null) {
        return feed;
    }
    // Add the friendly message text
    this.addMessageText(events);
    for (Event e : events) {
        Entry entry = new Entry();
        entry.setTitle(e.getTarget().toString() + " " + e.getType().toString());
        entry.setPublished(e.getTimestamp());
        entry.setUpdated(e.getTimestamp());
        entry.getAuthors().add(new Person("Red Hat, Inc."));
        URI eventURI = null;
        try {
            eventURI = new URI(url + e.getId());
        } catch (Exception error) {
        // ignore, shouldn't happen
        }
        entry.setId(eventURI);
        entry.getLinks().add(new Link("alternate", eventURI, MediaType.APPLICATION_JSON_TYPE));
        Content content = new Content();
        content.setType(MediaType.APPLICATION_XML_TYPE);
        content.setJAXBObject(e);
        entry.setContent(content);
        entry.setSummary(e.getMessageText());
        feed.getEntries().add(entry);
    }
    // get modified, if they do then the feed published date could be inaccurate.
    if (events.size() > 0) {
        feed.setUpdated(events.get(0).getTimestamp());
    }
    return feed;
}
Also used : Entry(org.jboss.resteasy.plugins.providers.atom.Entry) Content(org.jboss.resteasy.plugins.providers.atom.Content) Person(org.jboss.resteasy.plugins.providers.atom.Person) URI(java.net.URI) Date(java.util.Date) Link(org.jboss.resteasy.plugins.providers.atom.Link) Feed(org.jboss.resteasy.plugins.providers.atom.Feed)

Aggregations

URI (java.net.URI)2 Date (java.util.Date)2 Content (org.jboss.resteasy.plugins.providers.atom.Content)2 Entry (org.jboss.resteasy.plugins.providers.atom.Entry)2 Feed (org.jboss.resteasy.plugins.providers.atom.Feed)2 Link (org.jboss.resteasy.plugins.providers.atom.Link)2 Person (org.jboss.resteasy.plugins.providers.atom.Person)2 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1