Package org.apache.roller.planet.pojos

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


    public void testFetchSubscription() throws Exception {
       
        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);
    }
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

            throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // store
        Subscription testSub = new Subscription();
        testSub.setFeedURL(feedUrl);
        testSub.setTitle(feedUrl);
        mgr.saveSubscription(testSub);
       
        // flush
        PlanetFactory.getPlanet().flush();
       
        // query to make sure we return the persisted object
        Subscription sub = mgr.getSubscriptionById(testSub.getId());
       
        if(sub == null)
            throw new PlanetException("error inserting new subscription");
       
        return sub;
View Full Code Here

     */
    public static void teardownSubscription(String id) throws Exception {
       
        // lookup
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        Subscription sub = mgr.getSubscriptionById(id);
       
        // remove
        mgr.deleteSubscription(sub);
       
        // flush
View Full Code Here

            throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // make sure we are using a persistent object
        Subscription testSub = mgr.getSubscriptionById(sub.getId());
       
        // store
        SubscriptionEntry testEntry = new SubscriptionEntry();
        testEntry.setPermalink(title);
        testEntry.setTitle(title);
        testEntry.setPubTime(new java.sql.Timestamp(System.currentTimeMillis()));
        testEntry.setSubscription(testSub);
        testSub.getEntries().add(testEntry);
        mgr.saveEntry(testEntry);
       
        // flush
        PlanetFactory.getPlanet().flush();
       
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

        strategy.store(entry);
    }
   
    public void saveSubscription(Subscription sub)
    throws PlanetException {
        Subscription existing = getSubscription(sub.getFeedURL());
        if (existing == null || (existing.getId().equals(sub.getId()))) {
            strategy.store(sub);
        } else {
            throw new PlanetException("ERROR: duplicate feed URLs not allowed");
        }
    }
View Full Code Here

            log.debug("Skipping unmodified LOCAL weblog");
            return null;
        }
       
        // build planet subscription from weblog
        Subscription newSub = new Subscription();
        newSub.setFeedURL(feedURL);
        newSub.setSiteURL(WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogURL(localWeblog, null, true));
        newSub.setTitle(localWeblog.getName());
        newSub.setAuthor(localWeblog.getName());
        newSub.setLastUpdated(localWeblog.getLastModified());
       
        // must have a last updated time
        if(newSub.getLastUpdated() == null) {
            newSub.setLastUpdated(new Date());
        }
       
        // lookup recent entries from weblog and add them to the subscription
        try {
            int entryCount = WebloggerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");
           
            // grab recent entries for this weblog
            WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
            List<WeblogEntry> entries = wmgr.getWeblogEntries(
                    localWeblog,
                    null,
                    null,                        // startDate
                    null,                        // endDate
                    null,                        // catName
                    null,WeblogEntry.PUBLISHED,   // status
                    null,                        // text
                    null,                        // sortby (null means pubTime)
                    null,
                    null,                        // locale
                    0,                           // offset
                    entryCount);
           
            // Populate subscription object with new entries
            PluginManager ppmgr = WebloggerFactory.getWeblogger().getPluginManager();
            Map pagePlugins = ppmgr.getWeblogEntryPlugins(localWeblog);
            for ( WeblogEntry rollerEntry : entries ) {
                SubscriptionEntry entry = new SubscriptionEntry();
                String content = "";
                if (!StringUtils.isEmpty(rollerEntry.getText())) {
                    content = rollerEntry.getText();
                } else {
                    content = rollerEntry.getSummary();
                }
                content = ppmgr.applyWeblogEntryPlugins(pagePlugins, rollerEntry, content);
               
                entry.setAuthor(rollerEntry.getCreator().getScreenName());
                entry.setTitle(rollerEntry.getTitle());
                entry.setPubTime(rollerEntry.getPubTime());
                entry.setText(content);
                entry.setPermalink(rollerEntry.getPermalink());
                entry.setCategoriesString(rollerEntry.getCategory().getPath());
               
                newSub.addEntry(entry);
            }
           
        } catch (WebloggerException ex) {
            throw new FetcherException("Error processing entries for local weblog - "+weblogHandle, ex);
        }
View Full Code Here

               
                // add feed url to the "live" list
                liveUserFeeds.add(feedUrl);
               
                // if sub already exists then update it, otherwise add it
                Subscription sub = pmgr.getSubscription(feedUrl);
                if (sub == null) {
                    log.debug("ADDING feed: "+feedUrl);
                   
                    sub = new Subscription();
                    sub.setTitle(weblog.getName());
                    sub.setFeedURL(feedUrl);
                    sub.setSiteURL(WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogURL(weblog, null, true));
                    sub.setAuthor(weblog.getName());
                    sub.setLastUpdated(new Date(0));
                   
                    pmgr.saveSubscription(sub);
                    group.getSubscriptions().add(sub);
                    pmgr.saveGroup(group);
                } else {
                    log.debug("UPDATING feed: "+feedUrl);
                   
                    sub.setTitle(weblog.getName());
                    sub.setAuthor(weblog.getName());
                   
                    pmgr.saveSubscription(sub);
                }
               
                // save as we go
                PlanetFactory.getPlanet().flush();
            }
           
            // new subs added, existing subs updated, now delete old subs
            Set<Subscription> deleteSubs = new HashSet();
            Set<Subscription> subs = group.getSubscriptions();
            for( Subscription sub : subs ) {
               
                // only delete subs from the group if ...
                // 1. they are local
                // 2. they are no longer listed as a weblog
                if (sub.getFeedURL().startsWith("weblogger:") &&
                        !liveUserFeeds.contains(sub.getFeedURL())) {
                    deleteSubs.add(sub);
                }
            }
           
            // now go back through deleteSubs and do actual delete
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.