roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r632847 [1/2] - in /roller/branches/roller_4.0/sandbox: bsf-renderer/ bsf-renderer/lib/ bsf-renderer/src/ bsf-renderer/src/org/ bsf-renderer/src/org/apache/ bsf-renderer/src/org/apache/roller/ bsf-renderer/src/org/apache/roller/scripting/ g...
Date Sun, 02 Mar 2008 21:09:32 GMT
Author: snoopdave
Date: Sun Mar  2 13:09:23 2008
New Revision: 632847

URL: http://svn.apache.org/viewvc?rev=632847&view=rev
Log:
Cleaning up scripting examples, upgrading to Groovy 1.5.4, preparing for Adv. Roller talk, etc.

Added:
    roller/branches/roller_4.0/sandbox/bsf-renderer/   (with props)
    roller/branches/roller_4.0/sandbox/bsf-renderer/README.txt
    roller/branches/roller_4.0/sandbox/bsf-renderer/ant.properties
    roller/branches/roller_4.0/sandbox/bsf-renderer/build.xml
    roller/branches/roller_4.0/sandbox/bsf-renderer/lib/
    roller/branches/roller_4.0/sandbox/bsf-renderer/lib/bsf.jar   (with props)
    roller/branches/roller_4.0/sandbox/bsf-renderer/src/
    roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/
    roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/
    roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/
    roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/
    roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRenderer.java
    roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRendererFactory.java
    roller/branches/roller_4.0/sandbox/groovy-adminapi/   (with props)
    roller/branches/roller_4.0/sandbox/groovy-adminapi/README.txt
    roller/branches/roller_4.0/sandbox/groovy-adminapi/ant.properties
    roller/branches/roller_4.0/sandbox/groovy-adminapi/build.xml
    roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/
    roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/createuser.gy
    roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/deleteuser.gy
    roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/
    roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/commons-codec-1.3.jar   (with props)
    roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/jdom.jar   (with props)
    roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/roller-rap-sdk.jar   (with props)
    roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listcollections.gy
    roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listusers.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/   (with props)
    roller/branches/roller_4.0/sandbox/groovy-renderer/README.txt
    roller/branches/roller_4.0/sandbox/groovy-renderer/ant.properties
    roller/branches/roller_4.0/sandbox/groovy-renderer/build.xml
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/README.txt
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/createuser.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/deleteuser.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/commons-codec-1.3.jar   (with props)
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/jdom.jar   (with props)
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/roller-rap-sdk.jar   (with props)
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listcollections.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listusers.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/bin/
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/bin/groovy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/README.txt
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/checkuser.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createblog.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createcomment.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createentry.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createtestdata.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createuser.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/groovy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/listusers.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/logs/
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/logs/README.txt
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/removeuser.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/roller-custom.properties
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/roller-startup.log
    roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/runsql.gy
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRenderer.java
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRendererFactory.java
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRenderer.java
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRendererFactory.java
    roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovyRollerBinding.java
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/   (with props)
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/README.txt
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/ant.properties
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/build.xml
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/checkuser.gy
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createblog.gy
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createcomment.gy
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createentry.gy
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createtestdata.gy
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createuser.gy
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/groovyroller.sh   (with props)
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/listusers.gy
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/logs/
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/logs/README.txt
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/removeuser.gy
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/roller-custom.properties
    roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/roller-startup.log

Propchange: roller/branches/roller_4.0/sandbox/bsf-renderer/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Mar  2 13:09:23 2008
@@ -0,0 +1 @@
+build

Added: roller/branches/roller_4.0/sandbox/bsf-renderer/README.txt
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/bsf-renderer/README.txt?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/bsf-renderer/README.txt (added)
+++ roller/branches/roller_4.0/sandbox/bsf-renderer/README.txt Sun Mar  2 13:09:23 2008
@@ -0,0 +1,29 @@
+
+Some experiments with using BSF to enable scripting in Roller templates.
+
+
+To use it in Roller:
+
+1) Put roller-scripting.jar and bsf.jar in WEB-INF/lib
+
+2) Add the jars necessary JavaScript, Groovy or JRuby to WEB-INF/lib
+
+3) In your roller-custom.properies file add this override:
+
+   rendering.rollerRendererFactories=\
+      org.apache.roller.ui.rendering.velocity.VelocityRendererFactory,\
+      org.apache.roller.scripting.BSFRendererFactory
+
+4) Restart Roller
+
+5) Create a new Weblog Template and set the Template Language to either 
+   "groovy", "jruby" or "javascript"
+
+6) In your page template you'll have access to all normal Roller models
+   plus the name "out" will be bound to a Writer that you can use for output.
+   For example, Here's Groovy for a simple Hello World template:
+
+        import java.io.PrintWriter;
+        pw = new PrintWriter(out);
+        pw.println("Hello World, my blog is named ${model.weblog.name}");
+

Added: roller/branches/roller_4.0/sandbox/bsf-renderer/ant.properties
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/bsf-renderer/ant.properties?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/bsf-renderer/ant.properties (added)
+++ roller/branches/roller_4.0/sandbox/bsf-renderer/ant.properties Sun Mar  2 13:09:23 2008
@@ -0,0 +1,9 @@
+rollersrc.dir=../../apps/weblogger
+
+# Need this to build Roller/BSF plugins
+bsf.home=/Applications/Java/bsf
+
+# Need these to run Roller/BSF plugins
+jruby.home=/Applications/Java/jruby
+rhino.home=/Applications/Java/rhino
+groovy.home=/Applications/Java/groovy

Added: roller/branches/roller_4.0/sandbox/bsf-renderer/build.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/bsf-renderer/build.xml?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/bsf-renderer/build.xml (added)
+++ roller/branches/roller_4.0/sandbox/bsf-renderer/build.xml Sun Mar  2 13:09:23 2008
@@ -0,0 +1,66 @@
+
+<project name="roller-groovy-renderers" default="build" basedir=".">
+    <description>Build Roller-BSF integration classes</description>   
+
+    <property file="./ant.properties" />
+    <property name="builddir" value="./build/groovy-adminapi-4.0" />
+    <property name="distdir" value="./dist" />
+    <property name="distfile" value="groovy-adminapi-4.0" />
+    
+    <path id="scripting.path">
+        <fileset dir="${rollersrc.dir}/build/webapp/WEB-INF/lib">   
+            <include name="roller-core.jar"/>   
+            <include name="roller-web.jar"/>   
+            <include name="roller-business.jar"/>   
+            <include name="commons-logging.jar"/>   
+        </fileset>
+        <fileset dir="${bsf.home}/lib">
+            <include name="bsf.jar"/>
+        </fileset>                      
+    </path>
+    
+    <target name="build">        
+        <mkdir dir="./build/classes" />
+        <javac debug="on" destdir="./build/classes">
+            <src path="./src" />
+            <classpath>
+                <path refid="scripting.path"/>
+            </classpath>
+        </javac>
+        <mkdir dir="./dist" />
+        <jar basedir="build/classes" jarfile="./dist/roller-scripting.jar" />
+    </target>
+
+    <!--
+    Copy BSF, JRuby, Groovy and Rhino jars. 
+    Versions tested:
+       - Groovy 1.0
+       - BSF 2.4.0
+       - JRuby 0.9.8
+       - Rhino 1.6 R5
+    -->
+    <target name="copy-to-roller" >
+        <copy todir="../../../build/webapp/WEB-INF/lib">
+            <fileset dir="./dist">
+               <include name="roller-scripting.jar" />
+            </fileset>
+            <fileset dir="./lib">
+               <include name="bsf.jar" />
+            </fileset>
+            <fileset dir="${groovy.home}/embeddable">
+               <include name="groovy-all-1.0.jar" />
+            </fileset>
+            <fileset dir="${jruby.home}/lib">
+               <include name="jruby.jar" />
+            </fileset>
+            <fileset dir="${rhino.home}">
+               <include name="js.jar" />
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="clean">
+        <delete dir="./build" />
+    </target>
+    
+</project>

