private SyndFeed getFeed(final SyndFeedInfo syndFeedInfo, final String urlStr, final HttpMethod method, final int statusCode) throws IOException, HttpException, FetcherException, FeedException { if (statusCode == HttpURLConnection.HTTP_NOT_MODIFIED && syndFeedInfo != null) { fireEvent(FetcherEvent.EVENT_TYPE_FEED_UNCHANGED, urlStr); return syndFeedInfo.getSyndFeed(); } final SyndFeed feed = retrieveFeed(urlStr, method); fireEvent(FetcherEvent.EVENT_TYPE_FEED_RETRIEVED, urlStr, feed); return feed; }
/** * @param eventType The event type to fire * @param urlStr the current url as a string */ protected void fireEvent(final String eventType, final String urlStr) { fireEvent(eventType, urlStr, null); }
@Override public SyndFeedInfo getFeedInfo(final URL url) { final String fileName = generateFilename(url); return getFeedInfo(fileName); }
public DeltaSyndFeedInfo(final SyndFeedInfo backingFeedInfo) { setETag(backingFeedInfo.getETag()); setId(backingFeedInfo.getId()); setLastModified(backingFeedInfo.getLastModified()); setSyndFeed(backingFeedInfo.getSyndFeed()); }
protected void retrieveAndCacheFeed(final URL feedUrl, final SyndFeedInfo syndFeedInfo, final HttpURLConnection connection) throws IllegalArgumentException, FeedException, FetcherException, IOException { handleErrorCodes(connection.getResponseCode()); resetFeedInfo(feedUrl, syndFeedInfo, connection); final FeedFetcherCache cache = getFeedInfoCache(); // resetting feed info in the cache // could be needed for some implementations // of FeedFetcherCache (eg, distributed HashTables) if (cache != null) { cache.setFeedInfo(feedUrl, syndFeedInfo); } }
@Override public SyndFeedInfo getFeedInfo(final URL feedUrl) { return backingCache.getFeedInfo(feedUrl); }
private SyndFeed getSyndFeedFromStream(final InputStream inputStream, final URLConnection connection) throws IOException, IllegalArgumentException, FeedException { final SyndFeed feed = readSyndFeedFromStream(inputStream, connection); fireEvent(FetcherEvent.EVENT_TYPE_FEED_RETRIEVED, connection, feed); return feed; }
@Override protected boolean removeEldestEntry(final Map.Entry<String, SyndFeedInfo> eldest) { return size() > getMaxEntries(); }
@Override public SyndFeed retrieveFeed(final URL url) throws IllegalArgumentException, IOException, FeedException, FetcherException { return this.retrieveFeed(getUserAgent(), url); }
@Override public SyndFeed retrieveFeed(final URL feedUrl) throws IllegalArgumentException, IOException, FeedException, FetcherException { return this.retrieveFeed(getUserAgent(), feedUrl); }
public SimpleRSSFeedFetcher() { this.feedInfoCache = HashMapFeedInfoCache.getInstance(); }
/** * <p> * Constructor for HashMapFeedInfoCache * </p> * * <p> * Only use this if you want multiple instances of the cache. Usually getInstance() is more * appropriate. * </p> * */ public HashMapFeedInfoCache() { setInfoCache(createInfoCache()); }
@Override public SyndFeedInfo remove(final URL feedUrl) { return backingCache.remove(feedUrl); }
@Override public void clear() { backingCache.clear(); }
/** * Get the global instance of the cache * * @return an implementation of FeedFetcherCache */ public static synchronized FeedFetcherCache getInstance() { if (instance == null) { instance = new HashMapFeedInfoCache(); } return instance; }
/** * Constructor to enable HttpURLFeedFetcher to cache feeds * * @param feedInfoCache - an instance of the FeedFetcherCache interface */ public HttpURLFeedFetcher(final FeedFetcherCache feedInfoCache) { setFeedInfoCache(feedInfoCache); }
/** * @return The currently used connect timeout for the HttpClient but using the URLConnection * method name. Uses the HttpClientParams method getConnectionManagerTimeout instead of * getConnectTimeout * */ public int getConnectTimeout() { return (int) getHttpClientParams().getConnectionManagerTimeout(); }
@Override public SyndFeedInfo getFeedInfo(final URL feedUrl) { return backingCache.getFeedInfo(feedUrl); }
@Override public SyndFeedInfo remove(final URL feedUrl) { return backingCache.remove(feedUrl); }
@Override public void clear() { backingCache.clear(); }