roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r189695 [11/67] - in /incubator/roller/trunk: ./ contrib/ contrib/lib/ contrib/plugins/ contrib/plugins/src/ contrib/plugins/src/org/ contrib/plugins/src/org/roller/ contrib/plugins/src/org/roller/presentation/ contrib/plugins/src/org/roller/presentation/velocity/ contrib/plugins/src/org/roller/presentation/velocity/plugins/ contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/ contrib/plugins/src/org/roller/presentation/velocity/plugins/bookmarks/ contrib/plugins/src/org/roller/presentation/velocity/plugins/email/ contrib/plugins/src/org/roller/presentation/velocity/plugins/jspwiki/ contrib/plugins/src/org/roller/presentation/velocity/plugins/radeox/ contrib/plugins/src/org/roller/presentation/velocity/plugins/readmore/ contrib/plugins/src/org/roller/presentation/velocity/plugins/smileys/ contrib/plugins/src/org/roller/presentation/velocity/plugins/textile/ contrib/plugins/src/org/roller/presentation/velocity/plugins/topictag/ custom/ custom/src/ custom/web/ docs/ docs/images/ docs/installguide/ docs/installguide/old/ docs/userguide/ docs/userguide/images/ docs/userguide/old/ metadata/ metadata/database/ metadata/database/hibernate/ metadata/xdoclet/ nbproject/ personal/ personal/eclipse/ personal/testing/ sandbox/ sandbox/planetroller/ sandbox/planetroller/metadata/ sandbox/planetroller/metadata/database/ sandbox/planetroller/src/ sandbox/planetroller/src/org/ sandbox/planetroller/src/org/roller/ sandbox/planetroller/src/org/roller/tools/ sandbox/planetroller/src/org/roller/tools/planet/ sandbox/planetroller/templates/ sandbox/planetroller/test/ sandbox/planetroller/test/org/ sandbox/planetroller/test/org/roller/ sandbox/planetroller/test/org/roller/model/ sandbox/planetroller/test/org/roller/tools/ sandbox/planetroller/test/org/roller/tools/planet/ sandbox/planetroller/testdata/ sandbox/planetroller/testdata/cache/ sandbox/planetroller/testdata/output/ sandbox/standalone/ sandbox/standalone/jspwiki/ sandbox/standalone/jspwiki/default/ sandbox/standalone/jspwiki/default/images/ sandbox/standalone/lib/ sandbox/standalone/src/ sandbox/standalone/src/org/ sandbox/standalone/src/org/roller/ sandbox/standalone/src/org/roller/jspwiki/ sandbox/standalone/src/org/roller/tomcat/ sandbox/standalone/src/org/roller/util/ sandbox/standalone/tests/ sandbox/standalone/tests/org/ sandbox/standalone/tests/org/roller/ sandbox/standalone/tests/org/roller/util/ sandbox/standalone/tomcat/ src/ src/org/ src/org/roller/ src/org/roller/business/ src/org/roller/business/hibernate/ src/org/roller/business/search/ src/org/roller/business/search/operations/ src/org/roller/business/utils/ src/org/roller/config/ src/org/roller/config/runtime/ src/org/roller/model/ src/org/roller/pojos/ src/org/roller/presentation/ src/org/roller/presentation/atomapi/ src/org/roller/presentation/bookmarks/ src/org/roller/presentation/bookmarks/actions/ src/org/roller/presentation/bookmarks/formbeans/ src/org/roller/presentation/bookmarks/tags/ src/org/roller/presentation/filters/ src/org/roller/presentation/forms/ src/org/roller/presentation/newsfeeds/ src/org/roller/presentation/pagecache/ src/org/roller/presentation/pagecache/rollercache/ src/org/roller/presentation/pings/ src/org/roller/presentation/planet/ src/org/roller/presentation/tags/ src/org/roller/presentation/tags/calendar/ src/org/roller/presentation/tags/menu/ src/org/roller/presentation/util/ src/org/roller/presentation/velocity/ src/org/roller/presentation/weblog/ src/org/roller/presentation/weblog/actions/ src/org/roller/presentation/weblog/formbeans/ src/org/roller/presentation/weblog/tags/ src/org/roller/presentation/website/ src/org/roller/presentation/website/actions/ src/org/roller/presentation/website/formbeans/ src/org/roller/presentation/website/tags/ src/org/roller/presentation/xmlrpc/ src/org/roller/util/ src/org/roller/util/rome/ tests/ tests/org/ tests/org/roller/ tests/org/roller/ant/ tests/org/roller/business/ tests/org/roller/presentation/ tests/org/roller/presentation/atomapi/ tests/org/roller/presentation/bookmarks/ tests/org/roller/presentation/filters/ tests/org/roller/presentation/velocity/ tests/org/roller/presentation/velocity/plugins/ tests/org/roller/presentation/velocity/plugins/smileys/ tests/org/roller/presentation/velocity/plugins/textile/ tests/org/roller/presentation/weblog/ tests/org/roller/presentation/xmlrpc/ tests/org/roller/util/ tests/org/roller/util/rome/ tools/ tools/buildtime/ tools/buildtime/ant-1.6.2/ tools/buildtime/findbugs/ tools/buildtime/findbugs/lib/ tools/buildtime/findbugs/plugin/ tools/buildtime/mockrunner-0.3/ tools/buildtime/mockrunner-0.3/lib/ tools/buildtime/mockrunner-0.35/ tools/buildtime/mockrunner-0.35/lib/ tools/buildtime/tomcat-4.1.24/ tools/buildtime/xdoclet-1.2/ tools/buildtime/xdoclet-1.2/lib/ tools/hibernate-2.1/ tools/hibernate-2.1/lib/ tools/lib/ tools/standard-1.0.3/ tools/standard-1.0.3/lib/ tools/standard-1.0.3/tld/ tools/struts-1.2.4/ tools/struts-1.2.4/lib/ web/ web/WEB-INF/ web/WEB-INF/classes/ web/WEB-INF/classes/flavors/ web/WEB-INF/classes/themes/ web/bookmarks/ web/editor/ web/editor/images/ web/images/ web/images/editor/ web/images/midas/ web/images/preview/ web/images/smileys/ web/planet/ web/tags/ web/templates/ web/theme/ web/theme/images/ web/theme/lavender/ web/theme/scripts/ web/theme/scripts/classes/ web/themes/ web/themes/basic/ web/themes/berkley/ web/themes/berkley/images/ web/themes/brushedmetal/ web/themes/brushedmetal/images/ web/themes/cheb/ web/themes/cheb/images/ web/themes/cheb/scripts/ web/themes/clean/ web/themes/currency-i18n/ web/themes/currency-i18n/images/ web/themes/currency/ web/themes/currency/images/ web/themes/grey2/ web/themes/moonshine/ web/themes/movablemanila/ web/themes/movablemanila/images/ web/themes/pacifica/ web/themes/robot/ web/themes/rolling/ web/themes/rolling/images/ web/themes/sotto/ web/themes/sotto/images/ web/themes/sotto/styles/ web/themes/sunsets/ web/themes/sunsets/images/ web/themes/sunsets/scripts/ web/themes/sunsets/styles/ web/themes/werner/ web/themes/x2/ web/themes/x2/images/ web/themes/x2/scripts/ web/themes/x2/styles/ web/weblog/ web/website/
Date Thu, 09 Jun 2005 03:19:20 GMT
Added: incubator/roller/trunk/sandbox/planetroller/src/org/roller/tools/planet/PlanetTool.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/src/org/roller/tools/planet/PlanetTool.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/src/org/roller/tools/planet/PlanetTool.java (added)
+++ incubator/roller/trunk/sandbox/planetroller/src/org/roller/tools/planet/PlanetTool.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,438 @@
+/*
+ * Copyright 2005 David M Johnson
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.roller.tools.planet;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.texen.Generator;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.jdom.xpath.XPath;
+import org.roller.RollerException;
+import org.roller.business.PlanetManagerImpl;
+import org.roller.pojos.PlanetConfigData;
+import org.roller.pojos.PlanetEntryData;
+import org.roller.pojos.PlanetGroupData;
+import org.roller.pojos.PlanetSubscriptionData;
+import org.roller.util.Utilities;
+
+
+/**
+ * Utility that aggregates multiple newsfeeds using Rome Fetcher and calls 
+ * Velocity Texen control template generate files (HTML, RSS, OPML, etc.).
+ * Does everything in memory; no database storage is used.
+ * <p />
+ * Written for Blogs, Wikis, and Feeds in Action and designed for use outside 
+ * of Roller.
+ *
+ * @author David M Johnson
+ */
+public class PlanetTool extends PlanetManagerImpl
+{
+    private static Log logger = 
+        LogFactory.getFactory().getInstance(PlanetTool.class);
+
+    protected PlanetConfigData config = null;
+    protected Map subsByURL = new HashMap(); // keys are URL strings
+    protected Map groupsByHandle = new HashMap(); // keys are handle strings
+    protected Map aggregationsByGroup = new HashMap(); // keys are GroupData objects
+    
+    /** 
+     * Construct by reading confuration JDOM Document. 
+     */
+    public PlanetTool(Document doc) throws RollerException
+    {
+        try
+        {
+            initFromXML(doc);
+        }
+        catch (JDOMException e)
+        {
+            throw new RollerException("Extracting config from parsed XML", e);
+        }
+    }
+
+    /**
+     * Call Texen control template specified by configuration to generate files.
+     */
+    public void generatePlanet() throws RollerException
+    {
+        try
+        {
+            VelocityEngine engine = new VelocityEngine();
+            engine.setProperty("resource.loader","file");
+            engine.setProperty("file.resource.loader.class",
+                 "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
+            engine.setProperty("file.resource.loader.path", 
+                 getConfiguration().getTemplateDir());
+            engine.init();
+            
+            VelocityContext context = new VelocityContext();
+            context.put("date", new Date());
+            context.put("utilities", new Utilities());
+            context.put("planet", this);
+
+            Generator generator = Generator.getInstance();
+            generator.setVelocityEngine(engine);
+            generator.setOutputEncoding("utf-8");
+            generator.setInputEncoding("utf-8");
+            generator.setOutputPath(getConfiguration().getOutputDir());
+            generator.setTemplatePath(getConfiguration().getTemplateDir());
+            generator.parse(config.getMainPage(), context);           
+            generator.shutdown();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            throw new RollerException("Writing planet files",e);
+        }
+    }
+    
+    public void saveConfiguration(PlanetConfigData config) throws RollerException
+    {
+        this.config = config;
+    }
+
+    public void saveGroup(PlanetGroupData sub) throws RollerException
+    {
+        groupsByHandle.put(sub.getHandle(), sub);
+    }
+
+    public void saveSubscription(PlanetSubscriptionData sub) throws RollerException
+    {
+        subsByURL.put(sub.getFeedUrl(), sub);
+    }
+    
+    public void saveEntry(PlanetEntryData entry) throws RollerException
+    {
+        // no-op
+    }
+
+    public PlanetSubscriptionData getSubscription(String feedUrl) 
+        throws RollerException
+    {
+        return (PlanetSubscriptionData)subsByURL.get(feedUrl);
+    }
+
+    public PlanetConfigData getConfiguration() throws RollerException
+    {
+        return config;
+    }
+
+    public List getGroupHandles() throws RollerException
+    {
+        return new ArrayList(groupsByHandle.keySet());
+    }
+
+    public List getGroups() throws RollerException
+    {
+        return new ArrayList(groupsByHandle.values());
+    }
+
+    public PlanetGroupData getGroup(String handle) throws RollerException
+    {
+        return (PlanetGroupData)groupsByHandle.get(handle);
+    }
+    
+    public List getAggregation(
+            PlanetGroupData group, int maxEntries) throws RollerException
+    {
+        long startTime = System.currentTimeMillis();
+        List aggregation = null;
+        try
+        {
+            // Get aggregation from cache
+            aggregation = (List)aggregationsByGroup.get(group);
+            if (aggregation == null) 
+            {
+                // No aggregation found in cache, let's create a new one
+                aggregation = new ArrayList();
+                
+                // Comparator to help us create reverse chrono sorted list of entries
+                Comparator entryDateComparator = new EntryDateComparator(); 
+                
+                // Add all of group's subscription's entries to ordered collection
+                Set sortedEntries = new TreeSet(entryDateComparator);
+                Iterator subs = group.getSubscriptions().iterator();
+                while (subs.hasNext())
+                {
+                    PlanetSubscriptionData sub = (PlanetSubscriptionData)subs.next();
+                    Iterator candidates = sub.getEntries().iterator();
+                    while (candidates.hasNext())
+                    {
+                        PlanetEntryData candidate = (PlanetEntryData) candidates.next();
+                        if (group.qualified(candidate))
+                        {
+                            sortedEntries.add(candidate);                        
+                        }
+                    }
+                }
+                
+                // Throw away all but first maxEntris of our new entry list
+                int count = 0;
+                Iterator entries = sortedEntries.iterator();
+                while (entries.hasNext() && count++ < maxEntries)
+                {
+                    aggregation.add(entries.next());
+                }
+                aggregationsByGroup.put(group, aggregation);
+            }
+        }
+        catch (Exception e)
+        {
+            logger.error("ERROR: building aggregation for: "+group.getHandle(), e);
+            throw new RollerException(e);
+        }
+        long endTime = System.currentTimeMillis();
+        logger.info("Generated aggregation in "
+                +((endTime-startTime)/1000.0)+" seconds");
+        return aggregation; 
+    }
+    
+    public void deleteEntry(PlanetEntryData entry) throws RollerException
+    {
+        // no-op
+    }
+
+    public void deleteGroup(PlanetGroupData group) throws RollerException
+    {
+        // no-op
+    }
+
+    public void deleteSubscription(PlanetSubscriptionData group) throws RollerException
+    {
+        // no-op
+    }
+    
+    public List getTopSubscriptions(int max) throws RollerException
+    {
+        throw new RuntimeException("Not implemented");
+    }
+
+    public PlanetSubscriptionData getSubscriptionById(String id) 
+        throws RollerException
+    {
+        throw new RuntimeException("NOT SUPPORTED");
+    }
+
+    public PlanetGroupData getGroupById(String id) 
+        throws RollerException
+    {
+        throw new RuntimeException("NOT SUPPORTED");
+    }
+    
+    public List getAggregation(int maxEntries) throws RollerException
+    {
+        throw new RuntimeException("NOT SUPPORTED");
+    }
+
+    //--------------------------------------------------------------------- console
+    
+    public static void main(String[] args) 
+    {       
+        String success = "Planet complete!";
+        String error = null;
+        Exception traceWorthy = null;
+        String fileName = "planet-config.xml"; 
+        if (args.length == 1)
+        {
+            fileName = args[0];
+        }
+        try
+        {
+            SAXBuilder builder = new SAXBuilder();
+            Document doc = builder.build(new FileInputStream(fileName));
+            PlanetTool planet = new PlanetTool(doc);         
+            planet.refreshEntries();
+            planet.generatePlanet();
+            System.out.println(success);
+            System.exit(0);
+        }
+        catch (FileNotFoundException fnfe)
+        {
+            error = "Configuration file ["+fileName+"] not found";
+        }
+        catch (JDOMException jde)
+        {
+            error = "Error parsing configuration file ["+fileName+"]";
+            traceWorthy = jde;
+        }
+        catch (IOException ioe)
+        {
+            error = "IO error. Using configuration file ["+fileName+"]";
+            traceWorthy = ioe;
+        }
+        catch (RollerException re)
+        {
+            error = re.getMessage();
+        }    
+        if (error != null) 
+        {
+            System.out.println(error);
+            if (traceWorthy != null) traceWorthy.printStackTrace();
+            System.exit(-1);
+        }
+    }
+    
+    public Iterator getAllSubscriptions()
+    {
+        return subsByURL.values().iterator();
+    }
+    
+    //-------------------------------------------------------------------- privates
+
+    /**
+     * Load config data from XML using XPath.
+     */
+    protected void initFromXML(Document doc) throws RollerException, JDOMException
+    {
+        Map subsByID = new HashMap();
+        Element elem = doc.getRootElement();
+        
+        config = new PlanetConfigData();
+        config.setCacheDir(   getString(elem,"/planet-config/cache-dir"));
+        config.setMainPage(   getString(elem,"/planet-config/main-page"));
+        config.setGroupPage(  getString(elem,"/planet-config/group-page"));
+        config.setAdminName(  getString(elem,"/planet-config/admin-name"));
+        config.setAdminEmail( getString(elem,"/planet-config/admin-email"));
+        config.setSiteUrl(    getString(elem,"/planet-config/site-url"));
+        config.setOutputDir(  getString(elem,"/planet-config/output-dir"));
+        config.setTemplateDir(getString(elem,"/planet-config/template-dir"));
+        config.setTitle(      getString(elem,"/planet-config/title"));
+        config.setDescription(getString(elem,"/planet-config/description"));
+        
+        XPath subsPath = XPath.newInstance("/planet-config/subscription");
+        Iterator subs = subsPath.selectNodes(doc).iterator();
+        while (subs.hasNext()) 
+        {
+            Element subElem = (Element)subs.next();
+            PlanetSubscriptionData sub = new PlanetSubscriptionData();
+            String id = subElem.getAttributeValue("id");
+            sub.setTitle(   getString(subElem, "title"));
+            sub.setAuthor(  getString(subElem, "author"));
+            sub.setFeedUrl( getString(subElem, "feed-url"));
+            sub.setSiteUrl( getString(subElem, "site-url"));           
+            subsByURL.put(sub.getFeedUrl(), sub);
+            subsByID.put(id, sub);
+        }
+        logger.info("Found "+subsByID.size()+" subscriptions");
+                
+        XPath groupsPath = XPath.newInstance("/planet-config/group");
+        Iterator groups = groupsPath.selectNodes(doc).iterator();
+        while (groups.hasNext()) 
+        {
+            Element groupElem = (Element)groups.next();
+            PlanetGroupData group = new PlanetGroupData();
+            group.setHandle(groupElem.getAttributeValue("handle"));
+            group.setTitle(          getString(groupElem, "title"));
+            group.setDescription(    getString(groupElem, "description"));
+            group.setMaxFeedEntries( getInt(   groupElem, "max-feed-entries"));
+            group.setMaxPageEntries( getInt(   groupElem, "max-page-entries"));
+            group.setCategoryRestriction(
+                                     getString(groupElem, "category-restriction"));
+
+            XPath refsPath = XPath.newInstance("subscription-ref");
+            Iterator refs = refsPath.selectNodes(groupElem).iterator();
+            while (refs.hasNext())
+            {
+                Element refElem = (Element)refs.next();
+                String includeAll = refElem.getAttributeValue("include-all");
+                if (includeAll != null && includeAll.equals("true"))
+                {
+                    //group.getSubscriptions().addAll(subsByID.values());
+                    group.addSubscriptions(subsByID.values());
+                }
+                else 
+                {
+                    String refid = refElem.getAttributeValue("refid");
+                    PlanetSubscriptionData sub = (PlanetSubscriptionData)subsByID.get(refid);
+                    if (sub == null) 
+                    {
+                        throw new RollerException("No such subscription ["+refid+"]");
+                    }
+                    //group.getSubscriptions().add(sub);
+                    group.addSubscription(sub); 
+                }
+            }
+            groupsByHandle.put(group.getHandle(), group);
+        }
+        logger.info("Found "+groupsByHandle.size()+" groups");
+    }
+
+    //--------------------------------------------------------------- utilities
+    
+    protected String getString(Element elem, String path) throws JDOMException {
+        XPath xpath = XPath.newInstance(path);
+        Element e = (Element)xpath.selectSingleNode(elem);
+        return e!=null ? e.getText() : null;
+    }
+    
+    protected int getInt(Element elem, String path) throws JDOMException {
+        XPath xpath = XPath.newInstance(path);
+        Element e = (Element)xpath.selectSingleNode(elem);
+        return e!=null ? Integer.parseInt(e.getText()) : 0;
+    }
+    
+    public class EntryDateComparator implements Comparator
+    {
+        public int compare(Object o1, Object o2)
+        {
+            PlanetEntryData e1 = (PlanetEntryData)o1;
+            PlanetEntryData e2 = (PlanetEntryData)o2;
+            if (e1.getPublished() != null && e2.getPublished() != null)
+            {
+                return e2.getPublished().compareTo(e1.getPublished());
+            }
+            if (e1.getPublished() == null)
+            {
+                logger.warn("Entry missing pubDate in sub: " 
+                        + e1.getSubscription().getFeedUrl());
+            }
+            if (e2.getPublished() == null)
+            {
+                logger.warn("Entry missing pubDate in sub: " 
+                        + e2.getSubscription().getFeedUrl());
+            }            
+            return 0;
+        }            
+    }
+
+    /**
+     * Total number of subscriptions.
+     */
+    public int getSubscriptionCount() throws RollerException 
+    {
+        return this.subsByURL.size();
+    };
+}
+

Added: incubator/roller/trunk/sandbox/planetroller/templates/control.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/templates/control.vm?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/templates/control.vm (added)
+++ incubator/roller/trunk/sandbox/planetroller/templates/control.vm Wed Jun  8 20:18:46 2005
@@ -0,0 +1,10 @@
+#set ($groupHandles = $planet.groupHandles)
+#foreach ($groupHandle in $groupHandles)
+    #set ($outputFile = $strings.concat([$groupHandle, ".html"]))
+    $generator.parse("html.vm", $outputFile, "groupHandle", $groupHandle)
+    #set ($outputFile = $strings.concat([$groupHandle, ".rss"]))
+    $generator.parse("rss.vm",  $outputFile, "groupHandle", $groupHandle)
+    #set ($outputFile = $strings.concat([$groupHandle, ".opml"]))
+    $generator.parse("opml.vm", $outputFile, "groupHandle", $groupHandle)
+#end
+ê
\ No newline at end of file

Added: incubator/roller/trunk/sandbox/planetroller/templates/html-planet.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/templates/html-planet.vm?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/templates/html-planet.vm (added)
+++ incubator/roller/trunk/sandbox/planetroller/templates/html-planet.vm Wed Jun  8 20:18:46 2005
@@ -0,0 +1,82 @@
+<html>
+#set($group = $planet.getGroup($groupHandle))
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+   <title>$group.title</title>
+   <link rel="stylesheet" media="screen" type="text/css" href="planet-roller.css">
+</head>
+<body>
+
+<div id="banner">
+&nbsp;$group.title<br />
+</div>
+
+<div class="dateheading">
+</div>
+#set($entries = $planet.getAggregation($group, $group.maxPageEntries))
+#foreach($entry in $entries)
+<div class="entry"> 
+   <h2>
+       <a href="$entry.subscription.siteUrl" title="$entry.subscription.title">
+       #if ($entry.author) $entry.author
+       #else $utilities.truncateNicely($entry.subscription.title, 15, 20, "...")
+       #end
+       </a> - <a href="$entry.permalink">$entry.title</a>
+       <br /><span  style="font-size:small">$entry.getCategoriesAsString("|")</a>
+       <span class="techno">
+          <a href="http://www.technorati.com/cosmos/search.html?rak=&amp;sub=mtcosmos&amp;url=$entry.permalink">
+             <img class="button" src="cosmos.gif" alt="[Technorati links]" height="18" width="19">
+          </a>
+       </span>
+   </h2>
+   <div class="date">
+      <a href="$entry.permalink">$entry.published</a> 
+   </div>
+$entry.content
+</div>
+#end
+
+<br>
+
+<div id="sidebar">
+   <div id="about">
+   <h1>About</h1>
+   <p>
+      Planet Roller is an aggregation of public weblogs written by folks interested
+      in the <a href="http://rollerweblogger.org">Roller Weblogger.</a>.
+      The opinions expressed in those weblogs and hence
+      this aggregation are those of the original authors.
+   </p>
+   <p>
+      Planet Roller is powered by an experimental new proposed 
+      <a href="">Roller</a> feature called, drum role please... Planet Roller.
+   </p>
+   <p>
+	  Site design borrowed from David Edmonson's 
+	  <a href="http://planetsun.org">Planet Sun</a> design.
+   </p>
+   <p>
+      <a href="$planet.configuration.siteUrl/${groupHandle}.rss"><img class="button"
+         src="rss20.png" alt="[RSS 2.0 Feed]" height="15" width="80"></a>
+      <a href="$planet.configuration.siteUrl/${groupHandle}.opml"><img class="button"
+         src="opml.png" alt="[OPML Subscriptions]" height="15" width="80"></a>
+   </p>
+</div>
+
+<div id="freshness">
+   <p>Last updated: $utilities.formatRfc822Date($date)</p>
+</div>
+
+<div id="blogroll">
+   <h1>Subscriptions</h1>
+   <ul>
+   #foreach ($sub in $group.subscriptions)
+      <li><a href="$sub.siteUrl">$sub.title</a><a href="$sub.feedUrl">(feed)</a></li>
+   #end
+   </ul>
+</div>
+</div>
+
+</body>
+</html>
+

Added: incubator/roller/trunk/sandbox/planetroller/templates/html-twocol.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/templates/html-twocol.vm?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/templates/html-twocol.vm (added)
+++ incubator/roller/trunk/sandbox/planetroller/templates/html-twocol.vm Wed Jun  8 20:18:46 2005
@@ -0,0 +1,67 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+	<link rel="stylesheet" href="twocol.css" type="text/css" />
+	<title>Blog Together</title>
+</head>
+<body>
+<div id="container">
+
+<!-- head ================================================================ -->
+<div id="head">
+#set($group = $planet.getGroup($groupHandle))
+<h1>$group.title</h1>
+$group.description
+</div>
+
+<!-- left ================================================================ -->
+<div id="left">
+   <p>An aggregated weblog that includes these weblogs:</p>
+   #foreach ($sub in $group.subscriptions)
+      <a href="$sub.siteUrl">$sub.title</a><a href="$sub.feedUrl">(feed)</a><br />
+   #end
+   <p />
+   <a href="$planet.configuration.siteUrl/${groupHandle}.rss"><img class="button"
+      src="rss20.png" alt="[RSS 2.0 Feed]" height="15" width="80"></a>
+   <br />
+   <br />
+   <a href="$planet.configuration.siteUrl/${groupHandle}.opml"><img class="button"
+      src="opml.png" alt="[OPML Subscriptions]" height="15" width="80"></a>
+</div>
+
+<!-- right =============================================================== -->
+<div id="right">
+&nbsp;
+</div>
+
+<!-- center ============================================================== -->
+<div id="center">
+HI
+#set($entries = $planet.getAggregation($group, $group.maxPageEntries))
+#foreach($entry in $entries)
+<div class="entry"> 
+   <h3>
+       <a href="$entry.subscription.siteUrl" title="$entry.subscription.title">
+       #if ($entry.author) $entry.author
+       #else $utilities.truncateNicely($entry.subscription.title, 15, 20, "...")
+       #end
+       </a> - <a href="$entry.permalink">$entry.title</a>
+       <br /><span  style="font-size:small">[$entry.getCategoriesAsString("|")]</span>
+   </h3>
+   <div class="date">
+      <a href="$entry.permalink">$entry.published</a> 
+   </div>
+$entry.content
+</div>
+#end
+</div>
+
+<!-- footer -->
+<div id="foot">&nbsp;</div>
+
+</div>
+
+</body>
+</html>

Added: incubator/roller/trunk/sandbox/planetroller/templates/html.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/templates/html.vm?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/templates/html.vm (added)
+++ incubator/roller/trunk/sandbox/planetroller/templates/html.vm Wed Jun  8 20:18:46 2005
@@ -0,0 +1,36 @@
+<html>
+#set($group = $planet.getGroup($groupHandle))
+#set($entries = $planet.getAggregation($group, $group.maxPageEntries))
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
+<title>$group.title</title>
+</head>
+<body>
+<table>
+   <tr>
+      <td width="80%" valign="top">
+         <h1>$group.title</h1>
+         <p><i>$group.description<i/></p>
+         <p>Last updated: $utilities.formatRfc822Date($date)</p>
+         #foreach($entry in $entries)
+            <h2>$entry.title</h2>
+            Blog: $entry.subscription.title <br/>
+            Date: $entry.published<br/>
+            <a href="$entry.permalink">Permalink</a><br/>
+            <p>$entry.content</p>
+         #end
+      </td>
+      <td width="20%" valign="top">
+         <h3>Other formats</h3>
+         <a href="$planet.configuration.siteUrl/${groupHandle}.rss">
+            <img src="rss20.png" alt="RSS 2.0 Feed" border="0"></a><p />
+         <a href="$planet.configuration.siteUrl/${groupHandle}.opml">
+            <img src="opml.png" alt="OPML Subscriptions" border="0"></a>
+         <h3>Subscriptions</h3>
+         #foreach ($sub in $group.subscriptions)
+         <a href="$sub.siteUrl">$sub.title</a> <a href="$sub.feedUrl">(feed)</a>
+         <br/>
+         #end
+      </td>
+</tr>
+</body></html>

Added: incubator/roller/trunk/sandbox/planetroller/templates/opml.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/templates/opml.vm?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/templates/opml.vm (added)
+++ incubator/roller/trunk/sandbox/planetroller/templates/opml.vm Wed Jun  8 20:18:46 2005
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding='utf-8'?>
+#set($group = $planet.getGroup($groupHandle))
+<opml version="1.1">
+<head>
+   <title>$group.description</title>
+   <dateCreated>$utilities.formatRfc822Date($date)</dateCreated>
+   <dateModified>$utilities.formatRfc822Date($date)</dateModified>
+   <ownerName>$planet.configuration.adminName</ownerName>
+   <ownerEmail>$planet.configuration.adminEmail</ownerEmail>
+</head>
+<body>
+#foreach($sub in $group.subscriptions)
+   <outline text="$utilities.textToHTML($sub.title)" 
+          xmlUrl="$utilities.textToHTML($sub.feedUrl)" 
+         htmlUrl="$utilities.textToHTML($sub.siteUrl)" />
+#end
+</body>
+</opml>

Added: incubator/roller/trunk/sandbox/planetroller/templates/rss.vm
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/templates/rss.vm?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/templates/rss.vm (added)
+++ incubator/roller/trunk/sandbox/planetroller/templates/rss.vm Wed Jun  8 20:18:46 2005
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
+<channel>
+  #set($group = $planet.getGroup($groupHandle))
+  <title>$utilities.textToHTML($group.title,true)</title>
+  <link>$utilities.textToHTML(${planet.configuration.siteUrl})/${group.handle}.html</link>
+  <description>$utilities.textToHTML($group.description,true)</description>
+  <lastBuildDate>$utilities.formatRfc822Date($date)</lastBuildDate>
+  <generator>Roller Planet 1.1-dev</generator>
+  #set($entries = $planet.getAggregation($group, $group.maxFeedEntries))
+  #foreach( $entry in $entries )
+  <item>
+    #if($entry.title)<title>$utilities.textToHTML($entry.title,true)</title> #end
+    #if($entry.content)
+       <description>$utilities.textToHTML($entry.content,true)</description> #end
+    #if($entry.categories)
+        #foreach($cat in $entry.categories)
+     	   <category>$utilities.textToHTML($cat,true)</category>
+     	#end
+    #end
+    #if($entry.permalink)<link>$utilities.textToHTML($entry.permalink)</link> #end
+    <pubDate>$utilities.formatRfc822Date($entry.published)</pubDate>
+    #if($entry.author)
+       <dc:creator>$utilities.textToHTML($entry.author,true)</dc:creator>
+    #end
+  </item>
+  #end
+</channel>
+</rss>

Added: incubator/roller/trunk/sandbox/planetroller/test/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/test/log4j.properties?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/test/log4j.properties (added)
+++ incubator/roller/trunk/sandbox/planetroller/test/log4j.properties Wed Jun  8 20:18:46 2005
@@ -0,0 +1,55 @@
+# Properties for configuring Log4j for this application
+# This is the configuring for logging displayed in the Application Server
+log4j.rootCategory=INFO, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+#log4j.appender.stdout.layout.ConversionPattern=%p [%t] [%c] %C{1}.%M(%L) | %m%n
+log4j.appender.stdout.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} | %C{1}:%M | %m%n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=planet.log
+
+# Keep two 1MB log backup files
+log4j.appender.R.MaxFileSize=1MB
+log4j.appender.R.MaxBackupIndex=2
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+#log4j.appender.R.layout.ConversionPattern=%5p %t %c - %m%n
+log4j.appender.R.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %C{1}:%M - %m%n
+
+# If programmed properly the most messages would be at DEBUG
+# and the least at FATAL.
+
+# Options are: DEBUG, INFO, WARN, ERROR, FATAL
+log4j.category.com.ecyrd.jspwiki=ERROR
+log4j.category.com.opensymphony.oscache=ERROR
+log4j.category.net.sf.hibernate=ERROR
+log4j.category.org.roller=ERROR
+log4j.category.org.roller.business.utils=INFO
+log4j.category.org.apache.struts=ERROR
+log4j.category.org.tuckey.web.filters.urlrewrite=DEBUG
+#log4j.category.org.roller.presentation.MainPageAction=DEBUG
+#log4j.category.org.roller.presentation.pagecache.rollercache.LRUCacheHandler=DEBUG
+#log4j.category.org.roller.presentation.filters.IfModifiedFilter=DEBUG
+#log4j.category.org.roller.persistence.hibernate.HibernateStrategy=DEBUG
+
+# Tomcat's ClientAbortExceptions cause Velocity to talk way
+# too much so by default Velocity is set to STFU mode.
+log4j.category.org.apache.velocity=FATAL
+
+# Configuration for receiving e-mails when ERROR messages occur.
+#log4j.appender.mail=org.apache.log4j.net.SMTPAppender
+#log4j.appender.mail.To=you@yours.com
+#log4j.appender.mail.From=you@yours.com
+#log4j.appender.mail.SMTPHost=127.0.0.1
+#log4j.appender.mail.Threshold=ERROR
+#log4j.appender.mail.BufferSize=1
+#log4j.appender.mail.Subject=Roller Exception
+
+#log4j.appender.mail.layout=org.apache.log4j.PatternLayout
+#log4j.appender.mail.layout.ConversionPattern=%p [%d{yyyy-MM-dd HH:mm:ss,SSS}] %C{1}.%M(%L) | %m%n
+
+

