hs.hsadmin/hsarweb/src/de/hsadmin/web/Remote.java

51 lines
1.3 KiB
Java
Raw Normal View History

2010-09-23 17:30:34 +02:00
package de.hsadmin.web;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class Remote {
private XmlRpcClient client;
2010-12-15 14:15:52 +01:00
private GenericModule module;
2010-09-23 17:30:34 +02:00
2010-12-15 14:15:52 +01:00
public Remote(GenericModule module) {
this.module = module;
2010-09-23 17:30:34 +02:00
}
2010-12-15 14:15:52 +01:00
public Object callSearch(String user, Map<String, String> where) throws HsarwebException {
2010-09-23 17:30:34 +02:00
Object[] params = new Object[3];
params[0] = user;
2010-12-15 14:15:52 +01:00
params[1] = module.getProxyTicket();
2010-09-23 17:30:34 +02:00
params[2] = where;
Object res;
try {
2010-12-15 14:15:52 +01:00
res = getClient().execute(module.getModuleConfig().getName() + ".search", params);
2010-09-23 17:30:34 +02:00
} catch (XmlRpcException e) {
throw new HsarwebException("error in remote server call", e);
}
return res;
}
2010-10-05 21:43:30 +02:00
private XmlRpcClient getClient() throws HsarwebException {
if (client == null) {
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
try {
2010-12-15 14:15:52 +01:00
String xmlrpcURL = module.getContextParam("xmlrpcURL");
2010-10-05 21:43:30 +02:00
config.setServerURL(new URL(xmlrpcURL));
} catch (MalformedURLException e) {
throw new HsarwebException("error in remote server url", e);
}
client = new XmlRpcClient();
client.setConfig(config);
}
return client;
}
2010-12-15 14:15:52 +01:00
2010-09-23 17:30:34 +02:00
}