Package com.sun.syndication.feed.atom

Examples of com.sun.syndication.feed.atom.Link


                        Entry savedEntry = handler.postEntry(pathInfo, unsavedEntry);
                       
                        // return member entry URI as location header
                        Iterator links = savedEntry.getOtherLinks().iterator();
                        while (links.hasNext()) {
                            Link link = (Link) links.next();
                            if (link.getRel().equals("edit") || link.getRel() == null) {
                                res.addHeader("Location", link.getHref());
                                break;
                            }
                        }
                        // write entry back out to response
                        res.setStatus(HttpServletResponse.SC_CREATED);
                        res.setContentType("application/atom+xml; charset=utf-8");
                        Writer writer = res.getWriter();
                        serializeEntry(savedEntry, writer);
                        writer.close();
                   
                    } else if (req.getContentType() != null) {
                        // get incoming title and slug from HTTP header
                        String title = req.getHeader("Title");
                        String slug = req.getHeader("Slug");

                        // hand input stream off to hander to post file
                        Entry resource = handler.postMedia(
                            pathInfo, title, slug, req.getContentType(), req.getInputStream());
                       
                        res.setStatus(HttpServletResponse.SC_CREATED);
                        com.sun.syndication.feed.atom.Content content =
                            (com.sun.syndication.feed.atom.Content)resource.getContents().get(0);

                        // return member entry URI as location header
                        Iterator links = resource.getOtherLinks().iterator();
                        while (links.hasNext()) {
                            Link link = (Link) links.next();
                            if (link.getRel().equals("edit") || link.getRel() == null) {
                                res.addHeader("Location", link.getHref());
                                break;
                            }
                        }
                        Writer writer = res.getWriter();
                        serializeEntry(resource, writer);
View Full Code Here


            Feed feed = new Feed();
            feed.setId(atomURL
                +"/"+website.getHandle() + "/entries/" + start);
            feed.setTitle(website.getName());

            Link link = new Link();
            link.setHref(absUrl + "/" + website.getHandle());
            link.setRel("alternate");
            link.setType("text/html");
            feed.setAlternateLinks(Collections.singletonList(link));

            List atomEntries = new ArrayList();
            int count = 0;
            for (Iterator iter = entries.iterator(); iter.hasNext() && count < maxEntries; count++) {
                WeblogEntry rollerEntry = (WeblogEntry)iter.next();
                Entry entry = createAtomEntry(rollerEntry);
                atomEntries.add(entry);
                if (count == 0) {
                    // first entry is most recent
                    feed.setUpdated(entry.getUpdated());
                }
            }
            List links = new ArrayList();
            if (entries.size() > max) { // add next link
                int nextOffset = start + max;
                String url = atomURL+"/"
                        + website.getHandle() + "/entries/" + nextOffset;
                Link nextLink = new Link();
                nextLink.setRel("next");
                nextLink.setHref(url);
                links.add(nextLink);
            }
            if (start > 0) { // add previous link
                int prevOffset = start > max ? start - max : 0;
                String url = atomURL+"/"
                        +website.getHandle() + "/entries/" + prevOffset;
                Link prevLink = new Link();
                prevLink.setRel("previous");
                prevLink.setHref(url);
                links.add(prevLink);
            }
            if (links.size() > 0) feed.setOtherLinks(links);
            // Use collection URI as id
            feed.setEntries(atomEntries);
View Full Code Here

            Feed feed = new Feed();
            feed.setId(atomURL
                +"/"+website.getHandle() + "/resources/" + path + start);               
            feed.setTitle(website.getName());

            Link link = new Link();
            link.setHref(absUrl + "/" + website.getHandle());
            link.setRel("alternate");
            link.setType("text/html");
            feed.setAlternateLinks(Collections.singletonList(link));

            FileManager fmgr = roller.getFileManager();
            ThemeResource[] files = fmgr.getFiles(website, path);

            SortedSet sortedSet = new TreeSet(new Comparator() {
                public int compare(Object o1, Object o2) {
                    ThemeResource f1 = (ThemeResource)o1;
                    ThemeResource f2 = (ThemeResource)o2;
                    if (f1.getLastModified() < f2.getLastModified()) return 1;
                    else if (f1.getLastModified() == f2.getLastModified()) return 0;
                    else return -1;
                }
            });
                                   
            if (files != null && start < files.length) { 
                for (int j=0; j<files.length; j++) {
                    sortedSet.add(files[j]);
                }
                int count = 0;
                ThemeResource[] sortedResources =
                   (ThemeResource[])sortedSet.toArray(new ThemeResource[sortedSet.size()]);
                List atomEntries = new ArrayList();
                for (int i=start; i<(start + max) && i<(sortedResources.length); i++) {
                    Entry entry = createAtomResourceEntry(website, sortedResources[i]);
                    atomEntries.add(entry);
                    if (count == 0) {
                        // first entry is most recent
                        feed.setUpdated(entry.getUpdated());
                    }
                    count++;
                }

                List otherLinks = new ArrayList();
                if (start + count < files.length) { // add next link
                    int nextOffset = start + max;
                    String url = atomURL
                        +"/"+ website.getHandle() + "/resources/" + path + nextOffset;
                    Link nextLink = new Link();
                    nextLink.setRel("next");
                    nextLink.setHref(url);
                    otherLinks.add(nextLink);
                }
                if (start > 0) { // add previous link
                    int prevOffset = start > max ? start - max : 0;
                    String url = atomURL
                        +"/"+website.getHandle() + "/resources/" + path + prevOffset;
                    Link prevLink = new Link();
                    prevLink.setRel("previous");
                    prevLink.setHref(url);
                    otherLinks.add(prevLink);
                }
                feed.setOtherLinks(otherLinks);
                feed.setEntries(atomEntries);
            }
View Full Code Here

            newcat.setTerm(tag.getName());
            categories.add(newcat);
        }       
        atomEntry.setCategories(categories);
       
        Link altlink = new Link();
        altlink.setRel("alternate");
        altlink.setHref(absUrl + entry.getPermaLink());
        List altlinks = new ArrayList();
        altlinks.add(altlink);
        atomEntry.setAlternateLinks(altlinks);
       
        Link editlink = new Link();
        editlink.setRel("edit");
        editlink.setHref(
                atomURL
                +"/"+entry.getWebsite().getHandle() + "/entry/" + entry.getId());
        List otherlinks = new ArrayList();
        otherlinks.add(editlink);
        atomEntry.setOtherLinks(otherlinks);
