You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2007/03/08 18:50:00 UTC

svn commit: r516118 - in /incubator/roller/trunk/sandbox/scripting: groovy/ src/org/apache/roller/util/

Author: snoopdave
Date: Thu Mar  8 09:49:55 2007
New Revision: 516118

URL: http://svn.apache.org/viewvc?view=rev&rev=516118
Log:
Cleaning up and refining scripts

Removed:
    incubator/roller/trunk/sandbox/scripting/groovy/rollertest1.gy
    incubator/roller/trunk/sandbox/scripting/groovy/run-groovy
    incubator/roller/trunk/sandbox/scripting/groovy/run-groovy2
    incubator/roller/trunk/sandbox/scripting/groovy/spamattack.gy
Modified:
    incubator/roller/trunk/sandbox/scripting/groovy/README.txt
    incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy
    incubator/roller/trunk/sandbox/scripting/groovy/createblog.gy
    incubator/roller/trunk/sandbox/scripting/groovy/createentry.gy
    incubator/roller/trunk/sandbox/scripting/groovy/createuser.gy
    incubator/roller/trunk/sandbox/scripting/groovy/listusers.gy
    incubator/roller/trunk/sandbox/scripting/groovy/roller-custom.properties
    incubator/roller/trunk/sandbox/scripting/src/org/apache/roller/util/GroovyRunner.java

Modified: incubator/roller/trunk/sandbox/scripting/groovy/README.txt
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/README.txt?view=diff&rev=516118&r1=516117&r2=516118
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/README.txt (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/README.txt Thu Mar  8 09:49:55 2007
@@ -1,6 +1 @@
-
-Some experiments with using Groovy to script Roller.
-
-Broken in 3.0 release.
-
-Working in 3.1.
+Some experiments with using Groovy to script Roller

Modified: incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy?view=diff&rev=516118&r1=516117&r2=516118
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/checkuser.gy Thu Mar  8 09:49:55 2007
@@ -16,16 +16,17 @@
 * directory of this distribution.
 */
 
-username = "admin";
+if (args.length < 1) {
+    println "USAGE: groovy checkuser.gy <username>";
+    return;
+}
 
 roller = org.apache.roller.business.RollerFactory.getRoller();
-user = roller.getUserManager().getUserByUserName(username);
-
-println roller.getUserManager().getUsers(0,-1);
+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:";
+    println "User ${user.userName} with id [${user.id}] has roles:";
     user.getRoles().each({ item -> println "   ${item.getRole()}" });
 }

