Package org.apache.wink.common.model.atom

Examples of org.apache.wink.common.model.atom.AtomEntry


            Annotation[] annotations, MediaType mediaType,
            MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
            throws IOException, WebApplicationException {


        AtomEntry atomEntry = (AtomEntry) super.readFrom(type, genericType, annotations, mediaType, httpHeaders,
                entityStream);

        /*
         * The value in the AtomContent object is arbitrary, set by the server.  We want to use the
         * built-in AND client application supplied providers.  Because these providers are collected
         * on the thread local store, and the unmarshalling of the AtomContent value is done lazily
         * (after the client-server context has expired), we need some way to hold onto the Providers
         * long enough for the client app to be able to seamlessly get the value off the AtomContent
         * object.  Thus the need to set the *real* providers list on the AtomContent object, so it
         * can use the list to pass to ModelUtils when it needs to retrieve and unmarshal the AtomContent
         * value.
         *
         * We have to be careful to use the real Providers list instead of the one from the injected
         * local providers field in this class.  The injected object may be a "proxy" to the real
         * providers, and could cause an infinite loop when ModelUtils.readValue calls back through
         * the providers.
         */
        AtomContent content = atomEntry.getContent();
        if (content != null) {
            content.setProviders(RuntimeContextTLS.getRuntimeContext().getAttribute(Providers.class));
        }

        return atomEntry;
View Full Code Here


                              MediaType mediaType,
                              MultivaluedMap<String, String> httpHeaders,
                              InputStream entityStream) throws IOException, WebApplicationException {
        MessageBodyReader<AtomEntry> reader =
            providers.getMessageBodyReader(AtomEntry.class, genericType, annotations, mediaType);
        AtomEntry entry =
            reader.readFrom(AtomEntry.class,
                            genericType,
                            annotations,
                            mediaType,
                            httpHeaders,
                            entityStream);
       
        /*
         * The value in the AtomContent object is arbitrary, set by the server.  We want to use the
         * built-in AND client application supplied providers.  Because these providers are collected
         * on the thread local store, and the unmarshalling of the AtomContent value is done lazily
         * (after the client-server context has expired), we need some way to hold onto the Providers
         * long enough for the client app to be able to seamlessly get the value off the AtomContent
         * object.  Thus the need to set the *real* providers list on the AtomContent object, so it
         * can use the list to pass to ModelUtils when it needs to retrieve and unmarshal the AtomContent
         * value.
         *
         * We have to be careful to use the real Providers list instead of the one from the injected
         * local providers field in this class.  The injected object may be a "proxy" to the real
         * providers, and could cause an infinite loop when ModelUtils.readValue calls back through
         * the providers.
         */
        SyndEntry returnVal = entry.toSynd(new SyndEntry());
        SyndContent content = returnVal.getContent();
        if (content != null) {
            content.setProviders(RuntimeContextTLS.getRuntimeContext().getAttribute(Providers.class));
        }
       
View Full Code Here

                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream) throws IOException, WebApplicationException {
        AtomEntry entry = new AtomEntry(t);
        MessageBodyWriter<AtomEntry> writer =
            providers.getMessageBodyWriter(AtomEntry.class, genericType, annotations, mediaType);

        // already checked for non-null writer in isWriteable
       
View Full Code Here

                                                        MediaType.APPLICATION_ATOM_XML);
        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());
        Unmarshaller u =
            JAXBContext.newInstance(AtomEntry.class.getPackage().getName()).createUnmarshaller();
        AtomEntry entry =
            ((JAXBElement<AtomEntry>)u.unmarshal(new ByteArrayInputStream(response
                .getContentAsByteArray()))).getValue();
        assertEquals("toptenvalidators", entry.getId());
        assertEquals("top ten validators", entry.getTitle().getValue());
        assertEquals("http://b216:8080/reporting/reports/toptenvalidators?alt=application/json",
                     entry.getLinks().get(0).getHref());
        assertEquals("alternate", entry.getLinks().get(0).getRel());
        assertEquals("admin", entry.getAuthors().get(0).getName());
        assertEquals("urn:com:systinet:reporting:kind", entry.getCategories().get(0).getScheme());
        assertEquals("urn:com:systinet:reporting:kind:definition", entry.getCategories().get(0)
            .getTerm());
        assertEquals("report definition", entry.getCategories().get(0).getLabel());
    }
