roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r632847 [2/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
Added: roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/runsql.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/runsql.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/runsql.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/examples/rollerapi/runsql.gy Sun Mar  2 13:09:23 2008
@@ -0,0 +1,170 @@
+/*
+* 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.
+*/
+
+import java.sql.*;
+import java.io.*;
+
+/**
+ * SQL script runner, parses script and allows you to run it. 
+ * You can run the script multiple times if necessary.
+ * Assumes that anything on an input line after "--" or ";" can be ignored.
+ */
+class SQLScriptRunner {
+    private List<String> commands = new ArrayList<String>();
+    private List<String> messages = new ArrayList<String>();
+    private boolean      failed = false;
+    private boolean      errors = false;        
+    
+    /** Creates a new instance of SQLScriptRunner */
+    public SQLScriptRunner(InputStream is) throws IOException {
+
+        BufferedReader br = new BufferedReader(new InputStreamReader(is));
+        String command = ""; 
+        String line;
+        while ((line = br.readLine()) != null) {
+            line = line.trim();            
+            if (!line.startsWith("--") && !line.startsWith("/*")) {   
+                
+                if (line.indexOf("--") > 0) {
+                    // trim comment off end of line
+                    line = line.substring(0, line.indexOf("--")).trim();
+                }
+                
+                // add line to current command
+                command += line.trim();
+                if (command.endsWith(";")) { 
+                    if (!command.trim().startsWith("DROP")
+                    && !command.trim().startsWith("LOCK")
+                    && !command.trim().startsWith("UNLOCK")) {
+                        // ";" is end of command, so add completed command to list
+                        commands.add(command.substring(0, command.length() - 1));
+                    }
+                    command = "";
+                } else {
+                    command += " "; // still more command coming so add space
+                }
+            } 
+        }
+        br.close();
+    }
+    
+    
+    /** Creates a new instance of SQLScriptRunner */
+    public SQLScriptRunner(String scriptPath) throws IOException {
+        this(new FileInputStream(scriptPath));
+    }
+    
+    
+    /** Number of SQL commands in script */
+    public int getCommandCount() {
+        return commands.size();
+    }
+    
+    
+    /** Return messages from last run of script, empty if no previous run */
+    public List<String> getMessages() {
+        return messages;
+    }
+    
+    
+    /** Returns true if last call to runScript() threw an exception */
+    public boolean getFailed() {
+        return failed;
+    }
+    
+    
+    /** Returns true if last run had any errors */
+    public boolean getErrors() {
+        return errors;
+    }
+    
+    
+    /** Run script, logs messages, and optionally throws exception on error */
+    public void runScript(
+            Connection con, boolean stopOnError) throws SQLException {
+        failed = false;
+        errors = false;
+        for (String command : commands) {
+            
+            // run each command
+            try {
+                Statement stmt = con.createStatement();
+                stmt.executeUpdate(command);
+                if (!con.getAutoCommit()) con.commit();
+                
+                // on success, echo command to messages
+                successMessage(command);
+                
+            } catch (SQLException ex) {
+                // add error message with text of SQL command to messages
+                errorMessage("ERROR: SQLException executing SQL [" + command 
+                        + "] : " + ex.getLocalizedMessage());
+                // add stack trace to messages
+                StringWriter sw = new StringWriter();
+                ex.printStackTrace(new PrintWriter(sw));
+                errorMessage(sw.toString());
+                if (stopOnError) {
+                    failed = true;
+                    throw ex;
+                }
+            }
+        }
+    }
+    
+    
+    private void errorMessage(String msg) {
+        messages.add(msg);
+    }    
+    
+    
+    private void successMessage(String msg) {
+        messages.add(msg);
+    }    
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////////
+
+if (args.length < 2) {
+    println "USAGE: groovy runsql.gy <filename>";
+    return;
+}
+
+Properties props = new Properties();
+props.load(new FileInputStream("roller-custom.properties"));
+println "Loaded Roller properties";
+
+Class.forName(props.getProperty("database.jdbc.driverClass"));
+
+con = DriverManager.getConnection(
+    props.getProperty("database.jdbc.connectionURL"),
+    props.getProperty("database.jdbc.username"),
+    props.getProperty("database.jdbc.password"));
+println "Created database connection";
+
+runner = null;
+try {
+    runner = new SQLScriptRunner(new FileInputStream(args[0]));
+    runner.runScript(con, true);
+} catch (Exception e) {
+    e.printStackTrace();
+}
+runner.messages.each() {
+     print it;
+}
+
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRenderer.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRenderer.java?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRenderer.java (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRenderer.java Sun Mar  2 13:09:23 2008
@@ -0,0 +1,96 @@
+/*
+ * 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 groovy.lang.Binding;
+import groovy.lang.GroovyShell;
+import groovy.text.TemplateEngine;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.pojos.Template;
+import org.apache.roller.weblogger.pojos.WeblogTemplate;
+import org.apache.roller.weblogger.ui.rendering.Renderer;
+import org.apache.roller.weblogger.ui.rendering.RenderingException;
+
+/**
+ * Renderer that compiles/executes Roller Template as a Groovy Template.
+ *
+ * <p>Implementation notes</p>
+ * 
+ * <p>Uses TemplateEngine passed from RefererFactory, which is probably the 
+ * right thing to do. Need to add some caching so we don't have to recompile
+ * every time a tempalte is executed.</p>
+ *
+ * <p>Check the TemplateServlet code for some examples of template execution:</br />
+ * http://svn.codehaus.org/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/ 
+ */
+public class GSPRenderer implements Renderer {
+    private static Log log = LogFactory.getLog(GroovletRenderer.class);
+    private groovy.text.Template groovyTemplate = null;   
+    private WeblogTemplate template = null;
+    private Exception parseException = null;
+    
+    public GSPRenderer(TemplateEngine templateEngine, WeblogTemplate template) {
+        this.template = template;
+        try {
+            // TODO: implement caching for compiled templates
+            groovyTemplate = templateEngine.createTemplate(template.getContents());
+        } catch (Exception ex) {
+            log.debug("Creating Groovy template", ex);
+            parseException = ex;
+        }
+    }
+    
+    public void render(Map model, Writer writer) throws RenderingException {
+        try {
+            if (parseException == null) {                
+
+                long startTime = System.currentTimeMillis();
+                Binding binding = new GroovyRollerBinding(model, writer);
+                groovyTemplate.make(binding.getVariables()).writeTo(writer);
+                long endTime = System.currentTimeMillis();
+                
+                long renderTime = (endTime - startTime)/1000;
+                log.debug("Rendered ["+template.getId()+"] in "+renderTime+" secs");
+            } else {
+                renderThrowable(parseException, writer);
+            }
+            
+        } catch (Exception ex) {
+            log.debug("Executing Groovy template", ex);
+            renderThrowable(ex, writer);
+        }
+    }
+    
+    private void renderThrowable(Throwable ex, Writer writer) {
+        Binding binding = new Binding();
+        binding.setVariable("ex", ex);
+        binding.setVariable("out", new PrintWriter(writer));
+        GroovyShell shell = new GroovyShell(binding);
+        shell.evaluate(
+             "s = \"<p><b>Exception</b>: ${ex}<br /><b>Message</b>: ${ex.message}</p>\";"
+           +" out.println(s);"
+           +" out.flush();");         
+    }
+}
+
+

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRendererFactory.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRendererFactory.java?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRendererFactory.java (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GSPRendererFactory.java Sun Mar  2 13:09:23 2008
@@ -0,0 +1,53 @@
+/*
+ * 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 groovy.text.SimpleTemplateEngine;
+import groovy.text.TemplateEngine;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.pojos.Template;
+import org.apache.roller.weblogger.pojos.WeblogTemplate;
+import org.apache.roller.weblogger.ui.rendering.Renderer;
+import org.apache.roller.weblogger.ui.rendering.RendererFactory;
+
+/**
+ * RendererFactory that handles Groovy Server Page (GSP) style templates 
+ * w/language name "gsp"
+ */
+public class GSPRendererFactory implements RendererFactory {
+    private static Log log = LogFactory.getLog(GroovletRendererFactory.class);
+    private TemplateEngine templateEngine = new SimpleTemplateEngine();
+    
+    public Renderer getRenderer(Template template) {
+        Renderer renderer = null;
+        if(template.getTemplateLanguage() == null || template.getId() == null) {
+            return null;
+        }
+        if("gsp".equals(template.getTemplateLanguage()) && template instanceof WeblogTemplate) {
+            try {
+                renderer = new GSPRenderer(templateEngine, (WeblogTemplate)template); 
+            } catch(Exception ex) {
+                return null;
+            }
+        }
+        return renderer;
+    }
+    
+}

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRenderer.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRenderer.java?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRenderer.java (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRenderer.java Sun Mar  2 13:09:23 2008
@@ -0,0 +1,82 @@
+/*
+ * 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 groovy.lang.Binding;
+import groovy.lang.GroovyShell;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.pojos.WeblogTemplate;
+import org.apache.roller.weblogger.ui.rendering.Renderer;
+import org.apache.roller.weblogger.ui.rendering.RenderingException;
+
+/**
+ * Renderer that evaluates Roller Template as Groovy script.
+ *
+ * <p>Implementation notes</p>
+ * 
+ * <p>Executes template using GroovyShell. I'd much prefer to use the 
+ * GroovyScriptEngine, but it doesn't seem flexible enough as it returns each 
+ * resource as a URLConnection.</p>
+ *
+ * <p>Check the Groovy Servlet code for an example of GroovyScriptEngine:</br />
+ * http://svn.codehaus.org/groovy/trunk/groovy/groovy-core/src/main/groovy/servlet/
+ * </p>
+ */
+public class GroovletRenderer implements Renderer {
+    private static Log log = LogFactory.getLog(GroovletRenderer.class);
+    private WeblogTemplate template = null;
+    
+    public GroovletRenderer(WeblogTemplate template) {
+        this.template = template;
+    }
+    
+    public void render(Map model, Writer writer) throws RenderingException {
+        try {
+            long startTime = System.currentTimeMillis();            
+            Binding binding = new GroovyRollerBinding(model, writer);
+            GroovyShell shell = new GroovyShell(binding);
+            shell.evaluate(template.getContents());              
+            long endTime = System.currentTimeMillis();
+
+            long renderTime = (endTime - startTime)/1000;
+            log.debug("Rendered ["+template.getId()+"] in "+renderTime+" secs"); 
+            
+        } catch (Throwable ex) {
+            log.debug("Executing Groovy script", ex);
+            renderThrowable(ex, writer);
+        }
+    }
+    
+    private void renderThrowable(Throwable ex, Writer writer) {
+        Binding binding = new Binding();
+        binding.setVariable("ex", ex);
+        binding.setVariable("out", new PrintWriter(writer));
+        GroovyShell shell = new GroovyShell(binding);
+        shell.evaluate(
+             "s = \"<p><b>Exception</b>: ${ex}<br /><b>Message</b>: ${ex.message}</p>\";"
+           +" out.println(s);"
+           +" out.flush();");         
+    }
+}
+
+    

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRendererFactory.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRendererFactory.java?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRendererFactory.java (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovletRendererFactory.java Sun Mar  2 13:09:23 2008
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.pojos.Template;
+import org.apache.roller.weblogger.pojos.WeblogTemplate;
+import org.apache.roller.weblogger.ui.rendering.Renderer;
+import org.apache.roller.weblogger.ui.rendering.RendererFactory;
+
+/**
+ * RendererFactory that handles Groovlet-style templates w/language name "groovlet"
+ */
+public class GroovletRendererFactory implements RendererFactory {
+    private static Log log = LogFactory.getLog(GroovletRendererFactory.class);
+    
+    public Renderer getRenderer(Template template) {        
+        Renderer renderer = null;
+        if(template.getTemplateLanguage() == null || template.getId() == null) {
+            return null;
+        }        
+        if("groovlet".equals(template.getTemplateLanguage()) && template instanceof WeblogTemplate) {             
+            try {
+               renderer = new GroovletRenderer((WeblogTemplate)template);
+            } catch(Exception ex) {
+                return null;
+            }                        
+        }        
+        return renderer;
+    }
+    
+}

Added: roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovyRollerBinding.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovyRollerBinding.java?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovyRollerBinding.java (added)
+++ roller/branches/roller_4.0/sandbox/groovy-renderer/src/org/apache/roller/scripting/GroovyRollerBinding.java Sun Mar  2 13:09:23 2008
@@ -0,0 +1,90 @@
+/*
+ * 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 groovy.lang.Binding;
+import groovy.xml.MarkupBuilder;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.ui.rendering.model.UtilitiesModel;
+
+/**
+ * Binds Roller model objects along with Groovlet and GSP style "out" and "html" variables.
+ */
+public class GroovyRollerBinding extends Binding {
+    private static Log log = LogFactory.getLog(GroovyRollerBinding.class);
+    private Binding binding;
+    private MarkupBuilder html;
+    private PrintWriter printWriter;
+    
+    public GroovyRollerBinding(Map model, Writer writer) {
+        this.printWriter = new PrintWriter(writer);
+        binding = new Binding(model);
+        binding.setVariable("utils", new UtilitiesModel()); 
+    }
+        
+    public void setVariable(String name, Object value) {
+        if (name == null) {
+            throw new IllegalArgumentException("Can't bind variable to null key.");
+        }
+        if (name.length() == 0) {
+            throw new IllegalArgumentException("Can't bind variable to blank key name. [length=0]");
+        }
+        if ("out".equals(name)) {
+            throw new IllegalArgumentException("Can't bind variable to key named '" + name + "'.");
+        }
+        if ("html".equals(name)) {
+            throw new IllegalArgumentException("Can't bind variable to key named '" + name + "'."); 
+        }
+        binding.setVariable(name, value);
+    }
+
+    public Map getVariables() {
+        return binding.getVariables();
+    }
+
+    public Object getVariable(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("No variable with null key name.");
+        }
+        if (name.length() == 0) {
+            throw new IllegalArgumentException("No variable with blank key name. [length=0]");
+        }
+        try {
+            if ("out".equals(name)) {
+                return printWriter;
+            }
+            if ("html".equals(name)) {
+                if (html == null) {
+                    html = new MarkupBuilder(printWriter);
+                }
+                return html;
+            }
+        } catch (Exception e) {
+            String message = "Failed to get writer or output stream from response.";
+            log.error(message, e);
+            throw new RuntimeException(message, e);
+        }
+
+        return binding.getVariable(name);
+    }    
+}

Propchange: roller/branches/roller_4.0/sandbox/groovy-rollerapi/
------------------------------------------------------------------------------
--- 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-rollerapi/README.txt
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/README.txt?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/README.txt (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/README.txt Sun Mar  2 13:09:23 2008
@@ -0,0 +1,31 @@
+
+Groovy scripts that run against the Roller API
+-------------------------------------------------------------------------------
+
+The example scripts in the scripts directory are designed to the computer on 
+which Roller is installed. Because they use Roller's Java API directly, you 
+must run them with the provided "rollergroovy" script which sets up the 
+classpath correctly for calling into the Roller code base. 
+
+Before you can run you must:
+
+1) Have Groovy 1.5.4 installed on your system
+
+2) Have Roller 4.0 installed and configured on yoru system
+
+3) Edit the provided rollergroovy script to set the GROOVY_HOME, WEBAPP_DIR and 
+   JARS_DIR. If you have a newer version of Groovy than 1.5.4, you'll also have 
+   to change some of the jar names to those included in your newer Groovy 
+   distrivution. 
+
+4) Edit the provided roller-custom.properties to point to your Roller database
+   and to use the correct connection parameters, username, password, etc.
+
+Once you've done that you can run the scripts like so:
+
+   $ ./rollergroovy listusers.gy
+
+For a complete listing of Roller's Java classes see the Roller Javadocs:
+    http://people.apache.org/~snoopdave/javadocs/roller40/
+
+TODO: Provide a rollergroovy.bat file so scipts can run on Microsoft Windows

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

Added: roller/branches/roller_4.0/sandbox/groovy-rollerapi/build.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/build.xml?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/build.xml (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/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 Roller 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-rollerapi/scripts/checkuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/checkuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/checkuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/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-rollerapi/scripts/createblog.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createblog.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createblog.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/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-rollerapi/scripts/createcomment.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createcomment.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createcomment.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/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-rollerapi/scripts/createentry.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createentry.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createentry.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/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-rollerapi/scripts/createtestdata.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createtestdata.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createtestdata.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/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-rollerapi/scripts/createuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/createuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/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-rollerapi/scripts/groovyroller.sh
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/groovyroller.sh?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/groovyroller.sh (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/groovyroller.sh 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.5.4.jar:\
+${GROOVY_HOME}/lib/commons-cli-1.0.jar:\
+${GROOVY_HOME}/lib/ant-1.7.0.jar:\
+${GROOVY_HOME}/lib/ant-launcher.1.7.0.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

Propchange: roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/groovyroller.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/listusers.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/listusers.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/listusers.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/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-rollerapi/scripts/logs/README.txt
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/logs/README.txt?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/logs/README.txt (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/logs/README.txt Sun Mar  2 13:09:23 2008
@@ -0,0 +1 @@
+The groovyroller script will store log files in this directory 

Added: roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/removeuser.gy
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/removeuser.gy?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/removeuser.gy (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/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-rollerapi/scripts/roller-custom.properties
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/roller-custom.properties?rev=632847&view=auto
==============================================================================
--- roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/roller-custom.properties (added)
+++ roller/branches/roller_4.0/sandbox/groovy-rollerapi/scripts/roller-custom.properties Sun Mar  2 13:09:23 2008
@@ -0,0 +1,11 @@
+
+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
+
+log4j.category.org.apache.weblogger.roller=DEBUG
+
+themes.dir=.
\ No newline at end of file

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



Mime
View raw message