Package com.sun.syndication.feed.atom

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


        }
        return atomEntries;
    }

    protected Entry createAtomEntry(SyndEntry sEntry) {
        Entry aEntry = new Entry();
        aEntry.setModules(ModuleUtils.cloneModules(sEntry.getModules()));

        aEntry.setId(sEntry.getUri());

        aEntry.setTitle(sEntry.getTitle());

        // separate SyndEntry's links collection into alternate and other links
        List alternateLinks = new ArrayList();
        List otherLinks = new ArrayList();
        List slinks = sEntry.getLinks();
        if (slinks != null) {
            for (Iterator iter=slinks.iterator(); iter.hasNext();) {      
                SyndLink syndLink = (SyndLink)iter.next();               
                Link link = new Link();
                link.setRel(syndLink.getRel());
                link.setHref(syndLink.getHref());
                link.setHreflang(syndLink.getHreflang());
                link.setLength(syndLink.getLength());               
                if ("alternate".equals(syndLink.getRel())) {
                    alternateLinks.add(link);
                } else {
                    otherLinks.add(link);
                }
            }
        }
        // no alternate link? then use THE link if there is one
        if (alternateLinks.size() == 0 && sEntry.getLink() != null) {
            Link link = new Link();
            link.setRel("alternate");
            link.setHref(sEntry.getLink());
            alternateLinks.add(link);
        }
        if (alternateLinks.size() > 0) aEntry.setAlternateLinks(alternateLinks);
        if (otherLinks.size() > 0) aEntry.setOtherLinks(otherLinks);
      
        List sCats = sEntry.getCategories();
        List aCats = new ArrayList();
        if (sCats != null) {
            for (Iterator iter=sCats.iterator(); iter.hasNext();) {
                SyndCategory sCat = (SyndCategory)iter.next();
                Category aCat = new Category();
                aCat.setTerm(sCat.getName());
                // TODO: aCat.setLabel(sCat.getLabel());
                aCat.setScheme(sCat.getTaxonomyUri());
                aCats.add(aCat);
            }
        }
        if (aCats.size() > 0) aEntry.setCategories(aCats);
       
        SyndContent sDescription = sEntry.getDescription();
        if (sDescription!=null) {
            Content summary = new Content();
            summary.setType(sDescription.getType());
            summary.setValue(sDescription.getValue());
            aEntry.setSummary(summary);
        }

        // take first item in contents collection as the content
        List syndContents = sEntry.getContents();
        if (syndContents != null && syndContents.size() > 0) {
            SyndContent syndContent = (SyndContent)syndContents.get(0);
            Content content = new Content();
            content.setType(syndContent.getType());
            content.setValue(syndContent.getValue());
            aEntry.setSummary(content);
        }

        List authors = sEntry.getAuthors();
        if (authors!=null && authors.size() > 0) {
            aEntry.setAuthors(ConverterForAtom03.createAtomPersons(authors));
        }

        aEntry.setPublished(sEntry.getPublishedDate());
        aEntry.setUpdated(sEntry.getUpdatedDate());
       
        // TODO: @FID42 Atom 1.0 Date (Updated or Published) Not Set
        if(aEntry.getUpdated() == null && sEntry.getPublishedDate() != null)
            ROME.failed(Failure.ROME42);
        return aEntry;
    }
View Full Code Here


        }
        return atomEntries;
    }

    protected Entry createAtomEntry(SyndEntry sEntry) {
        Entry aEntry = new Entry();
        aEntry.setModules(ModuleUtils.cloneModules(sEntry.getModules()));

        aEntry.setId(sEntry.getUri());

        aEntry.setTitle(sEntry.getTitle());

        String sLink = sEntry.getLink();
        if (sLink!=null) {
            Link link = new Link();
            link.setRel("alternate");
            link.setHref(sLink);
            List list = new ArrayList();
            list.add(link);
            aEntry.setAlternateLinks(list);
        }

        SyndContent sContent = sEntry.getDescription();
        if (sContent!=null) {
            Content content = new Content();
            content.setType(sContent.getType());
            content.setValue(sContent.getValue());
            content.setMode(Content.ESCAPED);
            aEntry.setSummary(content);
        }

        List contents = sEntry.getContents();
        if (contents.size()>0) {
            List aContents = new ArrayList();
            for (int i=0;i<contents.size();i++) {
                sContent = (SyndContentImpl) contents.get(i);
                Content content = new Content();
                content.setType(sContent.getType());
                content.setValue(sContent.getValue());
                content.setMode(Content.ESCAPED);
                aContents.add(content);

            }
            aEntry.setContents(aContents);
        }

        List sAuthors = sEntry.getAuthors();
        if (sAuthors!=null && sAuthors.size() > 0) {
            aEntry.setAuthors(createAtomPersons(sAuthors));
        }

        aEntry.setModified(sEntry.getPublishedDate());
        aEntry.setIssued(sEntry.getPublishedDate());

        return aEntry;
    }
