Examples of PlanetManager


Examples of org.apache.roller.model.PlanetManager

            {
                BasePageModel pageModel = new BasePageModel(
                    "planetConfig.pageTitle", request, response, mapping);
                request.setAttribute("model",pageModel);               
                Roller roller = RollerFactory.getRoller();
                PlanetManager planet = roller.getPlanetManager();
                PlanetConfigData config = planet.getConfiguration();
                if (config == null)
                {
                    config = new PlanetConfigData();
                }
                PlanetConfigForm form = (PlanetConfigForm) actionForm;
                ActionErrors errors = validate(form);
                if (errors.isEmpty())
                {
                    form.copyTo(config, request.getLocale());
                    planet.saveConfiguration(config);
                    if (planet.getGroup("external") == null)
                    {
                        PlanetGroupData group = new PlanetGroupData();
                        group.setHandle("external");
                        group.setTitle("external");
                        planet.saveGroup(group);
                    }
                    roller.flush();
                    ActionMessages messages = new ActionMessages();
                    messages.add(null, new ActionMessage("planetConfig.success.saved"));
                    saveMessages(request, messages);
View Full Code Here

Examples of org.apache.roller.model.PlanetManager

            String baseURL = RollerRuntimeConfig.getProperty("site.absoluteurl");
            if (baseURL == null || baseURL.trim().length()==0) {
                logger.error("ERROR: cannot sync websites with Planet Roller - "
                        +"absolute URL not specified in Roller Config");
            } else {
                PlanetManager planet = roller.getPlanetManager();
                UserManager userManager = roller.getUserManager();
                PlanetGroupData group = planet.getGroup("all");
                if (group == null) {
                    group = new PlanetGroupData();
                    group.setHandle("all");
                    group.setTitle("all");
                    planet.saveGroup(group);
                    roller.flush();
                }
                try {
                    String baseFeedURL = baseURL + "/rss/";
                    String baseSiteURL = baseURL + "/page/";
                    // get list of all enabled and active weblogs
                    Iterator websites =
                        roller.getUserManager().getWebsites(null, Boolean.TRUE, Boolean.TRUE).iterator();
                    while (websites.hasNext()) {
                        WebsiteData website = (WebsiteData)websites.next();
                       
                        StringBuffer sitesb = new StringBuffer();
                        sitesb.append(baseSiteURL);
                        sitesb.append(website.getHandle());
                        String siteUrl = sitesb.toString();
                       
                        StringBuffer feedsb = new StringBuffer();
                        feedsb.append(baseFeedURL);
                        feedsb.append(website.getHandle());
                        String feedUrl = feedsb.toString();
                       
                        liveUserFeeds.add(feedUrl);
                       
                        PlanetSubscriptionData sub =
                                planet.getSubscription(feedUrl);
                        if (sub == null) {
                            logger.info("ADDING feed: "+feedUrl);
                            sub = new PlanetSubscriptionData();
                            sub.setTitle(website.getName());
                            sub.setFeedUrl(feedUrl);
                            sub.setSiteUrl(siteUrl);
                            sub.setAuthor(website.getHandle());
                            planet.saveSubscription(sub);
                            group.addSubscription(sub);
                        } else {
                            sub.setTitle(website.getName());
                            sub.setAuthor(website.getHandle());
                            planet.saveSubscription(sub);
                        }
                    }
                    planet.saveGroup(group);
                    roller.flush();
                    roller.release();
                   
                    // TODO: new planet manager method deleteSubs(list)
                    group = group = planet.getGroup("all");
                    Iterator subs = group.getSubscriptions().iterator();
                    while (subs.hasNext()) {
                        PlanetSubscriptionData sub =
                                (PlanetSubscriptionData)subs.next();
                        if (!liveUserFeeds.contains(sub.getFeedUrl())) {
                            logger.info("DELETING feed: "+sub.getFeedUrl());
                            planet.deleteSubscription(sub);
                        }
                    }
                    roller.flush();
                } finally {
                    roller.release();
View Full Code Here

Examples of org.apache.roller.model.PlanetManager

     */
    private void rankSubscriptions() {
        int count = 0;
        int errorCount = 0;
        try {
            PlanetManager planet = roller.getPlanetManager();
            PlanetConfigData config = planet.getConfiguration();
            Technorati technorati = null;
            try {
                if (config.getProxyHost()!=null && config.getProxyPort() != -1) {
                    technorati = new Technorati(
                            config.getProxyHost(), config.getProxyPort());
                } else {
                    technorati = new Technorati();
                }
            } catch (IOException e) {
                logger.error("Aborting collection of Technorati rankings.\n"
                +"technorati.license not found at root of classpath.\n"
                +"Get license at http://technorati.com/developers/apikey.html\n"
                +"Put the license string in a file called technorati.license.\n"
                +"And place that file at the root of Roller's classpath.\n"
                +"For example, in the /WEB-INF/classes directory.");
                return;
            }
            UserManager userManager = roller.getUserManager();
            try {
                int limit = RollerConfig.getIntProperty(
                    "planet.aggregator.technorati.limit", 500);
                int userCount = planet.getSubscriptionCount();
                int mod = (userCount / limit) + 1;
               
                Calendar cal = Calendar.getInstance();
                cal.setTime(new Date());
                int day = cal.get(Calendar.DAY_OF_YEAR);
               
                int start = (day % mod) * limit;
                int end = start + limit;
                end = end > userCount ? userCount : end;
                logger.info("Updating subscriptions ["+start+":"+end+"]");
               
                Iterator subs = planet.getAllSubscriptions();
                while (subs.hasNext()) {
                    PlanetSubscriptionData sub =
                            (PlanetSubscriptionData)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());
                                logger.debug("Adding rank for "
                                        +sub.getFeedUrl()+" ["+count+"|"
                                        +sub.getInboundblogs()+"|"
                                        +sub.getInboundlinks()+"]");
                            } else {
                                logger.debug(
                                        "No ranking available for "
                                        +sub.getFeedUrl()+" ["+count+"]");
                                sub.setInboundlinks(0);
                                sub.setInboundblogs(0);
                            }
                            planet.saveSubscription(sub);
                        } catch (Exception e) {
                            logger.warn("WARN ranking subscription ["
                                    + count + "]: " + e.getMessage());
                            if (errorCount++ > 5) {
                                logger.warn(
View Full Code Here

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

        }
    }
   
    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.run();          
           
            RefreshRollerPlanetTask refreshTask = new RefreshRollerPlanetTask();
            refreshTask.run();
           
            Planet planetObject = planet.getPlanet("default");
            PlanetGroup 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

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

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

    public static Planet setupPlanet(String handle) throws Exception {
       
        Planet testPlanet = new Planet(handle, handle, handle);
       
        // store
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        mgr.savePlanet(testPlanet);
       
        // flush
        PlanetFactory.getPlanet().flush();
       
        // query to make sure we return the persisted object
        Planet planet = mgr.getPlanet(handle);
       
        if(planet == null)
            throw new PlanetException("error inserting new planet");
       
        return planet;
View Full Code Here

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

     * Convenience method for removing a planet.
     */
    public static void teardownPlanet(String id) throws Exception {
       
        // lookup
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        Planet planet = mgr.getPlanetById(id);
       
        // remove
        mgr.deletePlanet(planet);
       
        // flush
        PlanetFactory.getPlanet().flush();
    }
View Full Code Here

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

     * Convenience method that creates a group and stores it.
     */
    public static PlanetGroup setupGroup(Planet planet, String handle)
            throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // make sure we are using a persistent object
        Planet testPlanet = mgr.getPlanetById(planet.getId());
       
        // store
        PlanetGroup testGroup = new PlanetGroup(testPlanet, handle, handle, handle);
        testPlanet.getGroups().add(testGroup);
        mgr.saveGroup(testGroup);
       
        // flush
        PlanetFactory.getPlanet().flush();
       
        // query to make sure we return the persisted object
        PlanetGroup group = mgr.getGroupById(testGroup.getId());
       
        if(group == null)
            throw new PlanetException("error inserting new group");
       
        return group;
View Full Code Here

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

     * Convenience method for removing a group.
     */
    public static void teardownGroup(String id) throws Exception {
       
        // lookup
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
        PlanetGroup group = mgr.getGroupById(id);
       
        // remove
        mgr.deleteGroup(group);
        group.getPlanet().getGroups().remove(group);
       
        // flush
        PlanetFactory.getPlanet().flush();
    }
View Full Code Here

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

     * Convenience method that creates a sub and stores it.
     */
    public static Subscription setupSubscription(String feedUrl)
            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
TOP
Copyright © 2018 www.massapi.com. 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.