svn commit: r547443 - in /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp: event/XmlRpcEventHandler.java test/XmlRpcTests.java xmlrpc/AliasSupportedTransportFactory.java xmlrpc/XmlRpcClient.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r547443 - in /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp: event/XmlRpcEventHandler.java test/XmlRpcTests.java xmlrpc/AliasSupportedTransportFactory.java xmlrpc/XmlRpcClient.java

jaz-3
Author: jaz
Date: Thu Jun 14 16:24:08 2007
New Revision: 547443

URL: http://svn.apache.org/viewvc?view=rev&rev=547443
Log:
added new RpcClient class which handles all the transport configuration internally (simpler to use); updated the RPC glue test

Added:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/XmlRpcClient.java   (with props)
Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/AliasSupportedTransportFactory.java

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java?view=diff&rev=547443&r1=547442&r2=547443
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java Thu Jun 14 16:24:08 2007
@@ -218,7 +218,7 @@
             }
             if (ServiceUtil.isError(resp)) {
                 Debug.logError(ServiceUtil.getErrorMessage(resp), module);                
-                throw new XmlRpcException(ServiceUtil.getErrorMessage(resp));
+                //throw new XmlRpcException(ServiceUtil.getErrorMessage(resp));
             }
 
             // return only definied parameters                        

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java?view=diff&rev=547443&r1=547442&r2=547443
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/test/XmlRpcTests.java Thu Jun 14 16:24:08 2007
@@ -23,8 +23,8 @@
 import org.ofbiz.service.GenericDispatcher;
 import org.ofbiz.service.ModelService;
 import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.webapp.xmlrpc.XmlRpcClient;
 import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.apache.xmlrpc.client.XmlRpcClient;
 
 import java.util.Map;
 import java.net.URL;
@@ -57,11 +57,11 @@
         config.setBasicUserName("admin");
         config.setBasicPassword("ofbiz");
 
-        XmlRpcClient client = new XmlRpcClient();
+        XmlRpcClient client = new XmlRpcClient(config);
         client.setConfig(config);
 
-        Object[] params = new Object[] { new Double(55.00), "message from xml-rpc client" };
+        Object[] params = new Object[] { 55.00, "message from xml-rpc client" };
         Map result = (Map) client.execute("testScv", params);
-        assertEquals("XML-RPC Service result success", ModelService.RESPOND_SUCCESS, result.get(ModelService.RESPONSE_MESSAGE));        
+        assertEquals("XML-RPC Service result success", "service done", result.get("resp"));        
     }
 }

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/AliasSupportedTransportFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/AliasSupportedTransportFactory.java?view=diff&rev=547443&r1=547442&r2=547443
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/AliasSupportedTransportFactory.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/AliasSupportedTransportFactory.java Thu Jun 14 16:24:08 2007
@@ -44,7 +44,7 @@
 
     private final AliasSupportedTransport transport;
 
-    public AliasSupportedTransportFactory(XmlRpcClient client, KeyStore ks, String password, String alias) {
+    public AliasSupportedTransportFactory(org.apache.xmlrpc.client.XmlRpcClient client, KeyStore ks, String password, String alias) {
         super(client);
         transport = new AliasSupportedTransport(client, ks, password, alias);
     }
@@ -61,7 +61,7 @@
         private String alias;
         private KeyStore ks;
 
-        protected AliasSupportedTransport(XmlRpcClient client, KeyStore ks, String password, String alias) {
+        protected AliasSupportedTransport(org.apache.xmlrpc.client.XmlRpcClient client, KeyStore ks, String password, String alias) {
             super(client, userAgent);
             this.password = password;
             this.alias = alias;

Added: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/XmlRpcClient.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/XmlRpcClient.java?view=auto&rev=547443
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/XmlRpcClient.java (added)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/XmlRpcClient.java Thu Jun 14 16:24:08 2007
@@ -0,0 +1,69 @@
+/*
+ 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.
+ */
+
+package org.ofbiz.webapp.xmlrpc;
+
+import org.apache.xmlrpc.client.XmlRpcClientConfig;
+import org.apache.xmlrpc.client.XmlRpcTransportFactory;
+import org.ofbiz.base.component.ComponentConfig;
+import org.ofbiz.base.util.KeyStoreUtil;
+import org.ofbiz.base.util.Debug;
+
+import java.security.KeyStore;
+
+/**
+ * XmlRpcClient
+ */
+public class XmlRpcClient extends org.apache.xmlrpc.client.XmlRpcClient {
+
+    public static final String module = XmlRpcClient.class.getName();
+    
+    protected String keyStoreComponent;
+    protected String keyStoreName;
+    protected String keyAlias;
+
+    public XmlRpcClient(XmlRpcClientConfig config, String keyStoreComponent, String keyStoreName, String keyAlias) {
+        this(config);
+        this.keyStoreComponent = keyStoreComponent;
+        this.keyStoreName = keyStoreName;
+        this.keyAlias = keyAlias;
+        this.setTransportFactory(this.getClientTransportFactory());
+    }
+
+    public XmlRpcClient(XmlRpcClientConfig config) {
+        super();
+        this.setConfig(config);
+    }
+
+    public XmlRpcTransportFactory getClientTransportFactory() {
+        if (keyStoreComponent == null || keyStoreName == null || keyAlias == null) {
+            return this.getTransportFactory();
+        }
+
+        ComponentConfig.KeystoreInfo ks = ComponentConfig.getKeystoreInfo(keyStoreComponent, keyStoreName);
+        KeyStore keyStore = null;
+        try {
+            keyStore = KeyStoreUtil.getStore(ks.createResourceHandler().getURL(), ks.getPassword(), ks.getType());
+        } catch (Exception e) {
+            Debug.logError(e, "Unable to load keystore: " + keyStoreName, module);
+        }
+
+        return new AliasSupportedTransportFactory(this, keyStore, ks.getPassword(), keyAlias);
+    }
+}

Propchange: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/XmlRpcClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/XmlRpcClient.java
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/xmlrpc/XmlRpcClient.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain