Package org.apache.roller.planet.pojos

Examples of org.apache.roller.planet.pojos.Subscription


   
   
    public void testEntryCRUD() throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        Subscription sub = mgr.getSubscriptionById(testSub.getId());
       
        SubscriptionEntry testEntry = new SubscriptionEntry();
        testEntry.setPermalink("entryBasics");
        testEntry.setTitle("entryBasics");
        testEntry.setPubTime(new java.sql.Timestamp(System.currentTimeMillis()));
View Full Code Here


        SubscriptionEntry entry = mgr.getEntryById(testEntry1.getId());
        assertNotNull(entry);
        assertEquals("entryFuncTestEntry1", entry.getPermalink());
       
        // by subscription
        Subscription sub = mgr.getSubscriptionById(testSub2.getId());
        assertEquals(2, sub.getEntries().size());
       
        // by subscription through manager
        assertEquals(2, mgr.getEntries(sub, 0, 10).size());
       
        // by group
View Full Code Here

   
   
    public void testDeleteEntries() throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        Subscription sub = mgr.getSubscriptionById(testSub2.getId());
       
        // make sure entries are there
        assertEquals(2, sub.getEntries().size());
       
        // purge entries
        mgr.deleteEntries(sub);
        TestUtils.endSession(true);
       
        // verify
        sub = mgr.getSubscriptionById(testSub2.getId());
        assertEquals(0, sub.getEntries().size());
    }
View Full Code Here

                end = end > userCount ? userCount : end;
                log.info("Updating subscriptions ["+start+":"+end+"]");
               
                Iterator subs = planet.getSubscriptions().iterator();
                while (subs.hasNext()) {
                    Subscription sub =
                            (Subscription)subs.next();
                    if (count >= start && count < end) {
                        try {
                            Technorati.Result result =
                                    technorati.getBloginfo(sub.getSiteURL());
                            if (result != null && result.getWeblog() != null) {
                                sub.setInboundblogs(
                                        result.getWeblog().getInboundblogs());
                                sub.setInboundlinks(
                                        result.getWeblog().getInboundlinks());
                                log.debug("Adding rank for "
                                        +sub.getFeedURL()+" ["+count+"|"
                                        +sub.getInboundblogs()+"|"
                                        +sub.getInboundlinks()+"]");
                            } else {
                                log.debug(
                                        "No ranking available for "
                                        +sub.getFeedURL()+" ["+count+"]");
                                sub.setInboundlinks(0);
                                sub.setInboundblogs(0);
                            }
                            planet.saveSubscription(sub);
                        } catch (Exception e) {
                            log.warn("WARN ranking subscription ["
                                    + count + "]: " + e.getMessage());
View Full Code Here

    }
   
   
    public List getFeedEntries(String feedUrl, int maxEntries) throws Exception {
        try {
            Subscription sub = planetManager.getSubscription(feedUrl);
            if(sub != null) {
                return planetManager.getEntries(sub, 0, maxEntries);
            } else {
                return Collections.EMPTY_LIST;
            }
View Full Code Here

    public void testFetchFeed() throws Exception {
       
        FeedFetcher feedFetcher = PlanetFactory.getPlanet().getFeedFetcher();

        // fetch feed
        Subscription sub = feedFetcher.fetchSubscription(feed_url);
        assertNotNull(sub);
        assertEquals(feed_url, sub.getFeedURL());
        assertEquals("http://rollerweblogger.org/roller/", sub.getSiteURL());
        assertEquals("Blogging Roller", sub.getTitle());
        assertNotNull(sub.getLastUpdated());
        assertTrue(sub.getEntries().size() > 0);
    }
View Full Code Here

    public void testFetchFeedConditionally() throws Exception {
       
        FeedFetcher feedFetcher = PlanetFactory.getPlanet().getFeedFetcher();

        // fetch feed
        Subscription sub = feedFetcher.fetchSubscription(feed_url);
        assertNotNull(sub);
        assertEquals(feed_url, sub.getFeedURL());
        assertEquals("http://rollerweblogger.org/roller/", sub.getSiteURL());
        assertEquals("Blogging Roller", sub.getTitle());
        assertNotNull(sub.getLastUpdated());
        assertTrue(sub.getEntries().size() > 0);
       
        // now do a conditional fetch and we should get back null
        Subscription updatedSub = feedFetcher.fetchSubscription(feed_url, sub.getLastUpdated());
        assertNull(updatedSub);
    }
View Full Code Here

            PlanetManager planetManager = PlanetFactory.getPlanet().getPlanetManager();
            Planet defaultPlanet = planetManager.getPlanet(DEFAULT_PLANET_HANDLE);
            PlanetGroup planetGroup = planetManager.getGroup(defaultPlanet, groupHandle);
            List subs = planetManager.getTopSubscriptions(planetGroup, 0, length);
            for (Iterator it = subs.iterator(); it.hasNext();) {
                Subscription sub = (Subscription) it.next();
                // TODO needs pojo wrapping from planet
                list.add(sub);
            }
        } catch (Exception e) {
            log.error("ERROR: get ranked blogs", e);
View Full Code Here

        }
       
        log.debug("Feed pulled, extracting data into Subscription");
       
        // build planet subscription from fetched feed
        Subscription newSub = new Subscription();
        newSub.setFeedURL(feedURL);
        newSub.setSiteURL(feed.getLink());
        newSub.setTitle(feed.getTitle());
        newSub.setAuthor(feed.getAuthor());
        newSub.setLastUpdated(feed.getPublishedDate());
       
       
        // normalize any data that couldn't be properly extracted
        if(newSub.getSiteURL() == null) {
            // set the site url to the feed url then
            newSub.setSiteURL(newSub.getFeedURL());
        }
        if(newSub.getAuthor() == null) {
            // 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));
                    }
                }
            } catch (MalformedURLException ex) {
                // should never happen since we check this above
            }
        }
       
        // check if feed is unchanged and bail now if so
        if(lastModified != null && newSub.getLastUpdated() != null &&
                !newSub.getLastUpdated().after(lastModified)) {
            return null;
        }
       
        if(log.isDebugEnabled()) {
            log.debug("Subscription is: "+newSub.toString());
        }
       
       
        // some kludge to deal with feeds w/ no entry dates
        // we assign arbitrary dates chronologically by entry starting either
        // from the current time or the last update time of the subscription
        Calendar cal = Calendar.getInstance();
        if (newSub.getLastUpdated() != null) {
            cal.setTime(newSub.getLastUpdated());
        } else {
            cal.setTime(new Date());
            cal.add(Calendar.DATE, -1);
        }
       
        // add entries
        List<SyndEntry> feedEntries = feed.getEntries();
        for( SyndEntry feedEntry : feedEntries ) {
            SubscriptionEntry newEntry = buildEntry(feedEntry);
           
            // some kludge to handle feeds with no entry dates
            if (newEntry.getPubTime() == null) {
                log.debug("No published date, assigning fake date for "+feedURL);
                newEntry.setPubTime(new Timestamp(cal.getTimeInMillis()));
                cal.add(Calendar.DATE, -1);
            }
           
            if(newEntry != null) {
                newSub.addEntry(newEntry);
            }
        }
       
        log.debug(feedEntries.size()+" entries included");
       
View Full Code Here

    public void testFetchSubscription() throws Exception {
        try {
            FeedFetcher feedFetcher = PlanetFactory.getPlanet().getFeedFetcher();

            // first fetch non-conditionally so we know we should get a Sub
            Subscription sub = feedFetcher.fetchSubscription(feed_url);
            assertNotNull(sub);
            assertEquals(feed_url, sub.getFeedURL());
            assertNotNull(sub.getLastUpdated());

            // now do a conditional fetch and we should get back null
            Subscription updatedSub = feedFetcher.fetchSubscription(feed_url, sub.getLastUpdated());
            assertNull(updatedSub);

        } catch (Throwable e) {
            e.printStackTrace();
        }
View Full Code Here

TOP

Related Classes of org.apache.roller.planet.pojos.Subscription

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.