Package com.sun.syndication.feed.atom

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


                + "/resources/" + website.getHandle()
                + "/" + file.getName();
        FileTypeMap map = FileTypeMap.getDefaultFileTypeMap();
        String contentType = map.getContentType(file);

        Entry entry = new Entry();
        entry.setTitle(file.getName());
        entry.setUpdated(new Date(file.lastModified()));

        Link editlink = new Link();
        editlink.setRel("edit");
        editlink.setHref(editURI);
        List otherlinks = new ArrayList();
        otherlinks.add(editlink);
        entry.setOtherLinks(otherlinks);

        Content content = new Content();
        content.setSrc(viewURI);
        content.setType(contentType);
        List contents = new ArrayList();
        contents.add(content);
        entry.setContents(contents);
       
        return entry;
    }
View Full Code Here


        Link link = new Link();
        link.setHref("http://incubator.apache.org/tuscany");
        feed.getAlternateLinks().add(link);

        // Add the Account report entry
        Entry entry = get("1234");
        feed.getEntries().add(entry);

        return feed;
    }
View Full Code Here

        // Get the account report for the specified customer ID
        double balance = accountService.getAccountReport(id);
        String value = Double.toString(balance);
       
        Entry entry = new Entry();
        entry.setId("account-" + id);
        entry.setTitle("Account Report Entry");
        Content summary = new Content();
        summary.setType(Content.HTML);
        summary.setValue("This is your account report: <b>" + value + "</b>");
        entry.setSummary(summary);
        Content content = new Content();
        content.setValue(value);
        entry.setContents(Collections.singletonList(content));
        return entry;
    }
View Full Code Here

        public Message invoke(Message msg) {

            // Put an entry
            Object[] args = (Object[])msg.getBody();
            String id = (String)args[0];
            Entry entry = (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();
                AtomEntryUtil.writeEntry(entry, "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 =
                            AtomEntryUtil.readEntry("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 entry = (Entry)feed.getEntries().get(0);
        return entry;
    }
View Full Code Here

                requestMessage.setBody(new Object[] {id});
                Message responseMessage = getInvoker.invoke(requestMessage);
                if (responseMessage.isFault()) {
                    throw new ServletException((Throwable)responseMessage.getBody());
                }
                Entry entry = responseMessage.getBody();

                // Write the Atom entry
                if (entry != null) {
                    response.setContentType("application/atom+xml; charset=utf-8");
                    try {
View Full Code Here

        // Get the request path
        String path = request.getPathInfo();

        if (path == null || path.length() == 0 || path.equals("/")) {
            Entry createdEntry = null;

            // Create a new Atom entry
            String contentType = request.getContentType();
            if (contentType.startsWith("application/atom+xml")) {

                // Read the entry from the request
                Entry entry;
                try {
                    entry = AtomEntryUtil.readEntry(feedType, request.getReader());
                } catch (JDOMException e) {
                    throw new ServletException(e);
                } catch (FeedException e) {
View Full Code Here

        // Get the request path
        String path = request.getPathInfo();

        if (path != null && path.startsWith("/")) {
            String id = path.substring(1);
            Entry updatedEntry = null;

            // Update an Atom entry
            String contentType = request.getContentType();
            if (contentType.startsWith("application/atom+xml")) {

                // Read the entry from the request
                Entry entry;
                try {
                    entry = AtomEntryUtil.readEntry(feedType, request.getReader());
                } catch (JDOMException e) {
                    throw new ServletException(e);
                } catch (FeedException e) {
View Full Code Here

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

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

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

        @Override
        public Message invoke(Message msg) {

            // Post an entry
            Entry entry = (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();
                AtomEntryUtil.writeEntry(entry, "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 =
                        AtomEntryUtil
                            .readEntry("atom_1.0", new InputStreamReader(postMethod.getResponseBodyAsStream()));
                    msg.setBody(createdEntry);

                } else if (status == 404) {
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.