Added: incubator/roller/trunk/sandbox/planetroller/test/org/roller/model/PlanetManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/test/org/roller/model/PlanetManagerTest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/test/org/roller/model/PlanetManagerTest.java (added)
+++ incubator/roller/trunk/sandbox/planetroller/test/org/roller/model/PlanetManagerTest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,425 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.roller.model;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.roller.RollerException;
+import org.roller.pojos.PlanetConfigData;
+import org.roller.pojos.PlanetEntryData;
+import org.roller.pojos.PlanetGroupData;
+import org.roller.pojos.PlanetSubscriptionData;
+import org.roller.pojos.UserData;
+
+/**
+ * Test database implementation of PlanetManager.
+ * @author Dave Johnson
+ */
+public class PlanetManagerTest extends TestCase
+{
+    private Roller roller = null;
+    
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(PlanetManagerTest.class);
+    }
+
+    public void testConfigurationStorage() throws Exception
+    {
+        Roller roller = getRoller();
+        assertNotNull(roller);       
+        PlanetManager planet = roller.getPlanetManager();
+        assertNotNull(planet);    
+        
+        {   // save config with default group
+            roller.begin();
+            
+            PlanetConfigData config = new PlanetConfigData();
+            config.setCacheDir("test_cache_dir");
+            config.setTitle("test_title");
+            config.setAdminEmail("test_admin_email");
+
+            PlanetGroupData group = new PlanetGroupData();
+            group.setDescription("test_group_desc");
+            group.setHandle("test_handle");
+            group.setTitle("test_title");
+            planet.saveGroup(group);
+            
+            config.setDefaultGroup(group);
+            planet.saveConfiguration(config);
+            
+            roller.commit();
+        }
+        {   // retrieve config and default group
+            roller.begin();
+            PlanetConfigData config = planet.getConfiguration();
+            assertEquals("test_cache_dir",config.getCacheDir());
+            assertEquals("test_title", config.getTitle());
+            assertEquals("test_admin_email", config.getAdminEmail());
+            
+            PlanetGroupData group = config.getDefaultGroup();
+            assertEquals("test_group_desc",group.getDescription());
+            assertEquals("test_title",group.getTitle());
+            
+            roller.rollback();
+        }
+        {   // remove config
+            roller.begin();
+            PlanetConfigData config = planet.getConfiguration();
+            config.remove();
+            roller.commit();
+        }
+        {
+            // make sure config and group are gone
+            roller.begin();
+            PlanetConfigData config = planet.getConfiguration();
+            assertNull(config);
+            PlanetGroupData group = planet.getGroup("test_handle");
+            assertNull(group);
+            roller.rollback();
+        }
+    }
+    
+    public void testGroupStorage() throws Exception
+    {
+        Roller roller = getRoller();
+        assertNotNull(roller);       
+        PlanetManager planet = roller.getPlanetManager();
+        assertNotNull(planet);  
+        
+        {   // save group
+            roller.begin(UserData.SYSTEM_USER);
+            PlanetGroupData group = new PlanetGroupData();
+            group.setDescription("test_group_desc");
+            group.setHandle("test_handle");
+            group.setTitle("test_title");
+            planet.saveGroup(group);
+            roller.commit();
+        }
+        {   // retrieve group 
+            roller.begin();
+            PlanetGroupData group = planet.getGroup("test_handle");
+            assertEquals("test_group_desc",group.getDescription());
+            assertEquals("test_title",group.getTitle());
+            assertEquals(1, planet.getGroupHandles().size());
+            roller.rollback();
+        }
+        {   // remove group
+            roller.begin();
+            PlanetGroupData group = planet.getGroup("test_handle");
+            planet.deleteGroup(group);
+            roller.commit();
+        }
+        {   // verify that it is gone
+            roller.begin();
+            PlanetGroupData group = planet.getGroup("test_handle");
+            assertNull(group);
+            roller.rollback();
+        }
+    }
+    
+    public void testSubscriptionStorage() throws Exception
+    {
+        Roller roller = getRoller();
+        assertNotNull(roller);       
+        PlanetManager planet = roller.getPlanetManager();
+        assertNotNull(planet);        
+        
+        {   // save subscription
+            roller.begin();
+            PlanetSubscriptionData sub = new PlanetSubscriptionData();
+            sub.setFeedUrl("test_url");
+            planet.saveSubscription(sub);
+            roller.commit();
+        }
+        {   // retrieve subscription and add to group
+            roller.begin();
+            
+            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);
+
+            roller.commit();
+        }
+        {   // get group and check it's subscriptions, remove it
+            roller.begin();
+            PlanetGroupData group = planet.getGroup("test_handle");
+            Set subs = group.getSubscriptions();
+            assertEquals(2, subs.size());            
+            planet.deleteGroup(group);
+            roller.commit();
+        }
+        {   // make sure group gone, subs still there, then remove them too
+            roller.begin();
+            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);
+            roller.commit();
+        }
+        {   // make sure subscriptions are gone
+            roller.begin();
+            PlanetSubscriptionData sub = planet.getSubscription("test_url");
+            assertNull(sub);
+            PlanetSubscriptionData sub1 = planet.getSubscription("test_url1");
+            assertNull(sub1);
+            roller.rollback();
+        }
+    }
+    public void testSubscriptionEntryStorage() throws Exception
+    {
+        Roller roller = getRoller();
+        assertNotNull(roller);       
+        PlanetManager planet = roller.getPlanetManager();
+        assertNotNull(planet);        
+        
+        {   // save subscription
+            roller.begin();
+            PlanetSubscriptionData sub = new PlanetSubscriptionData();
+            sub.setFeedUrl("test_url");
+            planet.saveSubscription(sub);
+            roller.commit();
+        }
+        {   // retrieve subscription and add entries
+            roller.begin();
+            PlanetSubscriptionData sub = planet.getSubscription("test_url");
+            assertNotNull(sub);
+            
+            PlanetEntryData entry1 = new PlanetEntryData();
+            entry1.setPermalink("test_entry1");
+            entry1.setCategoriesString("test,test2");
+            entry1.setSubscription(sub);
+            entry1.setPublished(new Date());
+            entry1.save();
+            sub.addEntry(entry1);
+            
+            PlanetEntryData entry2 = new PlanetEntryData();
+            entry2.setPermalink("test_entry2");
+            entry2.setCategoriesString("test_cat1,test_cat2,test_cat3");
+            entry2.setSubscription(sub);
+            entry2.setPublished(new Date());
+            entry2.save();
+            sub.addEntry(entry2);
+            
+            roller.commit();
+        }
+        {   // get sub and check it's entries, remove it
+            roller.begin();
+            PlanetSubscriptionData sub = planet.getSubscription("test_url");
+            assertEquals(2, sub.getEntries().size());
+            planet.deleteSubscription(sub);
+            roller.commit();
+        }
+        {   // make sure sub is gone
+            roller.begin();
+            PlanetSubscriptionData sub = planet.getSubscription("test_url");
+            assertNull(sub);
+            roller.rollback();
+        }
+    }
+    public void testRefreshEntries() throws Exception
+    {
+        Roller roller = getRoller();
+        assertNotNull(roller);       
+        PlanetManager planet = roller.getPlanetManager();
+        assertNotNull(planet);     
+        String feed_url1 = "http://rollerweblogger.org/rss/roller";
+        {   
+            roller.begin();
+            PlanetConfigData config = new PlanetConfigData();
+            config.setCacheDir("/tmp"); // TODO use real temp dir
+            config.setTitle("test_title");
+            config.setAdminEmail("test_admin_email");
+            planet.saveConfiguration(config);
+            
+            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);
+            
+            roller.commit();
+        }        
+        {   
+            roller.begin();
+            planet.refreshEntries();
+            roller.commit();
+            
+            roller.begin();
+            PlanetSubscriptionData sub = planet.getSubscription(feed_url1);
+            assertTrue(sub.getEntries().size() > 0);
+      
+            PlanetGroupData group = planet.getGroup("test_handle");
+            assertNotNull(group);
+            
+            planet.deleteSubscription(sub);
+            planet.deleteGroup(group);
+            
+            PlanetConfigData config = planet.getConfiguration();
+            config.remove();
+            roller.commit();
+        }
+    }
+    public void testAggregations() throws Exception
+    {
+        Roller roller = getRoller();
+        assertNotNull(roller);       
+        PlanetManager planet = roller.getPlanetManager();
+        assertNotNull(planet);     
+        String feed_url1 = "http://rollerweblogger.org/rss/roller";
+        String feed_url2 = "http://linuxintegrators.com/acoliver/?flavor=rss2";
+        {   
+            roller.begin();
+            PlanetConfigData config = new PlanetConfigData();
+            config.setCacheDir("/tmp"); // TODO use real temp dir
+            config.setTitle("test_title");
+            config.setAdminEmail("test_admin_email");
+            planet.saveConfiguration(config);
+            
+            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);
+            
+            roller.commit();
+        }        
+        {   
+            roller.begin();
+            planet.refreshEntries();
+            roller.commit();
+            
+            roller.begin();
+            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, 1000);
+            assertEquals(bigag.size(), count);
+                  
+            List littleag = planet.getAggregation(group, 10);
+            assertEquals(littleag.size(), count);
+                              
+            planet.deleteSubscription(sub1);
+            planet.deleteSubscription(sub2);
+            planet.deleteGroup(group);
+            
+            PlanetConfigData config = planet.getConfiguration();
+            config.remove();
+            roller.commit(); 
+        }
+    }
+    public void testSubscriptionCount() throws Exception
+    {
+        Roller roller = getRoller();
+        assertNotNull(roller);       
+        PlanetManager planet = roller.getPlanetManager();
+        assertNotNull(planet);     
+        String feed_url1 = "http://rollerweblogger.org/rss/roller";
+        String feed_url2 = "http://linuxintegrators.com/acoliver/?flavor=rss2";
+        {   
+            roller.begin();            
+            PlanetSubscriptionData sub1 = new PlanetSubscriptionData();
+            sub1.setFeedUrl(feed_url1);
+            planet.saveSubscription(sub1);            
+            PlanetSubscriptionData sub2 = new PlanetSubscriptionData();
+            sub2.setFeedUrl(feed_url2);
+            planet.saveSubscription(sub2);
+            roller.commit();
+
+            roller.begin();
+            assertEquals(2, planet.getSubscriptionCount());
+            roller.rollback();
+        }        
+    }
+    /*
+    public void testRankingRange()
+    {
+        int limit = 1000;
+        int count = 5500;
+        int mod = (count / limit) + 1;        
+        for (int i=0; i<20; i++)
+        {
+            int start = (i % mod) * limit;
+            int end = start + 999;
+            end = end > count ? count : end; 
+            System.out.println("start="+start+" end="+end);
+        }
+    }
+    */
+    public Roller getRoller() throws RollerException
+    {
+        return RollerFactory.getRoller();
+    }
+}
+    

