Package com.sun.syndication.fetcher.impl

Examples of com.sun.syndication.fetcher.impl.FeedFetcherCache


            // set the author to the title
            newSub.setAuthor(newSub.getTitle());
        }
        if(newSub.getLastUpdated() == null) {
            // no update time specified in feed, so try consulting feed info cache
            FeedFetcherCache feedCache = getRomeFetcherCache();
            try {
                SyndFeedInfo feedInfo = feedCache.getFeedInfo(new URL(newSub.getFeedURL()));
                if(feedInfo.getLastModified() != null) {
                    long lastUpdatedLong = ((Long)feedInfo.getLastModified()).longValue();
                    if (lastUpdatedLong != 0) {
                        newSub.setLastUpdated(new Date(lastUpdatedLong));
                    }
View Full Code Here



    // get a feed fetcher
    private FeedFetcher getRomeFetcher() {
       
        FeedFetcherCache feedCache = getRomeFetcherCache();
       
        FeedFetcher feedFetcher = null;
        if(feedCache != null) {
            feedFetcher = new HttpURLFeedFetcher(feedCache);
        } else {
View Full Code Here


        System.setProperty("httpclient.useragent", "Openfire Admin Console: v" +
                XMPPServer.getInstance().getServerInfo().getVersion().getVersionString());
        String urlStr = feedUrl.toString();
    FeedFetcherCache cache = getFeedInfoCache();
    if (cache != null) {
      // retrieve feed
      HttpMethod method = new GetMethod(urlStr);
      method.addRequestHeader("Accept-Encoding", "gzip");
      try {
        if (isUsingDeltaEncoding()) {
            method.setRequestHeader("A-IM", "feed");
        }

        // get the feed info from the cache
          // Note that syndFeedInfo will be null if it is not in the cache
        SyndFeedInfo syndFeedInfo = cache.getFeedInfo(feedUrl);
          if (syndFeedInfo != null) {
            method.setRequestHeader("If-None-Match", syndFeedInfo.getETag());

            if (syndFeedInfo.getLastModified() instanceof String) {
                method.setRequestHeader("If-Modified-Since", (String)syndFeedInfo.getLastModified());
            }
          }

          method.setFollowRedirects(true);

        int statusCode = client.executeMethod(method);
        fireEvent(FetcherEvent.EVENT_TYPE_FEED_POLLED, urlStr);
        handleErrorCodes(statusCode);

          SyndFeed feed = getFeed(syndFeedInfo, urlStr, method, statusCode);

        syndFeedInfo = buildSyndFeedInfo(feedUrl, urlStr, method, feed, statusCode);

        cache.setFeedInfo(new URL(urlStr), syndFeedInfo);

        // the feed may have been modified to pick up cached values
        // (eg - for delta encoding)
        feed = syndFeedInfo.getSyndFeed();
View Full Code Here

        syndFeedInfo.setUrl(new URL(urlStr));
        syndFeedInfo.setId(feedUrl.toString());

        Header imHeader = method.getResponseHeader("IM");
        if (imHeader != null && imHeader.getValue().indexOf("feed") >= 0 && isUsingDeltaEncoding()) {
      FeedFetcherCache cache = getFeedInfoCache();
      if (cache != null && statusCode == 226) {
          // client is setup to use http delta encoding and the server supports it and has returned a delta encoded response
          // This response only includes new items
          SyndFeedInfo cachedInfo = cache.getFeedInfo(feedUrl);
          if (cachedInfo != null) {
            SyndFeed cachedFeed = cachedInfo.getSyndFeed();

            // set the new feed to be the orginal feed plus the new items
            feed = combineFeeds(cachedFeed, feed);
View Full Code Here

        if (!cacheDir.canWrite()) {
            log.error("Planet cache directory is not writable");
            return;
        }
       
        FeedFetcherCache feedInfoCache =
                new DiskFeedInfoCache(cacheDirName);
       
        if (config.getProxyHost()!=null && config.getProxyPort() > 0) {
            System.setProperty("proxySet", "true");
            System.setProperty("http.proxyHost", config.getProxyHost());
View Full Code Here

    public static void main(String[] args) {
        boolean ok = false;
        try {
            URL feedUrl = new URL("http://www.oksnevad.org/tmp/nyheter.xml");

            FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
//            FeedFetcherCache feedInfoCache = new DiskFeedInfoCache("/srv/torrcast_test");
            FeedFetcher fetcher = new HttpURLFeedFetcher(feedInfoCache);

//            FetcherEventListenerImpl listener = new FetcherEventListenerImpl();
            PodcastListener listener = new PodcastListener();
View Full Code Here

            // set the author to the title
            newSub.setAuthor(newSub.getTitle());
        }
        if(newSub.getLastUpdated() == null) {
            // no update time specified in feed, so try consulting feed info cache
            FeedFetcherCache feedCache = getRomeFetcherCache();
            try {
                SyndFeedInfo feedInfo = feedCache.getFeedInfo(new URL(newSub.getFeedURL()));
                if(feedInfo.getLastModified() != null) {
                    long lastUpdatedLong = ((Long)feedInfo.getLastModified()).longValue();
                    if (lastUpdatedLong != 0) {
                        newSub.setLastUpdated(new Date(lastUpdatedLong));
                    }
View Full Code Here


    // get a feed fetcher
    private FeedFetcher getRomeFetcher() {
       
        FeedFetcherCache feedCache = getRomeFetcherCache();
       
        FeedFetcher feedFetcher = null;
        if(feedCache != null) {
            feedFetcher = new HttpURLFeedFetcher(feedCache);
        } else {
View Full Code Here

            feed = input.build(reader);
        } catch (FeedException e) {
            logger.error("Error retrieving RSS feed from URL: " + url + ". Cause: " + e.getMessage(), e);
        } catch (IOException e) {
            // another way to load feed RSS
            final FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
            final FeedFetcher fetcher = new HttpURLFeedFetcher(feedInfoCache);
            try {
                feed = fetcher.retrieveFeed(new URL(url));
            } catch (Exception e1) {
                logger.error("Error retrieving RSS feed from URL: " + url + ". Cause: " + e1.getMessage(), e1);
View Full Code Here

        }
        else //does not require auth
        {
          try
          {
            FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance();
            FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache);
            if ((null != source.getRssConfig()) && (null != source.getRssConfig().getUserAgent())) {
              feedFetcher.setUserAgent(source.getRssConfig().getUserAgent());
            }
            SyndFeed retVal = feedFetcher.retrieveFeed(new URL(this.cleanUrlStart(url)));
View Full Code Here

TOP

Related Classes of com.sun.syndication.fetcher.impl.FeedFetcherCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.