roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r465339 - in /incubator/roller/trunk: sandbox/planetroller/ sandbox/planetroller/src/org/apache/roller/planet/tasks/ sandbox/planetroller/templates/ sandbox/planetroller/web/WEB-INF/classes/ src/org/apache/roller/business/hibernate/ src/org...
Date Wed, 18 Oct 2006 18:59:11 GMT
Author: snoopdave
Date: Wed Oct 18 11:59:10 2006
New Revision: 465339

URL: http://svn.apache.org/viewvc?view=rev&rev=465339
Log:
More fixes in planet tasks

Removed:
    incubator/roller/trunk/sandbox/planetroller/templates/html-planet.vm
    incubator/roller/trunk/sandbox/planetroller/templates/html-twocol.vm
Modified:
    incubator/roller/trunk/sandbox/planetroller/build.xml
    incubator/roller/trunk/sandbox/planetroller/src/org/apache/roller/planet/tasks/GeneratePlanetTask.java
    incubator/roller/trunk/sandbox/planetroller/templates/html.vm
    incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/hibernate.cfg.xml
    incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/planet.properties
    incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/rome.properties
    incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java
    incubator/roller/trunk/src/org/apache/roller/business/runnable/TaskRunner.java
    incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java

Modified: incubator/roller/trunk/sandbox/planetroller/build.xml
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/planetroller/build.xml?view=diff&rev=465339&r1=465338&r2=465339
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/build.xml (original)
+++ incubator/roller/trunk/sandbox/planetroller/build.xml Wed Oct 18 11:59:10 2006
@@ -67,8 +67,6 @@
     <target name="stage-webapp" description="Build Planet webapp">
         
         <mkdir dir="./build/classes" />
-        <mkdir dir="./build/webapp/WEB-INF/lib" />
-
         <javac debug="on" destdir="./build/classes">
             <src path="./src" />
             <classpath>
@@ -76,46 +74,23 @@
             </classpath>
         </javac>
 
+        <mkdir dir="./build/webapp/WEB-INF/lib" />
         <jar basedir="./build/classes" destfile="./build/webapp/WEB-INF/lib/roller-planet.jar"
/>
-        
         <copy todir="./build/webapp/WEB-INF/lib">
             <fileset refid="roller-jars" />
-        </copy> 
-        
+        </copy>         
+
         <copy todir="./build/webapp">
             <fileset dir="./web" includes="**/**" />
         </copy> 
-        
-    </target>
-    
-    <target name="release" depends="stage-webapp" description="Package for release">
-        
-        <!-- Include jars needed to run -->
-        <mkdir dir="./build/planetroller/lib" />
-        <jar basedir="./build/classes" 
-            destfile="./build/planetroller/lib/roller-planet.jar" />
-        <copy todir="./build/planetroller/lib">
-            <fileset refid="roller-jars" />
-        </copy>
-        
-        <!-- Include sample theme, template, and config files -->
-        <mkdir dir="./build/planetroller/templates" />
-        <copy todir="./build/planetroller/templates">
-            <fileset dir="./templates" includes="*.vm" />
-        </copy>
 
-        <copy todir="./build/planetroller" >
-            <fileset dir="./etc" includes="**/**" />
-        </copy>
-        <chmod file="./build/planetroller/setenv.sh" perm="+x" />
-        <chmod file="./build/planetroller/planet-tool.sh" perm="+x" />
-              
-        <!-- Package it up -->
-        <mkdir dir="./dist" />
-        <tar destfile="./dist/roller-planet.tar" 
-            basedir="./build" includes="planetroller/**" />
-        
+        <mkdir dir="./build/webapp/WEB-INF/templates" />
+        <copy todir="./build/webapp/WEB-INF/templates">
+            <fileset dir="./templates" includes="**/**" />
+        </copy> 
+
     </target>
+    
    
     <!-- Copy files locally for convenience in IDE -->
     <target name="copy-roller-jars-for-ide">

Modified: incubator/roller/trunk/sandbox/planetroller/src/org/apache/roller/planet/tasks/GeneratePlanetTask.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/planetroller/src/org/apache/roller/planet/tasks/GeneratePlanetTask.java?view=diff&rev=465339&r1=465338&r2=465339
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/src/org/apache/roller/planet/tasks/GeneratePlanetTask.java
(original)
+++ incubator/roller/trunk/sandbox/planetroller/src/org/apache/roller/planet/tasks/GeneratePlanetTask.java
Wed Oct 18 11:59:10 2006
@@ -23,6 +23,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
+import org.apache.roller.planet.config.PlanetConfig;
 import org.apache.roller.planet.model.Planet;
 import org.apache.roller.planet.model.PlanetFactory;
 import org.apache.roller.planet.model.PlanetManager;
