geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r508623 - in /geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey: ConfluenceConnection.groovy HokeyPokey.groovy commands/HokeyPokeyCommand.groovy commands/addpage.groovy
Date Fri, 16 Feb 2007 22:24:28 GMT
Author: jdillon
Date: Fri Feb 16 14:24:27 2007
New Revision: 508623

URL: http://svn.apache.org/viewvc?view=rev&rev=508623
Log:
Make URL configurable
Use more magical groovy bits to hide the security token and protocol fluff from usage
Use nicer output when page added to show content

Removed:
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/ConfluenceConnection.groovy
Modified:
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/HokeyPokeyCommand.groovy
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy

Modified: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy?view=diff&rev=508623&r1=508622&r2=508623
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy (original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy Fri Feb
16 14:24:27 2007
@@ -40,8 +40,9 @@
         def cli = new CliBuilder(usage : 'hokeypokey [option]* <command> [command-option]*')
         
         cli.h(longOpt: 'help', 'Print out this message.')
-        cli.u(longOpt: 'username', args: 1, argName: 'name', 'Specify the Confluence user
name to authenticate with')
-        cli.p(longOpt: 'password', args: 1, argName: 'pass', 'Specify the Confluence password
to authenticate with')
+        cli.U(longOpt: 'url', args: 1, argName: 'url', 'The confluence URL')
+        cli.u(longOpt: 'username', args: 1, argName: 'name', 'User name to authenticate with')
+        cli.p(longOpt: 'password', args: 1, argName: 'pass', 'Password to authenticate with')
         
         def options = cli.parse(args)
         if (options == null) {
@@ -50,6 +51,7 @@
         }
         
         if (options.h) { cli.usage(); return }
+        if (options.U) { url = new URL(options.U) }
         if (options.u) { username = options.u }
         if (options.p) { password = options.p }
         
@@ -64,23 +66,12 @@
     }
     
     def run(command, args) {
-        println "Running command: $command w/args: ${args.join(', ')}"
+        // println "Running command: $command w/args: ${args.join(', ')}"
         
         def type = getClass().classLoader.loadClass("hokeypokey.commands.${command}")
         def obj = type.newInstance()
-        obj.connection = connect()
+        obj.client = new Client(url, username, password)
         obj.run(args)
-    }
-    
-    ConfluenceConnection connect() {
-        println "Connecting to: $url"
-        def proxy = new XMLRPCServerProxy("$url")
-        def client = proxy.confluence1
-        
-        println "Authenticating with: $username/${'*' * password.size()}"
-        def sectok = client.login(username, password)
-        
-        return new ConfluenceConnection(client, sectok)
     }
     
     static void main(String[] args) {

Modified: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/HokeyPokeyCommand.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/HokeyPokeyCommand.groovy?view=diff&rev=508623&r1=508622&r2=508623
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/HokeyPokeyCommand.groovy
(original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/HokeyPokeyCommand.groovy
Fri Feb 16 14:24:27 2007
@@ -23,13 +23,13 @@
 
 package hokeypokey.commands
 
-import hokeypokey.ConfluenceConnection
+import hokeypokey.Client
 
 /**
  * Do the Hokey Pokey!
  */
 abstract class HokeyPokeyCommand
 {
-    public ConfluenceConnection connection
+    public Client client
 }
 

Modified: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy?view=diff&rev=508623&r1=508622&r2=508623
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy (original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy Fri
Feb 16 14:24:27 2007
@@ -34,7 +34,7 @@
     private String title
     
     def run(args) {
-        println "Running ${args.join(', ')}"
+        // println "Running ${args.join(', ')}"
         
         def cli = new CliBuilder(usage : 'hokeypokey addpage [option]* <file>')
         
@@ -70,14 +70,24 @@
             content: file.text
         ]
         
-        def resultPage = connection.client.storePage(connection.sectok, page)
+        client.login()
         
-        println "Added page; details:"
-        resultPage.each {
-            println "    $it"
+        try {
+            def resultPage = client.storePage(page)
+            
+            println 'Added page; details:'
+            resultPage.each {
+                if (it.key != 'content') {
+                    println "    $it"
+                }
+            }
+            println '----8<----'
+            println resultPage['content']
+            println '---->8----'
+        }
+        finally {
+            client.logout()
         }
-        
-        assert connection.client.logout(connection.sectok) : "Logout failed"
     }
 }
 



Mime
View raw message