Search in sources :

Example 1 with XmlRpcCommonsTransportFactory

use of org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory 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)

Aggregations

MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Issue (org.apache.maven.plugins.issues.Issue)1 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1 XmlRpcClient (org.apache.xmlrpc.client.XmlRpcClient)1 XmlRpcClientConfigImpl (org.apache.xmlrpc.client.XmlRpcClientConfigImpl)1 XmlRpcCommonsTransportFactory (org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory)1