• Julien Béti
    Julien Béti, 2012/10/31 15:39

    As our Jira installation is in "private" mode, only authenticated user are allowed to access the tickets. The Jira Macro then fails with an HTTP 400 error, as returned by the Jira server (note: the Jira server is sending a message associated with the error 400 that is not displayed in the Jira Macro stack trace:

    Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://tracker.example.com/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=issueKey+in+%28MIG-1%2CMIG-2%29
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1615)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:217)
    at org.jdom2.input.sax.SAXBuilderEngine.build(SAXBuilderEngine.java:277)
    at org.jdom2.input.SAXBuilder.build(SAXBuilder.java:1141)
    at org.xwiki.rendering.internal.macro.jira.source.AbstractJIRADataSource.getXMLDocument(AbstractJIRADataSource.java:79)

    Knowing that both XWiki and Jira are using LDAP for authentication, users that have an account on XWiki also have an account in Jira with the same login, is this possible to

    • initiate the XWiki to Jira server connection using a configurable bot-user
    • send the connected user login to Jira in order to let Jira provide the information accessible to that user
  • DanJones
    DanJones, 2012/11/08 16:32

    I added a class to actually use custom fields, if anyone is interested. It will work if your custom field ID's start with "customfield_" as in

    <assignee username="djones">Dan Jones</assignee>
    <reporter username="dmiller">Dave Miller</reporter>
    <created>Tue, 20 Dec 2011 09:48:08 -0500</created>
    <updated>Wed, 15 Aug 2012 15:31:46 -0400</updated>
    <fixVersion>WebServices 2.0 Phase 3</fixVersion>
    <timeoriginalestimate seconds="43200">12h</timeoriginalestimate>
    <timeestimate seconds="43200">12h</timeestimate>
    <comment id="10249" author="dmiller" created="Tue, 20 Dec 2011 09:49:53 -0500"><p>Attachment: Res_After_Archive.docx</p></comment>
    <attachment id="10103" name="Res_After_Archive.docx" size="86345" author="dmiller" created="Tue, 20 Dec 2011 09:51:19 -0500"/></attachments>
    <customfield id="customfield_10407" key="com.atlassian.jira.plugin.system.customfieldtypes:userpicker"><customfieldname>Developer</customfieldname>

    I created a new class called CustomfieldJIRAFieldDispalyer.java containing:

     * See the NOTICE file distributed with this work for additional
     * information regarding copyright ownership.
     * This is free software; you can redistribute it and/or modify it
     * under the terms of the GNU Lesser General Public License as
     * published by the Free Software Foundation; either version 2.1 of
     * the License, or (at your option) any later version.
     * This software is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * Lesser General Public License for more details.
     * You should have received a copy of the GNU Lesser General Public
     * License along with this software; if not, write to the Free
     * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
     * 02110-1301 USA, or see the FSF site: http://www.fsf.org.

    package org.xwiki.rendering.internal.macro.jira.displayer.field;

    import java.util.Arrays;
    import java.util.Collections;
    import java.util.List;

    import javax.inject.Named;
    import javax.inject.Singleton;

    import org.jdom2.Element;
    import org.xwiki.component.annotation.Component;
    import org.xwiki.rendering.block.Block;
    import org.xwiki.rendering.block.FormatBlock;
    import org.xwiki.rendering.block.LinkBlock;
    import org.xwiki.rendering.block.VerbatimBlock;
    import org.xwiki.rendering.listener.Format;
    import org.xwiki.rendering.listener.reference.ResourceReference;
    import org.xwiki.rendering.listener.reference.ResourceType;
    import org.xwiki.rendering.macro.jira.JIRAFieldDisplayer;
    import org.xwiki.rendering.macro.jira.JIRAFields;

     * Displayer for the "key" JIRA field (displayed with an external link to the JIRA issue).
     * @version $Id: 203682fc6917cfd0c09e7ad3ef8e203d2e8a392d $
     * @since 4.2M1

    public class CustomfieldJIRAFieldDisplayer implements JIRAFieldDisplayer
       public List<Block> displayField(String fieldName, Element issue)
            List<Block> result = Collections.emptyList();

    List<Element> children  = issue.getChild("customfields").getChildren("customfield");

    for (Element child: children){
    String id = child.getAttributeValue("id");

    if (fieldName.equals(id)){
    List<Element> moreKids = child.getChild("customfieldvalues").getChildren("customfieldvalue");
    String val = "";
    for (Element kid : moreKids){
    if (!val.equals("")){
    val += " ,";
    val += kid.getText() + "";
    if (!val.equals("")){
         result = Arrays.<Block>asList(new VerbatimBlock(val, true));
    } else {
    result = Collections.emptyList();
    return result;

    I modified the TableJiraDisplayer.java - (checking for the "customfield" field parameter)

            // Construct the data rows, one row per issue
           for (Element issue : issues) {
               List<Block> dataCellBlocks = new ArrayList<Block>();
               for (String field : getFields(parameters)) {
                   // Use the displayer for the field
    if (field.startsWith("customfield")){
    dataCellBlocks.add(new TableCellBlock(getFieldDisplayer("customfield").displayField(field, issue)));
                   dataCellBlocks.add(new TableCellBlock(getFieldDisplayer(field).displayField(field, issue)));

               rowBlocks.add(new TableRowBlock(dataCellBlocks));

    I added this to the components.txt in the package's resources:


    and then replaced the xwiki rendering jira jar after building. I can now use it like

    {{jira url="http://devmgmt:8080" style="table" source="jql" fields="type, key, status, summary, created, customfield_10412" fieldNames="'Issue type', 'Issue Id', 'Status', 'Summary', 'Created',   'Heat Ticket" }}

Get Connected