com.rometools.rome.feed.synd.SyndPerson Java Examples

The following examples show how to use com.rometools.rome.feed.synd.SyndPerson. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomerAtomFeedView.java    From event-driven-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
	feed.setId("https://github.com/mploed/event-driven-spring-boot/customer");
	feed.setTitle("Customer");
	List<Link> alternateLinks = new ArrayList<>();
	Link link = new Link();
	link.setRel("self");
	link.setHref(baseUrl(request) + "feed");
	alternateLinks.add(link);
	List<SyndPerson> authors = new ArrayList<SyndPerson>();
	Person person = new Person();
	person.setName("Big Pug Bank");
	authors.add(person);
	feed.setAuthors(authors);

	feed.setAlternateLinks(alternateLinks);
	feed.setUpdated(customerRepository.lastUpdate());
	Content subtitle = new Content();
	subtitle.setValue("List of all customers");
	feed.setSubtitle(subtitle);
}
 
Example #2
Source File: Atom10Generator.java    From rome with Apache License 2.0 6 votes vote down vote up
protected void fillPersonElement(final Element element, final SyndPerson person) {

        final String name = person.getName();
        if (name != null) {
            element.addContent(generateSimpleElement("name", name));
        }

        final String uri = person.getUri();
        if (uri != null) {
            element.addContent(generateSimpleElement("uri", uri));
        }

        final String email = person.getEmail();
        if (email != null) {
            element.addContent(generateSimpleElement("email", email));
        }

        generatePersonModules(person.getModules(), element);

    }
 
Example #3
Source File: Atom03Generator.java    From rome with Apache License 2.0 6 votes vote down vote up
protected void fillPersonElement(final Element element, final SyndPerson person) {

        final String name = person.getName();
        if (name != null) {
            element.addContent(generateSimpleElement("name", name));
        }

        final String uri = person.getUri();
        if (uri != null) {
            element.addContent(generateSimpleElement("url", uri));
        }

        final String email = person.getEmail();
        if (email != null) {
            element.addContent(generateSimpleElement("email", email));
        }

    }
 
Example #4
Source File: ConverterForRSS091Userland.java    From rome with Apache License 2.0 6 votes vote down vote up
@Override
protected WireFeed createRealFeed(final String type, final SyndFeed syndFeed) {
    final Channel channel = (Channel) super.createRealFeed(type, syndFeed);
    channel.setLanguage(syndFeed.getLanguage()); // c
    channel.setCopyright(syndFeed.getCopyright()); // c
    channel.setPubDate(syndFeed.getPublishedDate()); // c
    channel.setDocs(syndFeed.getDocs());
    channel.setManagingEditor(syndFeed.getManagingEditor());
    channel.setWebMaster(syndFeed.getWebMaster());
    channel.setGenerator(syndFeed.getGenerator());

    final List<SyndPerson> authors = syndFeed.getAuthors();
    if (Lists.isNotEmpty(authors)) {
        final SyndPerson author = authors.get(0);
        channel.setManagingEditor(author.getName());
    }

    return channel;
}
 
Example #5
Source File: PersonRatingAtomFeedView.java    From ddd-with-spring with Apache License 2.0 6 votes vote down vote up
@Override
protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
	feed.setId("https://github.com/mploed/ddd-with-spring/credit-agency");
	feed.setTitle("Credit Agency Ratings");
	List<Link> alternateLinks = new ArrayList<>();
	Link link = new Link();
	link.setRel("self");
	link.setHref(baseUrl(request) + "feed");
	alternateLinks.add(link);
	List<SyndPerson> authors = new ArrayList<SyndPerson>();
	Person person = new Person();
	person.setName("Big Pug Bank");
	authors.add(person);
	feed.setAuthors(authors);

	feed.setAlternateLinks(alternateLinks);
	feed.setUpdated(personRatingRepository.lastUpdate());
	Content subtitle = new Content();
	subtitle.setValue("List of all valid person ratings");
	feed.setSubtitle(subtitle);
}
 
Example #6
Source File: CreditDecisionAtomFeedView.java    From event-driven-spring-boot with Apache License 2.0 6 votes vote down vote up
@Override
protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
	feed.setId("https://github.com/mploed/event-driven-spring-boot/credit-decision");
	feed.setTitle("Approved Credit Applications");
	List<Link> alternateLinks = new ArrayList<>();
	Link link = new Link();
	link.setRel("self");
	link.setHref(baseUrl(request) + "feed");
	alternateLinks.add(link);
	List<SyndPerson> authors = new ArrayList<SyndPerson>();
	Person person = new Person();
	person.setName("Big Pug Bank");
	authors.add(person);
	feed.setAuthors(authors);

	feed.setAlternateLinks(alternateLinks);
	feed.setUpdated(decisionMemoRepository.lastUpdate());
	Content subtitle = new Content();
	subtitle.setValue("List of all APPROVED credit applications");
	feed.setSubtitle(subtitle);
}
 
