use of org.apache.xmlrpc.client.XmlRpcClientConfigImpl in project camel by apache.
the class XmlRpcEndpoint method createClient.
public XmlRpcClient createClient() throws MalformedURLException {
XmlRpcClient client = new XmlRpcClient();
// setup the client with the configuration from the XmlRpcEndpoint
XmlRpcClientConfigImpl config = clientConfig.cloneMe();
// setup the server url
config.setServerURL(new URL(getAddress()));
client.setConfig(config);
if (clientConfigurer != null) {
clientConfigurer.configureXmlRpcClient(client);
}
return client;
}
use of org.apache.xmlrpc.client.XmlRpcClientConfigImpl in project camel by apache.
the class MyClientConfigurer method configureXmlRpcClient.
@Override
public void configureXmlRpcClient(XmlRpcClient client) {
// get the configure first
XmlRpcClientConfigImpl clientConfig = (XmlRpcClientConfigImpl) client.getClientConfig();
// change the value of clientConfig
clientConfig.setEnabledForExtensions(true);
// set the option on the XmlRpcClient
client.setMaxThreads(10);
}
use of org.apache.xmlrpc.client.XmlRpcClientConfigImpl in project maven-plugins by apache.
the class TracDownloader method getIssueList.
public List<Issue> getIssueList() throws MalformedURLException, XmlRpcException {
// Create and configure an XML-RPC client
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
try {
config.setServerURL(new URL(getUrl() + "/login/xmlrpc"));
} catch (MalformedURLException e) {
throw new MalformedURLException("The Trac URL is incorrect.");
}
config.setBasicUserName(tracUser);
config.setBasicPassword(tracPassword);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
client.setTransportFactory(new XmlRpcCommonsTransportFactory(client));
// Fetch issues
String qstr = "";
if (!StringUtils.isEmpty(query)) {
qstr = query;
}
Object[] params = new Object[] { qstr };
Object[] queryResult;
ArrayList<Issue> issueList = new ArrayList<Issue>();
try {
queryResult = (Object[]) client.execute("ticket.query", params);
for (Object aQueryResult : queryResult) {
params = new Object[] { aQueryResult };
Object[] ticketGetResult;
ticketGetResult = (Object[]) client.execute("ticket.get", params);
issueList.add(createIssue(ticketGetResult));
}
} catch (XmlRpcException e) {
throw new XmlRpcException("XmlRpc Error.", e);
}
return issueList;
}
use of org.apache.xmlrpc.client.XmlRpcClientConfigImpl in project processdash by dtuma.
the class CCDefectTypeLookup method main.
/**
* Run a simple, standalone test to see if our known strategies work against
* a particular server.
*/
public static void main(String[] args) {
URL baseUrl, url;
try {
baseUrl = new URL(args[0]);
url = new URL(baseUrl, "/xmlrpc/secure");
} catch (IOException ioe) {
throw new RuntimeException("Malformed URL " + args[0]);
}
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(url);
config.setBasicUserName(args[1]);
config.setBasicPassword(args[2]);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
try {
execute(client, "getServerVersion");
} catch (Exception e) {
throw new RuntimeException("Unable to contact server " + baseUrl + " - cannot validate defect lookup strategy");
}
CCDefectTypeLookup lookup = getTypeLookup(client);
String oneType = lookup.getType(1);
if (oneType != null) {
System.out.println("Code Collaborator defect type lookup " + "strategy succeeded against URL " + baseUrl);
return;
} else {
throw new RuntimeException("Code Collaborator defect type lookup " + "strategy failed against URL " + baseUrl);
}
}
use of org.apache.xmlrpc.client.XmlRpcClientConfigImpl in project processdash by dtuma.
the class BoundXmlRpcConnection method openConnectionImpl.
protected XmlRpcClient openConnectionImpl(boolean printException) throws ErrorDataValueException {
String username = null;
String password = null;
try {
// look up the information needed to make the connection
String baseUrl = this.baseUrl.getValue();
String urlSuffix = this.urlSuffix.getValue();
username = getUsername(this.username.getValue());
password = getPassword(this.password.getValue());
URL url = new URL(baseUrl.trim());
if (StringUtils.hasValue(urlSuffix))
url = new URL(url, urlSuffix);
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(url);
config.setEnabledForExtensions(true);
if (username != null && password != null) {
config.setBasicUserName(username);
config.setBasicPassword(password);
}
XmlRpcClient connection = new XmlRpcClient();
connection.setConfig(config);
if (StringUtils.hasValue(testMethodName))
connection.execute(testMethodName, Collections.EMPTY_LIST);
if (!validateCredentials(connection, username, password))
throw new ErrorDataValueException(BAD_USERNAME_PASS, ErrorData.SEVERE);
setError(null, ErrorData.NO_ERROR);
return connection;
} catch (MalformedURLException mue) {
throw new ErrorDataValueException(INVALID_URL, ErrorData.SEVERE);
} catch (XmlRpcNotAuthorizedException nae) {
throw getBadCredentialsException(username, password);
} catch (ErrorDataValueException edve) {
throw edve;
} catch (Exception e) {
// we were unable to open a connection; return null.
if (printException)
e.printStackTrace();
return null;
}
}
Aggregations