@@ -33,24 +34,32 @@
 
 
 /**
- * Fetch feeds as needed and regenerate Planet pages based.
+ * Updates Planet aggregator's database of feed entries and generates Planet
+ * files based on those entries and the Planet configuration. 
+ *
+ * - Calls Roller business layer to refresh entries
+ * - Uses Velocity Texen to generate the static files
+ * - Designed to be run outside of Roller via the TaskRunner class
  */
 public class GeneratePlanetTask implements Runnable {
-    private static Log logger = LogFactory.getLog(GeneratePlanetTask.class);
+    private static Log log = LogFactory.getLog(GeneratePlanetTask.class);
+    
     
     public void run() {
         try {            
             // Update all feeds in planet
+            log.info("Refreshing Planet entries");
             Planet planet = PlanetFactory.getPlanet();
             planet.getPlanetManager().refreshEntries();
             planet.flush();
             planet.release();
             
             // Run the planet generation templates
+            log.info("Generating Planet files");
             generatePlanet(); 
             
         } catch (RollerException e) {
-            logger.error("ERROR refreshing entries", e);
+            log.error("ERROR refreshing entries", e);
         }
     }
     
@@ -59,14 +68,31 @@
         try {
             Planet planet = PlanetFactory.getPlanet();
             PlanetManager planetManager = planet.getPlanetManager();
-            
+                        
+            // Ignore values from database
+            //String mainPage = planetManager.getConfiguration().getMainPage();
+            //String templateDir = planetManager.getConfiguration().getTemplateDir();
+            //String outputDir = planetManager.getConfiguration().getMainPage();
+            
+            // Use values from PlanetConfig instead
+            String mainPage =    
+                PlanetConfig.getProperty("planet.aggregator.mainPage");
+            String templateDir = 
+                PlanetConfig.getProperty("planet.aggregator.template.dir"); 
+            String outputDir =   
+                PlanetConfig.getProperty("planet.aggregator.output.dir");
+            
+            log.info("Calling Velocity Texen to generate Planet files");
+            log.info("   Control file       ["+mainPage+"]");
+            log.info("   Template directory ["+templateDir+"]"); 
+            log.info("   Output directory   ["+outputDir+"]");
+
             // Fire up Velocity engine, point it at templates and init
             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",
-                    planetManager.getConfiguration().getTemplateDir());
+              "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
+            engine.setProperty("file.resource.loader.path", templateDir);
             engine.init();
             
             // Build context with current date 
@@ -75,20 +101,21 @@
             context.put("utilities", new Utilities());
             context.put("planet", new StaticPlanetModel());
             
-            File outputDir = new File(planetManager.getConfiguration().getOutputDir());
-            if (!outputDir.exists()) outputDir.mkdirs();
+            // Ensure that output directory exists
+            File outputDirObj = new File(outputDir);
+            if (!outputDirObj.exists()) outputDirObj.mkdirs();
             
+            // Execute mainPage Texen control template
             Generator generator = Generator.getInstance();
             generator.setVelocityEngine(engine);
             generator.setOutputEncoding("utf-8");
             generator.setInputEncoding("utf-8");
-            generator.setOutputPath(planetManager.getConfiguration().getOutputDir());
-            generator.setTemplatePath(planetManager.getConfiguration().getTemplateDir());
-            generator.parse(planetManager.getConfiguration().getMainPage(), context);
+            generator.setOutputPath(outputDir);
+            generator.setTemplatePath(templateDir);
+            generator.parse(mainPage, context);
             generator.shutdown();
             
         } catch (Exception e) {
-            e.printStackTrace();
             throw new RollerException("Writing planet files",e);
         }
     }    

Modified: incubator/roller/trunk/sandbox/planetroller/templates/html.vm
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/planetroller/templates/html.vm?view=diff&rev=465339&r1=465338&r2=465339
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/templates/html.vm (original)
+++ incubator/roller/trunk/sandbox/planetroller/templates/html.vm Wed Oct 18 11:59:10 2006
@@ -1,6 +1,6 @@
 <html>
 #set($group = $planet.getGroup($groupHandle))
