zondag 10 augustus 2008

Trac XML-RPC java plugin

Next I'll get into this plugin: http://trac-hacks.org/wiki/XmlRpcPlugin

install the plugin with easy_install:
easy_install /path/to/unpacked/xmlrpcplugin.zip/trunk

and add the module to the trac.ini in /path/to/project/conf/trac.ini:
tracrpc.* = enabled

assign privileges to anonymous user account:
trac-admin /path/to/project permission add anonymous XML_RPC

Also other permissions might be required, like TICKET_CREATE, etc.

Now you can connect over Java using the following code (for required libs see http://trac-hacks.org/wiki/XmlRpcPlugin java example code and the apache xml rpc client.

This example code creates a new ticket:
String connUrl = "http://test:test@localhost:8000/project/login/xmlrpc";

XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL(connUrl));
XmlRpcClient client = new XmlRpcClient();

TrackerDynamicProxy proxy = new TrackerDynamicProxy(client);

Ticket ticket = (Ticket)proxy.newInstance(Ticket.class);
int newCreatedTicketId = ticket.create("test", "test-description");

I'm currently experimenting with these interfaces. I figured out I can query for a property using:
Vector ticketIds = ticket.query("description=value");

Geen opmerkingen:

Een reactie plaatsen