use of com.rometools.rome.feed.synd.SyndContentImpl in project wildfly-camel by wildfly-extras.
the class RSSFeedServlet method createFeedEntry.
private SyndEntry createFeedEntry(String title, String content, int index) {
SyndEntry entry = new SyndEntryImpl();
entry.setTitle(title + index);
entry.setLink("http://localhost:8080/rss-tests/" + index);
entry.setPublishedDate(new Date());
SyndContent description = new SyndContentImpl();
description.setType("text/plain");
description.setValue(content + index);
entry.setDescription(description);
return entry;
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project rubia-forums by flashboss.
the class FeedsServlet method getEntry.
private SyndEntry getEntry(PostBean post, String url, String urlType) {
SyndEntry entry;
SyndContent description;
entry = new SyndEntryImpl();
entry.setTitle(post.getMessage().getSubject() + BY + post.getPoster().getUserId());
entry.setLink(postLink(post.getId().toString(), url, urlType));
entry.setPublishedDate(post.getCreateDate());
description = new SyndContentImpl();
description.setType("text/html");
String text = post.getMessage().getText();
description.setValue(post.getMessage().getHTMLEnabled() ? escapeHtml4(text) : text);
entry.setDescription(description);
return entry;
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project haikudepotserver by haiku.
the class CreatedUserRatingSyndEntrySupplier method generate.
@Override
public List<SyndEntry> generate(final FeedSpecification specification) {
Preconditions.checkNotNull(specification);
if (specification.getSupplierTypes().contains(FeedSpecification.SupplierType.CREATEDUSERRATING)) {
if (null != specification.getPkgNames() && specification.getPkgNames().isEmpty()) {
return Collections.emptyList();
}
ObjectSelect<UserRating> objectSelect = ObjectSelect.query(UserRating.class).where(UserRating.ACTIVE.isTrue()).and(UserRating.PKG_VERSION.dot(PkgVersion.ACTIVE).isTrue()).and(UserRating.PKG_VERSION.dot(PkgVersion.PKG).dot(Pkg.ACTIVE).isTrue()).statementFetchSize(specification.getLimit()).orderBy(UserRating.CREATE_TIMESTAMP.desc());
if (null != specification.getPkgNames()) {
objectSelect.and(UserRating.PKG_VERSION.dot(PkgVersion.PKG).dot(Pkg.NAME).in(specification.getPkgNames()));
}
ObjectContext context = serverRuntime.newContext();
List<UserRating> userRatings = objectSelect.select(serverRuntime.newContext());
NaturalLanguage naturalLanguage = deriveNaturalLanguage(context, specification);
return userRatings.stream().map(ur -> {
SyndEntry entry = new SyndEntryImpl();
entry.setPublishedDate(ur.getCreateTimestamp());
entry.setUpdatedDate(ur.getModifyTimestamp());
entry.setAuthor(ur.getUser().getNickname());
entry.setUri(URI_PREFIX + Hashing.sha1().hashUnencodedChars(String.format("%s_::_%s_::_%s_::_%s", this.getClass().getCanonicalName(), ur.getPkgVersion().getPkg().getName(), ur.getPkgVersion().toVersionCoordinates().toString(), ur.getUser().getNickname())).toString());
entry.setLink(String.format("%s/#!/userrating/%s", baseUrl, ur.getCode()));
ResolvedPkgVersionLocalization resolvedPkgVersionLocalization = pkgLocalizationService.resolvePkgVersionLocalization(context, ur.getPkgVersion(), null, naturalLanguage);
entry.setTitle(messageSource.getMessage("feed.createdUserRating.atom.title", new Object[] { Optional.ofNullable(resolvedPkgVersionLocalization.getTitle()).orElse(ur.getPkgVersion().getPkg().getName()), ur.getUser().getNickname() }, new Locale(specification.getNaturalLanguageCode())));
String contentString = ur.getComment();
if (null != contentString && contentString.length() > CONTENT_LENGTH) {
contentString = contentString.substring(0, CONTENT_LENGTH) + "...";
}
if (null != ur.getRating()) {
contentString = buildRatingIndicator(ur.getRating()) + (Strings.isNullOrEmpty(contentString) ? "" : " -- " + contentString);
}
SyndContentImpl content = new SyndContentImpl();
content.setType(MediaType.PLAIN_TEXT_UTF_8.type());
content.setValue(contentString);
entry.setDescription(content);
return entry;
}).collect(Collectors.toList());
}
return Collections.emptyList();
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project opencast by opencast.
the class RomeRssFeed method toRomeContent.
/**
* Converts the content to a <code>ROME</code> object.
*
* @param content
* original content
* @return <code>ROME</code> content object
*/
private SyndContent toRomeContent(Content content) {
if (content == null) {
return null;
}
SyndContentImpl romeContent = new SyndContentImpl();
romeContent.setMode(content.getMode().toString().toLowerCase());
romeContent.setType(content.getType());
romeContent.setValue(content.getValue());
return romeContent;
}
use of com.rometools.rome.feed.synd.SyndContentImpl in project coffeenet-frontpage-plugin-rss by coffeenet.
the class FeedParserTest method parseBlogAtom.
@Test
public void parseBlogAtom() throws FeedException, IOException {
SyndContentImpl content = new SyndContentImpl();
content.setValue("content");
SyndEntryImpl syndEntry = new SyndEntryImpl();
syndEntry.setContents(singletonList(content));
syndEntry.setPublishedDate(getDate());
final SyndImageImpl image = new SyndImageImpl();
image.setUrl("http://this-is-a-test-url.coffee");
SyndFeed result = new SyndFeedImpl();
result.setImage(image);
result.setEntries(singletonList(syndEntry));
when(feedFactory.build(any(URL.class))).thenReturn(result);
FeedDto feedDto = sut.parse("http://blog/feed/", 10, 150);
assertThat(feedDto.getImage().getUrl(), is("http://this-is-a-test-url.coffee"));
List<FeedEntryDto> blogEntries = feedDto.getEntries();
assertThat(blogEntries, hasSize(1));
assertThat(blogEntries.get(0).getDescription(), is("content"));
assertThat(blogEntries.get(0).getGregorianPublishedDate(), is("2014-12-03 10:15"));
assertThat(blogEntries.get(0).getUserSeenPublishedDate(), is("3. December 2014"));
}
Aggregations