Package com.sun.syndication.feed.atom

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


     * @param item
     * @return
     */
    private Entry createEntry(Object key, Object item) {
        if (item != null) {
            Entry entry = new Entry();
            entry.setId(key.toString());
            entry.setTitle("item");
   
            // Convert the item to XML
            String value = mediator.mediate(item, itemClassType, itemXMLType, null).toString();
            value = value.substring(value.indexOf('>') +1);
           
            Content content = new Content();
            content.setType("text/xml");
            content.setValue(value);
            List<Content> contents = new ArrayList<Content>();
            contents.add(content);
            entry.setContents(contents);
   
            Link link = new Link();
            link.setRel("edit");
            link.setHref(key.toString());
            entry.getOtherLinks().add(link);
            link = new Link();
            link.setRel("alternate");
            link.setHref(key.toString());
            entry.getAlternateLinks().add(link);
   
            entry.setCreated(new Date());
            return entry;
        } else {
            return null;
        }
    }
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

            // 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

        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);
        if (entry.getContents().size() != 0) {
            Content content = (Content)entry.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

    public CustomerCollectionImpl() {

        for (int i = 0; i < 4; i++) {
            String id = "urn:uuid:customer-" + UUID.randomUUID().toString();

            Entry entry = new Entry();
            entry.setTitle("customer " + "Jane Doe_" + String.valueOf(i));
            entry.setId(id);

            Content content = new Content();
            content.setValue("Jane Doe_" + String.valueOf(i));
            content.setType(Content.TEXT);
            entry.setContents(Collections.singletonList(content));

            List<Link> links = new ArrayList<Link>();
            Link link = new Link();
            link.setRel("edit");
            link.setHref("" + id);
            links.add(link);
            entry.setOtherLinks(links);

            links = new ArrayList<Link>();
            link = new Link();
            link.setRel("alternate");
            link.setHref("" + id);
            links.add(link);
            entry.setAlternateLinks(links);

            entry.setCreated(new Date());

            entries.put(id, entry);
            System.out.println(">>> id=" + id);
        }
    }
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

    @Reference
    public Collection resourceCollection;

    public void testCustomerCollection() throws Exception {

        Entry newEntry = newEntry("Sponge Bob");
        System.out.println(">>> post entry=" + newEntry.getTitle());
        newEntry = resourceCollection.post(newEntry);
        System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle());

        newEntry = newEntry("Jane Bond");
        System.out.println(">>> post entry=" + newEntry.getTitle());
        newEntry = resourceCollection.post(newEntry);
        System.out.println("<<< post id=" + newEntry.getId() + " entry=" + newEntry.getTitle());

        System.out.println(">>> get id=" + newEntry.getId());
        Entry entry = resourceCollection.get(newEntry.getId());
        System.out.println("<<< get id=" + entry.getId() + " entry=" + entry.getTitle());

        System.out.println(">>> put id=" + newEntry.getId() + " entry=" + entry.getTitle());
        entry = resourceCollection.put(entry.getId(), updateEntry(entry, "James Bond"));
        System.out.println("<<< put id=" + entry.getId() + " entry=" + entry.getTitle());

        System.out.println(">>> delete id=" + entry.getId());
        resourceCollection.delete(entry.getId());
        System.out.println("<<< delete id=" + entry.getId());

        System.out.println(">>> get collection");
        Feed feed = resourceCollection.getFeed();
        System.out.println("<<< get collection");
        for (Object o : feed.getEntries()) {
            Entry e = (Entry)o;
            System.out.println("id = " + e.getId() + " entry = " + e.getTitle());
        }
    }
View Full Code Here

        }
    }

    private Entry newEntry(String value) {

        Entry entry = new Entry();
        entry.setTitle("customer " + value);

        Content content = new Content();
        content.setValue(value);
        content.setType(Content.TEXT);
        List<Object> list = new ArrayList<Object>();
        list.add(content);
        entry.setContents(list);

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