Added: roller/branches/roller_4.0/sandbox/bsf-renderer/lib/bsf.jar
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/bsf-renderer/lib/bsf.jar?rev=632847&view=auto
==============================================================================
Binary file - no diff available.

Propchange: roller/branches/roller_4.0/sandbox/bsf-renderer/lib/bsf.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRenderer.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRenderer.java?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRenderer.java (added)
+++ roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRenderer.java Sun Mar  2 13:09:23 2008
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.scripting;
+
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.bsf.BSFException;
+import org.apache.bsf.BSFManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.pojos.Template;
+import org.apache.roller.ui.rendering.Renderer;
+import org.apache.roller.ui.rendering.RenderingException;
+
+/**
+ * Renderer that evaluates template as BSF script.
+ * Supports groovy, javascript, jruby and others (via BSF).
+ */
+public class BSFRenderer implements Renderer {
+    private static Log log = LogFactory.getLog(BSFRenderer.class);
+    private Template template = null;    
+    static {
+        // Javascript, other BSF langs are registered by default
+        // and Groovy self-registers, so we need only to register JRuby 
+        BSFManager.registerScriptingEngine("jruby", 
+            "org.jruby.javasupport.bsf.JRubyEngine", new String[] {"rb"});        
+    }
+    
+    public BSFRenderer(Template template) {
+        this.template = template;
+    }    
+    public void render(Map model, Writer writer) throws RenderingException {
+        try {
+            long startTime = System.currentTimeMillis();
+            
+            BSFManager manager = new BSFManager();            
+            for (Iterator it = model.keySet().iterator(); it.hasNext();) {
+                String key = (String)it.next();
+                manager.declareBean(key, model.get(key), model.get(key).getClass());
+                manager.registerBean(key, model.get(key));
+            }
+            manager.declareBean("out", writer, Writer.class);
+            manager.registerBean("out", writer);
+            manager.exec(template.getTemplateLanguage(), 
+                    "(java)", 1, 1, template.getContents());
+
+            long endTime = System.currentTimeMillis();
+            long renderTime = (endTime - startTime)/1000;
+            log.debug("Rendered ["+template.getId()+"] with language ["
+                    +template.getTemplateLanguage()+"] in "+renderTime+" secs"); 
+            
+        } catch (BSFException ex) {
+            log.debug("Executing BSF script", ex);
+            renderThrowable(ex, writer);
+        }
+        finally {}
+    }
+    
+    private void renderThrowable(BSFException ex, Writer writer) {
+        PrintWriter pw = new PrintWriter(writer);
+        if (ex.getTargetException() != null) {
+            pw.println("<p><b>Exception</b>: "+ex.getTargetException()
+                + "<br /><b>Message</b>: "+ex.getTargetException().getMessage()+"</p>");
+        } else {
+            pw.println("<p><b>Exception</b>: "+ex
+                + "<br /><b>Message</b>: "+ex.getMessage()+"</p>");
+        }
+        pw.flush();
+    }
+}

Added: roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRendererFactory.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRendererFactory.java?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRendererFactory.java (added)
+++ roller/branches/roller_4.0/sandbox/bsf-renderer/src/org/apache/roller/scripting/BSFRendererFactory.java Sun Mar  2 13:09:23 2008
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * 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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.scripting;
+
+import java.util.Arrays;
+import java.util.List;
+import org.apache.roller.config.RollerConfig;
+import org.apache.roller.pojos.Template;
+import org.apache.roller.ui.rendering.Renderer;
+import org.apache.roller.ui.rendering.RendererFactory;
+import org.apache.roller.util.Utilities;
+
+/**
+ * RendererFactory that calls BSF scripting languages (groovy, jruby and javascript).
+ */
+public class BSFRendererFactory implements RendererFactory {   
+    private static String[] names = {"groovy", "jruby", "javascript"};
+    private static final List bsfLanguages; 
+    static {
+        String value = RollerConfig.getProperty("bsfrenderer.languageNames");
+        if (value != null) {
+            names = Utilities.stringToStringArray(value,",");            
+        } 
+        bsfLanguages = Arrays.asList(names);
+    }        
+    public Renderer getRenderer(Template template) {        
+        Renderer renderer = null;
+        if(template.getTemplateLanguage() == null || template.getId() == null) {
+            return null;
+        }        
+        if(bsfLanguages.contains(template.getTemplateLanguage())) {             
+            try {
+               renderer = new BSFRenderer(template);
+            } catch(Exception ex) {
+                return null;
+            }                        
+        }      
+        return renderer;
+    }    
+}

