use of com.sun.syndication.io.SyndFeedInput in project eclipse-integration-commons by spring-projects.
the class CachedFeedsManager method readCachedFeeds.
public void readCachedFeeds(IProgressMonitor monitor) throws FeedException {
SyndFeedInput input = new SyndFeedInput();
File[] cachedFiles = getCachedFeeds();
for (File cachedFile : cachedFiles) {
String fileName = cachedFile.getName().replaceAll(".xml", "");
String iconPath = hashedFeedsToIconsMap.get(fileName);
try {
reader.readFeeds(new FileReader(cachedFile), input, iconPath);
} catch (FileNotFoundException e) {
StatusHandler.log(new Status(IStatus.ERROR, IdeUiPlugin.PLUGIN_ID, "An unexpected error occurred while retrieving feed content from cache.", e));
}
}
}
use of com.sun.syndication.io.SyndFeedInput in project UniversalMediaServer by UniversalMediaServer.
the class Feed method parse.
@SuppressWarnings("unchecked")
public void parse() throws Exception {
SyndFeedInput input = new SyndFeedInput();
byte[] b = downloadAndSendBinary(url);
if (b != null) {
SyndFeed feed = input.build(new XmlReader(new ByteArrayInputStream(b)));
name = feed.getTitle();
if (feed.getCategories() != null && feed.getCategories().size() > 0) {
SyndCategory category = (SyndCategory) feed.getCategories().get(0);
tempCategory = category.getName();
}
List<SyndEntry> entries = feed.getEntries();
for (SyndEntry entry : entries) {
tempItemTitle = entry.getTitle();
tempItemLink = entry.getLink();
tempFeedLink = entry.getUri();
tempItemThumbURL = null;
ArrayList<Element> elements = (ArrayList<Element>) entry.getForeignMarkup();
for (Element elt : elements) {
if ("group".equals(elt.getName()) && "media".equals(elt.getNamespacePrefix())) {
List<Content> subElts = elt.getContent();
for (Content subelt : subElts) {
if (subelt instanceof Element) {
parseElement((Element) subelt, false);
}
}
}
parseElement(elt, true);
}
List<SyndEnclosure> enclosures = entry.getEnclosures();
for (SyndEnclosure enc : enclosures) {
if (StringUtils.isNotBlank(enc.getUrl())) {
tempItemLink = enc.getUrl();
}
}
manageItem();
}
}
setLastModified(System.currentTimeMillis());
}
use of com.sun.syndication.io.SyndFeedInput in project xwiki-platform by xwiki.
the class DefaultRomeFeedFactory method createFeed.
@Override
public SyndFeed createFeed(RssMacroParameters parameters) throws MacroExecutionException {
if (StringUtils.isEmpty(parameters.getFeed())) {
throw new MacroExecutionException("The required 'feed' parameter is missing");
}
SyndFeedInput syndFeedInput = new SyndFeedInput();
SyndFeed feed;
try {
if (StringUtils.startsWith(parameters.getFeed().toLowerCase(), "https")) {
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) parameters.getFeedURL().openConnection();
httpsURLConnection.setConnectTimeout(TIMEOUT_MILLISECONDS);
httpsURLConnection.setRequestProperty(USER_AGENT_HEADER, USER_AGENT);
feed = syndFeedInput.build(new XmlReader(httpsURLConnection.getInputStream(), true, parameters.getEncoding()));
} else {
URLConnection httpURLConnection = parameters.getFeedURL().openConnection();
httpURLConnection.setConnectTimeout(TIMEOUT_MILLISECONDS);
httpURLConnection.setRequestProperty(USER_AGENT_HEADER, USER_AGENT);
feed = syndFeedInput.build(new XmlReader(httpURLConnection.getInputStream(), true, parameters.getEncoding()));
}
} catch (SocketTimeoutException ex) {
throw new MacroExecutionException(MessageFormat.format("Connection timeout when trying to reach [{0}]", parameters.getFeedURL()));
} catch (Exception ex) {
throw new MacroExecutionException(MessageFormat.format("Error processing [{0}] : {1}", parameters.getFeedURL(), ex.getMessage()), ex);
}
if (feed == null) {
throw new MacroExecutionException(MessageFormat.format("No feed found at [{0}]", parameters.getFeedURL()));
}
return feed;
}
use of com.sun.syndication.io.SyndFeedInput 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.SyndFeedInput in project play-cookbook by spinscale.
the class FeedTest method getFeed.
private SyndFeed getFeed(Response response) throws Exception {
SyndFeedInput input = new SyndFeedInput();
InputSource s = new InputSource(IOUtils.toInputStream(getContent(response)));
return input.build(s);
}
Aggregations