View Full Code Here

        }
        return atomEntries;
    }

    protected Entry createAtomEntry(SyndEntry sEntry) {
        Entry aEntry = new Entry();
        aEntry.setModules(ModuleUtils.cloneModules(sEntry.getModules()));

        aEntry.setId(sEntry.getUri());

        aEntry.setTitle(sEntry.getTitle());

        String sLink = sEntry.getLink();
        if (sLink!=null) {
            Link link = new Link();
            link.setRel(Link.ALTERNATE);
            link.setHref(sLink);
            List list = new ArrayList();
            list.add(link);
            aEntry.setAlternateLinks(list);
        }

        SyndContent sContent = sEntry.getDescription();
        if (sContent!=null) {
            Content content = new Content();
            content.setType(sContent.getType());
            content.setValue(sContent.getValue());
            content.setMode(Content.XML);
            aEntry.setSummary(content);
        }

        List contents = sEntry.getContents();
        if (contents.size()>0) {
            List aContents = new ArrayList();
            for (int i=0;i<contents.size();i++) {
                sContent = (SyndContentImpl) contents.get(i);
                Content content = new Content();
                content.setType(sContent.getType());
                content.setValue(sContent.getValue());
                content.setMode(Content.XML);
                aContents.add(content);

            }
            aEntry.setContents(aContents);
        }

        String sAuthor = sEntry.getAuthor();
        if (sAuthor!=null) {
            Person person = new Person();
            person.setName(sAuthor);
            aEntry.setAuthor(person);
        }

        aEntry.setModified(sEntry.getPublishedDate());

        return aEntry;
    }
View Full Code Here

        }
        return (entries.size()>0) ? entries : null;
    }

    private Entry parseEntry(Feed feed, Element eEntry, URL baseURI) {
        Entry entry = new Entry();

        String xmlBase = eEntry.getAttributeValue("base", Namespace.XML_NAMESPACE);
        if (xmlBase != null) {
            entry.setXmlBase(xmlBase);
        }
       
        Element e = eEntry.getChild("title",getAtomNamespace());
        if (e!=null) {
            entry.setTitle(e.getText());
        }

        List eList = eEntry.getChildren("link",getAtomNamespace());
        entry.setAlternateLinks(parseAlternateLinks(feed, entry, baseURI, eList));
        entry.setOtherLinks(parseOtherLinks(feed, entry, baseURI, eList));

        eList = eEntry.getChildren("author", getAtomNamespace());
        if (eList.size()>0) {
            entry.setAuthors(parsePersons(baseURI, eList));
        }

        eList = eEntry.getChildren("contributor",getAtomNamespace());
        if (eList.size()>0) {
            entry.setContributors(parsePersons(baseURI, eList));
        }

        e = eEntry.getChild("id",getAtomNamespace());
        if (e!=null) {
            entry.setId(e.getText());
        }

        e = eEntry.getChild("updated",getAtomNamespace());
        if (e!=null) {
            entry.setUpdated(DateParser.parseDate(e.getText()));
        }

        e = eEntry.getChild("published",getAtomNamespace());
        if (e!=null) {
            entry.setPublished(DateParser.parseDate(e.getText()));
        }

        e = eEntry.getChild("summary",getAtomNamespace());
        if (e!=null) {
            entry.setSummary(parseContent(e));
        }

        e = eEntry.getChild("content",getAtomNamespace());
        if (e!=null) {
            List contents = new ArrayList();
            contents.add(parseContent(e));
            entry.setContents(contents);
        }

        e = eEntry.getChild("rights",getAtomNamespace());
        if (e!=null) {
            entry.setRights(e.getText());
        }

        List cList = eEntry.getChildren("category",getAtomNamespace());
        entry.setCategories(parseCategories(baseURI, cList));

        // TODO: SHOULD handle Atom entry source element
       
        entry.setModules(parseItemModules(eEntry));

        return entry;
    }
