use of org.jboss.resteasy.plugins.providers.atom.Feed 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;
}
use of org.jboss.resteasy.plugins.providers.atom.Feed 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;
}
use of org.jboss.resteasy.plugins.providers.atom.Feed in project candlepin by candlepin.
the class OwnerResourceTest method ownersAtomFeed.
@Test
public void ownersAtomFeed() {
Owner owner2 = new Owner("anotherOwner");
ownerCurator.create(owner2);
Event e1 = createConsumerCreatedEvent(owner);
// Make an event from another owner:
createConsumerCreatedEvent(owner2);
// Make sure we're acting as the correct owner admin:
setupPrincipal(owner, Access.ALL);
securityInterceptor.enable();
Feed feed = ownerResource.getOwnerAtomFeed(owner.getKey());
assertEquals(1, feed.getEntries().size());
Entry entry = feed.getEntries().get(0);
assertEquals(e1.getTimestamp(), entry.getPublished());
}
use of org.jboss.resteasy.plugins.providers.atom.Feed in project candlepin by candlepin.
the class EventAdapterTest method toFeed.
@Test
public void toFeed() {
EventAdapter ea = new EventAdapterImpl(new ConfigForTesting(), i18n);
List<Event> events = new LinkedList<>();
events.add(mockEvent(Event.Target.CONSUMER, Event.Type.CREATED));
events.add(mockEvent(Event.Target.ENTITLEMENT, Event.Type.DELETED));
Feed f = ea.toFeed(events, "/test/path");
assertNotNull(f);
assertNotNull(f.getEntries());
assertFalse(f.getEntries().isEmpty());
assertEquals(2, f.getEntries().size());
Entry e = f.getEntries().get(0);
assertNotNull(e);
assertNotNull(e.getTitle());
assertTrue(e.getTitle().contains("CONSUMER"));
assertTrue(e.getTitle().contains("CREATED"));
assertTrue(e.getSummary().contains("unit"));
assertTrue(e.getSummary().contains("created"));
assertEquals(events.get(0).getTimestamp(), f.getUpdated());
}
use of org.jboss.resteasy.plugins.providers.atom.Feed in project candlepin by candlepin.
the class EventAdapterTest method nullList.
@Test
public void nullList() {
EventAdapter ea = new EventAdapterImpl(new ConfigForTesting(), i18n);
Feed f = ea.toFeed(null, null);
assertNotNull(f);
assertNotNull(f.getEntries());
assertTrue(f.getEntries().isEmpty());
}
Aggregations