Package org.apache.roller.planet.pojos

Examples of org.apache.roller.planet.pojos.PlanetGroup


        PlanetManager planet = PlanetFactory.getPlanet().getPlanetManager();
       
        // retrieve subscriptions and add to group
        Subscription sub1 = planet.getSubscriptionById(testSub1.getId());
        Subscription sub2 = planet.getSubscriptionById(testSub2.getId());
        PlanetGroup group = planet.getGroupById(testGroup1.getId());
       
        // make sure no subs in group yet
        assertEquals(0, group.getSubscriptions().size());
       
        // add
        group.getSubscriptions().add(sub1);
        sub1.getGroups().add(group);

        group.getSubscriptions().add(sub2);
        sub2.getGroups().add(group);
       
        planet.saveGroup(group);
        TestUtils.endSession(true);
       
        // verify
        group = null;
        group = planet.getGroupById(testGroup1.getId());
        sub1 = planet.getSubscriptionById(testSub1.getId());
        sub2 = planet.getSubscriptionById(testSub2.getId());
        assertEquals(2, group.getSubscriptions().size());
       
        // remove
        group.getSubscriptions().remove(sub1);
        sub1.getGroups().remove(group);
       
        group.getSubscriptions().remove(sub2);
        sub2.getGroups().remove(group);

        planet.saveGroup(group);
        TestUtils.endSession(true);
       
        // verify
        group = null;
        group = planet.getGroupById(testGroup1.getId());
        assertEquals(0, group.getSubscriptions().size());
    }
View Full Code Here


    public void testGroupLookups() throws Exception {
       
        PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
       
        // lookup group by id
        PlanetGroup group = mgr.getGroupById(testGroup1.getId());
        assertNotNull(group);
        assertEquals("groupFuncTest1", group.getHandle());
       
        // lookup group by planet & handle
        group = null;
        group = mgr.getGroup(testPlanet, testGroup1.getHandle());
        assertNotNull(group);
        assertEquals("groupFuncTest1", group.getHandle());
       
        // lookup all groups in planet
        Planet planet = mgr.getPlanetById(testPlanet.getId());
        Set groups = planet.getGroups();
        assertNotNull(groups);
View Full Code Here

       
        // by subscription through manager
        assertEquals(2, mgr.getEntries(sub, 0, 10).size());
       
        // by group
        PlanetGroup group = mgr.getGroupById(testGroup1.getId());
        assertEquals(3, mgr.getEntries(group, 0, 10).size());
       
        // by group with timeframe constraint
        assertEquals(0, mgr.getEntries(group, new Date(), null, 0, 10).size());
    }
View Full Code Here

    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

     * Get PlanetGroup by handle.
     * @param groupHandle Handle of PlanetGroup to fetch.
     * @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);           
View Full Code Here

            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");
View Full Code Here

        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();
View Full Code Here

       
        myValidate();
       
        if (!hasActionErrors()) try {
           
            PlanetGroup group = getGroup();
            if(group == null) {
                log.debug("Adding New Group");
                group = new PlanetGroup();
                group.setPlanet(getPlanet());
            } else {
                log.debug("Updating Existing Group");
            }
           
            // copy in submitted data
View Full Code Here

       
        List<PlanetGroup> displayGroups = new ArrayList();
       
        Iterator allgroups = getPlanet().getGroups().iterator();
        while (allgroups.hasNext()) {
            PlanetGroup agroup = (PlanetGroup) allgroups.next();
           
            // The "all" group is considered a special group and cannot be
            // managed independently
            if (!agroup.getHandle().equals("all")) {
                displayGroups.add(agroup);
            }
        }
       
        return displayGroups;
View Full Code Here

                List entries = null;
                if (feedURL != null) {
                    Subscription sub = planetManager.getSubscription(feedURL);
                    entries = planetManager.getEntries(sub, offset, length+1);
                } else if (groupHandle != null) {
                    PlanetGroup group = planetManager.getGroup(planet, groupHandle);
                    entries = planetManager.getEntries(group, startDate, null, offset, length+1);
                } else {
                    PlanetGroup group = planetManager.getGroup(planet, "all");
                    entries = planetManager.getEntries(group, startDate, null, offset, length+1);
                }
               
                // wrap 'em
                int count = 0;
View Full Code Here

TOP

Related Classes of org.apache.roller.planet.pojos.PlanetGroup

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.