Modified: incubator/roller/trunk/sandbox/scripting/groovy/createblog.gy
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/createblog.gy?view=diff&rev=516118&r1=516117&r2=516118
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/createblog.gy (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/createblog.gy Thu Mar  8 09:49:55 2007
@@ -16,17 +16,25 @@
 * directory of this distribution.
 */
 
-// assumes user 'scratch' already exists
+if (args.length < 2) {
+    println "USAGE: groovy createblog.gy <username> <handle>";
+    return;
+}
 
-username =    "scratch";
-blogname =    "Technomajikal";
-description = "Who put the voodoo pon reggae";
-handle =      "scratchblog";
+username =    args[0];
+handle =      args[1];
+
+blogname =    handle;
+description = handle;
 theme =       "basic";
 
 roller = org.apache.roller.business.RollerFactory.getRoller();
 
 user = roller.getUserManager().getUserByUserName(username);
+if (user == null) {
+    println "ERROR: user ${username} not found";
+    System.exit(-1);
+} 
 website = new org.apache.roller.pojos.WebsiteData(
    handle, 
    user,
@@ -37,10 +45,11 @@
    theme,
    user.getLocale(),
    user.getTimeZone());
-
-roller.getUserManager().addWebsite(website);
-roller.flush();
-
+try {
+   roller.getUserManager().addWebsite(website);
+   roller.flush();
+} catch (Exception e) {
+   e.printStackTrace();
+}
 blog = roller.getUserManager().getWebsiteByHandle(handle);
 println "Created blog ${blog.name} with id ${blog.id}";
-

Modified: incubator/roller/trunk/sandbox/scripting/groovy/createentry.gy
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/createentry.gy?view=diff&rev=516118&r1=516117&r2=516118
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/createentry.gy (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/createentry.gy Thu Mar  8 09:49:55 2007
@@ -15,17 +15,34 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-username = "scratch";
-handle =   "scratchblog";
-title =    "Test post";
-text =     "Testing 1 2 3 <em>Hello World!</em>";
-catpath =  "/General";
+
+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];
  
 roller = org.apache.roller.business.RollerFactory.getRoller();
-
 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.pojos.WeblogEntryData();
 entry.setWebsite(blog);

Modified: incubator/roller/trunk/sandbox/scripting/groovy/createuser.gy
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/createuser.gy?view=diff&rev=516118&r1=516117&r2=516118
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/createuser.gy (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/createuser.gy Thu Mar  8 09:49:55 2007
@@ -16,12 +16,18 @@
 * directory of this distribution.
 */
 
-username =    "scratch";
-password =    "jam342down";
-fullName =    "Lee Perry";
-email =       "lee.perry@upsetter.net";
-locale =      "en_GB";
-timeZone =    "America/Jamaica";
+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.pojos.UserData();
 user.setUserName(username);
@@ -32,13 +38,9 @@
 user.setTimeZone(timeZone);
 user.setDateCreated(new java.util.Date());
 
-try {
-   roller = org.apache.roller.business.RollerFactory.getRoller();
-   roller.getUserManager().addUser(user);
-   roller.flush();
-} catch (org.apache.roller.RollerException re) {
-   re.printStackTrace();
-}
+roller = org.apache.roller.business.RollerFactory.getRoller();
+roller.getUserManager().addUser(user);
+roller.flush();
+
 user = roller.getUserManager().getUserByUserName(username);
 println "Created user ${user.userName} with id ${user.id}";
-

Modified: incubator/roller/trunk/sandbox/scripting/groovy/listusers.gy
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/listusers.gy?view=diff&rev=516118&r1=516117&r2=516118
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/listusers.gy (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/listusers.gy Thu Mar  8 09:49:55 2007
@@ -17,9 +17,8 @@
 */
 
 roller = org.apache.roller.business.RollerFactory.getRoller();
+users = roller.getUserManager().getUsers(null, null, null, null, 0, -1);
 
-println "\nFirst 10 users in the system:"
-users = roller.getUserManager().getUsers(0, 10);
 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);
@@ -27,4 +26,3 @@
       println "      Belongs to weblog [${w.handle}]";
    }
 } 
-println "\nDONE\n"

Modified: incubator/roller/trunk/sandbox/scripting/groovy/roller-custom.properties
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/roller-custom.properties?view=diff&rev=516118&r1=516117&r2=516118
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/groovy/roller-custom.properties (original)
+++ incubator/roller/trunk/sandbox/scripting/groovy/roller-custom.properties Thu Mar  8 09:49:55 2007
@@ -1,9 +1,7 @@
 
 jdbc.driverClass=org.apache.derby.jdbc.ClientDriver
-jdbc.connectionURL=jdbc:derby://localhost:1527/roller31
+jdbc.connectionURL=jdbc:derby://localhost:1527/roller-jpa
 jdbc.username=APP 
 jdbc.password=APP 
 
-hibernate.configResource=/hibernate.cfg.xml
 hibernate.dialect=org.hibernate.dialect.DerbyDialect
-

Modified: incubator/roller/trunk/sandbox/scripting/src/org/apache/roller/util/GroovyRunner.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/src/org/apache/roller/util/GroovyRunner.java?view=diff&rev=516118&r1=516117&r2=516118
==============================================================================
--- incubator/roller/trunk/sandbox/scripting/src/org/apache/roller/util/GroovyRunner.java (original)
+++ incubator/roller/trunk/sandbox/scripting/src/org/apache/roller/util/GroovyRunner.java Thu Mar  8 09:49:55 2007
@@ -75,3 +75,20 @@
     }
 }
 
+
+/*
+# --- SHOULD NOT NEED TO EDIT BELOW THIS LINE ---
+
+export RGPATH=\
+../build/classes:\
+${GROOVY_HOME}/embeddable/groovy-all-1.0.jar:\
+${GROOVY_HOME}/lib/commons-cli-1.0.jar:\
+${WEBAPP_DIR}/WEB-INF/lib/roller-business.jar
+echo ${RGPATH}
+
+# Hack: setting catalina.base=. allows us to save log in ./logs
+java \
+-Droller.custom.config=roller-custom.properties \
+-Dcatalina.base=. \
+-cp ${RGPATH} org.apache.roller.util.GroovyRunner $WEBAPP_DIR $JARS_DIR $1
+*/