public void callback(final String callbackPath, final SyndFeed feed) { if (!callbackPath.startsWith(callbackPrefix)) { throw new HttpStatusCodeException(404, "Not a valid callback prefix.", new Exception(callbackPath + " doesnt start with " + callbackPrefix)); } final String id = callbackPath.substring(callbackPrefix.length()); LOG.debug("Got callback for {}", id); final Subscription s = dao.findById(id); if (s == null) { throw new HttpStatusCodeException(404, "Not a valid callback.", null); } validateLink(feed, s.getSourceUrl()); SyndFeedInfo info = null; URL url = null; try { url = new URL(s.getSourceUrl()); info = cache.getFeedInfo(url); } catch (final MalformedURLException ex) { LOG.error("Malformed URL", ex); } if (info == null) { info = new SyndFeedInfo(); info.setId(s.getId()); info.setUrl(url); } info.setLastModified(System.currentTimeMillis()); info.setSyndFeed(feed); cache.setFeedInfo(url, info); s.getCallback().onNotify(s, info); }
public void callback(final String callbackPath, final SyndFeed feed) { if (!callbackPath.startsWith(callbackPrefix)) { throw new HttpStatusCodeException(404, "Not a valid callback prefix.", new Exception(callbackPath + " doesnt start with " + callbackPrefix)); } final String id = callbackPath.substring(callbackPrefix.length()); LOG.debug("Got callback for {}", id); final Subscription s = dao.findById(id); if (s == null) { throw new HttpStatusCodeException(404, "Not a valid callback.", null); } validateLink(feed, s.getSourceUrl()); SyndFeedInfo info = null; URL url = null; try { url = new URL(s.getSourceUrl()); info = cache.getFeedInfo(url); } catch (final MalformedURLException ex) { LOG.error("Malformed URL", ex); } if (info == null) { info = new SyndFeedInfo(); info.setId(s.getId()); info.setUrl(url); } info.setLastModified(System.currentTimeMillis()); info.setSyndFeed(feed); cache.setFeedInfo(url, info); s.getCallback().onNotify(s, info); }
syndFeedInfo.setLastModified(connection.getLastModified());
syndFeedInfo.setLastModified(lastModifiedHeader.getValue());
private void refreshFeedInfo(URL feedUrl, com.rometools.fetcher.impl.SyndFeedInfo syndFeedInfo, URLConnection connection) throws IOException, FeedException { // need to always set the URL because this may have changed due to 3xx redirects syndFeedInfo.setUrl(connection.getURL()); // the ID is a persistent value that should stay the same // even if the URL for the feed changes (eg, by 3xx redirects) syndFeedInfo.setId(feedUrl.toString()); // This will be 0 if the server doesn't support or isn't setting the last modified header syndFeedInfo.setLastModified(connection.getLastModified()); // get the contents InputStream inputStream = null; try { inputStream = connection.getInputStream(); SyndFeed syndFeed = this.readFeedFromStream(inputStream, connection); syndFeedInfo.setSyndFeed(syndFeed); } finally { try { inputStream.close(); } catch (Exception e) { // ignore } } }