Propchange: roller/branches/roller_4.0/sandbox/groovy-adminapi/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Mar  2 13:09:23 2008
@@ -0,0 +1,2 @@
+build
+dist

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/README.txt
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/README.txt?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-adminapi/README.txt (added)
+++ roller/branches/roller_4.0/sandbox/groovy-adminapi/README.txt Sun Mar  2 13:09:23 2008
@@ -0,0 +1,24 @@
+
+Groovy scripts that run against the Roller Admin Protocol
+-------------------------------------------------------------------------------
+
+These scripts are designed to against a remote Roller installation using the
+Roller Admin Protocol (RAP). 
+
+
+1) Have Groovy 1.0 installed on your system
+
+2) Put the RAP SDK, JDOM and Commons Codec jars in your classpath. For example:
+
+   $ export CLASSPATH=./lib/jdom.jar:./lib/roller-rap-sdk.jar:./lib/commons-codec-1.3.jar
+ 
+   Alternatively, you can place them in your Groovy lib directory.
+
+Once you've done that you can run the scripts like so:
+
+  $ groovy <script> <username> <password> <endpoint-url>
+
+For example:
+
+  $ groovy listusers.gy admin admin http://localhost:8080/roller/roller-services/rap
+

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/ant.properties
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/ant.properties?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-adminapi/ant.properties (added)
+++ roller/branches/roller_4.0/sandbox/groovy-adminapi/ant.properties Sun Mar  2 13:09:23 2008
@@ -0,0 +1,4 @@
+builddir=./build
+distdir=./dist
+distfilebase=groovy-adminapi-4.0
+    

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/build.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/build.xml?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-adminapi/build.xml (added)
+++ roller/branches/roller_4.0/sandbox/groovy-adminapi/build.xml Sun Mar  2 13:09:23 2008
@@ -0,0 +1,29 @@
+
+<project name="roller-groovy-adminapi" default="dist" basedir=".">
+    <description>Bundle up Groovy Admin API examples</description>   
+    
+    <property file="./ant.properties" />
+    
+    <target name="build" >
+        <mkdir dir="${builddir}/${distfilebase}" />
+        <copy todir="${builddir}/${distfilebase}">
+            <fileset dir="./scripts">
+               <include name="**/**" />
+            </fileset>
+        </copy>
+    </target>    
+    
+    <target name="dist" depends="build" description="Build tar distro file">
+        <mkdir dir="${distdir}" />
+        <tar destfile="${distdir}/${distfilebase}.tar.gz"
+             longfile="gnu" compression="gzip">
+            <tarfileset dir="${builddir}" />
+        </tar>    
+    </target>    
+    
+    <target name="clean" description="Delete build and dist dirs">
+        <delete dir="./build" />
+        <delete dir="./dist" />
+    </target>
+    
+</project>

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/createuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/createuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/createuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/createuser.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,87 @@
+
+import java.io.*;
+import java.net.*;
+import org.jdom.output.*;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.roller.weblogger.webservices.adminprotocol.sdk.*;
+
+if (args.length < 6) {
+    println "USAGE: groovy createuser.gy <admin-username> <admin-password> <new-username> <new-password> <email> <rap-endpoint>"; 
+    return;
+}
+
+admin_username = args[0];
+admin_password = args[1];
+username = args[2];
+password = args[3];
+email    = args[4];
+rapuri   = args[5];
+
+fullName = username;
+locale   = "en_US";
+timeZone = "America/New_York";
+
+
+credentials = admin_username + ":" + admin_password; 
+authString = "Basic " + new String(Base64.encodeBase64(credentials.getBytes()));
+
+// get service doc
+
+url = new URL(rapuri);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+s = new Service(conn.getInputStream());
+
+// find user collection in service
+
+userCollectionURI = null;
+baseURI = null;
+for (w in s.entries) {
+    for (c in w.entries) {
+        if (c.memberType == "user") {
+            userCollectionURI = c.href;
+            baseURI = c.href.substring(0, c.href.length() - "users".length());
+            break;
+        }
+    }
+}
+
+// create new user
+
+user = new UserEntry(username, baseURI);
+
+user.setScreenName(  username);
+user.setPassword(    password);
+user.setFullName(    fullName);
+user.setEmailAddress(email);
+user.setLocale(      locale);
+user.setTimezone(    timeZone);
+user.setDateCreated( new java.util.Date());
+
+userSet = new UserEntrySet(baseURI);
+userSet.setEntries((Entry[])[user]);
+
+// post new user to user collection URI
+
+// open connection
+url = new URL(userCollectionURI);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+conn.setDoOutput(true);
+
+// serialize XML to connection's output stream
+doc = userSet.toDocument();
+outputter = new XMLOutputter();
+outputter.output(doc, conn.getOutputStream());
+conn.getOutputStream().flush();
+conn.getOutputStream().close();
+
+println "--- Response from server ---";
+
+s = null; 
+is = new BufferedReader(new InputStreamReader(conn.getInputStream())); 
+while ((s = is.readLine()) != null) {
+    println s
+}
+
+

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/deleteuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/deleteuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/deleteuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/deleteuser.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,79 @@
+
+import java.io.*;
+import java.net.*;
+import org.jdom.output.*;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.roller.weblogger.webservices.adminprotocol.sdk.*;
+
+if (args.length < 4) {
+    println "USAGE: groovy deleteuser.gy <admin-username> <admin-password> <username> <rap-endpoint>"; 
+    return;
+}
+
+admin_username = args[0];
+admin_password = args[1];
+username = args[2];
+rapuri   = args[3];
+
+fullName = username;
+locale   = "en_US";
+timeZone = "America/New_York";
+
+
+credentials = admin_username + ":" + admin_password; 
+authString = "Basic " + new String(Base64.encodeBase64(credentials.getBytes()));
+
+// get service doc
+
+url = new URL(rapuri);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+s = new Service(conn.getInputStream());
+
+// find user collection in service
+
+userCollectionURI = null;
+baseURI = null;
+for (w in s.entries) {
+    for (c in w.entries) {
+        if (c.memberType == "user") {
+            userCollectionURI = c.href;
+            baseURI = c.href.substring(0, c.href.length() - "users".length());
+            break;
+        }
+    }
+}
+
+
+// open connection
+url = new URL(userCollectionURI);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+UserEntrySet users = new UserEntrySet(conn.getInputStream(), rapuri);
+user = null;
+for (u in users) {
+    for (i in 0..(u.getEntries().length - 1)) {
+        if (username == u.getEntries()[i].name) {
+           user = u.getEntries()[i];
+           break;
+        }
+    }
+}
+
+if (user) {
+    url = new URL(user.getHref());         
+    conn = url.openConnection();
+    conn.setRequestProperty("Authorization", authString);
+    conn.setRequestMethod("DELETE");
+  
+    println "--- Response from server ---";
+    s = null; 
+    is = new BufferedReader(new InputStreamReader(conn.getInputStream())); 
+    while ((s = is.readLine()) != null) {
+        println s
+    }
+
+} else {
+    println "User not found";
+}
+

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/commons-codec-1.3.jar
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/commons-codec-1.3.jar?rev=632847&view=auto
==============================================================================
Binary file - no diff available.

Propchange: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/commons-codec-1.3.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/jdom.jar
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/jdom.jar?rev=632847&view=auto
==============================================================================
Binary file - no diff available.

Propchange: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/jdom.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/roller-rap-sdk.jar
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/roller-rap-sdk.jar?rev=632847&view=auto
==============================================================================
Binary file - no diff available.

Propchange: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/lib/roller-rap-sdk.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listcollections.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listcollections.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listcollections.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listcollections.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,30 @@
+
+import java.io.*;
+import java.net.*;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.roller.weblogger.webservices.adminprotocol.sdk.*;
+
+if (args.length < 3) {
+    println "USAGE: groovy listcollections.gy <username> <password> <rap-endpoint-uri>";
+    return;
+}
+username = args[0];
+password = args[1];
+rapuri = args[2];
+
+String credentials = username + ":" + password; 
+url = new URL(rapuri);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", 
+   "Basic " + new String(Base64.encodeBase64(credentials.getBytes())));
+
+
+s = new Service(conn.getInputStream());
+for (w in s.entries) {
+    println "Workspace [${w.title}]";
+    for (c in w.entries) {
+        println "   Collection [${c.title}]";
+        println "      URI: ${c.href}";
+        println "      Member-type: ${c.memberType}";
+    }
+}

Added: roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listusers.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listusers.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listusers.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-adminapi/scripts/listusers.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,46 @@
+
+import java.io.*;
+import java.net.*;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.roller.weblogger.webservices.adminprotocol.sdk.*;
+
+if (args.length < 3) {
+    println "USAGE: groovy listusers.gy <username> <password> <rap-endpoint-uri>";
+    return;
+}
+username = args[0];
+password = args[1];
+rapuri = args[2];
+
+credentials = username + ":" + password; 
+authString = "Basic " + new String(Base64.encodeBase64(credentials.getBytes()));
+
+url = new URL(rapuri);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+
+s = new Service(conn.getInputStream());
+
+// find user collection
+
+for (w in s.entries) {
+    for (c in w.entries) {
+        if (c.memberType == "user") {
+
+            url = new URL(c.href);         
+            baseurl = c.href.substring(0, c.href.length() - "users".length());
+
+            conn = url.openConnection();
+            conn.setRequestProperty("Authorization", authString);
+
+            userEntrySet = new UserEntrySet(conn.getInputStream(), baseurl);
+
+            for (u in userEntrySet.entries) {
+                println u.fullName;
+            }
+
+            break;
+
+        }
+    }
+}