View Full Code Here

        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());

        Unmarshaller u =
            JAXBContext.newInstance(AtomEntry.class.getPackage().getName()).createUnmarshaller();
        AtomEntry entry =
            ((JAXBElement<AtomEntry>)u.unmarshal(new ByteArrayInputStream(response
                .getContentAsByteArray()))).getValue();
        assertEquals("toptenvalidators", entry.getId());
        assertEquals("top ten validators", entry.getTitle().getValue());
        assertEquals("http://b216:8080/reporting/reports/toptenvalidators?alt=application/json",
                     entry.getLinks().get(0).getHref());
        assertEquals("alternate", entry.getLinks().get(0).getRel());
        assertEquals("admin", entry.getAuthors().get(0).getName());
        assertEquals("urn:com:systinet:reporting:kind", entry.getCategories().get(0).getScheme());
        assertEquals("urn:com:systinet:reporting:kind:definition", entry.getCategories().get(0)
            .getTerm());
        assertEquals("report definition", entry.getCategories().get(0).getLabel());
    }
View Full Code Here

        assertEquals("urn:com:systinet:reporting:kind", feed.getCategories().get(0).getScheme());
        assertEquals("urn:com:systinet:reporting:kind:definitions:collection", feed.getCategories()
            .get(0).getTerm());
        assertEquals("report definitions", feed.getCategories().get(0).getLabel());

        AtomEntry entry = feed.getEntries().get(0);
        assertEquals("toptenvalidators", entry.getId());
        assertEquals("top ten validators", entry.getTitle().getValue());
        assertEquals("http://b216:8080/reporting/reports/toptenvalidators?alt=application/json",
                     entry.getLinks().get(0).getHref());
        assertEquals("alternate", entry.getLinks().get(0).getRel());
        assertEquals("admin", entry.getAuthors().get(0).getName());
        assertEquals("urn:com:systinet:reporting:kind", entry.getCategories().get(0).getScheme());
        assertEquals("urn:com:systinet:reporting:kind:definition", entry.getCategories().get(0)
            .getTerm());
        assertEquals("report definition", entry.getCategories().get(0).getLabel());
    }
View Full Code Here

        assertEquals("urn:com:systinet:reporting:kind", feed.getCategories().get(0).getScheme());
        assertEquals("urn:com:systinet:reporting:kind:definitions:collection", feed.getCategories()
            .get(0).getTerm());
        assertEquals("report definitions", feed.getCategories().get(0).getLabel());

        AtomEntry entry = feed.getEntries().get(0);
        assertEquals("toptenvalidators", entry.getId());
        assertEquals("top ten validators", entry.getTitle().getValue());
        assertEquals("http://b216:8080/reporting/reports/toptenvalidators?alt=application/json",
                     entry.getLinks().get(0).getHref());
        assertEquals("alternate", entry.getLinks().get(0).getRel());
        assertEquals("admin", entry.getAuthors().get(0).getName());
        assertEquals("urn:com:systinet:reporting:kind", entry.getCategories().get(0).getScheme());
        assertEquals("urn:com:systinet:reporting:kind:definition", entry.getCategories().get(0)
            .getTerm());
        assertEquals("report definition", entry.getCategories().get(0).getLabel());
    }
View Full Code Here

        @GET
        @Path("atomentries/collection")
        @Produces("application/json")
        public List<AtomEntry> getAtomEntriesCollection() throws IOException {
            List<AtomEntry> entries = new ArrayList<AtomEntry>();
            AtomEntry entry1 = AtomEntry.unmarshal(new StringReader(ENTRY_STR_1));
            AtomEntry entry2 = AtomEntry.unmarshal(new StringReader(ENTRY_STR_2));
            entries.add(entry1);
            entries.add(entry2);
            return entries;
        }
View Full Code Here

        @GET
        @Path("atomentryelements/collection")
        @Produces("application/json")
        public List<JAXBElement<AtomEntry>> getAtomEntryElementCollection() throws IOException {
            List<JAXBElement<AtomEntry>> entries = new ArrayList<JAXBElement<AtomEntry>>();
            AtomEntry entry1 = AtomEntry.unmarshal(new StringReader(ENTRY_STR_1));
            AtomEntry entry2 = AtomEntry.unmarshal(new StringReader(ENTRY_STR_2));
            org.apache.wink.common.model.atom.ObjectFactory of =
                new org.apache.wink.common.model.atom.ObjectFactory();
            entries.add(of.createEntry(entry1));
            entries.add(of.createEntry(entry2));
            return entries;
View Full Code Here

        @GET
        @Path("atomentry")
        @Produces("application/json")
        public AtomEntry getAtomEntry() throws IOException {
            AtomEntry entry = AtomEntry.unmarshal(new StringReader(ENTRY_STR));
            return entry;
        }
View Full Code Here

TOP

Related Classes of org.apache.wink.common.model.atom.AtomEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.