Added: incubator/roller/trunk/sandbox/planetroller/test/org/roller/tools/planet/PlanetToolTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/sandbox/planetroller/test/org/roller/tools/planet/PlanetToolTest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/test/org/roller/tools/planet/PlanetToolTest.java (added)
+++ incubator/roller/trunk/sandbox/planetroller/test/org/roller/tools/planet/PlanetToolTest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.roller.tools.planet;
+
+import java.io.FileInputStream;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.velocity.app.Velocity;
+import org.jdom.Document;
+import org.jdom.input.SAXBuilder;
+import org.roller.model.PlanetManager;
+import org.roller.pojos.PlanetConfigData;
+import org.roller.pojos.PlanetGroupData;
+import org.roller.pojos.PlanetSubscriptionData;
+import org.roller.util.rome.ContentModule;
+
+import com.sun.syndication.feed.module.DCModule;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.XmlReader;
+
+/**
+ * Test command line version of PlanetManager (and misc. parsing tests)
+ * @author David M Johnson
+ */
+public class PlanetToolTest extends TestCase
+{
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(PlanetToolTest.class);
+    }
+
+    public void _testLoadConfig() throws Exception
+    {
+        SAXBuilder builder = new SAXBuilder();
+        Document doc = builder.build(
+                new FileInputStream("./testdata/planet-test.xml"));
+        
+        Properties props = new Properties();
+        Velocity.init(props);
+        
+        PlanetManager planetTool = new PlanetTool(doc);
+        PlanetConfigData config = planetTool.getConfiguration();
+ 
+        assertNotNull(config.getMainPage());
+        assertEquals(3, planetTool.getGroupHandles().size());
+        assertNotNull(planetTool.getGroup("all"));
+        assertNotNull(planetTool.getGroup("roller"));
+        assertNotNull(planetTool.getGroup("davejava"));
+        
+        PlanetGroupData allGroup = planetTool.getGroup("all");
+        assertEquals(2, allGroup.getSubscriptions().size());
+        
+        PlanetGroupData lanceGroup = planetTool.getGroup("roller");
+        assertEquals(2, lanceGroup.getSubscriptions().size());
+        
+        PlanetGroupData rollerGroup = planetTool.getGroup("davejava");
+        assertEquals(1, rollerGroup.getSubscriptions().size());
+        
+        Iterator subs = allGroup.getSubscriptions().iterator();
+        while (subs.hasNext())
+        {
+            PlanetSubscriptionData sub = (PlanetSubscriptionData) subs.next();
+            assertNotNull(sub.getFeedUrl());
+            assertNotNull(sub.getSiteUrl());
+        }
+    }
+    public void _testAggregation() throws Exception
+    {
+        SAXBuilder builder = new SAXBuilder();
+        Document doc = builder.build(
+                new FileInputStream("./testdata/planet-test.xml"));
+         
+        PlanetManager planetTool = new PlanetTool(doc);
+        planetTool.refreshEntries();
+        
+        PlanetGroupData allGroup = planetTool.getGroup("all");
+        List ag2 = planetTool.getAggregation(allGroup, 100);
+        assertEquals(30, ag2.size());
+        
+        PlanetGroupData rollerGroup = planetTool.getGroup("roller");
+        List ag3 = planetTool.getAggregation(rollerGroup, 100);
+        assertEquals(15, ag3.size());
+
+        PlanetGroupData daveGroup = planetTool.getGroup("davejava");
+        List ag4 = planetTool.getAggregation(daveGroup, 15);
+        assertEquals(15, ag4.size());        
+    }
+    /**
+     * We had to extend Rome to handle Goslings's weird mix of RSS 0.91 + pubDates
+     */
+    public void testPubDateParsing() throws Exception
+    { 
+        _testPubDateParsing("http://weblogs.java.net/jag/blog.rss");
+        _testPubDateParsing("http://lotusmedia.org/feed/");
+        _testPubDateParsing("http://sciencepolitics.blogspot.com/atom.xml");
+        _testPubDateParsing("http://mistersugar.com/?atom=1");
+        _testPubDateParsing("http://alvinphillips.com/?atom=1");
+        _testPubDateParsing("http://mistersugar.com/blogtogether/?rss=1");
+        _testPubDateParsing("http://www.irelan.net/becoming/wp-rss.php");
+    }
+    public void _testPubDateParsing(String url) throws Exception
+    { 
+        HttpClient client = new HttpClient();
+        GetMethod method = new GetMethod(url);
+        System.setProperty("httpclient.useragent", "Rome Fetcher");
+        int code = client.executeMethod(method);
+        SyndFeedInput input = new SyndFeedInput();
+        SyndFeed feed = input.build(new XmlReader(method.getResponseBodyAsStream())); 
+        assertNotNull(((SyndEntry)feed.getEntries().get(0)).getPublishedDate());
+    }
+    /**
+     * Had to work around Rome bug that squashed &lt;dc:date&gt;
+     */
+    public void testDCDateParsing() throws Exception
+    { 
+        // Test funky RSS 2.0 with <dc:date> instead of <pubDate> 
+        _testDCDateParsing("http://bitworking.org/index.rss");
+        _testDCDateParsing("http://silflayhraka.com/index.xml");
+        
+        // Test RSS 1.0 with <dc:date>  
+        _testDCDateParsing("http://www.isthatlegal.org/rss/isthatlegal.xml");
+    }
+    public void _testDCDateParsing(String url) throws Exception
+    { 
+        URL feedUrl = new URL(url);
+        SyndFeedInput input = new SyndFeedInput();
+        SyndFeed feed = input.build(new XmlReader(feedUrl)); 
+        SyndEntry entry = (SyndEntry)feed.getEntries().get(0);
+        DCModule dcm = (DCModule)entry.getModule(DCModule.URI);
+        assertNotNull(dcm.getDate());
+    }
+    /**
+     * Feeds with content in &lt;content:encoded%gt; 
+     */
+    public void testContentEncodedParsing() throws Exception
+    { 
+        // Test feeds with content in <content:encoded> 
+        _testContentEncodedParsing("http://www.intertwingly.net/blog/index.rdf");
+        _testContentEncodedParsing("http://www.isthatlegal.org/rss/isthatlegal.xml");
+    }
+    public void _testContentEncodedParsing(String url) throws Exception
+    { 
+        URL feedUrl = new URL(url);
+        SyndFeedInput input = new SyndFeedInput();
+        SyndFeed feed = input.build(new XmlReader(feedUrl)); 
+        SyndEntry entry = (SyndEntry)feed.getEntries().get(0);
+        ContentModule cm = (ContentModule)entry.getModule(ContentModule.URI);
+        assertNotNull(cm.getEncoded());
+    }
+}
+
+
+
+
+
+
+



Mime
View raw message