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….

11 Responses to “Developer’s Instructions”

  1. Brandon Says:

    If I want to execute this example, what imports should I include?

  2. Ralph Says:

    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.*”

  3. Ragunath Says:

    Could you please let me know what entry should be given in

    for login and password.

  4. Ragunath Says:

    Could you please let me know what entry should be given in

    for login and password in “ProxyAuthorizationCallback” tag in report-config.xml

  5. Ralph Says:

    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.

  6. Ragunath Says:

    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

  7. Ragunath Says:

    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

  8. Ralph Says:

    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

  9. Ben Says:

    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

  10. Ralph Says:

    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> :)

  11. prabhu Says:

    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”

Leave a Reply