geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r508624 - /geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/Client.groovy
Date Fri, 16 Feb 2007 22:29:32 GMT
Author: jdillon
Date: Fri Feb 16 14:29:31 2007
New Revision: 508624

URL: http://svn.apache.org/viewvc?view=rev&rev=508624
Log:
Oops, for got the magic

Added:
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/Client.groovy   (with props)

Added: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/Client.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/Client.groovy?view=auto&rev=508624
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/Client.groovy (added)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/Client.groovy Fri Feb 16
14:29:31 2007
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  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.
+ */
+
+//
+// $Id$
+//
+
+package hokeypokey
+
+import groovy.net.xmlrpc.XMLRPCServerProxy
+import groovy.net.xmlrpc.XMLRPCCallFailureException
+
+/**
+ * Do the Hokey Pokey!
+ */
+class Client
+{
+    def url
+    def username
+    def password
+    def proxy
+    def client
+    def token
+    
+    def Client(URL url, username, password) {
+        assert url
+        
+        this.url = url
+        this.username = username
+        this.password = password
+        this.proxy = new XMLRPCServerProxy("$url")
+        this.client = proxy.confluence1
+    }
+    
+    Object invokeMethod(String name, Object args) {
+        assert name
+        
+        // println "INVOKE: $name w/args: $args"
+        
+        switch (name) {
+            case 'invokeMethod':
+                return super.invokeMethod(name, args)
+            
+            case 'login':
+                // Save the security token
+                token = client.login(username, password)
+                return token
+            
+            default:
+                try {
+                    def _name = 'do' + name[0].toUpperCase() + name[1..-1] 
+                    return this["$_name"](name, args)
+                }
+                catch (MissingPropertyException e) {
+                    return defaultAction(name, args)
+                }
+        }
+    }
+    
+    private List encodeToken(args) {
+        def list = [token]
+        list.addAll(args.toList())
+        return list
+    }
+    
+    private Object defaultAction(String name, Object args) {
+        return client.invokeMethod(name, encodeToken(args))
+    }
+    
+    private Closure doLogout = { name, args ->
+        if (!defaultAction(name, args)) {
+            throw new Exception('Failed to logout')
+        }
+    }
+}
+

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/Client.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/Client.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/Client.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message