Package com.sun.syndication.feed.atom

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


            String[] pathInfo = getPathInfo(req);
            try {
                if (handler.isEntryURI(pathInfo)) {
                   
                    // parse incoming entry
                    Entry unsavedEntry = parseEntry(new BufferedReader(
                        new InputStreamReader(
                            req.getInputStream(), "UTF-8")));
                   
                    // call handler to put entry
                    Entry updatedEntry = handler.putEntry(pathInfo, unsavedEntry);
                   
                    // write entry back out to response
                    res.setContentType("application/atom+xml; charset=utf-8");
                    Writer writer = res.getWriter();
                    serializeEntry(updatedEntry, writer);
                    res.setStatus(HttpServletResponse.SC_OK);
                    writer.close();
                   
                } else if (handler.isMediaEditURI(pathInfo)) {
                   
                    // hand input stream to handler
                    Entry updatedEntry = handler.putMedia(
                        pathInfo, req.getContentType(), req.getInputStream());
                                       
                    // write entry back out to response
                    res.setContentType("application/atom+xml; charset=utf-8");
                    Writer writer = res.getWriter();
View Full Code Here


                httpClient.executeMethod(getMethod);
                int status = getMethod.getStatusCode();

                // Read the Atom entry
                if (status == 200) {
                    Entry feedEntry =
                        AtomFeedEntryUtil.readFeedEntry("atom_1.0", new InputStreamReader(getMethod.getResponseBodyAsStream()));
                    msg.setBody(feedEntry);

                } else if (status == 404) {
                    msg.setFaultBody(new NotFoundException());
View Full Code Here

        @Override
        public Message invoke(Message msg) {

            // Post an entry
            Entry feedEntry = (Entry)((Object[])msg.getBody())[0];

            // Send an HTTP POST
            PostMethod postMethod = new PostMethod(uri);
            postMethod.setRequestHeader("Authorization", authorizationHeader);
            try {

                // Write the Atom entry
                StringWriter writer = new StringWriter();
                AtomFeedEntryUtil.writeFeedEntry(feedEntry, "atom_1.0", writer);
                postMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
                postMethod.setRequestEntity(new StringRequestEntity(writer.toString()));

                httpClient.executeMethod(postMethod);
                int status = postMethod.getStatusCode();

                // Read the Atom entry
                if (status == 200 || status == 201) {
                    Entry createdEntry =
                        AtomFeedEntryUtil
                            .readFeedEntry("atom_1.0", new InputStreamReader(postMethod.getResponseBodyAsStream()));
                    msg.setBody(createdEntry);

                } else if (status == 404) {
View Full Code Here

        public Message invoke(Message msg) {

            // Put an entry
            Object[] args = (Object[])msg.getBody();
            String id = (String)args[0];
            Entry feedEntry = (Entry)args[1];

            // Send an HTTP PUT
            PutMethod putMethod = new PutMethod(uri + "/" + id);
            putMethod.setRequestHeader("Authorization", authorizationHeader);
            try {

                // Write the Atom entry
                StringWriter writer = new StringWriter();
                AtomFeedEntryUtil.writeFeedEntry(feedEntry, "atom_1.0", writer);
                putMethod.setRequestHeader("Content-type", "application/atom+xml; charset=utf-8");
                putMethod.setRequestEntity(new StringRequestEntity(writer.toString()));

                httpClient.executeMethod(putMethod);
                int status = putMethod.getStatusCode();

                // Read the Atom entry
                if (status == 200 || status == 201) {
                    try {
                        Entry updatedEntry =
                            AtomFeedEntryUtil.readFeedEntry("atom_1.0", new InputStreamReader(putMethod
                                .getResponseBodyAsStream()));
                        msg.setBody(updatedEntry);
                    } catch (Exception e) {
                        // Returning the updated entry is optional
View Full Code Here

        WireFeedOutput wireFeedOutput = new WireFeedOutput();
        document = wireFeedOutput.outputJDom(feed);
        document.getRootElement().addContent(root);
        WireFeedInput input = new WireFeedInput();
        feed = (Feed)input.build(document);
        Entry feedEntry = (Entry)feed.getEntries().get(0);
        if (feedEntry.getContents().size() != 0) {
            Content content = (Content)feedEntry.getContents().get(0);
            if ("text/xml".equals(content.getType())) {
                Element element = root.getChild("content", root.getNamespace());
                if (!element.getChildren().isEmpty()) {
                    element = (Element)element.getChildren().get(0);
                    XMLOutputter outputter = new XMLOutputter();
View Full Code Here

                    outputter.output(feedDoc, writer);
                    writer.close();
                    res.setStatus(HttpServletResponse.SC_OK);
                } else if (handler.isEntryURI(pathInfo)) {
                    // return an entry
                    Entry entry = handler.getEntry(pathInfo);
                    if (entry != null) {
                        Writer writer = res.getWriter();
                        res.setContentType("application/atom+xml; charset=utf-8");
                        serializeEntry(entry, writer);
                        writer.close();
                    } else {
                        res.setStatus(HttpServletResponse.SC_NOT_FOUND);
                    }
                } else if (handler.isMediaURI(pathInfo)) {
                    // return a resource entry
                    Entry entry = handler.getMedia(pathInfo);
                    if (entry != null) {
                        Writer writer = res.getWriter();
                        res.setContentType("application/atom+xml; charset=utf-8");
                        serializeEntry(entry, writer);
                        writer.close();
View Full Code Here

            String[] pathInfo = getPathInfo(req);
            try {
                if (handler.isEntryCollectionURI(pathInfo)) {
                           
                    // parse incoming entry
                    Entry unsavedEntry = parseEntry(
                        new InputStreamReader(req.getInputStream()));
                    
                    // call handler to post it
                    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);
                    res.setContentType("application/atom+xml; charset=utf-8");
                    Writer writer = res.getWriter();
                    serializeEntry(savedEntry, writer);
                    writer.close();
                } else if (handler.isMediaCollectionURI(pathInfo)) {
                    // get incoming file name from HTTP header
                    String name = req.getHeader("Title");
                   
                    // hand input stream of to hander to post file
                    Entry resource = handler.postMedia(
                        pathInfo, name, 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);
                    res.setHeader("Location", content.getSrc());
                    Writer writer = res.getWriter();
                    serializeEntry(resource, writer);
                    writer.close();
                } else {
View Full Code Here

        if (userName != null) {
            String[] pathInfo = getPathInfo(req);
            try {
                if (handler.isEntryURI(pathInfo)) {
                    // parse incoming entry
                    Entry unsavedEntry = parseEntry(
                            new InputStreamReader(req.getInputStream()));
                   
                    // call handler to put entry
                    Entry updatedEntry = handler.putEntry(pathInfo, unsavedEntry);
                   
                    // write entry back out to response
                    res.setContentType("application/atom+xml; charset=utf-8");
                    Writer writer = res.getWriter();
                    serializeEntry(updatedEntry, writer);
                    res.setStatus(HttpServletResponse.SC_OK);
                    writer.close();
                } else if (handler.isMediaURI(pathInfo)) {
                    // hand input stream to handler
                    Entry updatedEntry = handler.putMedia(
                        pathInfo, req.getContentType(), req.getInputStream());
                                       
                    // write entry back out to response
                    res.setContentType("application/atom+xml; charset=utf-8");
                    Writer writer = res.getWriter();
View Full Code Here

            Feed feed = new Feed();
            List atomEntries = new ArrayList();
            int count = 0;
            if (files != null && start < files.length) {
                for (int i=start; i<(start + max) && i<(files.length); i++) {                  
                    Entry entry = createAtomResourceEntry(website, files[i]);
                    atomEntries.add(entry);
                    count++;
                }
            }
            if (start + count < files.length) { // add next link
View Full Code Here

     * Create a Rome Atom entry based on a Roller entry.
     * Content is escaped.
     * Link is stored as rel=alternate link.
     */
    private Entry createAtomEntry(WeblogEntryData entry) {
        Entry atomEntry = new Entry();
        Content content = new Content();
        content.setType(Content.HTML);
        content.setValue(entry.getText());
        List contents = new ArrayList();
        contents.add(content);
       
        String absUrl = mRollerContext.getAbsoluteContextUrl(mRequest);
        atomEntry.setId(        absUrl + entry.getPermaLink());
        atomEntry.setTitle(     entry.getTitle());
        atomEntry.setContentscontents);
        atomEntry.setPublished( entry.getPubTime());
        atomEntry.setUpdated(   entry.getUpdateTime());       

        UserData creator = entry.getCreator();       
        Person author = new Person();
        author.setName(         creator.getUserName());  
        author.setEmail(        creator.getEmailAddress());                       
        atomEntry.setAuthors(   Collections.singletonList(author));
       
        List categories = new ArrayList();
        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);
       
        List modules = new ArrayList();
        PubControlModule pubControl = new PubControlModuleImpl();
        pubControl.setDraft(
            !WeblogEntryData.PUBLISHED.equals(entry.getStatus()));
        modules.add(pubControl);
        atomEntry.setModules(modules);
       
        return atomEntry;
    }
View Full Code Here

TOP

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

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.