Package org.apache.wink.common.model.synd

Examples of org.apache.wink.common.model.synd.SyndFeed


     * @return the SyndFeed instance that will be serialized as an Atom
     */
    @GET
    @Produces( {MediaType.APPLICATION_ATOM_XML})
    public SyndFeed getBookmarks(@Context LinkBuilders linkBuilders, @Context UriInfo uriInfo) {
        SyndFeed feed = new SyndFeed();
        feed.setId("urn:collection:bookmarks");
        feed.setTitle(new SyndText("My Bookmarks"));
        feed.setUpdated(new Date());
        feed.setBase(uriInfo.getAbsolutePath().toString());

        // add entries to the feed, based on the existing bookmarks in the
        // memory store
        // (feed entries have no content, they have just metadata so there is no
        // need to set content
        // here)
        Map<String, String> bookmarks = BookmarkStore.getInstance().getBookmarks();

        SystemLinksBuilder entryLinksBuilder = linkBuilders.createSystemLinksBuilder();
        for (String key : bookmarks.keySet()) {
            // set the sub-resource state of the builder for this entry
            entryLinksBuilder.subResource(key);
            SyndEntry entry = createEntry(key, bookmarks.get(key), entryLinksBuilder, null);
            feed.addEntry(entry);
        }
        // generate collection links in the response
        linkBuilders.createSystemLinksBuilder().build(feed.getLinks());
        return feed;
    }
View Full Code Here


        // the properties of entries in the collection.
        WebDAVResponseBuilder.CollectionPropertyHandler handler =
            new WebDAVResponseBuilder.CollectionPropertyHandler(new DefectPropertyHandler());

        // get the feed of the defects
        SyndFeed feed =
            super.getDefects(null, null, null).getSyndFeed(providers, linkProcessor, uriInfo);
        // use the feed to create the propfind response
        String depth = headers.getRequestHeaders().getFirst(WebDAVHeaders.DEPTH);
        return WebDAVResponseBuilder.create(uriInfo).propfind(feed, body, depth, handler);
    }
View Full Code Here

     */
    @WebDAVMethod.PROPFIND
    @Consumes( {MediaType.APPLICATION_XML, MediaType.TEXT_XML})
    @Produces(MediaType.APPLICATION_XML)
    public Response findProperties(String body, @Context HttpHeaders headers) throws IOException {
        SyndFeed feed = super.getTests(uriInfo).getSyndFeed(providers, linkProcessor, uriInfo);
        return WebDAVResponseBuilder.create(uriInfo).propfind(feed,
                                                              body,
                                                              headers.getRequestHeaders()
                                                                  .getFirst(WebDAVHeaders.DEPTH));
    }
View Full Code Here

     *         Json
     */
    @GET
    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
    public SyndFeed getBookmarks(@Context LinkBuilders linkProcessor, @Context UriInfo uriInfo) {
        SyndFeed feed = new SyndFeed();
        feed.setId("urn:collection:bookmarks");
        feed.setTitle(new SyndText("My Bookmarks"));
        feed.setUpdated(new Date());
        feed.setBase(uriInfo.getAbsolutePath().toString());

        // add entries to the feed, based on the existing bookmarks in the
        // memory store
        // (feed entries have no content, they have just metadata so there is no
        // need to set content
        // here)
        Map<String, String> bookmarks = BookmarkStore.getInstance().getBookmarks();

        for (String key : bookmarks.keySet()) {
            SyndEntry entry = createEntry(key, bookmarks.get(key), linkProcessor, null);
            feed.addEntry(entry);
        }
        // generate collection links in the response
        linkProcessor.createSystemLinksBuilder().build(feed.getLinks());
        return feed;
    }
View Full Code Here

     */
    @Produces
    public SyndFeed getSyndFeed(@Context Providers providers,
                                @Context LinkBuilders linkBuilders,
                                @Context UriInfo uriInfo) throws IOException {
        SyndFeed feed = new SyndFeed();
        feed.setId("urn:com:hp:qadefects:defects");
        feed.setTitle(new SyndText("Defects"));
        feed.addAuthor(new SyndPerson("admin"));
        feed.setUpdated(new Date());

        feed.setBase(uriInfo.getAbsolutePath().toString());

        boolean editable = true;

        SystemLinksBuilder systemLinksBuilder = linkBuilders.createSystemLinksBuilder();

        // generate history links
        if (history) {
            // all defects in the collection are the history of the same defect
            // and they all have the
            // same defect id, so we can use the id of the first one
            systemLinksBuilder.subResource(DefectsResource.DEFECT_HISTORY_URL)
                .pathParam(DefectsResource.DEFECT_VAR, defects.get(0).getId()).build(feed
                    .getLinks());
            if (!defects.isEmpty()) {
                // if this is a history of a defect, then the last defect in the
                // list is the latest state of the defect
                editable = !(defects.get(defects.size() - 1).isDeleted());
            }
        } else {
            // generate system links
            systemLinksBuilder.build(feed.getLinks());
        }

        // set the entries
        for (DefectBean defect : defects) {
            DefectAsset defectAsset = new DefectAsset(defect, true, history);
            // set whether to generate the edit link or not
            defectAsset.setEditable(editable);
            SyndEntry entry = defectAsset.getSyndEntry(providers, uriInfo, linkBuilders);
            // we don't want content for entries
            entry.setContent(null);
            feed.addEntry(entry);
        }

        return feed;
    }
