use of com.sun.syndication.io.FeedException in project eol-globi-data by jhpoelen.
the class StudyImporterForArthopodEasyCapture method getStudyImportersForRSSFeed.
public static List<StudyImporter> getStudyImportersForRSSFeed(Dataset datasetOrig, ParserFactory parserFactory, NodeFactory nodeFactory) throws StudyImporterException {
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed;
String rss = getRss(datasetOrig);
try {
feed = input.build(new XmlReader(new URL(rss)));
} catch (FeedException | IOException e) {
throw new StudyImporterException("failed to read rss feed [" + rss + "]", e);
}
List<StudyImporter> importers = new ArrayList<StudyImporter>();
final List entries = feed.getEntries();
for (Object entry : entries) {
if (entry instanceof SyndEntry) {
SyndEntry syndEntry = (SyndEntry) entry;
Dataset dataset = embeddedDatasetFor(datasetOrig, StringUtils.trim(syndEntry.getDescription().getValue()), URI.create(StringUtils.trim(syndEntry.getLink())));
final StudyImporterForSeltmann studyImporter = new StudyImporterForSeltmann(parserFactory, nodeFactory);
studyImporter.setDataset(dataset);
importers.add(studyImporter);
}
}
return importers;
}
use of com.sun.syndication.io.FeedException in project maven-plugins by apache.
the class FeedGenerator method export.
/**
* Extract a feed and export it to a Writer.
*
* @param releases the List of Releases. Only the last release is used in the feed.
* @param feedType The type of the feed to generate. See {@link #isSupportedFeedType(java.lang.String)} for
* supported values.
* @param writer a Writer. Note that this is not flushed nor closed upon exit.
* @throws IOException if an error occurs during export.
*/
public void export(final List<Release> releases, final String feedType, final Writer writer) throws IOException {
feed.setFeedType(feedType);
feed.setTitle(title);
feed.setAuthor(author);
feed.setPublishedDate(new Date());
feed.setLink(link);
feed.setDescription(rbundle.getString("report.changes.text.rssfeed.description"));
feed.setLanguage(rbundle.getLocale().getLanguage());
// feed.setCopyright( );
// feed.setEncoding();
feed.setEntries(getEntries(releases));
try {
new SyndFeedOutput().output(feed, writer);
} catch (FeedException ex) {
IOException ioex = new IOException(ex.getMessage());
ioex.initCause(ex);
throw ioex;
}
}
use of com.sun.syndication.io.FeedException in project jersey by jersey.
the class FeedEntriesAtomBodyWriter method writeSyndFeed.
private void writeSyndFeed(OutputStream entityStream, SyndFeed feed) {
try {
OutputStreamWriter writer = new OutputStreamWriter(entityStream);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, writer);
writer.close();
} catch (FeedException | IOException e) {
LOG.warn("An error occurred during writing a synd feed.", e);
}
}
use of com.sun.syndication.io.FeedException in project xwiki-platform by xwiki.
the class RSSValidator method validate.
@Override
protected void validate(Document document) {
try {
SyndFeedInput input = new SyndFeedInput();
input.build(getDocument());
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (FeedException e) {
if (e instanceof ParsingFeedException) {
ParsingFeedException pfe = (ParsingFeedException) e;
addError(Type.ERROR, pfe.getLineNumber(), pfe.getColumnNumber(), e.getMessage());
} else {
addError(Type.ERROR, -1, -1, e.getMessage());
}
}
}
use of com.sun.syndication.io.FeedException in project liferay-ide by liferay.
the class KBArticleServiceImpl method exportToRSS.
protected String exportToRSS(String rssDisplayStyle, String rssFormat, String name, String description, String feedURL, List<KBArticle> kbArticles, ThemeDisplay themeDisplay) throws SystemException {
SyndFeed syndFeed = new SyndFeedImpl();
syndFeed.setDescription(description);
List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
syndFeed.setEntries(syndEntries);
for (KBArticle kbArticle : kbArticles) {
SyndEntry syndEntry = new SyndEntryImpl();
String author = PortalUtil.getUserName(kbArticle);
syndEntry.setAuthor(author);
SyndContent syndContent = new SyndContentImpl();
syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);
String value = null;
if (rssDisplayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
value = HtmlUtil.extractText(kbArticle.getDescription());
if (Validator.isNull(value)) {
value = StringUtil.shorten(HtmlUtil.extractText(kbArticle.getContent()), 200);
}
} else if (rssDisplayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
value = StringPool.BLANK;
} else {
value = StringUtil.replace(kbArticle.getContent(), new String[] { "href=\"/", "src=\"/" }, new String[] { "href=\"" + themeDisplay.getURLPortal() + "/", "src=\"" + themeDisplay.getURLPortal() + "/" });
}
syndContent.setValue(value);
syndEntry.setDescription(syndContent);
String link = KnowledgeBaseUtil.getKBArticleURL(themeDisplay.getPlid(), kbArticle.getResourcePrimKey(), kbArticle.getStatus(), themeDisplay.getPortalURL(), false);
syndEntry.setLink(link);
syndEntry.setPublishedDate(kbArticle.getCreateDate());
syndEntry.setTitle(kbArticle.getTitle());
syndEntry.setUpdatedDate(kbArticle.getModifiedDate());
syndEntry.setUri(syndEntry.getLink());
syndEntries.add(syndEntry);
}
String feedType = RSSUtil.getFeedType(RSSUtil.getFormatType(rssFormat), RSSUtil.getFormatVersion(rssFormat));
syndFeed.setFeedType(feedType);
List<SyndLink> syndLinks = new ArrayList<SyndLink>();
syndFeed.setLinks(syndLinks);
SyndLink selfSyndLink = new SyndLinkImpl();
syndLinks.add(selfSyndLink);
selfSyndLink.setHref(feedURL);
selfSyndLink.setRel("self");
syndFeed.setPublishedDate(new Date());
syndFeed.setTitle(name);
syndFeed.setUri(feedURL);
try {
return RSSUtil.export(syndFeed);
} catch (FeedException fe) {
throw new SystemException(fe);
}
}
Aggregations