package de.hsadmin.remote;

import java.net.URL;

import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

import de.hsadmin.core.util.Config;

public class RemoteTestHelper {
	
	private static final String XMLRPC_URL = "https://admin.hostsharing.net:443/hsar/xmlrpc/hsadmin";
	private static final String BACKEND_URL = "https://admin.hostsharing.net:443/hsar/backend";
	
	private static XmlRpcClient client;

	public static XmlRpcClient getClient() throws Exception {
		if (client == null) {
			XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
			config.setServerURL(new URL(getXmlrpcURL()));
			config.setEnabledForExtensions(true);
			client = new XmlRpcClient();
			client.setConfig(config);
		}
		return client;
	}

	public static String getBackendURL() {
		return Config.getInstance().getProperty("backendURL", BACKEND_URL);
	}
	
	public static String getXmlrpcURL() {
		return Config.getInstance().getProperty("xmlrpcURL", XMLRPC_URL);
	}
}
