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

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


                            genericType,
                            annotations,
                            mediaType,
                            httpHeaders,
                            entityStream);
        return feed.toSynd(new SyndFeed());
    }
View Full Code Here


     * The method tests the CollectionHtmlDefaultAdapter that is used for
     * default case.
     */
    @Test
    public void testCollectionHtmlDefaultAdapter() {
        SyndFeed syndFeed = createSyndFeed();
        HtmlSyndFeedAdapter collectionAdapter = new HtmlSyndFeedAdapter(syndFeed);
        assertEquals("id", COL_ID, collectionAdapter.getId());
        assertEquals("updated", simpleDateFormat.format(CURRENT_DATE), collectionAdapter
            .getUpdated());
        assertEquals("title", COL_TITLE, collectionAdapter.getTitle());
View Full Code Here

     * The method creates CollectionResource with dummy data.
     *
     * @return CollectionResource<Object>
     */
    public static SyndFeed createSyndFeed() {
        SyndFeed feed = new SyndFeed();
        feed.setId(COL_ID);
        feed.setUpdated(CURRENT_DATE);
        feed.setTitle(new SyndText(COL_TITLE));
        SyndLink syndLink = new SyndLink();
        syndLink.setHref(COL_LINK_HREF);
        syndLink.setType(COL_LINK_TYPE);
        syndLink.setRel(COL_LINK_REL);
        feed.addLink(syndLink);
        SyndCategory category = new SyndCategory();
        category.setScheme(COL_CATEGORY_SCHEME);
        category.setTerm(COL_CATEGORY_TERM);
        feed.addCategory(category);
        SyndPerson person = new SyndPerson();
        person.setName(COL_OWNER);
        feed.addAuthor(person);
        feed.setSubtitle(new SyndText(COL_SUB_TITLE));
        return feed;
    }
View Full Code Here

            // HtmlCollectionResource resource = new
            // HtmlCollectionResource(CUSTOMIZED_COLLECTION_URL,
            // httpServletRequest, httpServletResponse);
            //
            // return resource;
            return new HtmlDescriptor(new SyndFeed(), CUSTOMIZED_COLLECTION_URL);
        }
View Full Code Here

    public SyndFeed getUsers(@Context LinkBuilders linkBuilders) {

        // Build SyndFeed that holds users collection.
        // Generate a system links for collection and for each collection member
        // by using LinkBuilders
        SyndFeed usersSyndFeed = createUsersSyndFeed(users.values(), linkBuilders);

        return usersSyndFeed;
    }
View Full Code Here

     * @param users collection
     * @param linkBuilders reference to LinkBuilders instance
     * @return SyndFeed syndication feed
     */
    private SyndFeed createUsersSyndFeed(Collection<User> users, LinkBuilders linkBuilders) {
        SyndFeed usersSyndFeed = new SyndFeed();
        usersSyndFeed.setId("urn:com:hp:users");
        usersSyndFeed.setTitle(new SyndText("Users"));
        usersSyndFeed.addAuthor(new SyndPerson("admin"));
        usersSyndFeed.setUpdated(new Date());

        // 1. Generate collection system links: "edit", "alternate"
        linkBuilders.createSystemLinksBuilder(). // Create SystemLinksBuilder
            build(usersSyndFeed.getLinks()); // Build all system links

        // 2. Add "custom" collection link with type "search". Make it always be
        // absolute
        linkBuilders.createSingleLinkBuilder(). // Create instance of
                                                // SingleLinkBuilder
            queryParam("q", "username"). // Set link query parameter
            rel("search"). // Set link relation type
            relativize(false). // Create absolute URI
            build(usersSyndFeed.getLinks()); // Build link

        // 3. Populate and set the collection members
        for (User user : users) {
            SyndEntry userSyndEntry = createUserSyndEntry(user);

            // generate collection member (single user) system links: "edit",
            // "alternate"
            // all link must be relative to users collection URI "users"
            linkBuilders.createSystemLinksBuilder().subResource(userSyndEntry.getId())
                .build(userSyndEntry.getLinks());

            usersSyndFeed.addEntry(userSyndEntry);
        }
        return usersSyndFeed;
    }
View Full Code Here

        return new Users(users);
    }

    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
    public SyndFeed getSyndFeed(@Context Providers providers, @Context UriInfo uriInfo) {
        SyndFeed synd = new SyndFeed();
        synd.setId("urn:com:hp:users");
        synd.setTitle(new SyndText("Users"));
        synd.addAuthor(new SyndPerson("admin"));
        synd.setUpdated(new Date());

        // set the entries
        for (User user : users) {
            SyndEntry entry = new SyndEntry();
            entry.setId(Integer.toString(user.getId()));
            entry.setPublished(new Date(System.currentTimeMillis()));
            entry.setUpdated(new Date(System.currentTimeMillis()));
            entry.setTitle(new SyndText(user.getLastName() + " " + user.getFirstName()));
            synd.addEntry(entry);
        }
        synd.setBase(uriInfo.getAbsolutePath().toString());
        return synd;
    }
View Full Code Here

    @Produces
    public SyndFeed getSyndFeed(@Context Providers providers,
                                @Context LinkBuilders linkBuilders,
                                @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 : getDefects()) {
            DefectAsset defectAsset = new DefectAsset(defect, true);
            SyndEntry entry = defectAsset.getSyndEntry(providers, uriInfo, linkBuilders);
            synd.addEntry(entry);
        }

        synd.setBase(uriInfo.getAbsolutePath().toString());
        linkBuilders.createSystemLinksBuilder().build(synd.getLinks());
        return synd;
    }
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:tests");
        synd.setTitle(new SyndText("Tests"));
        synd.addAuthor(new SyndPerson("admin"));
        synd.setUpdated(new Date());

        // set the entries
        for (TestBean test : tests) {
            TestAsset testAsset = new TestAsset(test, true);
            SyndEntry entry = testAsset.getSyndEntry(providers, uriInfo, linkProcessor);
            synd.addEntry(entry);
        }

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

     * @return syndFeed
     */
    @GET
    @Produces( {MediaType.APPLICATION_ATOM_XML})
    public SyndFeed getBookmarks(@Context LinkBuilders linksBuilders, @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), uriInfo);

            // Generate system links to sub-resource
            linksBuilders.createSystemLinksBuilder().subResource(SUB_RESOURCE_PATH)
                .pathParam(BOOKMARK, key).build(entry.getLinks());

            // Add entry to Feed
            feed.addEntry(entry);
        }

        // Generate system links for the resource;
        linksBuilders.createSystemLinksBuilder().build(feed.getLinks());

        return feed;
    }
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.