Package org.apache.roller.model

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


            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

     */
    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

   
   
    public void testAggregations() throws Exception {
       
        try {
            PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
           
            String feed_url1 = "http://rollerweblogger.org/rss/roller";
            String feed_url2 = "http://linuxintegrators.com/acoliver/?flavor=rss2";
           
            {
                PlanetGroupData group = new PlanetGroupData();
                group.setDescription("test_group_desc");
                group.setHandle("test_handle");
                group.setTitle("test_title");
                planet.saveGroup(group);
               
                PlanetSubscriptionData sub1 = new PlanetSubscriptionData();
                sub1.setFeedURL(feed_url1);
                planet.saveSubscription(sub1);
               
                PlanetSubscriptionData sub2 = new PlanetSubscriptionData();
                sub2.setFeedURL(feed_url2);
                planet.saveSubscription(sub2);
               
                group.addSubscription(sub1);
                group.addSubscription(sub2);
                planet.saveGroup(group);
                TestUtils.endSession(true);
            }
            {
                planet.refreshEntries();
                TestUtils.endSession(true);
               
                int count = 0;
                Iterator subs = planet.getAllSubscriptions();
                while  (subs.hasNext()) {
                    PlanetSubscriptionData sub= (PlanetSubscriptionData)subs.next();
                    count += sub.getEntries().size();
                }
                PlanetSubscriptionData sub1 = planet.getSubscription(feed_url1);
                assertTrue(sub1.getEntries().size() > 0);
                PlanetSubscriptionData sub2 = planet.getSubscription(feed_url2);
                assertTrue(sub2.getEntries().size() > 0);
                assertEquals(count, sub1.getEntries().size() + sub2.getEntries().size());
               
                PlanetGroupData group = planet.getGroup("test_handle");
                assertNotNull(group);
               
                List bigag = planet.getAggregation(group, null, null, 0, 30);
                assertEquals(30, bigag.size());
               
                List littleag = planet.getAggregation(group, null, null, 0, 10);
                assertEquals(10, littleag.size());
               
                planet.deleteGroup(group);
                planet.deleteSubscription(sub1);
                planet.deleteSubscription(sub2);
                TestUtils.endSession(true);
            }
        } catch (Exception e) {
            e.printStackTrace();
            fail();
View Full Code Here

   
   
    public void testSubscriptionCount() throws Exception {
       
        try {
            PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
           
            String feed_url1 = "http://rollerweblogger.org/rss/roller";
            String feed_url2 = "http://linuxintegrators.com/acoliver/?flavor=rss2";
           
            {
                PlanetSubscriptionData sub1 = new PlanetSubscriptionData();
                sub1.setFeedURL(feed_url1);
                planet.saveSubscription(sub1);
                PlanetSubscriptionData sub2 = new PlanetSubscriptionData();
                sub2.setFeedURL(feed_url2);
                planet.saveSubscription(sub2);
                TestUtils.endSession(true);
               
                assertEquals(2, planet.getSubscriptionCount());
               
                planet.deleteSubscription(planet.getSubscription(feed_url1));
                planet.deleteSubscription(planet.getSubscription(feed_url2));
                TestUtils.endSession(true);
            }
        } catch (Exception e) {
            e.printStackTrace();
            fail();
View Full Code Here

        RollerConfig.setPlanetCachePath("." + File.separator + "planet-cache");
    }
   
    public void testConfigurationStorage() throws Exception {
       
        PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
       
        {   // retrieve config
            PlanetConfigData config = planet.getConfiguration();
            assertNotNull(config);
            assertEquals("test_title", config.getTitle());
            assertEquals("test_admin_email", config.getAdminEmail());
            assertNull(config.getSiteURL());
        }
        {   // save config
            PlanetConfigData config = planet.getConfiguration();
            config.setSiteURL("http://footest/lskdf/null");
            planet.saveConfiguration(config);
            TestUtils.endSession(true);
        }
        {
            // make sure config was saved
            PlanetConfigData config = planet.getConfiguration();
            assertNotNull(config);
            assertEquals("http://footest/lskdf/null", config.getSiteURL());
        }
    }
View Full Code Here

    }
   
   
    public void testGroupStorage() throws Exception {
       
        PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
       
        {   // save group
            PlanetGroupData group = new PlanetGroupData();
            group.setDescription("test_group_desc");
            group.setHandle("test_handle");
            group.setTitle("test_title");
            planet.saveGroup(group);
            TestUtils.endSession(true);
        }
        {   // retrieve group
            PlanetGroupData group = planet.getGroup("test_handle");
            assertEquals("test_group_desc",group.getDescription());
            assertEquals("test_title",group.getTitle());
            assertTrue(planet.getGroupHandles().size() > 0);
        }
        {   // remove group
            PlanetGroupData group = planet.getGroup("test_handle");
            planet.deleteGroup(group);
            TestUtils.endSession(true);
        }
        {   // verify that it is gone
            PlanetGroupData group = planet.getGroup("test_handle");
            assertNull(group);
        }
    }
View Full Code Here

    }
   
   
    public void testSubscriptionStorage() throws Exception {
       
        PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
       
        {   // save subscription
            PlanetSubscriptionData sub = new PlanetSubscriptionData();
            sub.setFeedURL("test_url");
            planet.saveSubscription(sub);
            TestUtils.endSession(true);
        }
        {   // retrieve subscription and add to group
            PlanetGroupData group = new PlanetGroupData();
            group.setDescription("test_group_desc");
            group.setHandle("test_handle");
            group.setTitle("test_title");
            planet.saveGroup(group);
           
            PlanetSubscriptionData sub = planet.getSubscription("test_url");
            assertNotNull(sub);
            group.addSubscription(sub);
           
            PlanetSubscriptionData sub1 = new PlanetSubscriptionData();
            sub1.setFeedURL("test_url1");
            planet.saveSubscription(sub1);
           
            List subs = new ArrayList();
            subs.add(sub1);
            group.addSubscriptions(subs);
           
            planet.saveGroup(group);
            TestUtils.endSession(true);
        }
        {   // get group and check it's subscriptions, remove it
            PlanetGroupData group = planet.getGroup("test_handle");
            Set subs = group.getSubscriptions();
            assertEquals(2, subs.size());
            planet.deleteGroup(group);
            TestUtils.endSession(true);
        }
        {   // make sure group gone, subs still there, then remove them too
            PlanetGroupData group = planet.getGroup("test_handle");
            assertNull(group);
            PlanetSubscriptionData sub = planet.getSubscription("test_url");
            assertNotNull(sub);
            PlanetSubscriptionData sub1 = planet.getSubscription("test_url1");
            assertNotNull(sub1);
            planet.deleteSubscription(sub);
            planet.deleteSubscription(sub1);
            TestUtils.endSession(true);
        }
        {   // make sure subscriptions are gone
            PlanetSubscriptionData sub = planet.getSubscription("test_url");
            assertNull(sub);
            PlanetSubscriptionData sub1 = planet.getSubscription("test_url1");
            assertNull(sub1);
        }
    }
View Full Code Here

    }
   
   
    public void testSubscriptionEntryStorage() throws Exception {
       
        PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
       
        {   // save subscription
            PlanetSubscriptionData sub = new PlanetSubscriptionData();
            sub.setFeedURL("test_url");
            planet.saveSubscription(sub);
            TestUtils.endSession(true);
        }
        {   // retrieve subscription and add entries
            PlanetSubscriptionData sub = planet.getSubscription("test_url");
            assertNotNull(sub);
           
            PlanetEntryData entry1 = new PlanetEntryData();
            entry1.setPermalink("test_entry1");
            entry1.setCategoriesString("test,test2");
            entry1.setSubscription(sub);
            entry1.setPubTime(new Timestamp(System.currentTimeMillis()));
            sub.addEntry(entry1);
           
            PlanetEntryData entry2 = new PlanetEntryData();
            entry2.setPermalink("test_entry2");
            entry2.setCategoriesString("test_cat1,test_cat2,test_cat3");
            entry2.setSubscription(sub);
            entry2.setPubTime(new Timestamp(System.currentTimeMillis()));
            sub.addEntry(entry2);
           
            // save entries
            planet.saveSubscription(sub);
            TestUtils.endSession(true);
           
            // get sub and check it's entries
            sub = planet.getSubscription("test_url");
            assertEquals(2, sub.getEntries().size());
        }
        {
            // add a single entry
            PlanetSubscriptionData sub = planet.getSubscription("test_url");
            assertNotNull(sub);
           
            PlanetEntryData entry3 = new PlanetEntryData();
            entry3.setPermalink("test_entry3");
            entry3.setCategoriesString("test,test3");
            entry3.setSubscription(sub);
            entry3.setPubTime(new Timestamp(System.currentTimeMillis()));
            planet.saveEntry(entry3);
            TestUtils.endSession(true);
           
            // verify entry was added
            sub = planet.getSubscription("test_url");
            assertEquals(3, sub.getEntries().size());
        }
        {
            // purge entries
            PlanetSubscriptionData sub = planet.getSubscription("test_url");
            sub.purgeEntries();
            planet.saveSubscription(sub);
            TestUtils.endSession(true);
           
            // make sure they were removed
            sub = planet.getSubscription("test_url");
            assertEquals(0, sub.getEntries().size());
        }
        {
            // remove test subscription
            PlanetSubscriptionData sub = planet.getSubscription("test_url");
            planet.deleteSubscription(sub);
            TestUtils.endSession(true);
           
            // make sure sub is gone
            sub = planet.getSubscription("test_url");
            assertNull(sub);
        }
    }
View Full Code Here

    }
   
   
    public void testRefreshEntries() throws Exception {
       
        PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
       
        String feed_url1 = "http://rollerweblogger.org/rss/roller";
       
        {
            PlanetGroupData group = new PlanetGroupData();
            group.setDescription("test_group_desc");
            group.setHandle("test_handle");
            group.setTitle("test_title");
            planet.saveGroup(group);
           
            PlanetSubscriptionData sub = new PlanetSubscriptionData();
            sub.setFeedURL(feed_url1);
            planet.saveSubscription(sub);
           
            group.addSubscription(sub);
            planet.saveGroup(group);
            TestUtils.endSession(true);
        }
        {
            planet.refreshEntries();
            TestUtils.endSession(true);
           
            PlanetSubscriptionData sub = planet.getSubscription(feed_url1);
            int entriesSize = sub.getEntries().size();
           
            PlanetGroupData group = planet.getGroup("test_handle");
            assertNotNull(group);
           
            planet.deleteGroup(group);
            planet.deleteSubscription(sub);
            TestUtils.endSession(true);
           
            assertTrue(entriesSize > 0);
           
            Object feed = planet.getSubscription(feed_url1);
            assertNull(feed);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.model.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.