Developer’s Instructions
How to create a Bugzilla session
You basically need to instantiate HttpBugzillaSession and feed it with configuration data:
import org.apache.commons.configuration.XMLConfiguration; import java.io.File; import java.util.Iterator; import b4j.core.session.HttpBugzillaSession; import b4j.core.DefaultSearchData; import b4j.core.Issue; // Configure from file XMLConfiguration myConfig = new XMLConfiguration(new File("myConfig.xml")); // Create the session HttpBugzillaSession session = new HttpBugzillaSession(); session.configure(myConfig); // Open the session if (session.open()) { // Search abug DefaultSearchData searchData = new DefaultSearchData(); searchData.add("classification", "Java Projects"); searchData.add("product", "Bugzilla for Java"); // Perform the search Iterator i = session.searchBugs(searchData, null); while (i.hasNext()) { Issue issue = i.next(); System.out.println("Bug found: "+issue.getId()+" - "+issue.getShortDescription()); } // Close the session session.close(); }
where your config file is an XML file like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bugzilla-session class="b4j.core.session.HttpBugzillaSession">
<bugzilla-home>http://your-bugzilla.your-domain.com/<bugzilla-home>
<AuthorizationCallback>
<your-name>
<your-password>
</AuthorizationCallback>
<BugzillaBug>class="b4j.core.DefaultBugzillaBug"</BugzillaBug>
<bugzilla-session>
Separate setter methods for the configuration properties will follow in an update….
May 24th, 2010 at 4:51 pm
If I want to execute this example, what imports should I include?
May 27th, 2010 at 7:58 pm
You will need to include the Apache Commons Configuration and Commons Logging JAR files (delivered with B4J in lib directory) in your classpath. For the example above, you just need to “import org.apache.commons.configuration.*” and “import b4j.core.*”
June 14th, 2010 at 11:47 am
Could you please let me know what entry should be given in
for login and password.
June 14th, 2010 at 11:49 am
Could you please let me know what entry should be given in
for login and password in “ProxyAuthorizationCallback” tag in report-config.xml
June 14th, 2010 at 4:45 pm
Hi Ragunath!
This basically depends on what your proxy id and password is. If you do not use any proxy then just remove the ProxyAuthorizationCallback and proxy-host tag.
June 21st, 2010 at 7:48 am
Hi Ralph,
In bugzilla, we have “Status” , “Resolution”, “Severity”,”Priority”. But these thing are not captured in your xml file while creating a report. Please tell me wether these features are there in your tool.
Thanks
Ragunath.S
June 21st, 2010 at 1:45 pm
Hi Ralph,
Is ther anyway to export the http:url of the serach list to a file.please let me know.
Thanks
Ragunath.S
9176060120
June 21st, 2010 at 9:03 pm
Hi Ragunath,
if you are looking for configuring search criteria, you need to use <bug_status>NEW</bug_status>, <bug_severity>blocker</bug_severity> and <bug_priority>1</bug_priority> tags, see the example-report-config.xml. Multiple tags of the same name work like a “OR” condition.
The URL cannot be exported currently. However, if you enable debug level in Commons Logging, the URL will be given in your log. Usually it is <root -path-of-bugzilla>/buglist.cgi?<search -param-name>=<value>, e.g. http://mydomain.com/buglist.cgi?bug_status=NEW
Regards
Ralph
August 18th, 2010 at 6:49 am
Hi,
I would like to know more about the way to configure the search criterias ( what are the available tags ). Where is this example-report-config.xml you mentioned above ? I can’t find it in the archive you provide.
Thanks,
Ben
August 18th, 2010 at 9:19 am
Hi Ben,
The file is actually called report-config-example.xml and located in the conf sub directory. The tags are actually the GET parameter names that Bugzilla takes. So if you want to add some more search criteria, test it with your local Bugzilla app and use the parameter name.
E.g. you make a query for bugs opened against PC hardware. You’ll find this part in your Bugzilla URL after querying: &rep_platform=PC&. That’s why you would need to use the tag <rep_platform>PC</rep_platform>
January 10th, 2012 at 12:12 pm
I am getting the exception. java.lang.ClassCastException: org.apache.commons.configuration.XMLConfiguration cannot be cast to org.apache.commons.configuration.SubnodeConfiguration
XMLConfiguration myConfig = new XMLConfiguration(new File(“src/myConfig.xml”));
HttpBugzillaSession session = new HttpBugzillaSession();
session.configure(myConfig); //exception here
http://localhost/
p2@ss.com
password
class=”b4j.core.DefaultBugzillaBug”