Package org.apache.roller.planet.business

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


     * @param len         Max number of results to return
     */
    public List getRankedSubscriptions(String groupHandle, int sinceDays, int length) {
        List list = new ArrayList();
        try {
            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);
            }
View Full Code Here


     * @return List of Planet groups defined.
     */
    public List<PlanetGroup> getGroups() {
        List list = new ArrayList<PlanetGroup>();
        try {
            PlanetManager planetManager = PlanetFactory.getPlanet().getPlanetManager();
            Planet defaultPlanet = planetManager.getPlanet(DEFAULT_PLANET_HANDLE);
            Set<PlanetGroup> groups = (Set<PlanetGroup>)defaultPlanet.getGroups();
            for (PlanetGroup group : groups) {
                // TODO needs pojo wrapping from planet
                list.add(group);
            }
View Full Code Here

     * @return PlaneGroup specified by handle.
     */
    public PlanetGroup getGroup(String groupHandle) {
        PlanetGroup group = null;
        try {
            PlanetManager planetManager = PlanetFactory.getPlanet().getPlanetManager();
            Planet defaultPlanet = planetManager.getPlanet(DEFAULT_PLANET_HANDLE);           
            // TODO needs pojo wrapping from planet
            group = planetManager.getGroup(defaultPlanet, groupHandle);           
        } catch (Exception e) {
            log.error("ERROR: getting group", e);
        }
        return group;       
    }
View Full Code Here

        }
    }
   
    public void testRefreshEntries() {
        try {     
            PlanetManager planet = PlanetFactory.getPlanet().getPlanetManager();
           
            // run sync task to fill aggregator with websites created by super
            SyncWebsitesTask syncTask = new SyncWebsitesTask();
            syncTask.init();
            syncTask.runTask();
           
            Planet planetObject = planet.getPlanetById("zzz_default_planet_zzz");
            assertNotNull(planetObject);
            PlanetGroup group = planet.getGroup(planetObject, "all");
            assertEquals(1, group.getSubscriptions().size());

            RefreshRollerPlanetTask refreshTask = new RefreshRollerPlanetTask();
            refreshTask.runTask();
           
            planetObject = planet.getPlanet("default");
            group = planet.getGroup(planetObject, "all");
            List agg = planet.getEntries(group, 0, -1);
            assertEquals(3, agg.size());
        }
        catch (Exception e) {
            e.printStackTrace();
            fail();
View Full Code Here

    public void runTask() {
       
        log.info("Syncing local weblogs with planet subscriptions list");
       
        try {
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
           
            // first, make sure there is an "all" pmgr group
            Planet planetObject = pmgr.getPlanetById("zzz_default_planet_zzz");
            PlanetGroup group = pmgr.getGroup(planetObject, "all");
            if (group == null) {
                group = new PlanetGroup();
                group.setPlanet(planetObject);
                group.setHandle("all");
                group.setTitle("all");
                pmgr.saveGroup(group);
                PlanetFactory.getPlanet().flush();
            }
           
            // walk through all enable weblogs and add/update subs as needed
            List liveUserFeeds = new ArrayList();
            List<Weblog> websites = WebloggerFactory.getWeblogger()
                    .getWeblogManager().getWeblogs(Boolean.TRUE, Boolean.TRUE, null, null, 0, -1);
            for ( Weblog weblog : websites ) {
               
                log.debug("processing weblog - "+weblog.getHandle());
                String feedUrl = "weblogger:"+weblog.getHandle();
               
                // 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);
                   
                    sub.getGroups().add(group);
                    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
            // this is required because deleting a sub in the loop above
            // causes a ConcurrentModificationException because we can't
            // modify a collection while we iterate over it
            for( Subscription deleteSub : deleteSubs ) {
               
                log.debug("DELETING feed: "+deleteSub.getFeedURL());
                pmgr.deleteSubscription(deleteSub);
                group.getSubscriptions().remove(deleteSub);
            }
           
            // all done, lets save
            pmgr.saveGroup(group);
            PlanetFactory.getPlanet().flush();
           
        } catch (RollerException e) {
            log.error("ERROR refreshing entries", e);
        } finally {
View Full Code Here

   
    /**
     * Get the list of all planets.
     */
    public List getPlanets() {
        PlanetManager pMgr = PlanetFactory.getPlanet().getPlanetManager();
        try {
            return pMgr.getPlanets();
        } catch(Exception e) {
            log.error("Error getting planets list", e);
        }
       
        return null;
View Full Code Here

     */
    public String getPlanetURL(String planet) {
       
        StringBuffer url = new StringBuffer();
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
       
        url.append(PlanetRuntimeConfig.getProperty("site.absoluteurl"));
       
        return url.toString();
    }
View Full Code Here

                startDate = cal.getTime();
            }
           
            List results = new ArrayList();
            try {
                PlanetManager planetManager = PlanetFactory.getPlanet().getPlanetManager();
               
                List rawEntries = null;
                if (feedURL != null) {
                    Subscription sub = planetManager.getSubscription(feedURL);
                    if(sub != null) {
                        rawEntries = planetManager.getEntries(sub, offset, length+1);
                    }
                } else if (group != null) {
                    rawEntries = planetManager.getEntries(group, startDate, null, offset, length+1);
                } else {
                    //rawEntries = planetManager.getEntries(startDate, null, offset, length+1);
                    rawEntries = Collections.EMPTY_LIST;
                }
               
View Full Code Here

   
    /**
     * Return a list of the most recent 10 entries from this group.
     */
    public List getRecentEntries() {
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        try {
            return mgr.getEntries(this, 0, 10);
        } catch(Exception e) {
            return Collections.EMPTY_LIST;
        }
    }
View Full Code Here

   
   
    public Planet getPlanet() {
        if(planet == null) {
            try {
                PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
                planet = pmgr.getPlanet(DEFAULT_PLANET_HANDLE);
            } catch(Exception ex) {
                log.error("Error loading weblogger planet - "+DEFAULT_PLANET_HANDLE, ex);
            }
        }
        return planet;
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.