Search in sources :

Example 1 with Link

use of com.rometools.rome.feed.atom.Link in project wombat by PLOS.

the class AbstractFeedView method createAtomLink.

protected static Link createAtomLink(String href, String title, Optional<String> rel, Optional<String> mimetype) {
    Link link = new Link();
    link.setHref(href);
    link.setTitle(title);
    rel.ifPresent(link::setRel);
    mimetype.ifPresent(link::setType);
    return link;
}
Also used : Link(com.rometools.rome.feed.atom.Link)

Example 2 with Link

use of com.rometools.rome.feed.atom.Link in project wombat by PLOS.

the class ArticleFeedView method buildLinks.

private ImmutableList<Link> buildLinks(FeedMetadata feedMetadata, Map<String, ?> article) {
    String articleId = (String) article.get("id");
    String title = getArticleTitle(article);
    Link articleLink = createAtomLink(getArticleLink(feedMetadata, article), title, Optional.empty(), Optional.empty());
    Link pdfLink = createAtomLink(feedMetadata.buildLink(link -> link.toPattern(requestMappingContextDictionary, "asset").addQueryParameter("id", articleId + ".PDF").build()), "(PDF) " + title, Optional.of("related"), Optional.of("application/pdf"));
    Link xmlLink = createAtomLink(feedMetadata.buildLink(link -> link.toPattern(requestMappingContextDictionary, "asset").addQueryParameter("id", articleId + ".XML").build()), "(XML) " + title, Optional.of("related"), Optional.of("text/xml"));
    return ImmutableList.of(articleLink, pdfLink, xmlLink);
}
Also used : Iterables(com.google.common.collect.Iterables) Link(com.rometools.rome.feed.atom.Link) Guid(com.rometools.rome.feed.rss.Guid) Description(com.rometools.rome.feed.rss.Description) RequestMappingContextDictionary(org.ambraproject.wombat.config.site.RequestMappingContextDictionary) Date(java.util.Date) Autowired(org.springframework.beans.factory.annotation.Autowired) SimpleDateFormat(java.text.SimpleDateFormat) Collectors(java.util.stream.Collectors) Content(com.rometools.rome.feed.atom.Content) Item(com.rometools.rome.feed.rss.Item) Entry(com.rometools.rome.feed.atom.Entry) Strings(com.google.common.base.Strings) List(java.util.List) Calendar(java.util.Calendar) ImmutableList(com.google.common.collect.ImmutableList) Locale(java.util.Locale) Map(java.util.Map) LocalTime(java.time.LocalTime) Optional(java.util.Optional) ParseException(java.text.ParseException) Joiner(com.google.common.base.Joiner) Link(com.rometools.rome.feed.atom.Link)

Example 3 with Link

use of com.rometools.rome.feed.atom.Link in project wombat by PLOS.

the class CommentFeedView method createAtomEntry.

@Override
protected Entry createAtomEntry(FeedMetadata feedMetadata, Map<String, Object> comment) {
    Map<String, Object> article = (Map<String, Object>) comment.get("article");
    String commentId = (String) comment.get("commentUri");
    String commentTitle = (String) comment.get("title");
    Entry entry = new Entry();
    entry.setId(commentId);
    entry.setTitle(commentTitle);
    entry.setAuthors(ImmutableList.of(createAtomPerson(getCreatorDisplayName(comment))));
    createAtomCategory(comment).map(ImmutableList::of).ifPresent(entry::setCategories);
    Link commentLink = createAtomLink(getCommentUrl(feedMetadata, commentId), commentTitle, Optional.empty(), Optional.empty());
    Link articleLink = createAtomLink(getArticleUrl(feedMetadata, article), (String) article.get("title"), Optional.of("related"), Optional.empty());
    entry.setAlternateLinks(ImmutableList.of(commentLink, articleLink));
    Date lastModified = getCommentDate(comment);
    entry.setPublished(lastModified);
    entry.setUpdated(lastModified);
    com.rometools.rome.feed.atom.Content content = new com.rometools.rome.feed.atom.Content();
    content.setType(com.rometools.rome.feed.atom.Content.HTML);
    content.setValue(createCommentHtml(feedMetadata, comment));
    entry.setContents(ImmutableList.of(content));
    return entry;
}
Also used : Date(java.util.Date) Entry(com.rometools.rome.feed.atom.Entry) Map(java.util.Map) Link(com.rometools.rome.feed.atom.Link)

Aggregations

Link (com.rometools.rome.feed.atom.Link)3 Entry (com.rometools.rome.feed.atom.Entry)2 Date (java.util.Date)2 Map (java.util.Map)2 Joiner (com.google.common.base.Joiner)1 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 Iterables (com.google.common.collect.Iterables)1 Content (com.rometools.rome.feed.atom.Content)1 Description (com.rometools.rome.feed.rss.Description)1 Guid (com.rometools.rome.feed.rss.Guid)1 Item (com.rometools.rome.feed.rss.Item)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 LocalTime (java.time.LocalTime)1 Calendar (java.util.Calendar)1 List (java.util.List)1 Locale (java.util.Locale)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1