View Full Code Here

            // perform a GET on the resource. The resource will be returned as an Rss object
            RssFeed rssFeed = feedResource.accept(MediaType.APPLICATION_XML).get(RssFeed.class);

            // Map RSS into SyndFeed
            SyndFeed syndFeed = new SyndFeed();
            syndFeed = rssFeed.toSynd(syndFeed);

            // Now access RSS using SyndFeed APIs
            if (syndFeed.getTitle() != null) {
                System.out.println("Title = " + syndFeed.getTitle().getValue());
            }
            if (syndFeed.getSubtitle() != null) {
                System.out.println("Descritpion = " + syndFeed.getSubtitle().getValue());
            }
            if (syndFeed.getLink("alternate") != null) {
                System.out.println("Link = " + syndFeed.getLink("alternate").getHref());
            }
            int itemCount = 0;
            for (SyndEntry syndEntry : syndFeed.getEntries()) {
                System.out.println("Item " + ++itemCount + ":");
                if (syndEntry.getTitle() != null) {
                    System.out.println("\tTitle = " + syndEntry.getTitle().getValue());
                }
                if (syndEntry.getSummary() != null) {
View Full Code Here

    public String listFiles() throws ClientWebException {
        // create a resource
        Resource listOfDocumentsResource = restClient.resource(URL);

        // invoke GET on the resource and parse the result as SyndFeed
        SyndFeed list = listOfDocumentsResource.get(SyndFeed.class);

        // convert SyndFeed to String
        return feedToString(list);
    }
View Full Code Here

    @Produces
    public SyndFeed getSyndFeed(@Context Providers providers,
                                @Context LinkBuilders linkProcessor,
                                @Context UriInfo uriInfo) throws IOException {
        SyndFeed synd = new SyndFeed();
        synd.setId("urn:com:hp:qadefects:defects");
        synd.setTitle(new SyndText("Defects"));
        synd.addAuthor(new SyndPerson("admin"));
        synd.setUpdated(new Date());

        // set the entries
        for (DefectBean defect : defects) {
            DefectAsset defectAsset = new DefectAsset(defect, true);
            SyndEntry entry = defectAsset.getSyndEntry(providers, uriInfo, linkProcessor);
            synd.addEntry(entry);
        }

        synd.setBase(uriInfo.getAbsolutePath().toString());
        linkProcessor.createSystemLinksBuilder().build(synd.getLinks());
        return synd;
    }
View Full Code Here

        assertTrue(element instanceof RssFeed);
        RssFeed rssFeed = (RssFeed)element;
        assertNotNull(rssFeed);

        // Convert RssFeed into SyndFeed
        SyndFeed syndFeed = new SyndFeed();
        syndFeed = rssFeed.toSynd(syndFeed);
        assertNotNull(syndFeed);

        assertNotNull(syndFeed.getTitle());
        assertEquals(FEED_TITLE, syndFeed.getTitle().getValue());

        assertNotNull(syndFeed.getLink("alternate"));
        assertEquals(FEED_LINK, syndFeed.getLink("alternate").getHref());

        assertNotNull(syndFeed.getSubtitle());
        assertEquals(FEED_DESCRIPTION, syndFeed.getSubtitle().getValue());

        assertNotNull(syndFeed.getLang());
        assertEquals(FEED_LANGUAGE, syndFeed.getLang());

        assertNotNull(syndFeed.getRights());
        assertEquals(FEED_COPYRIGHT, syndFeed.getRights().getValue());

        assertTrue(syndFeed.getAuthors().size() > 0);
        assertEquals(FEED_EDITOR, syndFeed.getAuthors().get(0).getEmail());

        assertNotNull(syndFeed.getUpdated());
        assertEquals(RssChannel.convertRssDateToJavaDate(FEED_LASTBUILDDATE), syndFeed.getUpdated());

        assertTrue(syndFeed.getCategories().size() == 2);
        assertEquals(FEED_CTG1_DOMAIN, syndFeed.getCategories().get(0).getScheme());
        assertEquals(FEED_CTG1_VALUE, syndFeed.getCategories().get(0).getLabel());
        assertEquals(FEED_CTG2_DOMAIN, syndFeed.getCategories().get(1).getScheme());
        assertEquals(FEED_CTG2_VALUE, syndFeed.getCategories().get(1).getLabel());

        assertNotNull(syndFeed.getGenerator());
        assertEquals(FEED_GENERATOR, syndFeed.getGenerator().getValue());

        assertNotNull(syndFeed.getLogo());
        assertEquals(FEED_IMAGE_URL, syndFeed.getLogo());

        assertTrue(syndFeed.getEntries().size() > 0);
        SyndEntry syndEntry = syndFeed.getEntries().get(0);
        assertNotNull(syndEntry);

        assertNotNull(syndEntry.getTitle());
        assertEquals(ITEM_TITLE, syndEntry.getTitle().getValue());
View Full Code Here

        assertNotNull(element);
        if (element instanceof JAXBElement<?>) {
            element = ((JAXBElement<?>)element).getValue();
        }
        assertTrue(element instanceof AtomFeed);
        SyndFeed syndFeed1 = new SyndFeed();
        syndFeed1 = ((AtomFeed)element).toSynd(syndFeed1);
        assertNotNull(syndFeed1);
        // Convert SyndFeed into RssFeed
        RssFeed rssFeed1 = new RssFeed(syndFeed1);
View Full Code Here

TOP

Related Classes of org.apache.wink.common.model.synd.SyndFeed

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.