Package org.apache.roller.planet.business

Examples of org.apache.roller.planet.business.PlanetManager


                    +"absolute URL not specified in Roller Config");
            return;
        }
       
        try {
            PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
            UserManager userManager = RollerFactory.getRoller().getUserManager();
           
            // first, make sure there is an "all" planet group
            PlanetGroupData group = planet.getGroup("all");
            if(group == null) {
                group = new PlanetGroupData();
                group.setHandle("all");
                group.setTitle("all");
                planet.saveGroup(group);
            }
           
            // walk through all enable weblogs and add/update subs as needed
            List liveUserFeeds = new ArrayList();
            Iterator websites =
                    userManager.getWebsites(null, Boolean.TRUE, Boolean.TRUE, null, null, 0, -1).iterator();
            while(websites.hasNext()) {
                WebsiteData weblog = (WebsiteData) websites.next();
               
                String siteUrl = URLUtilities.getWeblogURL(weblog, null, true);
                String feedUrl = URLUtilities.getWeblogFeedURL(weblog, null, "entries", "rss", null, null, false, true);
               
                // add feed url to the "live" list
                liveUserFeeds.add(feedUrl);
               
                // if sub already exists then update it, otherwise add it
                PlanetSubscriptionData sub = planet.getSubscription(feedUrl);
                if (sub == null) {
                    log.info("ADDING feed: "+feedUrl);
                   
                    sub = new PlanetSubscriptionData();
                    sub.setTitle(weblog.getName());
                    sub.setFeedURL(feedUrl);
                    sub.setSiteURL(siteUrl);
                    sub.setAuthor(weblog.getHandle());
                   
                    planet.saveSubscription(sub);
                    group.getSubscriptions().add(sub);
                } else {
                    sub.setTitle(weblog.getName());
                    sub.setAuthor(weblog.getHandle());
                   
                    planet.saveSubscription(sub);
                }
            }
           
            // new subs added, existing subs updated, now delete old subs
            Iterator subs = group.getSubscriptions().iterator();
            while(subs.hasNext()) {
                PlanetSubscriptionData sub =
                        (PlanetSubscriptionData) subs.next();
                if (!liveUserFeeds.contains(sub.getFeedURL())) {
                    log.info("DELETING feed: "+sub.getFeedURL());
                    planet.deleteSubscription(sub);
                    group.getSubscriptions().remove(sub);
                }
            }
           
            // all done, lets save
            planet.saveGroup(group);
            RollerFactory.getRoller().flush();
           
        } catch (RollerException e) {
            log.error("ERROR refreshing entries", e);
        } finally {
View Full Code Here

TOP

Related Classes of org.apache.roller.planet.business.PlanetManager

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.