[freeside-commits] freeside/fs_selfservice/java/biz/freeside SelfService.java, NONE, 1.1

Jeff Finucane,420,, jeff at wavetail.420.am
Tue Oct 21 08:50:41 PDT 2008


Update of /home/cvs/cvsroot/freeside/fs_selfservice/java/biz/freeside
In directory wavetail.420.am:/tmp/cvs-serv12387/biz/freeside

Added Files:
	SelfService.java 
Log Message:
biz.freeside.SelfService class and sample applications

--- NEW FILE: SelfService.java ---
package biz.freeside;

// see http://ws.apache.org/xmlrpc/client.html for these classes
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfig;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

import java.util.HashMap;
import java.util.List;
import java.net.URL;

public class SelfService extends XmlRpcClient {

  public SelfService( String url ) throws Exception {
    super();
    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    config.setServerURL(new URL( url ));
    this.setConfig(config);
  }

  private String canonicalMethod ( String method ) {
    String canonical = new String(method);
    if (!canonical.startsWith( "FS.SelfService.XMLRPC." )) {
      canonical = "FS.SelfService.XMLRPC." + canonical;
    }
    return canonical;
  }

  private HashMap testResponse ( Object toTest ) throws XmlRpcException {
    if (! ( toTest instanceof HashMap )) {
      throw new XmlRpcException("expected HashMap but got" + toTest.getClass());
    }
    return (HashMap) toTest;
  }

  public HashMap execute( String method, List params ) throws XmlRpcException {
    return testResponse(super.execute( canonicalMethod(method), params ));
  }

  public HashMap execute( String method, Object[] params ) throws XmlRpcException {
    return testResponse(super.execute( canonicalMethod(method), params ));
  }

  public HashMap execute( XmlRpcClientConfig config, String method, List params ) throws XmlRpcException {
    return testResponse(super.execute( config, canonicalMethod(method), params ));
  }

  public HashMap execute( XmlRpcClientConfig config, String method, Object[] params ) throws XmlRpcException {
    return testResponse(super.execute( config, canonicalMethod(method), params ));
  }
}



More information about the freeside-commits mailing list