Example #7
Source File: OrderAtomFeedView.java    From microservice-atom with Apache License 2.0 6 votes vote down vote up
@Override
protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) {
	feed.setId("tag:ewolff.com/microservice-atom/order");
	feed.setTitle("Order");
	List<Link> alternateLinks = new ArrayList<>();
	Link link = new Link();
	link.setRel("self");
	link.setHref(baseUrl(request) + "feed");
	alternateLinks.add(link);
	List<SyndPerson> authors = new ArrayList<SyndPerson>();
	Person person = new Person();
	person.setName("Big Money Online Commerce Inc.");
	authors.add(person);
	feed.setAuthors(authors);

	feed.setAlternateLinks(alternateLinks);
	feed.setUpdated(orderRepository.lastUpdate());
	Content subtitle = new Content();
	subtitle.setValue("List of all orders");
	feed.setSubtitle(subtitle);
}
 
Example #8
Source File: ConverterForOPML10.java    From rome with Apache License 2.0 5 votes vote down vote up
protected void addOwner(final Opml opml, final SyndFeed syndFeed) {
    if (opml.getOwnerEmail() != null || opml.getOwnerName() != null) {
        final List<SyndPerson> authors = new ArrayList<SyndPerson>();
        final SyndPerson person = new SyndPersonImpl();
        person.setEmail(opml.getOwnerEmail());
        person.setName(opml.getOwnerName());
        authors.add(person);
        syndFeed.setAuthors(authors);
    }
}
 
Example #9
Source File: ConverterForAtom03.java    From rome with Apache License 2.0 5 votes vote down vote up
protected static List<SyndPerson> createSyndPersons(final List<SyndPerson> aPersons) {
    final List<SyndPerson> persons = new ArrayList<SyndPerson>();
    for (final SyndPerson person2 : aPersons) {
        final SyndPerson person = new SyndPersonImpl();
        person.setName(person2.getName());
        person.setUri(person2.getUri());
        person.setEmail(person2.getEmail());
        person.setModules(person2.getModules());
        persons.add(person);
    }
    return persons;
}
 
Example #10
Source File: ConverterForAtom03.java    From rome with Apache License 2.0 5 votes vote down vote up
protected static List<SyndPerson> createAtomPersons(final List<SyndPerson> sPersons) {
    final List<SyndPerson> persons = new ArrayList<SyndPerson>();
    for (final SyndPerson syndPerson : sPersons) {
        final SyndPerson sPerson = syndPerson;
        final Person person = new Person();
        person.setName(sPerson.getName());
        person.setUri(sPerson.getUri());
        person.setEmail(sPerson.getEmail());
        person.setModules(sPerson.getModules());
        persons.add(person);
    }
    return persons;
}
 
Example #11
Source File: AtomEntry.java    From rome with Apache License 2.0 4 votes vote down vote up
Entry copyToRomeEntry(final ClientEntry entry) {
    if (id != null) {
        entry.setId(id);
    }
    entry.setTitle(title);
    if (author != null) {
        final com.rometools.rome.feed.atom.Person person = new com.rometools.rome.feed.atom.Person();
        person.setName(author.getName());
        person.setEmail(author.getEmail());
        person.setUrl(author.getUrl());
        final List<SyndPerson> authors = new ArrayList<SyndPerson>();
        authors.add(person);
        entry.setAuthors(authors);
    }
    if (content != null) {
        final com.rometools.rome.feed.atom.Content romeContent = new com.rometools.rome.feed.atom.Content();
        romeContent.setValue(content.getValue());
        romeContent.setType(content.getType());
        final List<com.rometools.rome.feed.atom.Content> contents = new ArrayList<com.rometools.rome.feed.atom.Content>();
        contents.add(romeContent);
        entry.setContents(contents);
    }
    if (categories != null) {
        final List<com.rometools.rome.feed.atom.Category> romeCats = new ArrayList<com.rometools.rome.feed.atom.Category>();
        for (final Category cat : categories) {
            final com.rometools.rome.feed.atom.Category romeCategory = new com.rometools.rome.feed.atom.Category();
            romeCategory.setTerm(cat.getId());
            romeCategory.setScheme(cat.getUrl());
            romeCategory.setLabel(cat.getName());
            romeCats.add(romeCategory);
        }
        entry.setCategories(romeCats);
    }
    entry.setPublished(publicationDate == null ? new Date() : publicationDate);
    entry.setModified(modificationDate == null ? new Date() : modificationDate);

    final List<Module> modules = new ArrayList<Module>();
    final AppModule control = new AppModuleImpl();
    control.setDraft(new Boolean(draft));
    modules.add(control);
    entry.setModules(modules);

    return entry;
}
 