View Full Code Here

        entry.setTitle(file.getName());
        entry.setUpdated(new Date(file.getLastModified()));
       
        List otherlinks = new ArrayList();       
        entry.setOtherLinks(otherlinks);
        Link editlink = new Link();
            editlink.setRel("edit");
            editlink.setHref(editURI);       
            otherlinks.add(editlink);           
        Link editMedialink = new Link();
            editMedialink.setRel("edit-media");
            editMedialink.setHref(editMediaURI);       
            otherlinks.add(editMedialink);
       
        Content content = new Content();
        content.setSrc(viewURI);
        content.setType(contentType);
View Full Code Here

        osm.setStartIndex(1);
        osm.setTotalResults(searchResult.getResults().size());
        osm.setItemsPerPage(50);

        Link link = new Link();
        link.setHref("http://www.jahia.org/opensearch-description.xml");
        link.setType("application/opensearchdescription+xml");
        link.setTitle("Jahia Open Search");
        osm.setLink(link);

        OSQuery query = new OSQuery();
        query.setRole("request");
        query.setSearchTerms(searchString);
View Full Code Here

                    Entry savedEntry = handler.postEntry(pathInfo, unsavedEntry);
                    Iterator links = savedEntry.getAlternateLinks().iterator();
                    
                    // return alternate link as Location header
                    while (links.hasNext()) {
                        Link link = (Link) links.next();
                        if (link.getRel().equals("alternate") || link.getRel() == null) {
                            res.addHeader("Location", link.getHref());
                            break;
                        }
                    }
                    // write entry back out to response
                    res.setStatus(HttpServletResponse.SC_CREATED);
View Full Code Here

            }
            List links = new ArrayList();
            if (entries.size() > max) { // add next link
                int nextOffset = start + max;
                String url = absUrl + "/app/" + website.getHandle() + "/entries/" + nextOffset;
                Link nextLink = new Link();
                nextLink.setRel("next");
                nextLink.setHref(url);
                links.add(nextLink);
            }
            if (start > 0) { // add previous link
                int prevOffset = start > max ? start - max : 0;
                String url = absUrl + "/app/" +website.getHandle() + "/entries/" + prevOffset;
                Link prevLink = new Link();
                prevLink.setRel("previous");
                prevLink.setHref(url);
                links.add(prevLink);
            }
            if (links.size() > 0) feed.setOtherLinks(links);
            feed.setEntries(atomEntries);
            return feed;
View Full Code Here

                }
            }
            if (start + count < files.length) { // add next link
                int nextOffset = start + max;
                String url = absUrl + "/app/" + website.getHandle() + "/resources/" + nextOffset;
                Link nextLink = new Link();
                nextLink.setRel("next");
                nextLink.setHref(url);
                List next = new ArrayList();
                next.add(nextLink);
                feed.setOtherLinks(next);
            }
            if (start > 0) { // add previous link
                int prevOffset = start > max ? start - max : 0;
                String url = absUrl + "/app/" +website.getHandle() + "/resources/" + prevOffset;
                Link prevLink = new Link();
                prevLink.setRel("previous");
                prevLink.setHref(url);
                List prev = new ArrayList();
                prev.add(prevLink);
                feed.setOtherLinks(prev);
            }
            feed.setEntries(atomEntries);
View Full Code Here

        Category atomCat = new Category();
        atomCat.setTerm(entry.getCategory().getPath());
        categories.add(atomCat);
        atomEntry.setCategories(categories);
       
        Link altlink = new Link();
        altlink.setRel("alternate");
        altlink.setHref(absUrl + entry.getPermaLink());
        List altlinks = new ArrayList();
        altlinks.add(altlink);
        atomEntry.setAlternateLinks(altlinks);
       
        Link editlink = new Link();
        editlink.setRel("edit");
        editlink.setHref(absUrl + "/app/"
            + entry.getWebsite().getHandle() + "/entry/" + entry.getId());
        List otherlinks = new ArrayList();
        otherlinks.add(editlink);
        atomEntry.setOtherLinks(otherlinks);
       
View Full Code Here

TOP

Related Classes of com.sun.syndication.feed.atom.Link

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.