Package com.sun.syndication.fetcher.impl

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


        junit.textui.TestRunner.run(DiskFeedInfoCacheTest.class);
    }
   
    public void testCache() throws Exception {
        URL url = new URL("http://cnn.com");
        SyndFeedInfo info = new SyndFeedInfo();
        info.setUrl(url);
       
        String buildDir = System.getProperty("ro.build");
        assertNotNull("ro.build not null", buildDir);
        assertTrue("ro.build not zero length", buildDir.trim().length() > 0);
        if (!buildDir.startsWith("/")) buildDir = "..";
        File file = new File(buildDir);
       
        assertTrue("buildDir exists", file.exists());
        assertTrue("buildDir is directory", file.isDirectory());
       
        DiskFeedInfoCache cache =
                new DiskFeedInfoCache(buildDir + "/tests/planet-cache");
        cache.setFeedInfo(info.getUrl(), info);
       
        SyndFeedInfo info2 = cache.getFeedInfo(url);
        assertNotNull(info2);
        assertEquals(url, info2.getUrl());
    }
View Full Code Here


        }
        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));
                    }
                }
            } catch (MalformedURLException ex) {
View Full Code Here

    {
        this.cachePath = cachePath;
    }
    public SyndFeedInfo getFeedInfo(URL url)
    {
        SyndFeedInfo info = null;
        String fileName = cachePath + File.separator + "feed_"
                + Utilities.replaceNonAlphanumeric(url.toString(),'_').trim();       
        FileInputStream fis;
        try
        {
View Full Code Here

            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();

        return feed;
      } finally {
        method.releaseConnection();
      }
View Full Code Here

     * @param feed
     * @return
     * @throws MalformedURLException
     */
    private SyndFeedInfo buildSyndFeedInfo(URL feedUrl, String urlStr, HttpMethod method, SyndFeed feed, int statusCode) throws MalformedURLException {
        SyndFeedInfo syndFeedInfo;
        syndFeedInfo = new SyndFeedInfo();

        // this may be different to feedURL because of 3XX redirects
        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

        Date lastUpdated = new Date();
        try {
            feedUrl = new URL(sub.getFeedUrl());
            log.debug("Get feed from cache "+sub.getFeedUrl());
            feed = feedFetcher.retrieveFeed(feedUrl);
            SyndFeedInfo feedInfo = feedInfoCache.getFeedInfo(feedUrl);
            if (feedInfo.getLastModified() != null) {
                long lastUpdatedLong =
                        ((Long)feedInfo.getLastModified()).longValue();
                if (lastUpdatedLong != 0) {
                    lastUpdated = new Date(lastUpdatedLong);
                }
            }
            Thread.sleep(100); // be nice
View Full Code Here

        junit.textui.TestRunner.run(DiskFeedInfoCacheTest.class);
    }
   
    public void testCache() throws Exception {
        URL url = new URL("http://cnn.com");
        SyndFeedInfo info = new SyndFeedInfo();
        info.setUrl(url);
       
        String testPlanetCache = PlanetConfig.getProperty("cache.dir");
        assertNotNull("testPlanetCache not null", testPlanetCache);
        assertTrue("testPlanetCache not zero length", testPlanetCache.trim().length() > 0);
       
        File cacheDir = new File(testPlanetCache);
        if (!cacheDir.exists()) cacheDir.mkdirs();
       
        DiskFeedInfoCache cache =
                new DiskFeedInfoCache(PlanetConfig.getProperty("cache.dir"));
        cache.setFeedInfo(info.getUrl(), info);
       
        SyndFeedInfo info2 = cache.getFeedInfo(url);
        assertNotNull(info2);
        assertEquals(url, info2.getUrl());
    }
View Full Code Here

        }
        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));
                    }
                }
            } catch (MalformedURLException ex) {
View Full Code Here

        junit.textui.TestRunner.run(DiskFeedInfoCacheTest.class);
    }
   
    public void testCache() throws Exception {
        URL url = new URL("http://cnn.com");
        SyndFeedInfo info = new SyndFeedInfo();
        info.setUrl(url);
       
        String buildDir = System.getProperty("ro.build");
        assertNotNull("ro.build not null", buildDir);
        assertTrue("ro.build not zero length", buildDir.trim().length() > 0);
        if (!buildDir.startsWith("/")) buildDir = "..";
        File file = new File(buildDir);
       
        assertTrue("buildDir exists", file.exists());
        assertTrue("buildDir is directory", file.isDirectory());
       
        DiskFeedInfoCache cache =
                new DiskFeedInfoCache(buildDir + "/tests/planet-cache");
        cache.setFeedInfo(info.getUrl(), info);
       
        SyndFeedInfo info2 = cache.getFeedInfo(url);
        assertNotNull(info2);
        assertEquals(url, info2.getUrl());
    }
View Full Code Here

    {
        this.cachePath = cachePath;
    }
    public SyndFeedInfo getFeedInfo(URL url)
    {
        SyndFeedInfo info = null;
        String fileName = cachePath + File.separator + "feed_"
                + Utilities.replaceNonAlphanumeric(url.toString(),'_').trim();       
        FileInputStream fis;
        try
        {
View Full Code Here

TOP

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

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.