Example #12
Source File: AtomEntry.java    From rome with Apache License 2.0 4 votes vote down vote up
void copyFromRomeEntry(final ClientEntry entry) {
    id = entry.getId();
    title = entry.getTitle();
    editURI = entry.getEditURI();
    final List<Link> altlinks = entry.getAlternateLinks();
    if (altlinks != null) {
        for (final Link link : altlinks) {
            if ("alternate".equals(link.getRel()) || link.getRel() == null) {
                permalink = link.getHrefResolved();
                break;
            }
        }
    }
    final List<com.rometools.rome.feed.atom.Content> contents = entry.getContents();
    com.rometools.rome.feed.atom.Content romeContent = null;
    if (contents != null && !contents.isEmpty()) {
        romeContent = contents.get(0);
    }
    if (romeContent != null) {
        content = new BlogEntry.Content(romeContent.getValue());
        content.setType(romeContent.getType());
        content.setSrc(romeContent.getSrc());
    }
    if (entry.getCategories() != null) {
        final List<Category> cats = new ArrayList<Category>();
        final List<com.rometools.rome.feed.atom.Category> romeCats = entry.getCategories();
        for (final com.rometools.rome.feed.atom.Category romeCat : romeCats) {
            final BlogEntry.Category cat = new BlogEntry.Category();
            cat.setId(romeCat.getTerm());
            cat.setUrl(romeCat.getScheme());
            cat.setName(romeCat.getLabel());
            cats.add(cat);
        }
        categories = cats;
    }
    final List<SyndPerson> authors = entry.getAuthors();
    if (authors != null && !authors.isEmpty()) {
        final com.rometools.rome.feed.atom.Person romeAuthor = (com.rometools.rome.feed.atom.Person) authors.get(0);
        if (romeAuthor != null) {
            author = new Person();
            author.setName(romeAuthor.getName());
            author.setEmail(romeAuthor.getEmail());
            author.setUrl(romeAuthor.getUrl());
        }
    }
    publicationDate = entry.getPublished();
    modificationDate = entry.getModified();

    final AppModule control = (AppModule) entry.getModule(AppModule.URI);
    if (control != null && control.getDraft() != null) {
        draft = control.getDraft().booleanValue();
    } else {
        draft = false;
    }
}
 
Example #13
Source File: Atom03Parser.java    From rome with Apache License 2.0 4 votes vote down vote up
private Entry parseEntry(final Element eEntry, final Locale locale) {

        final Entry entry = new Entry();

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

        final List<Element> links = eEntry.getChildren("link", getAtomNamespace());
        entry.setAlternateLinks(parseAlternateLinks(links));
        entry.setOtherLinks(parseOtherLinks(links));

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

        final List<Element> contributors = eEntry.getChildren("contributor", getAtomNamespace());
        if (!contributors.isEmpty()) {
            entry.setContributors(parsePersons(contributors));
        }

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

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

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

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

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

        final List<Element> contents = eEntry.getChildren("content", getAtomNamespace());
        if (!contents.isEmpty()) {
            final List<Content> content = new ArrayList<Content>();
            for (final Element eContent : contents) {
                content.add(parseContent(eContent));
            }
            entry.setContents(content);
        }

        entry.setModules(parseItemModules(eEntry, locale));

        final List<Element> foreignMarkup = extractForeignMarkup(eEntry, entry, getAtomNamespace());
        if (!foreignMarkup.isEmpty()) {
            entry.setForeignMarkup(foreignMarkup);
        }

        return entry;

    }
 