-#set($entries = $planet.getAggregation($group, $group.maxPageEntries))
+#set($entries = $planet.getAggregation($group, 0, $group.maxPageEntries))
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
 <title>$group.title</title>

Modified: incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/hibernate.cfg.xml
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/hibernate.cfg.xml?view=diff&rev=465339&r1=465338&r2=465339
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/hibernate.cfg.xml (original)
+++ incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/hibernate.cfg.xml Wed
Oct 18 11:59:10 2006
@@ -22,58 +22,20 @@
 <hibernate-configuration>
     <session-factory>
     
-        <!-- By default Roller uses a JNDI DataSource -->
+        <!-- you can override with JDBC connection via planet-custom.properties -->
         <property name="connection.datasource">java:comp/env/jdbc/rollerdb</property>
-        <property name="show_sql">false</property>
-        
-        <!-- use thread local Session context -->
-        <property name="hibernate.current_session_context_class">thread</property>
-                
-        <!-- Dialect is now set via planet.properties
+                        
+        <!-- you can override the dialect via planet-custom.properties -->
         <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
-        -->
-        
-        <!--
-        If you want to use HSQLDB, PostgreSQL, DB2 or Derby, Oracle, SQLServer then use the
right dialect   
-        <property name="dialect">org.hibernate.dialect.HQLDBDialect</property>

-        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
-        <property name="dialect">org.hibernate.dialect.DB2Dialect</property>
-        <property name="dialect">org.hibernate.dialect.DerbyDialect</property>
-        <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
-        <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
-
-        For MySQL 5.X, use the MySQL5 dialect and J/Connector 3.1.X
-        <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
-        -->
-
-        <!--
-        Examples for configuring Hibernate to use the JDBC Driver Manager
-        <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
-        <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost:3219</property>
-        <property name="hibernate.connection.username">sa</property>
-        <property name="hibernate.connection.password"></property>
-        <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
 
-        <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
-        <property name="hibernate.connection.url">
-                        jdbc:mysql://localhost/roller?user=roller&amp;password=tiger</property>
-        <property name="hibernate.connection.username">roller</property>
-        <property name="hibernate.connection.password">tiger</property>
-        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
-
-        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
-        <property name="hibernate.connection.url">jdbc:postgresql://localhost/rollerdb</property>
-        <property name="hibernate.connection.username">scott</property>
-        <property name="hibernate.connection.password">tiger</property>
-        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
-        -->
+        <!-- use thread local Session context -->
+        <property name="hibernate.current_session_context_class">thread</property>
+        <property name="show_sql">false</property>
 
-        
         <!-- Hibernate L2 Caching -->
         <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
         <property name="hibernate.generate_statistics">true</property>
         <property name="hibernate.cache.use_structured_entries">true</property>
-        
         
         <!-- Map Planet POJO classes -->
         <mapping resource="org/apache/roller/planet/pojos/PlanetConfigData.hbm.xml" />

Modified: incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/planet.properties
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/planet.properties?view=diff&rev=465339&r1=465338&r2=465339
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/planet.properties (original)
+++ incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/planet.properties Wed
Oct 18 11:59:10 2006
@@ -44,9 +44,13 @@
 persistence.planet.classname=\
 org.apache.roller.planet.business.hibernate.HibernatePlanetImpl
 
-# Planet cache: MUST exist and be writable by Planet process
-# in the database now?
-#planet.aggregator.cache.dir=/var/roller/planetcache
+# You MUST override and set these three properties correctly:
+planet.aggregator.cache.dir=/var/planet/cache
+planet.aggregator.output.dir=/usr/local/planet/webapp
+planet.aggregator.template.dir=/usr/local/planet/webapp/WEB-INF/templates
+
+# Name of control template (in template dir) to be used
+planet.aggregator.mainPage=control.vm
 
 # Number of Technorati queries allowed per day
 planet.aggregator.technorati.limit=500

Modified: incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/rome.properties
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/rome.properties?view=diff&rev=465339&r1=465338&r2=465339
==============================================================================
--- incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/rome.properties (original)
+++ incubator/roller/trunk/sandbox/planetroller/web/WEB-INF/classes/rome.properties Wed Oct
18 11:59:10 2006
@@ -52,11 +52,6 @@
 rss_1.0.item.ModuleGenerator.classes =com.sun.syndication.io.impl.DCModuleGenerator \
                                       org.apache.roller.util.rome.ContentModuleGenerator
                                   
