roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r517300 - in /incubator/roller/trunk/apps/planet: src/java/org/apache/roller/planet/business/ src/java/org/apache/roller/planet/business/hibernate/ src/java/org/apache/roller/planet/tasks/ src/java/org/apache/roller/planet/ui/rendering/ tes...
Date Mon, 12 Mar 2007 17:37:28 GMT
Author: agilliland
Date: Mon Mar 12 10:37:27 2007
New Revision: 517300

URL: http://svn.apache.org/viewvc?view=rev&rev=517300
Log:
first pass at some Planet cleanup work.  removing unused or unnecessary methods, cleaning
up some queries, etc.


Modified:
    incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java
    incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
    incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java
    incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java
    incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/MultiPlanetRequestMapper.java
    incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/GroupTest.java
    incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/PlanetManagerTest.java

Modified: incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java?view=diff&rev=517300&r1=517299&r2=517300
==============================================================================
--- incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java
(original)
+++ incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/PlanetManager.java
Mon Mar 12 10:37:27 2007
@@ -62,30 +62,6 @@
     public void deleteGroup(PlanetGroupData group) throws RollerException;
     
     
-    /**
-     * Get handles for all defined groups
-     */
-    public List getGroupHandles() throws RollerException;
-    
-    
-    public List getGroupHandles(PlanetData planet) throws RollerException;
-    
-    
-    /**
-     * Get list of group objects
-     */
-    public List getGroups() throws RollerException;
-    
-    
-    public List getGroups(PlanetData planet) throws RollerException;
-    
-    
-    /**
-     * Get group by handle, group has subscriptions
-     */
-    public PlanetGroupData getGroup(String handle) throws RollerException;
-    
-    
     public PlanetGroupData getGroup(PlanetData planet, String handle) throws RollerException;
     
     
@@ -140,8 +116,8 @@
     /**
      * Get top X subscriptions, restricted by group.
      */
