Search in sources :

Example 1 with RequestMappingContextDictionary

use of org.ambraproject.wombat.config.site.RequestMappingContextDictionary 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)

Aggregations

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 Entry (com.rometools.rome.feed.atom.Entry)1 Link (com.rometools.rome.feed.atom.Link)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 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1