-# Handle Atom Pub Protocol pubcontrol extension
-                                      
-atom_1.0.item.ModuleParser.classes   =org.apache.roller.webservices.atomprotocol.PubControlModuleParser
-
-atom_1.0.item.ModuleGenerator.classes =org.apache.roller.webservices.atomprotocol.PubControlModuleGenerator
                                   
 
 

Modified: incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java?view=diff&rev=465339&r1=465338&r2=465339
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernatePersistenceStrategy.java
Wed Oct 18 11:59:10 2006
@@ -18,6 +18,7 @@
 
 package org.apache.roller.business.hibernate;
 
+import java.io.StringBufferInputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -38,6 +39,8 @@
 import org.jdom.Element;
 import org.jdom.input.SAXBuilder;
 import org.jdom.output.DOMOutputter;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
 
 
 /**
@@ -56,6 +59,13 @@
     
     private static Log log = LogFactory.getLog(HibernatePersistenceStrategy.class);
     
+    /** No-op so XML parser doesn't hit the network looking for Hibernate DTDs */
+    private EntityResolver noOpEntityResolver = new EntityResolver() {
+        public InputSource resolveEntity(String publicId, String systemId) {
+            return new InputSource(new StringBufferInputStream(""));
+        }
+    };
+    
     
     public HibernatePersistenceStrategy() {
     }   
@@ -71,6 +81,7 @@
         
         // read configResource into DOM form
         SAXBuilder builder = new SAXBuilder();
+        builder.setEntityResolver(noOpEntityResolver); 
         Document configDoc = builder.build(
             getClass().getResourceAsStream(configResource));
         Element root = configDoc.getRootElement();
@@ -118,6 +129,7 @@
         
         // read configResource into DOM form
         SAXBuilder builder = new SAXBuilder();
+        builder.setEntityResolver(noOpEntityResolver); 
         Document configDoc = builder.build(
             getClass().getResourceAsStream(configResource));
         Element root = configDoc.getRootElement();
@@ -512,3 +524,8 @@
     }
     
 }
+
+
+
+
+

Modified: incubator/roller/trunk/src/org/apache/roller/business/runnable/TaskRunner.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/runnable/TaskRunner.java?view=diff&rev=465339&r1=465338&r2=465339
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/runnable/TaskRunner.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/runnable/TaskRunner.java Wed Oct
18 11:59:10 2006
@@ -30,6 +30,7 @@
  * webapp.dir must specify Roller webapp directory
  * jars.dir must specify additional jars directory (e.g. Tomcat commons/lib)
  */
+
 public class TaskRunner {
     
     public static String WEBAPP_DIR = "webapp.dir"; 
@@ -106,3 +107,14 @@
         }
     }
 }
+
+/* for example:
+ java \
+    -Dwebapp.dir=/export/home/dave/roller_trunk/sandbox/planetroller/build/webapp \
+    -Djars.dir=/export/home/dave/tomcat/common/lib \
+    -Dplanet.custom.config=planet-custom.properties \
+    -Dcatalina.base=. \
+    -cp ./build/webapp/WEB-INF/lib/roller-business.jar \
+    org.apache.roller.business.runnable.TaskRunner \
+    org.apache.roller.planet.tasks.GeneratePlanetTask
+ */

Modified: incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java?view=diff&rev=465339&r1=465338&r2=465339
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernatePlanetManagerImpl.java
Wed Oct 18 11:59:10 2006
@@ -289,13 +289,13 @@
                 StringBuffer sb = new StringBuffer();
                 sb.append("select e from org.apache.roller.planet.pojos.PlanetEntryData e
");
                 sb.append("join e.subscription.groups g ");
-                sb.append("where g=:group and e.pubTime < :endDate ");
+                sb.append("where g.handle=:groupHandle and e.pubTime < :endDate ");
                 if (startDate != null) {
                     sb.append("and e.pubTime > :startDate ");
                 }
                 sb.append("order by e.pubTime desc");
                 Query query = session.createQuery(sb.toString());
-                query.setEntity("group", group);
+                query.setEntity("groupHandle", group.getHandle());
                 query.setFirstResult(offset);
                 if (length != -1) query.setMaxResults(length);
                 query.setParameter("endDate", endDate);



Mime
View raw message