Search in sources :

Example 16 with Entry

use of org.apache.abdera.model.Entry in project cxf by apache.

the class AtomBookStore method doGetBookAsFeed.

private Feed doGetBookAsFeed(@Context UriInfo uParam) {
    Factory factory = Abdera.getNewFactory();
    Feed f = factory.newFeed();
    f.setBaseUri(uParam.getAbsolutePath().toString());
    f.setTitle("Collection of Books");
    f.setId("http://www.books.com");
    f.addAuthor("BookStore Management Company");
    try {
        for (Book b : books.values()) {
            Entry e = AtomUtils.createBookEntry(factory, b);
            f.addEntry(e);
        }
    } catch (Exception ex) {
    // ignore
    }
    return f;
}
Also used : Entry(org.apache.abdera.model.Entry) Factory(org.apache.abdera.factory.Factory) WebApplicationException(javax.ws.rs.WebApplicationException) Feed(org.apache.abdera.model.Feed)

Example 17 with Entry

use of org.apache.abdera.model.Entry in project cxf by apache.

the class AtomPojoProvider method setFeedFromCollection.

// CHECKSTYLE:OFF
protected void setFeedFromCollection(Factory factory, Feed feed, Object wrapper, Class<?> wrapperCls, Object collection, Class<?> collectionCls, Type collectionType, boolean writerUsed) throws Exception {
    // CHECKSTYLE:ON
    Object[] arr = collectionCls.isArray() ? (Object[]) collection : ((Collection<?>) collection).toArray();
    Class<?> memberClass = InjectionUtils.getActualType(collectionType);
    for (Object o : arr) {
        Entry entry = createEntryFromObject(factory, o, memberClass);
        feed.addEntry(entry);
    }
    if (!writerUsed) {
        setFeedProperties(factory, feed, wrapper, wrapperCls, collection, collectionCls, collectionType);
    }
}
Also used : Entry(org.apache.abdera.model.Entry)

Example 18 with Entry

use of org.apache.abdera.model.Entry in project cxf by apache.

the class AtomEntryProviderTest method testWriteTo.

@Test
public void testWriteTo() throws Exception {
    InputStream is = getClass().getResourceAsStream("atomEntry.xml");
    Entry simple = afd.readFrom(Entry.class, null, null, MediaType.valueOf("application/atom+xml;type=entry"), null, is);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    afd.writeTo(simple, null, null, null, MediaType.valueOf("application/atom+xml;type=entry"), null, bos);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    Entry simpleCopy = afd.readFrom(Entry.class, null, null, MediaType.valueOf("application/atom+xml"), null, bis);
    assertEquals("Wrong entry title", "Atom-Powered Robots Run Amok", simpleCopy.getTitle());
    assertEquals("Wrong entry title", simple.getTitle(), simpleCopy.getTitle());
}
Also used : Entry(org.apache.abdera.model.Entry) FOMEntry(org.apache.abdera.parser.stax.FOMEntry) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 19 with Entry

use of org.apache.abdera.model.Entry in project cxf by apache.

the class AtomEntryProviderTest method testReadFrom.

@Test
public void testReadFrom() throws Exception {
    InputStream is = getClass().getResourceAsStream("atomEntry.xml");
    Entry simple = afd.readFrom(Entry.class, null, null, null, null, is);
    assertEquals("Wrong entry title", "Atom-Powered Robots Run Amok", simple.getTitle());
}
Also used : Entry(org.apache.abdera.model.Entry) FOMEntry(org.apache.abdera.parser.stax.FOMEntry) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 20 with Entry

use of org.apache.abdera.model.Entry in project wildfly-camel by wildfly-extras.

the class AtomIntegrationTest method testConsumeAtomFeed.

@Test
public void testConsumeAtomFeed() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("atom://http://localhost:8080/atom-test/atom/feed?splitEntries=true").to("seda:end");
        }
    });
    PollingConsumer pollingConsumer = camelctx.getEndpoint("seda:end").createPollingConsumer();
    pollingConsumer.start();
    camelctx.start();
    try {
        Entry result = pollingConsumer.receive(5000).getIn().getBody(Entry.class);
        Assert.assertEquals(FeedConstants.ENTRY_TITLE, result.getTitle());
        Assert.assertEquals(FeedConstants.ENTRY_CONTENT, result.getContent());
    } finally {
        camelctx.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) PollingConsumer(org.apache.camel.PollingConsumer) Entry(org.apache.abdera.model.Entry) RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

Entry (org.apache.abdera.model.Entry)22 Test (org.junit.Test)9 Feed (org.apache.abdera.model.Feed)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 StringWriter (java.io.StringWriter)4 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 JAXBContext (javax.xml.bind.JAXBContext)2 Factory (org.apache.abdera.factory.Factory)2 FOMEntry (org.apache.abdera.parser.stax.FOMEntry)2 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 Metacard (ddf.catalog.data.Metacard)1 Dataset (edu.harvard.iq.dataverse.Dataset)1 Dataverse (edu.harvard.iq.dataverse.Dataverse)1 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)1 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)1 UpdateDatasetCommand (edu.harvard.iq.dataverse.engine.command.impl.UpdateDatasetCommand)1