Propchange: roller/branches/roller_4.0/sandbox/groovy-renderer/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Mar  2 13:09:23 2008
@@ -0,0 +1,2 @@
+build
+dist

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/README.txt
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/README.txt?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/README.txt (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/README.txt Sun Mar  2 13:09:23 2008
@@ -0,0 +1,101 @@
+
+Groovy Renderers
+
+Two ways to use Groovy in your page templates: asa Groovlet and as a GSP
+
+A) Groovlet Renderer
+
+A Roller GroovletRenderer that can evaluate a Roller template as Groovy code 
+with Groovlet-style "out" and "html" bindings.
+
+   The implementation:
+
+        org.apache.roller.scripting.GroovletRenderer
+        org.apache.roller.scripting.GroovletRendererFactory   
+        org.apache.roller.scripting.GroovyRollerBinding
+
+    Here's an example Hello World template:
+
+        println "<html><body>Hello World</body></html>"
+
+    Here's an example template that displays recent entries from a weblog:
+
+        html.html { // html is implicitly bound to new MarkupBuilder(out)
+            head {
+                title(model.weblog.name)
+            }
+            body {
+                h1(model.weblog.name)
+                i(model.weblog.description)
+                map = model.getWeblogEntriesPager().getEntries();
+                map.keySet().each() {
+                   map.get(it).each() {
+                      h2(it.title)
+                      p(it.text)
+                      br()
+                   }
+                }
+            }
+        }
+
+B) GSP Renderer
+
+   A Roller GSPRenderer that can evaluate a Roller template as a Groovy Template
+   with GSP-style "out" and "html" bindings.
+
+    The implementation:
+
+        org.apache.roller.scripting.GSPRenderer
+        org.apache.roller.scripting.GSPRendererFactory   
+        org.apache.roller.scripting.GSPRollerBinding
+
+    Here's an example Hello World template:
+
+        <html>
+           <body>
+              <%= "Hello World" %>
+           </body>
+        </html>
+
+    Here's an example template that displays recent entries from a weblog:
+
+        <html>
+           <head>
+              <title>${model.weblog.name}</title>
+           </head>
+           <body>
+           <h1>${model.weblog.name}</h1>
+           <i>${model.weblog.description}</i>
+           <% map = model.getWeblogEntriesPager().getEntries();
+              map.keySet().each() { %>
+                 <% map.get(it).each() { %>
+                    <h2>${it.title}</h2>
+                    <p>${it.text}</p><br />
+                 <% } 
+              }%> 
+           </body>
+        </html>
+
+
+To use these renderers in Roller:
+
+1) Put roller-groovy.jar and groovy-all-1.5.4.jar in WEB-INF/lib
+
+3) In your roller-custom.properies file add this override:
+
+   rendering.rollerRendererFactories=\
+      org.apache.roller.ui.rendering.velocity.VelocityRendererFactory,\
+      org.apache.roller.scripting.GroovletRendererFactory,\
+      org.apache.roller.scripting.GSPRendererFactory,\
+
+4) Restart Roller
+
+5) Create a new Weblog Page Template and set Template Language to either 
+   "groovlet" or "gsp". 
+
+6) In your page template you'll have access to all normal Roller models
+   plus the name "out" will be bound to a Writer that you can use for output.
+   Also, the name "html" will be bound to a markup builder. 
+
+
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/ant.properties
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/ant.properties?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/ant.properties (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/ant.properties Sun Mar  2 13:09:23 2008
@@ -0,0 +1,4 @@
+
+tools.dir=../../tools
+rollersrc.dir=../../apps/weblogger
+groovy.home=/Applications/Java/groovy

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/build.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/build.xml?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/build.xml (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/build.xml Sun Mar  2 13:09:23 2008
@@ -0,0 +1,50 @@
+
+<project name="roller-groovy-renderers" default="build" basedir=".">
+    <description>Build and bundle Groovy Renderers for Roller</description>   
+
+    <property file="./ant.properties" />
+        
+    <path id="scripting.path">
+        <fileset dir="${rollersrc.dir}/build/webapp/WEB-INF/lib">   
+            <include name="roller-core.jar"/>   
+            <include name="roller-business.jar"/>   
+            <include name="roller-web.jar"/>   
+        </fileset>
+        <fileset dir="${tools.dir}/lib">   
+            <include name="commons-logging-1.0.4.jar"/>   
+        </fileset>
+        <fileset dir="${tools.dir}/openjpa-0.9.7">   
+            <include name="openjpa-0.9.7-incubating.jar"/>   
+        </fileset>
+        <fileset dir="${groovy.home}/lib">
+            <include name="groovy-1.5.4.jar"/>
+        </fileset>                      
+    </path>
+    
+    <target name="build">        
+        <mkdir dir="./build/classes" />
+        <javac debug="on" destdir="./build/classes">
+            <src path="./src" />
+            <classpath>
+                <path refid="scripting.path"/>
+            </classpath>
+        </javac>
+        <mkdir dir="./dist" />
+        <jar basedir="build/classes" jarfile="./dist/roller-groovy.jar" />
+    </target>
+    
+    <target name="copy-to-roller" >
+        <copy todir="../../../build/webapp/WEB-INF/lib">
+            <fileset dir="./dist">
+               <include name="roller-groovy.jar" />
+            </fileset>
+            <fileset dir="${groovy.home}/embeddable">
+               <include name="groovy-all-1.0.jar" />
+            </fileset>
+        </copy>
+    </target>    
+    <target name="clean">
+        <delete dir="./build" />
+    </target>
+    
+</project>

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/README.txt
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/README.txt?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/README.txt (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/README.txt Sun Mar  2 13:09:23 2008
@@ -0,0 +1,23 @@
+
+Groovy scripts that run against the Roller Admin Protocol
+-------------------------------------------------------------------------------
+
+These scripts are designed to against a remote Roller installation using the
+Roller Admin Protocol (RAP). 
+
+
+1) Have Groovy 1.0 installed on your system
+
+2) Put the RAP SDK, JDOM and Commons Codec jars in your classpath. For example:
+
+  $ export CLASSPATH=./lib/jdom.jar:./lib/roller-rap-sdk.jar:./lib/commons-codec-1.3.jar
+
+
+Once you've done that you can run the scripts like so:
+
+  $ groovy <script> <username> <password> <endpoint-url>
+
+For example:
+
+  $ groovy listusers.gy admin admin http://localhost:8080/roller/roller-services/rap
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/createuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/createuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/createuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/createuser.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,87 @@
+
+import java.io.*;
+import java.net.*;
+import org.jdom.output.*;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.roller.weblogger.webservices.adminprotocol.sdk.*;
+
+if (args.length < 6) {
+    println "USAGE: groovy createuser.gy <admin-username> <admin-password> <new-username> <new-password> <email> <rap-endpoint>"; 
+    return;
+}
+
+admin_username = args[0];
+admin_password = args[1];
+username = args[2];
+password = args[3];
+email    = args[4];
+rapuri   = args[5];
+
+fullName = username;
+locale   = "en_US";
+timeZone = "America/New_York";
+
+
+credentials = admin_username + ":" + admin_password; 
+authString = "Basic " + new String(Base64.encodeBase64(credentials.getBytes()));
+
+// get service doc
+
+url = new URL(rapuri);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+s = new Service(conn.getInputStream());
+
+// find user collection in service
+
+userCollectionURI = null;
+baseURI = null;
+for (w in s.entries) {
+    for (c in w.entries) {
+        if (c.memberType == "user") {
+            userCollectionURI = c.href;
+            baseURI = c.href.substring(0, c.href.length() - "users".length());
+            break;
+        }
+    }
+}
+
+// create new user
+
+user = new UserEntry(username, baseURI);
+
+user.setScreenName(  username);
+user.setPassword(    password);
+user.setFullName(    fullName);
+user.setEmailAddress(email);
+user.setLocale(      locale);
+user.setTimezone(    timeZone);
+user.setDateCreated( new java.util.Date());
+
+userSet = new UserEntrySet(baseURI);
+userSet.setEntries((Entry[])[user]);
+
+// post new user to user collection URI
+
+// open connection
+url = new URL(userCollectionURI);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+conn.setDoOutput(true);
+
+// serialize XML to connection's output stream
+doc = userSet.toDocument();
+outputter = new XMLOutputter();
+outputter.output(doc, conn.getOutputStream());
+conn.getOutputStream().flush();
+conn.getOutputStream().close();
+
+println "--- Response from server ---";
+
+s = null; 
+is = new BufferedReader(new InputStreamReader(conn.getInputStream())); 
+while ((s = is.readLine()) != null) {
+    println s
+}
+
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/deleteuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/deleteuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/deleteuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/deleteuser.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,79 @@
+
+import java.io.*;
+import java.net.*;
+import org.jdom.output.*;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.roller.weblogger.webservices.adminprotocol.sdk.*;
+
+if (args.length < 4) {
+    println "USAGE: groovy deleteuser.gy <admin-username> <admin-password> <username> <rap-endpoint>"; 
+    return;
+}
+
+admin_username = args[0];
+admin_password = args[1];
+username = args[2];
+rapuri   = args[3];
+
+fullName = username;
+locale   = "en_US";
+timeZone = "America/New_York";
+
+
+credentials = admin_username + ":" + admin_password; 
+authString = "Basic " + new String(Base64.encodeBase64(credentials.getBytes()));
+
+// get service doc
+
+url = new URL(rapuri);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+s = new Service(conn.getInputStream());
+
+// find user collection in service
+
+userCollectionURI = null;
+baseURI = null;
+for (w in s.entries) {
+    for (c in w.entries) {
+        if (c.memberType == "user") {
+            userCollectionURI = c.href;
+            baseURI = c.href.substring(0, c.href.length() - "users".length());
+            break;
+        }
+    }
+}
+
+
+// open connection
+url = new URL(userCollectionURI);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+UserEntrySet users = new UserEntrySet(conn.getInputStream(), rapuri);
+user = null;
+for (u in users) {
+    for (i in 0..(u.getEntries().length - 1)) {
+        if (username == u.getEntries()[i].name) {
+           user = u.getEntries()[i];
+           break;
+        }
+    }
+}
+
+if (user) {
+    url = new URL(user.getHref());         
+    conn = url.openConnection();
+    conn.setRequestProperty("Authorization", authString);
+    conn.setRequestMethod("DELETE");
+  
+    println "--- Response from server ---";
+    s = null; 
+    is = new BufferedReader(new InputStreamReader(conn.getInputStream())); 
+    while ((s = is.readLine()) != null) {
+        println s
+    }
+
+} else {
+    println "User not found";
+}
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/commons-codec-1.3.jar
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/commons-codec-1.3.jar?rev=632847&view=auto
==============================================================================
Binary file - no diff available.

Propchange: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/commons-codec-1.3.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/jdom.jar
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/jdom.jar?rev=632847&view=auto
==============================================================================
Binary file - no diff available.

Propchange: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/jdom.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/roller-rap-sdk.jar
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/roller-rap-sdk.jar?rev=632847&view=auto
==============================================================================
Binary file - no diff available.

Propchange: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/lib/roller-rap-sdk.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listcollections.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listcollections.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listcollections.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listcollections.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,30 @@
+
+import java.io.*;
+import java.net.*;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.roller.weblogger.webservices.adminprotocol.sdk.*;
+
+if (args.length < 3) {
+    println "USAGE: groovy listcollections.gy <username> <password> <rap-endpoint-uri>";
+    return;
+}
+username = args[0];
+password = args[1];
+rapuri = args[2];
+
+String credentials = username + ":" + password; 
+url = new URL(rapuri);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", 
+   "Basic " + new String(Base64.encodeBase64(credentials.getBytes())));
+
+
+s = new Service(conn.getInputStream());
+for (w in s.entries) {
+    println "Workspace [${w.title}]";
+    for (c in w.entries) {
+        println "   Collection [${c.title}]";
+        println "      URI: ${c.href}";
+        println "      Member-type: ${c.memberType}";
+    }
+}

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listusers.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listusers.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listusers.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/adminprotocol/listusers.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,46 @@
+
+import java.io.*;
+import java.net.*;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.roller.weblogger.webservices.adminprotocol.sdk.*;
+
+if (args.length < 3) {
+    println "USAGE: groovy listusers.gy <username> <password> <rap-endpoint-uri>";
+    return;
+}
+username = args[0];
+password = args[1];
+rapuri = args[2];
+
+credentials = username + ":" + password; 
+authString = "Basic " + new String(Base64.encodeBase64(credentials.getBytes()));
+
+url = new URL(rapuri);         
+conn = url.openConnection();
+conn.setRequestProperty("Authorization", authString);
+
+s = new Service(conn.getInputStream());
+
+// find user collection
+
+for (w in s.entries) {
+    for (c in w.entries) {
+        if (c.memberType == "user") {
+
+            url = new URL(c.href);         
+            baseurl = c.href.substring(0, c.href.length() - "users".length());
+
+            conn = url.openConnection();
+            conn.setRequestProperty("Authorization", authString);
+
+            userEntrySet = new UserEntrySet(conn.getInputStream(), baseurl);
+
+            for (u in userEntrySet.entries) {
+                println u.fullName;
+            }
+
+            break;
+
+        }
+    }
+}

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/bin/groovy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/bin/groovy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/bin/groovy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/bin/groovy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# -- ENSURE THESE ARE CORRECT ---
+
+# Directory where Groovy release is installed
+export GROOVY_HOME=/Applications/Java/groovy
+
+# Directory of Roller webapp context
+export WEBAPP_DIR=../../../../../apps/weblogger/build/webapp
+
+# Directory of additional jars
+export JARS_DIR=/Applications/Java/tomcat/common/lib
+
+
+# --- SHOULD NOT NEED TO EDIT BELOW THIS LINE ---
+
+RGPATH=${WEBAPP_DIR}/WEB-INF/classes:\
+${GROOVY_HOME}/embeddable/groovy-all-1.0.jar:\
+${GROOVY_HOME}/lib/commons-cli-1.0.jar:\
+${GROOVY_HOME}/lib/ant-1.6.5.jar:\
+${GROOVY_HOME}/lib/ant-launcher.1.6.5.jar
+
+for i in "$WEBAPP_DIR"/WEB-INF/lib/*.jar; do
+  RGPATH="$RGPATH":"$i"
+done
+
+for i in "$JARS_DIR"/*.jar; do
+  RGPATH="$RGPATH":"$i"
+done
+
+export RGPATH
+
+# Hack: setting catalina.base=. allows us to save log in ./logs
+java \
+ -Droller.custom.config=roller-custom.properties \
+-Dcatalina.base=. \
+-classpath ${RGPATH} groovy.lang.GroovyShell $1 $2 $3 $4 $5 $6 $7 $8 $9 $10

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/README.txt
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/README.txt?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/README.txt (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/README.txt Sun Mar  2 13:09:23 2008
@@ -0,0 +1,25 @@
+
+Groovy scripts that run against the Roller API
+-------------------------------------------------------------------------------
+
+These scripts are designed to the computer on which Roller is installed. 
+Because they use the Roller API directly, you must run them with the provided 
+"groovy" script which sets up the classpath correctly for calling into the 
+Roller code base. 
+
+Before you can run you must:
+
+1) Have Groovy 1.0 installed on your system
+
+2) Have Roller 4.0 or later installed and configured on yoru system
+
+3) Edit the provided groovy script to set GROOVY_HOME, WEBAPP_DIR and JARS_DIR
+
+4) Edit the provided roller-custom.properties to point to your Roller database
+
+Once you've done that you can run the scripts like so:
+
+   $ ./groovy listusers.gy
+
+
+TODO: Provide a groovy.bat file so scipts can run on Microsoft Windows

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/checkuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/checkuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/checkuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/checkuser.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* 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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+if (args.length < 1) {
+    println "USAGE: groovy checkuser.gy <username>";
+    return;
+}
+
+org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare();
+org.apache.roller.weblogger.business.WebloggerFactory.bootstrap();
+roller = org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger();
+
+user = roller.getUserManager().getUserByUserName(args[0]);
+
+if (user == null) {
+    println "User ${username} not found";
+} else {
+    println "User ${user.userName} with id [${user.id}] has roles:";
+    user.getRoles().each({ item -> println "   ${item.getRole()}" });
+}

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createblog.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createblog.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createblog.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createblog.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* 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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+if (args.length < 2) {
+    println "USAGE: groovy createblog.gy <username> <handle>";
+    return;
+}
+
+username =    args[0];
+handle =      args[1];
+
+blogname =    handle;
+description = handle;
+theme =       "basic";
+
+org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare();
+org.apache.roller.weblogger.business.WebloggerFactory.bootstrap();
+roller = org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger();
+
+user = roller.getUserManager().getUserByUserName(username);
+if (user == null) {
+    println "ERROR: user ${username} not found";
+    System.exit(-1);
+} 
+weblog = new org.apache.roller.weblogger.pojos.Weblog(
+   handle, user, blogname, description,
+   user.getEmailAddress(), user.getEmailAddress(), theme,
+   user.getLocale(), user.getTimeZone());
+try {
+   roller.getUserManager().addWebsite(weblog);
+   roller.flush();
+} catch (Exception e) {
+   e.printStackTrace();
+}
+blog = roller.getUserManager().getWebsiteByHandle(handle);
+println "Created blog ${blog.name} with id ${blog.id}";

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createcomment.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createcomment.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createcomment.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createcomment.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* 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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+handle =  "adminblog";
+name =    "Dave";
+email =   "dave@example.com";
+url =     "http://example.com";
+anchor =  "test_post";
+email =   "test@example.com";
+content = "Testing 1 2 3 <em>Hello World!</em>";
+ 
+org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare();
+org.apache.roller.weblogger.business.WebloggerFactory.bootstrap();
+roller = org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger();
+
+blog = roller.getUserManager().getWebsiteByHandle(handle);
+entry = roller.getWeblogManager().getWeblogEntryByAnchor(blog, anchor);
+
+println entry
+
+comment = new org.apache.roller.weblogger.pojos.WeblogEntryComment();
+comment.setWeblogEntry(entry);
+comment.setName(name);
+comment.setUrl(url);
+comment.setPostTime(new java.sql.Timestamp(new java.util.Date().getTime()));
+comment.setContent(content);
+comment.setNotify(Boolean.FALSE);
+comment.setPending(Boolean.FALSE);
+roller.getWeblogManager().saveComment(comment);
+
+roller.flush();
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createentry.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createentry.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createentry.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createentry.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,62 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* 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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+if (args.length < 2) {
+    println "USAGE: groovy createblog.gy <username> <handle> <title> <content> <catpath>";
+    return;
+}
+
+username = args[0];
+handle =   args[1];
+title =    args[2];
+text =     args[3];
+catpath =  args[4];
+ 
+org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare();
+org.apache.roller.weblogger.business.WebloggerFactory.bootstrap();
+roller = org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger();
+
+user = roller.getUserManager().getUser(username);
+if (user == null) {
+   println "ERROR: user ${username} not found";
+   return;
+}
+blog = roller.getUserManager().getWebsiteByHandle(handle);
+if (blog == null) {
+   println "ERROR: blog ${handle} not found";
+   return;
+}
+category = roller.getWeblogManager().getWeblogCategoryByPath(blog, null, catpath);
+if (category == null) {
+   println "ERROR: category ${catpath} not found";
+   return;
+}
+
+entry = new org.apache.roller.weblogger.pojos.WeblogEntry();
+entry.setWebsite(blog);
+entry.setCreator(user);
+entry.setCategory(category);
+entry.setPubTime(new java.sql.Timestamp(new java.util.Date().getTime()));
+entry.setUpdateTime(new java.sql.Timestamp(new java.util.Date().getTime()));
+entry.setTitle(title);
+entry.setText(text);
+entry.setStatus(org.apache.roller.weblogger.pojos.WeblogEntry.PUBLISHED);
+
+roller.getWeblogManager().save(entry);
+roller.flush();
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createtestdata.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createtestdata.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createtestdata.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createtestdata.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,302 @@
+
+if (args[0] != "droptables") {
+    println """
+        WARNING: this script will drop all Roller tables and create newones
+        populated with random but somewhat realistic Roller test data. If you 
+        are sure you want to do that, run again with argument \'droptables\'
+        """
+    return
+}
+
+// TODO: assumes database is Derby
+
+
+class RollerDatabaseGenerator {
+
+    def roller = null;
+
+    def userCount = 10 
+    def blogCount = 2*userCount
+    def entryCount = 10 
+    def commentCount = 3
+
+    def users = []
+
+    def blogs = []
+
+    def firstNames = ["Sarah","Nina","Rhonda","Elizabeth","Rosemary","Angela",
+    "Kim","Deborah","Steve","Mike","Jose","Bill","Fred","Tyrone","Abdul"]
+
+    def middleNames = ["Simpson","Rosewood","Arther","Michael","Sydney","Cook",
+    "Drake","Mohonk","Ratburger","Scoober","Albert","Eli","Pat","Reilly"]
+
+    def lastNames = ["Rockberry","Drummond","Shannon","Kingston","Pike","Svensen",
+    "Ramachandran","Hess","Young","Harper","Schmidt","Woodman","Colburn"]
+
+    def blogStart = ["Cool","Beginning","Nutty","Info","Super","Uber",
+    "One","Original","Random","New","Old","Worthless","Artful"]
+
+    def blogMiddle = ["Java","Oracle","Sun","Microsoft","DotNet","Security","3D",
+    "History","Political","Music","Watercolor","Photography"]
+
+    def blogEnd = ["Notebook","Journal","Blog", "Notes","Scribblings",
+    "Observations","Ravings","Vibrations","Noodlings","News","Views"]
+
+    def categories = ["Music", "Java", "General", "Politics", "Status"]
+
+    def blogText = [
+"""Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris non neque.
+Nam ultricies, diam id cursus ultrices, tellus pede ultricies ligula, vel 
+rutrum metus sem sed quam. Nam consectetuer dolor. Proin a nisl. Aliquam 
+malesuada, ligula eget porta nonummy, felis orci laoreet augue, non pulvinar 
+erat erat eu orci. Donec pretium libero pellentesque ante. Class aptent taciti 
+sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Morbi 
+tellus orci, posuere ut, consectetuer at, pulvinar sed, lectus. Sed non augue. 
+Pellentesque adipiscing tellus eget pede. Etiam ac ante. Sed consectetuer
+tellus sit amet elit. Sed malesuada, risus eu eleifend placerat, pede arcu 
+elementum metus, eget auctor ligula velit ac turpis. Vestibulum a est. Sed 
+sagittis dapibus magna. Integer urna velit, ullamcorper nec, tincidunt et, 
+ullamcorper tincidunt, urna. Pellentesque pede lorem, auctor non, sodales 
+sed, pharetra vel, augue.""",
+"""Phasellus sodales, quam sit amet viverra dignissim, neque enim fringilla 
+sem, vitae luctus sem ante id tellus. Mauris risus tortor, varius a, volutpat 
+ac, mollis in, mauris. Ut justo ante, consectetuer vel, sodales eget, facil 
+eu, justo. Sed venenatis consequat sapien. Nunc porttitor urna vel massa. 
+Praesent et mi. Curabitur aliquam eros sed lorem. Suspendisse potenti. 
+Suspendisse at felis quis sapien euismod posuere. Vivamus nunc odio, eleifend 
+eu, elementum id, mattis eu, augue.""",
+"""Suspendisse quis dolor. Duis mollis metus eu est. Donec bibendum mollis. 
+Vestibulum dignissim arcu eget leo. Curabitur orci. Aenean condimentum ante 
+nec neque. Etiam dignissim mauris sit amet nisi. Fusce quis ante. Sed et elit 
+quis ante tempor cursus. Maecenas turpis. Morbi est. Quisque urna ante, euis 
+eget, sollicitudin in, sagittis quis, nisl. Suspendisse non lorem in dui fau 
+venenatis. Pellentesque fermentum, elit sit amet volutpat rhoncus, massa nisl 
+ fringilla enim, non sodales magna risus eget nulla. In hac habitasse platea 
+dictumst. Suspendisse potenti.""",
+"""Maecenas ut justo id lacus fringilla blandit. Vestibulum ante ipsum primis 
+in faucibus orci luctus et ultrices posuere cubilia Curae; Donec malesuada 
+blandit risus. Donec sagittis varius ante. Aliquam velit orci, ultricies ut, 
+vehicula nec, nonummy quis, lectus. Vestibulum placerat. Morbi aliquam, pede 
+nec vestibulum viverra, justo magna mattis mi, quis molestie tortor metus nec 
+dolor. Nulla sed sapien. Vivamus faucibus, lectus et aliquet mollis, nunc 
+nulla dictum mi, feugiat accumsan metus velit vitae diam. Pellentesque 
+ habitant morbi tristique senectus et netus et malesuada fames ac turpis 
+egestas. Nulla facilisi. Proin ac ante eu diam fermentum tempor. Etiam in 
+purus. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla 
+at justo sed nisi viverra elementum. Nullam dolor nisl, dapibus at, commodo, 
+varius euismod, tortor. Suspendisse vel orci.""",
+"""Fusce feugiat neque id nisl. Ut sagittis. Praesent tempus, nibh et rhoncus 
+sodales, neque risus vehicula pede, vel tempus risus nibh nec pede. Vivamus 
+est pede, varius sit amet, tristique vel, ultricies vitae, urna. Cum sociis 
+natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. 
+Sed non mi ut turpis ullamcorper dapibus. Duis metus. Donec placerat pharetra 
+nisi. Duis lacinia enim id dui. Maecenas a leo. Duis lacus.""" ]
+
+    def randomUserNameList() {
+        String first  = firstNames[  (int)(firstNames.size()  * Math.random())] 
+        String middle = middleNames[ (int)(middleNames.size() * Math.random())]
+        String last   = lastNames[   (int)(lastNames.size()   * Math.random())]
+        return [first, middle, last]
+    }
+    def randomBlogNameList() {
+        String first  = blogStart[  (int)(blogStart.size()  * Math.random())] 
+        String middle = blogMiddle[ (int)(blogMiddle.size() * Math.random())]
+        String last   = blogEnd[    (int)(blogEnd.size()   * Math.random())]
+        return [first, middle, last]
+    }
+
+    def createUser(username, password, fullname, email) {
+        println "Creating user: " + username
+        try {
+            def locale   = "en_US";
+            def timeZone = "America/New_York";
+            def user = new org.apache.roller.weblogger.pojos.User();
+            user.setUserName(username);
+            user.setScreenName(username);
+            user.setPassword(password);
+            user.setFullName(fullname);
+            user.setEmailAddress(email);
+            user.setLocale(locale);
+            user.setTimeZone(timeZone);
+            user.setDateCreated(new java.util.Date());
+            roller.getUserManager().addUser(user);
+            roller.flush();
+            users.add(user)
+            return user
+        } catch (Exception e) {
+            e.printStackTrace()
+        }
+    }
+
+    def createBlog(user, handle, name, desc, theme) {
+        println "Creating blog: " + handle
+        try {
+            def website = new org.apache.roller.weblogger.pojos.Weblog(
+                handle, 
+                user,
+                name,
+                desc,
+                user.getEmailAddress(),
+                user.getEmailAddress(),
+                theme,
+                user.getLocale(),
+                user.getTimeZone());
+            def cat = new org.apache.roller.weblogger.pojos.WeblogCategory(
+                website, null, "cat1", "cat1", null);
+            roller.getWeblogManager().saveWeblogCategory(cat);
+            website.setDefaultCategory(cat);
+            roller.getUserManager().addWebsite(website);
+            roller.flush();
+            return website
+        } catch (Exception e) {
+            e.printStackTrace()
+        }
+    }
+
+    def createEntry(blog, title, text, pubTime) {
+        println "Creating entry title: " + title
+        try {
+            def entry = new org.apache.roller.weblogger.pojos.WeblogEntry();
+            entry.setWebsite(blog);
+            entry.setCreator(blog.getCreator());
+            def catName = categories.get((int)(Math.random() * categories.size()))
+            def category = roller.getWeblogManager().getWeblogCategoryByPath(blog,catName)
+            entry.setCategory(category);
+            entry.setPubTime(new java.sql.Timestamp(pubTime.getTime()));
+            entry.setUpdateTime(new java.sql.Timestamp(pubTime.getTime()));
+            entry.setStatus(org.apache.roller.weblogger.pojos.WeblogEntry.PUBLISHED);
+            entry.setText(text);
+            entry.setTitle(title);
+            entry.setLocale("en_US");
+            roller.getWeblogManager().saveWeblogEntry(entry);
+            roller.flush();
+            return entry
+        } catch (Exception e) {
+            e.printStackTrace()
+        }
+    }
+
+    def createComment(entry, commentername, content) { 
+        println "Creating comment from user: " + commentername
+        try {
+            def comment = new org.apache.roller.weblogger.pojos.WeblogEntryComment();
+            comment.setWeblogEntry(entry);
+            comment.setName(commentername);
+            comment.setPostTime(new java.sql.Timestamp(new java.util.Date().getTime()));
+            comment.setContent(content);
+            comment.setNotify(Boolean.FALSE);
+            comment.setStatus(org.apache.roller.weblogger.pojos.WeblogEntryComment.APPROVED);
+            roller.getWeblogManager().saveComment(comment);
+            roller.flush();
+        } catch (Exception e) {
+            e.printStackTrace()
+        }
+    }
+
+    def createDatabase() {
+        def properties = new Properties()
+        properties.load(new FileInputStream("roller-custom.properties"))
+        def jdbcClass    = properties.get("database.jdbc.driverClass")
+        def jdbcUrl      = properties.get("database.jdbc.connectionURL")
+        def jdbcUser     = properties.get("database.jdbc.username")
+        def jdbcPassword = properties.get("database.jdbc.password")
+        def ant = new AntBuilder()   
+        
+        // drop any existing Roller tables
+        ant.sql(onerror:"continue", driver:jdbcClass, url:jdbcUrl, 
+            userid:jdbcUser, password:jdbcPassword,
+            src:"../../../../../apps/weblogger/build/webapp/WEB-INF/classes/dbscripts/droptables.sql")   
+        
+        // create fresh set of Roller tables
+        ant.sql(onerror:"continue", driver:jdbcClass, url:jdbcUrl, 
+            userid:jdbcUser, password:jdbcPassword,
+            src:"../../../../../apps/weblogger/build/webapp/WEB-INF/classes/dbscripts/derby/createdb.sql") 
+
+        bootstrap()
+
+        // set database version to 400  
+        //def propManager = roller.getPropertiesManager();
+        //def versionProp = new org.apache.roller.weblogger.pojos.RuntimeConfigProperty(
+            //"roller.database.version","400")
+        //propManager.saveProperty(versionProp)
+    }
+
+    def bootstrap() {
+        org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare();
+        org.apache.roller.weblogger.business.WebloggerFactory.bootstrap();
+        org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger().getPropertiesManager().initialize();
+        org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger().flush();
+        roller = org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger();
+    }
+
+    def createMainBlog() {
+        def adminUser = createUser("admin", "admin", "Admin User", "admin@example.com")
+        def mainBlog = createBlog(adminUser, "main", "main", "main", "frontpage")
+        
+        def propManager = roller.getPropertiesManager();
+
+        def mainBlogProp = propManager.getProperty(
+            "site.frontpage.weblog.handle")
+        mainBlogProp.setValue(mainBlog.handle)
+        propManager.saveProperty(mainBlogProp)
+
+        def aggProp = propManager.getProperty(
+            "site.frontpage.weblog.aggregated")
+        aggProp.setValue("true")
+        propManager.saveProperty(aggProp)
+    }
+
+    def generateAllData() {
+
+        // create users
+        1.upto(userCount) {
+            def names    = randomUserNameList();
+            def username = "${names[0]}${names[1]}${names[2]}";
+            def password = "password"
+            def fullname = "${names[0]} ${names[1]} ${names[2]}";
+            def email    = "${names[0]}@${names[1]}${names[2]}.com"
+            def user = createUser(username, password, fullname, email)    
+            if (user) users.add(user)
+        }
+
+        // create blog
+        1.upto(blogCount) {
+           def names  = randomBlogNameList()
+           def user   = users[(int)(Math.random() * users.size())]
+           def handle = names[0] + names[1] + names[2]
+           def name   = handle
+           def desc   = "A blog named ${names[0]} ${names[1]} ${names[2]}"
+           def theme  = "basic"
+           def blog = createBlog(user, handle, name, desc, theme) 
+           if (blog) blogs.add(blog)
+        }
+
+        // Create blog entries and comments
+        blogs.each() { blog ->
+            1.upto(entryCount) {
+                def text = "";
+                def paraCount = (int)(Math.random() * 5);
+                0.upto(paraCount) {
+                    text += "<p>" + blogText[(int)(Math.random() * blogText.size())] + "</p>"
+                }
+                def title = text.substring(3,25)
+                def pubTime = new Date();
+                pubTime = pubTime - (int)(Math.random() * 60)
+                def entry = createEntry(blog, title, text, pubTime)
+                if (entry) 1.upto(commentCount) {
+                    def names = randomUserNameList()
+                    def commentername = "${names[0]} ${names[1]} ${names[2]}" 
+                    def content = blogText[(int)(Math.random()*blogText.size())]
+                    createComment(entry, commentername, content)
+                }
+
+            }
+        }
+    }
+}
+
+
+def generator = new RollerDatabaseGenerator()
+generator.createDatabase()
+generator.createMainBlog()
+generator.generateAllData()

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/createuser.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,50 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* 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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+if (args.length < 3) {
+    println "USAGE: groovy createuser.gy <username> <password> <email>"; 
+    return;
+}
+
+username = args[0];
+password = args[1]
+email    = args[2];
+
+fullName = username;
+locale   = "en_US";
+timeZone = "America/New_York";
+
+user = new org.apache.roller.weblogger.pojos.User();
+user.setUserName(username);
+user.setScreenName(username);
+user.setPassword(password);
+user.setFullName(fullName);
+user.setEmailAddress(email);
+user.setLocale(locale);
+user.setTimeZone(timeZone);
+user.setDateCreated(new java.util.Date());
+
+org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare();
+org.apache.roller.weblogger.business.WebloggerFactory.bootstrap();
+roller = org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger();
+
+roller.getUserManager().addUser(user);
+roller.flush();
+
+user = roller.getUserManager().getUserByUserName(username);
+println "Created user ${user.userName} with id ${user.id}";

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/groovy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/groovy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/groovy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/groovy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# -- ENSURE THESE ARE CORRECT ---
+
+# Directory where Groovy release is installed
+export GROOVY_HOME=/Applications/Java/groovy
+
+# Directory of Roller webapp context
+export WEBAPP_DIR=../../../../../apps/weblogger/build/webapp
+
+# Directory of additional jars
+export JARS_DIR=/Applications/Java/tomcat/common/lib
+
+
+# --- SHOULD NOT NEED TO EDIT BELOW THIS LINE ---
+
+RGPATH=${WEBAPP_DIR}/WEB-INF/classes:\
+${GROOVY_HOME}/embeddable/groovy-all-1.0.jar:\
+${GROOVY_HOME}/lib/commons-cli-1.0.jar:\
+${GROOVY_HOME}/lib/ant-1.6.5.jar:\
+${GROOVY_HOME}/lib/ant-launcher.1.6.5.jar
+
+for i in "$WEBAPP_DIR"/WEB-INF/lib/*.jar; do
+  RGPATH="$RGPATH":"$i"
+done
+
+for i in "$JARS_DIR"/*.jar; do
+  RGPATH="$RGPATH":"$i"
+done
+
+export RGPATH
+
+# Hack: setting catalina.base=. allows us to save log in ./logs
+java \
+ -Droller.custom.config=roller-custom.properties \
+-Dcatalina.base=. \
+-classpath ${RGPATH} groovy.lang.GroovyShell $1 $2 $3 $4 $5 $6 $7 $8 $9 $10

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/listusers.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/listusers.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/listusers.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/listusers.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* 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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+try {
+    org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare();
+    org.apache.roller.weblogger.business.WebloggerFactory.bootstrap();
+    roller = org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger();
+    
+    users = roller.getUserManager().getUsers(null, null, null, null, 0, -1);
+    for (u in users) {
+       println "   User [${u.userName}] has password [${u.password}]";
+       weblogs = roller.getUserManager().getWebsites(u, null, null, null, null, 0, Integer.MAX_VALUE);
+       for (w in weblogs) {
+          println "      Belongs to weblog [${w.handle}]";
+       }
+    } 
+} catch (Exception e) {
+    e.printStackTrace();
+}
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/logs/README.txt
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/logs/README.txt?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/logs/README.txt (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/logs/README.txt Sun Mar  2 13:09:23 2008
@@ -0,0 +1 @@
+Groovy-Roller logs should end up here.

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/removeuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/removeuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/removeuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/removeuser.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,39 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  The ASF licenses this file to You
+* 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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+if (args.length < 2) {
+    println "USAGE: groovy removeuser.gy <username>"; 
+    return;
+}
+
+username = args[0];
+
+org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare();
+org.apache.roller.weblogger.business.WebloggerFactory.bootstrap();
+roller = org.apache.roller.weblogger.business.WebloggerFactory.getWeblogger();
+
+user = roller.getUserManager().getUserByUserName(username);
+if (user == null) {
+    println "User ${username} not found";
+    return;
+}
+roller.getUserManager().removeUser(user);
+roller.flush();
+
+println "Removed user ${user.userName} with id ${user.id}";
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/roller-custom.properties
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/roller-custom.properties?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/roller-custom.properties (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/roller-custom.properties Sun Mar  2 13:09:23 2008
@@ -0,0 +1,17 @@
+
+database.configurationType=jdbc
+
+#database.jdbc.driverClass=org.apache.derby.jdbc.ClientDriver
+#database.jdbc.connectionURL=jdbc:derby://localhost:1527/roller40test;create=true
+#database.jdbc.username=APP
+#database.jdbc.password=APP
+
+database.configurationType=jdbc
+database.jdbc.driverClass=com.mysql.jdbc.Driver
+database.jdbc.connectionURL=jdbc:mysql://localhost:3306/blogs_sfbay_20080108
+database.jdbc.username=scott
+database.jdbc.password=tiger
+
+log4j.category.org.apache.roller=DEBUG
+
+themes.dir=.
\ No newline at end of file

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/roller-startup.log
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/roller-startup.log?rev=632847&view=auto
==============================================================================
    (empty)



Mime
View raw message