Search in sources :

Example 1 with XmlRpcClientConfigImpl

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;
}
Also used : XmlRpcClient(org.apache.xmlrpc.client.XmlRpcClient) XmlRpcClientConfigImpl(org.apache.xmlrpc.client.XmlRpcClientConfigImpl) URL(java.net.URL)

Example 2 with XmlRpcClientConfigImpl

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);
}
Also used : XmlRpcClientConfigImpl(org.apache.xmlrpc.client.XmlRpcClientConfigImpl)

Example 3 with XmlRpcClientConfigImpl

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) Issue(org.apache.maven.plugins.issues.Issue) XmlRpcClient(org.apache.xmlrpc.client.XmlRpcClient) ArrayList(java.util.ArrayList) XmlRpcCommonsTransportFactory(org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory) XmlRpcClientConfigImpl(org.apache.xmlrpc.client.XmlRpcClientConfigImpl) URL(java.net.URL) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 4 with XmlRpcClientConfigImpl

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);
    }
}
Also used : XmlRpcClient(org.apache.xmlrpc.client.XmlRpcClient) IOException(java.io.IOException) XmlRpcClientConfigImpl(org.apache.xmlrpc.client.XmlRpcClientConfigImpl) URL(java.net.URL) IOException(java.io.IOException)

Example 5 with XmlRpcClientConfigImpl

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;
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) XmlRpcNotAuthorizedException(org.apache.xmlrpc.common.XmlRpcNotAuthorizedException) XmlRpcClient(org.apache.xmlrpc.client.XmlRpcClient) XmlRpcClientConfigImpl(org.apache.xmlrpc.client.XmlRpcClientConfigImpl) URL(java.net.URL) XmlRpcException(org.apache.xmlrpc.XmlRpcException) MalformedURLException(java.net.MalformedURLException) XmlRpcNotAuthorizedException(org.apache.xmlrpc.common.XmlRpcNotAuthorizedException)

Aggregations

XmlRpcClientConfigImpl (org.apache.xmlrpc.client.XmlRpcClientConfigImpl)7 URL (java.net.URL)4 XmlRpcClient (org.apache.xmlrpc.client.XmlRpcClient)4 MalformedURLException (java.net.MalformedURLException)2 XmlRpcException (org.apache.xmlrpc.XmlRpcException)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Issue (org.apache.maven.plugins.issues.Issue)1 XmlRpcCommonsTransportFactory (org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory)1 XmlRpcNotAuthorizedException (org.apache.xmlrpc.common.XmlRpcNotAuthorizedException)1 Test (org.junit.Test)1