Example #14
Source File: Atom03Parser.java    From rome with Apache License 2.0 4 votes vote down vote up
protected WireFeed parseFeed(final Element eFeed, final Locale locale) {

        final String type = getType();
        final Document document = eFeed.getDocument();
        final String styleSheet = getStyleSheet(document);

        final Feed feed = new Feed(type);
        feed.setStyleSheet(styleSheet);

        final Element title = eFeed.getChild("title", getAtomNamespace());
        if (title != null) {
            feed.setTitleEx(parseContent(title));
        }

        final List<Element> links = eFeed.getChildren("link", getAtomNamespace());
        feed.setAlternateLinks(parseAlternateLinks(links));
        feed.setOtherLinks(parseOtherLinks(links));

        final Element author = eFeed.getChild("author", getAtomNamespace());
        if (author != null) {
            final List<SyndPerson> authors = new ArrayList<SyndPerson>();
            authors.add(parsePerson(author));
            feed.setAuthors(authors);
        }

        final List<Element> contributors = eFeed.getChildren("contributor", getAtomNamespace());
        if (!contributors.isEmpty()) {
            feed.setContributors(parsePersons(contributors));
        }

        final Element tagline = eFeed.getChild("tagline", getAtomNamespace());
        if (tagline != null) {
            feed.setTagline(parseContent(tagline));
        }

        final Element id = eFeed.getChild("id", getAtomNamespace());
        if (id != null) {
            feed.setId(id.getText());
        }

        final Element generator = eFeed.getChild("generator", getAtomNamespace());
        if (generator != null) {
            final Generator gen = new Generator();
            gen.setValue(generator.getText());
            String att = getAttributeValue(generator, "url");
            if (att != null) {
                gen.setUrl(att);
            }
            att = getAttributeValue(generator, "version");
            if (att != null) {
                gen.setVersion(att);
            }
            feed.setGenerator(gen);
        }

        final Element copyright = eFeed.getChild("copyright", getAtomNamespace());
        if (copyright != null) {
            feed.setCopyright(copyright.getText());
        }

        final Element info = eFeed.getChild("info", getAtomNamespace());
        if (info != null) {
            feed.setInfo(parseContent(info));
        }

        final Element modified = eFeed.getChild("modified", getAtomNamespace());
        if (modified != null) {
            feed.setModified(DateParser.parseDate(modified.getText(), locale));
        }

        feed.setModules(parseFeedModules(eFeed, locale));

        final List<Element> entries = eFeed.getChildren("entry", getAtomNamespace());
        if (!entries.isEmpty()) {
            feed.setEntries(parseEntries(entries, locale));
        }

        final List<Element> foreignMarkup = extractForeignMarkup(eFeed, feed, getAtomNamespace());
        if (!foreignMarkup.isEmpty()) {
            feed.setForeignMarkup(foreignMarkup);
        }

        return feed;

    }
 
Example #15
Source File: Atom10Parser.java    From rome with Apache License 2.0 3 votes vote down vote up
private List<SyndPerson> parsePersons(final String baseURI, final List<Element> ePersons, final Locale locale) {

        final List<SyndPerson> persons = new ArrayList<SyndPerson>();
        for (final Element ePerson : ePersons) {
            persons.add(parsePerson(baseURI, ePerson, locale));
        }

        return Lists.emptyToNull(persons);

    }
 
Example #16
Source File: Atom03Parser.java    From rome with Apache License 2.0 3 votes vote down vote up
private List<SyndPerson> parsePersons(final List<Element> ePersons) {

        final List<SyndPerson> persons = new ArrayList<SyndPerson>();

        for (final Element person : ePersons) {
            persons.add(parsePerson(person));
        }

        return Lists.emptyToNull(persons);

    }
 
Example #17
Source File: Feed.java    From rome with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the feed contributors.
 * <p>
 *
 * @param contributors the list of Person elements with the feed contributors to set, an empty
 *            list or <b>null</b> if none.
 *
 */
public void setContributors(final List<SyndPerson> contributors) {
    this.contributors = contributors;
}
 
Example #18
Source File: Feed.java    From rome with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the feed contributors.
 * <p>
 *
 * @return a list of Person elements with the feed contributors, an empty list if none.
 *
 */
public List<SyndPerson> getContributors() {
    return contributors = Lists.createWhenNull(contributors);
}
 
Example #19
Source File: Feed.java    From rome with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the feed author.
 * <p>
 *
 * @param authors the feed author to set, <b>null</b> if none.
 *
 */
public void setAuthors(final List<SyndPerson> authors) {
    this.authors = authors;
}
 
Example #20
Source File: Feed.java    From rome with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the feed author.
 * <p>
 *
 * @return the feed author, <b>null</b> if none.
 *
 */
public List<SyndPerson> getAuthors() {
    return authors = Lists.createWhenNull(authors);
}
 
Example #21
Source File: Entry.java    From rome with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the entry contributors.
 * <p>
 *
 * @return a list of Person elements with the entry contributors, an empty list if none.
 *
 */
public List<SyndPerson> getContributors() {
    return contributors = Lists.createWhenNull(contributors);
}
 
Example #22
Source File: Entry.java    From rome with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the entry contributors.
 * <p>
 *
 * @param contributors the list of Person elements with the entry contributors to set, an empty
 *            list or <b>null</b> if none.
 *
 */
public void setContributors(final List<SyndPerson> contributors) {
    this.contributors = contributors;
}
 
Example #23
Source File: Entry.java    From rome with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the entry author.
 * <p>
 *
 * @return the entry author, <b>null</b> if none.
 *
 */
public List<SyndPerson> getAuthors() {
    return authors = Lists.createWhenNull(authors);
}
 
Example #24
Source File: Entry.java    From rome with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the author of the entry.
 * <p>
 *
 * @param authors the author of the entry, <b>null</b> if none.
 *
 */
public void setAuthors(final List<SyndPerson> authors) {
    this.authors = authors;
}