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;
}
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);
}
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;
}
Aggregations