Search in sources :

Example 6 with SyndContentImpl

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;
}
Also used : SyndContent(com.rometools.rome.feed.synd.SyndContent) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) Date(java.util.Date)

Example 7 with SyndContentImpl

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;
}
Also used : SyndContent(com.rometools.rome.feed.synd.SyndContent) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl)

Example 8 with SyndContentImpl

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();
}
Also used : UserRating(org.haiku.haikudepotserver.dataobjects.UserRating) ObjectContext(org.apache.cayenne.ObjectContext) Hashing(com.google.common.hash.Hashing) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) StringUtils(org.apache.commons.lang3.StringUtils) FeedSpecification(org.haiku.haikudepotserver.feed.model.FeedSpecification) Value(org.springframework.beans.factory.annotation.Value) Strings(com.google.common.base.Strings) PkgVersion(org.haiku.haikudepotserver.dataobjects.PkgVersion) Locale(java.util.Locale) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) MessageSource(org.springframework.context.MessageSource) MediaType(com.google.common.net.MediaType) Pkg(org.haiku.haikudepotserver.dataobjects.Pkg) ResolvedPkgVersionLocalization(org.haiku.haikudepotserver.pkg.model.ResolvedPkgVersionLocalization) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) NaturalLanguage(org.haiku.haikudepotserver.dataobjects.NaturalLanguage) UserRating(org.haiku.haikudepotserver.dataobjects.UserRating) SyndEntrySupplier(org.haiku.haikudepotserver.feed.model.SyndEntrySupplier) Collectors(java.util.stream.Collectors) Component(org.springframework.stereotype.Component) List(java.util.List) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) ObjectSelect(org.apache.cayenne.query.ObjectSelect) PkgLocalizationService(org.haiku.haikudepotserver.pkg.model.PkgLocalizationService) ServerRuntime(org.apache.cayenne.configuration.server.ServerRuntime) Collections(java.util.Collections) Locale(java.util.Locale) ResolvedPkgVersionLocalization(org.haiku.haikudepotserver.pkg.model.ResolvedPkgVersionLocalization) SyndEntry(com.rometools.rome.feed.synd.SyndEntry) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) ObjectContext(org.apache.cayenne.ObjectContext) NaturalLanguage(org.haiku.haikudepotserver.dataobjects.NaturalLanguage)

Example 9 with SyndContentImpl

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;
}
Also used : SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl)

Example 10 with SyndContentImpl

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"));
}
Also used : SyndFeed(com.rometools.rome.feed.synd.SyndFeed) SyndImageImpl(com.rometools.rome.feed.synd.SyndImageImpl) SyndContentImpl(com.rometools.rome.feed.synd.SyndContentImpl) SyndEntryImpl(com.rometools.rome.feed.synd.SyndEntryImpl) SyndFeedImpl(com.rometools.rome.feed.synd.SyndFeedImpl) URL(java.net.URL) Test(org.junit.Test)

Aggregations

SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)32 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)28 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)26 SyndContent (com.rometools.rome.feed.synd.SyndContent)24 SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)15 ArrayList (java.util.ArrayList)14 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)13 SyndFeedOutput (com.rometools.rome.io.SyndFeedOutput)5 StatusGroup (org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup)4 StatusItem (org.onebusaway.enterprise.webapp.actions.status.model.StatusItem)4 SyndCategory (com.rometools.rome.feed.synd.SyndCategory)3 SyndImageImpl (com.rometools.rome.feed.synd.SyndImageImpl)3 SProject (org.bimserver.interfaces.objects.SProject)3 Preconditions (com.google.common.base.Preconditions)2 Hashing (com.google.common.hash.Hashing)2 MediaType (com.google.common.net.MediaType)2 SyndCategoryImpl (com.rometools.rome.feed.synd.SyndCategoryImpl)2 SyndImage (com.rometools.rome.feed.synd.SyndImage)2 SyndPerson (com.rometools.rome.feed.synd.SyndPerson)2 SyndPersonImpl (com.rometools.rome.feed.synd.SyndPersonImpl)2