-    public List getTopSubscriptions(
-            String groupHandle, int offset, int len) throws RollerException;
+    public List getTopSubscriptions(PlanetGroupData group, int offset, int len) 
+        throws RollerException;
     
     
     /**

Modified: incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java?view=diff&rev=517300&r1=517299&r2=517300
==============================================================================
--- incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
(original)
+++ incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
Mon Mar 12 10:37:27 2007
@@ -26,7 +26,6 @@
 import java.net.URL;
 import java.sql.Timestamp;
 import java.text.MessageFormat;
-import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
@@ -80,8 +79,7 @@
     
     
     // delete a Planet
-    public void deletePlanet(PlanetData planet) 
-        throws RollerException {
+    public void deletePlanet(PlanetData planet) throws RollerException {
         strategy.remove(planet);
     }
     
@@ -122,6 +120,7 @@
     
     // save a Group
     public void saveGroup(PlanetGroupData group)  throws RollerException {
+        // TODO: move this check outside this method?
         if (group.getId() == null || getGroupById(group.getId()) == null) {
             // If new group, make sure hadnle is unique within Planet
             if (getGroup(group.getPlanet(), group.getHandle()) != null) {
@@ -133,28 +132,25 @@
         
     
     // delete a Group
-    public void deleteGroup(PlanetGroupData group) 
-        throws RollerException {
+    public void deleteGroup(PlanetGroupData group) throws RollerException {
         strategy.remove(group);
     }
     
     
-    // TODO: remove method
-    public PlanetGroupData getGroup(String handle) throws RollerException {
-        return getGroup(null, handle);
-    }
-    
-    
     // lookup a Group by Planet & handle
-    public PlanetGroupData getGroup(PlanetData planet, String handle) throws RollerException
{
+    public PlanetGroupData getGroup(PlanetData planet, String handle) 
+            throws RollerException {
+        
+        if(planet == null) {
+            throw new RollerException("planet cannot be null");
+        }
+        
         try {
             Session session = strategy.getSession();
             Criteria criteria = session.createCriteria(PlanetGroupData.class);
-            criteria.setMaxResults(1);
+            criteria.add(Expression.eq("planet", planet));
             criteria.add(Expression.eq("handle", handle));
-            if(planet != null) {
-                criteria.add(Expression.eq("planet", planet));
-            }
+            criteria.setMaxResults(1);
             return (PlanetGroupData) criteria.uniqueResult();
         } catch (HibernateException e) {
             throw new RollerException(e);
@@ -166,51 +162,11 @@
     public PlanetGroupData getGroupById(String id) throws RollerException {
         return (PlanetGroupData) strategy.load(id, PlanetGroupData.class);
     }
-        
-    
-    // lookup all Groups
-    // TODO: remove method
-    public List getGroups() throws RollerException {
-        return getGroups(null);
-    }
-    
-    
-    // lookup all Groups by Planet
-    public List getGroups(PlanetData planet) throws RollerException {
-        try {
-            Session session = ((HibernatePersistenceStrategy)strategy).getSession();
-            Criteria criteria = session.createCriteria(PlanetGroupData.class);
-            if(planet != null) {
-                criteria.add(Expression.eq("planet", planet));
-            }
-            return criteria.list();
-        } catch (HibernateException e) {
-            throw new RollerException(e);
-        }
-    }
-    
-    
-    // TODO: remove method
-    public List getGroupHandles() throws RollerException {
-        return getGroupHandles(null);
-    }
-    
-    
-    // TODO: remove method
-    public List getGroupHandles(PlanetData planet) throws RollerException {
-        List handles = new ArrayList();
-        Iterator list = getGroups(planet).iterator();
-        while (list.hasNext()) {
-            PlanetGroupData group = (PlanetGroupData)list.next();
-            handles.add(group.getHandle());
-        }
-        return handles;
-    }
     
     
     // save a Subscription
     public void saveSubscription(PlanetSubscriptionData sub) 
-        throws RollerException {
+            throws RollerException {
         PlanetSubscriptionData existing = getSubscription(sub.getFeedURL());
         if (existing == null || (existing.getId().equals(sub.getId()))) {
             this.strategy.store(sub);
@@ -222,22 +178,21 @@
     
     // delete a Subscription
     public void deleteSubscription(PlanetSubscriptionData sub) 
-        throws RollerException {
+            throws RollerException {
         strategy.remove(sub);
     }
     
     
-    // lookup a Subscription by feed url
+    // lookup a Subscription by url
     public PlanetSubscriptionData getSubscription(String feedURL) 
-        throws RollerException {
+            throws RollerException {
         try {
             Session session = ((HibernatePersistenceStrategy)strategy).getSession();
             Criteria criteria =
                     session.createCriteria(PlanetSubscriptionData.class);
-            criteria.setMaxResults(1);
             criteria.add(Expression.eq("feedURL", feedURL));
-            List list = criteria.list();
-            return list.size()!=0 ? (PlanetSubscriptionData)list.get(0) : null;
+            criteria.setMaxResults(1);
+            return (PlanetSubscriptionData) criteria.uniqueResult();
         } catch (HibernateException e) {
             throw new RollerException(e);
         }
@@ -246,7 +201,7 @@
     
     // lookup a Subscription by id
     public PlanetSubscriptionData getSubscriptionById(String id) 
-        throws RollerException {
+            throws RollerException {
         return (PlanetSubscriptionData) strategy.load(id, PlanetSubscriptionData.class);
     }
     
@@ -254,7 +209,7 @@
     // lookup all Subscriptions
     // TODO: return List, not Iterator
     // TODO: make pageable
-    public Iterator getAllSubscriptions() {
+    public Iterator getAllSubscriptions() throws RollerException {
         try {
             Session session = ((HibernatePersistenceStrategy)strategy).getSession();
             Criteria criteria =
@@ -263,8 +218,7 @@
             List list = criteria.list();
             return list.iterator();
         } catch (Throwable e) {
-            throw new RuntimeException(
-                    "ERROR fetching subscription collection", e);
+            throw new RollerException("ERROR fetching subscription collection", e);
         }
     }
     
@@ -277,36 +231,36 @@
                     "select count(*) from org.apache.roller.planet.pojos.PlanetSubscriptionData").uniqueResult();
             return count.intValue();
         } catch (Throwable e) {
-            throw new RuntimeException(
-                    "ERROR fetching subscription count", e);
+            throw new RollerException("ERROR fetching subscription count", e);
         }
     }
     
     
-    // get popular subscriptions
-    public synchronized List getTopSubscriptions(int offset, int length) 
+    // get popular Subscriptions from all Planets & Groups
+    // TODO: test this method
+    public List getTopSubscriptions(int offset, int length) 
             throws RollerException {
         
         return getTopSubscriptions(null, offset, length);
     }
     
     
-    // get popular subscriptions
-    public synchronized List getTopSubscriptions(String groupHandle, int offset, int length)

+    // get popular Subscriptions from a specific Group
+    // TODO: test this method
+    public List getTopSubscriptions(PlanetGroupData group, int offset, int length) 
             throws RollerException {
         
         List ret = null;
         try {
             Session session = ((HibernatePersistenceStrategy)strategy).getSession();
             Query query = null;
-            if (groupHandle != null) {
+            if (group != null) {
                 query = session.createQuery(
                     "select sub from org.apache.roller.planet.pojos.PlanetSubscriptionData
sub "
                     +"join sub.groups group "
-                    +"where "
-                    +"group.handle=:groupHandle "
+                    +"where group=:group "
                     +"order by sub.inboundblogs desc");
-                query.setString("groupHandle", groupHandle);
+                query.setSerializable("group", group);
             } else {
                 query = session.createQuery(
                     "select sub from org.apache.roller.planet.pojos.PlanetSubscriptionData
sub "
@@ -327,22 +281,20 @@
     
     
     // save an Entry
-    public void saveEntry(PlanetEntryData entry) 
-        throws RollerException {
+    public void saveEntry(PlanetEntryData entry) throws RollerException {
         strategy.store(entry);
     }
     
     
     // delete an Entry
-    public void deleteEntry(PlanetEntryData entry) 
-        throws RollerException {
+    public void deleteEntry(PlanetEntryData entry) throws RollerException {
         strategy.remove(entry);
     }
     
     
     // delete all Entries from a Subscription
     public void deleteEntries(PlanetSubscriptionData sub) 
-        throws RollerException {
+            throws RollerException {
         Iterator entries = sub.getEntries().iterator();
         while(entries.hasNext()) {
             strategy.remove(entries.next());

Modified: incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java?view=diff&rev=517300&r1=517299&r2=517300
==============================================================================
--- incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java
(original)
+++ incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java
Mon Mar 12 10:37:27 2007
@@ -19,6 +19,7 @@
 package org.apache.roller.planet.tasks;
 
 import java.io.File;
+import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -88,7 +89,10 @@
             // Ensure that output directories exists, one for each group
             File outputDirObj = new File(outputDir);
             if (!outputDirObj.exists()) outputDirObj.mkdirs();
-            List groups = planetManager.getGroupHandles();
+            
+            List groups = Collections.EMPTY_LIST;
+            // groups must be part of a planet now, so getGroupHandles() was removed
+            //List groups = planetManager.getGroupHandles();
             for (Iterator it = groups.iterator(); it.hasNext();) {
                 String groupHandle = (String) it.next();
                 String groupDirName = outputDirObj + File.separator + groupHandle;

Modified: incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java?view=diff&rev=517300&r1=517299&r2=517300
==============================================================================
--- incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java
(original)
+++ incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/tasks/StaticPlanetModel.java
Mon Mar 12 10:37:27 2007
@@ -62,15 +62,15 @@
         }
     }
        
+    // removed now that groups must be part of a planet, this method no longer makes sense
+//    public List getGroups() throws RollerException {
+//        return planetManager.getGroups();
+//    }
     
-    public List getGroups() throws RollerException {
-        return planetManager.getGroups();
-    }
-    
-    
-    public PlanetGroupData getGroup(String handle) throws RollerException {
-        return planetManager.getGroup(handle);
-    }
+    // removed now that groups must be part of a planet, this method no longer makes sense
+//    public PlanetGroupData getGroup(String handle) throws RollerException {
+//        return planetManager.getGroup(handle);
+//    }
     
     
     public List getAggregation(

Modified: incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/MultiPlanetRequestMapper.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/MultiPlanetRequestMapper.java?view=diff&rev=517300&r1=517299&r2=517300
==============================================================================
--- incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/MultiPlanetRequestMapper.java
(original)
+++ incubator/roller/trunk/apps/planet/src/java/org/apache/roller/planet/ui/rendering/MultiPlanetRequestMapper.java
Mon Mar 12 10:37:27 2007
@@ -283,25 +283,4 @@
         return isPlanet;
     }
     
-    
-    private boolean isGroup(String groupHandle) {
-        
-        log.debug("checking group handle "+groupHandle);
-        
-        boolean isGroup = false;
-        
-        try {
-            PlanetManager mgr = PlanetFactory.getPlanet().getPlanetManager();
-            PlanetGroupData group = mgr.getGroup(groupHandle);
-            
-            if(group != null) {
-                isGroup = true;
-            }
-        } catch(Exception ex) {
-            // doesn't really matter to us why it's not a valid group
-        }
-        
-        return isGroup;
-    }
-    
 }

Modified: incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/GroupTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/GroupTest.java?view=diff&rev=517300&r1=517299&r2=517300
==============================================================================
--- incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/GroupTest.java
(original)
+++ incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/GroupTest.java
Mon Mar 12 10:37:27 2007
@@ -45,7 +45,7 @@
         testGroup.setPlanet(testPlanet);
         PlanetGroupData group = null;
         
-        group = mgr.getGroup("test_handle");
+        group = mgr.getGroup(testPlanet, "test_handle");
         assertNull(group);
         
         // add
@@ -106,22 +106,6 @@
             mgr.saveGroup(testGroup1);
             mgr.saveGroup(testGroup2);
             TestUtils.endSession(true);
-
-            // lookup all groups
-            groups = mgr.getGroups();
-            assertNotNull(groups);
-            assertEquals(2, groups.size());
-
-            // lookup groups in test planet
-            groups = mgr.getGroups(testPlanet);
-            assertNotNull(groups);
-            assertEquals(2, groups.size());
-
-            // lookup group handles in test planet
-            groups = null;
-            groups = mgr.getGroupHandles(testPlanet);
-            assertNotNull(groups);
-            assertEquals(2, groups.size());
 
             // lookup group by id
             group = null;

Modified: incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/PlanetManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/PlanetManagerTest.java?view=diff&rev=517300&r1=517299&r2=517300
==============================================================================
--- incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/PlanetManagerTest.java
(original)
+++ incubator/roller/trunk/apps/planet/test/java/org/apache/roller/planet/business/PlanetManagerTest.java
Mon Mar 12 10:37:27 2007
@@ -82,7 +82,7 @@
             
             PlanetSubscriptionData sub = planet.getSubscription("test_url");
             PlanetSubscriptionData sub1 = planet.getSubscription("test_url1");
-            PlanetGroupData group = planet.getGroup("test_handle");
+            PlanetGroupData group = planet.getGroup(testPlanet, "test_handle");
             
             group.getSubscriptions().add(sub);
             sub.getGroups().add(group);
@@ -98,19 +98,19 @@
         }
         {   // get group and remove one subscription
             PlanetSubscriptionData sub = planet.getSubscription("test_url");
-            PlanetGroupData group = planet.getGroup("test_handle");
+            PlanetGroupData group = planet.getGroup(testPlanet, "test_handle");
             group.getSubscriptions().remove(sub);
             TestUtils.endSession(true);
         }
         {   // get group and check it's subscriptions, remove it
-            PlanetGroupData group = planet.getGroup("test_handle");
+            PlanetGroupData group = planet.getGroup(testPlanet, "test_handle");
             Set subs = group.getSubscriptions();
             assertEquals(1, 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");
+            PlanetGroupData group = planet.getGroup(testPlanet, "test_handle");
             assertNull(group);
             PlanetSubscriptionData sub = planet.getSubscription("test_url");
             assertNotNull(sub);
@@ -243,7 +243,7 @@
             PlanetSubscriptionData sub = planet.getSubscription(feed_url1);
             int entriesSize = sub.getEntries().size();
             
-            PlanetGroupData group = planet.getGroup("test_handle");
+            PlanetGroupData group = planet.getGroup(testPlanet, "test_handle");
             assertNotNull(group);
             
             planet.deleteGroup(group);
@@ -305,7 +305,7 @@
                 assertTrue(sub2.getEntries().size() > 0);
                 assertEquals(count, sub1.getEntries().size() + sub2.getEntries().size());
                 
-                PlanetGroupData group = planet.getGroup("test_handle");
+                PlanetGroupData group = planet.getGroup(testPlanet, "test_handle");
                 assertNotNull(group);
                 
                 List bigag = planet.getAggregation(group, null, null, 0, 30);



Mime
View raw message