Package org.apache.roller.planet.business

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


   
   
    public void run() {
        try {           
            Planet planet = PlanetFactory.getPlanet();
            PlanetManager planetManager = planet.getPlanetManager();
                       
            // Ignore values from database
            //String mainPage = planetManager.getConfiguration().getMainPage();
            //String templateDir = planetManager.getConfiguration().getTemplateDir();
            //String outputDir = planetManager.getConfiguration().getMainPage();
View Full Code Here


    public void runTask() {
       
        log.info("Syncing local weblogs with planet subscriptions list");
       
        try {
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
            UserManager userManager = WebloggerFactory.getWeblogger().getUserManager();
           
            // 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);
            }
           
            // walk through all enable weblogs and add/update subs as needed
            List liveUserFeeds = new ArrayList();
            List<Weblog> websites = userManager.getWebsites(null, 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);
                    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

       
        // update subscription entries
        int entries = 0;
        Set<SubscriptionEntry> newEntries = updatedSub.getEntries();
        if(newEntries.size() > 0) try {
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
           
            // clear out old entries
            pmgr.deleteEntries(sub);
           
            // add fresh entries
            sub.getEntries().clear();
            sub.addEntries(newEntries);
           
            // save and flush
            pmgr.saveSubscription(sub);
            PlanetFactory.getPlanet().flush();
           
        } catch(PlanetException ex) {
            throw new UpdaterException("Error persisting updated subscription", ex);
        }
View Full Code Here

       
        long startTime = System.currentTimeMillis();
       
        try {
            // update all subscriptions in the system
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
            updateSubscriptions(pmgr.getSubscriptions());
        } catch (PlanetException ex) {
            throw new UpdaterException("Error getting subscriptions list", ex);
        }
       
        long endTime = System.currentTimeMillis();
View Full Code Here

   
   
    // convenience method which handles updating any arbitrary collection of subs
    private void updateSubscriptions(Collection<Subscription> subscriptions) {
       
        PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
       
        Iterator subs = subscriptions.iterator();
        while (subs.hasNext()) {
            Subscription sub = (Subscription)subs.next();
           
            try {
                // reattach sub.  sub gets detached as we iterate
                sub = pmgr.getSubscriptionById(sub.getId());
            } catch (PlanetException ex) {
                log.warn("Subscription went missing while doing update: "+ex.getMessage());
            }
           
            // this updates and saves
View Full Code Here

   
   
    @Override
    public void myPrepare() {
       
        PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // lookup group we are operating on, if none specified then use default
        if (getGroupHandle() == null) {
            setGroupHandle("all");
        }
       
        try {
            setGroup(pmgr.getGroup(getPlanet(), getGroupHandle()));
        } catch (RollerException ex) {
            log.error("Error looking up planet group - "+getGroupHandle(), ex);
        }
    }
View Full Code Here

    public String save() {
       
        myValidate();
       
        if(!hasActionErrors()) try {
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
           
            // check if this subscription already exists before adding it
            Subscription sub = pmgr.getSubscription(getSubUrl());
            if(sub == null) {
                log.debug("Adding New Subscription - "+getSubUrl());
               
                // sub doesn't exist yet, so we need to fetch it
                FeedFetcher fetcher = PlanetFactory.getPlanet().getFeedFetcher();
                sub = fetcher.fetchSubscription(getSubUrl());
               
                // save new sub
                pmgr.saveSubscription(sub);
            } else {
                log.debug("Adding Existing Subscription - "+getSubUrl());
               
                // Subscription already exists
                addMessage("planetSubscription.foundExisting", sub.getTitle());
            }
           
            // add the sub to the group
            group.getSubscriptions().add(sub);
            sub.getGroups().add(group);
            pmgr.saveGroup(group);
           
            // flush changes
            PlanetFactory.getPlanet().flush();
           
            // clear field after success
View Full Code Here

     */
    public String delete() {
       
        if(getSubUrl() != null) try {
           
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
           
            // remove subscription
            Subscription sub = pmgr.getSubscription(getSubUrl());
            getGroup().getSubscriptions().remove(sub);
            sub.getGroups().remove(getGroup());
            pmgr.saveGroup(getGroup());
            PlanetFactory.getPlanet().flush();
           
            // clear field after success
            setSubUrl(null);
           
View Full Code Here

   
    @Override
    public void myPrepare() {
       
        if(getPlanet() != null && getBean().getId() != null) try {
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
            setGroup(pmgr.getGroupById(getBean().getId()));
        } catch(Exception ex) {
            log.error("Error looking up planet group - "+getBean().getId(), ex);
        }
    }
View Full Code Here

           
            // copy in submitted data
            getBean().copyTo(group);
           
            // save and flush
            PlanetManager pmgr = PlanetFactory.getPlanet().getPlanetManager();
            pmgr.saveGroup(group);
            PlanetFactory.getPlanet().flush();
           
            addMessage("planetGroups.success.saved");
           
        } catch(Exception ex) {
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.