View Full Code Here

    }
    return (entries.size() > 0) ? entries : null;
  }

  private Entry parseEntry(Element eEntry) {
    Entry entry = new Entry();

    Element e = eEntry.getChild("title", getAtomNamespace());
    if (e != null) {
      entry.setTitleEx(parseContent(e));
    }

    List eList = eEntry.getChildren("link", getAtomNamespace());
    entry.setAlternateLinks(parseAlternateLinks(eList));
    entry.setOtherLinks(parseOtherLinks(eList));

    e = eEntry.getChild("author", getAtomNamespace());
    if (e != null) {
      List authors = new ArrayList();
      authors.add(parsePerson(e));
      entry.setAuthors(authors);
    }

    eList = eEntry.getChildren("contributor", getAtomNamespace());
    if (eList.size() > 0) {
      entry.setContributors(parsePersons(eList));
    }

    e = eEntry.getChild("id", getAtomNamespace());
    if (e != null) {
      entry.setId(e.getText());
    }

    e = eEntry.getChild("modified", getAtomNamespace());
    if (e != null) {
      entry.setModified(DateParser.parseDate(e.getText()));
    }

    e = eEntry.getChild("issued", getAtomNamespace());
    if (e != null) {
      entry.setIssued(DateParser.parseDate(e.getText()));
    }

    e = eEntry.getChild("created", getAtomNamespace());
    if (e != null) {
      entry.setCreated(DateParser.parseDate(e.getText()));
    }

    e = eEntry.getChild("summary", getAtomNamespace());
    if (e != null) {
      entry.setSummary(parseContent(e));
    }

    eList = eEntry.getChildren("content", getAtomNamespace());
    if (eList.size() > 0) {
      List content = new ArrayList();
      for (int i = 0; i < eList.size(); i++) {
        content.add(parseContent((Element) eList.get(i)));
      }
      entry.setContents(content);
    }

    entry.setModules(parseItemModules(eEntry));

    List foreignMarkup = extractForeignMarkup(eEntry, entry, getAtomNamespace());
    if (foreignMarkup.size() > 0) {
      entry.setForeignMarkup(foreignMarkup);
    }
    return entry;
  }
View Full Code Here

        //get the ATOM feed
        Feed feed = r.path("collection").accept("application/atom+xml").get(Feed.class);
        int numberOfEntries = feed.getEntries().size();
        List<Entry> feedEntries = feed.getEntries();
        Iterator<Entry> entryIterator = feedEntries.iterator();
        Entry feedEntry = null;
        if(entryIterator.hasNext()) {
          feedEntry = entryIterator.next();
        }
        String entryId = feedEntry.getId();

        //get the entry content
        String entryText = r.path("collection").path(entryId).path("media")
                .accept(MediaType.TEXT_PLAIN).get(String.class);
        assertEquals("Retrieved entry doesn't have the pushed text.",
View Full Code Here

        String mediaPath = AtomStore.getMediaPath(entryId);
        AtomStore.checkExistence(mediaPath);

        // Get the atom entry
        Feed f = AtomStore.getFeedDocument();
        Entry e = AtomStore.findEntry(entryId, f);
       
        // Update the entry
        e.setUpdated(new Date());
        UriBuilder editMediaEntryUri = getUriBuilder();
        AtomStore.updateLink(e, "edit-media",
                editMediaEntryUri.build());
        editMediaEntryUri.path("..");
        AtomStore.updateLink(e, "edit",
View Full Code Here

            UriInfo uriInfo, MessageBodyWorkers bodyContext) throws FeedException {
        super(entryId, uriInfo, bodyContext);
       
        // Get the edit link in the entry
        Feed f = AtomStore.getFeedDocument();
        Entry e = AtomStore.findEntry(entryId, f);       
        String editLink = AtomStore.getLink(e, "edit");
       
        // Compare against the requested link
        String editUri = uriInfo.getAbsolutePath().toString();
        if (!editUri.startsWith(editLink)) {
View Full Code Here

            byte[] entry) throws IOException, FeedException {
        // Get the next unique name of the entry
        String entryId = FileStore.FS.getNextId();

        // Create a default entry
        Entry e = AtomStore.createDefaulMediaLinkEntryDocument();
               
        UriBuilder entryUriBuilder = uriInfo.getAbsolutePathBuilder().path(entryId);
        UriBuilder editEntryUriBuilder = getEditUriBuilder().path(entryId);
       
        // Set the self link
        URI entryUri = entryUriBuilder.build();       
        AtomStore.addLink(e, "self", entryUri);
       
        // Set the edit link
        URI editEntryUri = editEntryUriBuilder.build();
        AtomStore.addLink(e, "edit", editEntryUri);
       
        // Set the edit-media link
        URI editMediaUri = editEntryUriBuilder.
                path("media").build();
        AtomStore.addLink(e, "edit-media", editMediaUri);       
       
        // Set the id
        e.setId(entryId);
       
        // Set the content to link to the media
        Content c = new Content();
        c.setType(headers.getMediaType().toString());
        URI mediaUri = entryUriBuilder.
                path("media").
                build();
        c.setSrc(mediaUri.toString());
        e.getContents().add(c);
       
        // Store entry document
        AtomStore.createEntryDocument(bodyContext, entryId, e);
        // Store the media
        AtomStore.createMediaDocument(entryId, entry);
View Full Code Here

        updateFeedDocument(bodyContext, f);
    }
       
    static void updateFeedDocumentRemovingEntry(MessageBodyWorkers bodyContext,
            Feed f, String id) throws IOException {
        Entry e = findEntry(id, f);
        f.getEntries().remove(e);

        updateFeedDocument(bodyContext, f);
    }
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.