Comments on JIRA Macro
Last modified by Vincent Massol on 2024/02/19 00:12
Choose the export format from the list below:
Export as Portable Document Format (PDF) using the Web Browser
Export as HyperText Markup Language (HTML)
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:
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
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
<reporter username="dmiller">Dave Miller</reporter>
<labels>
</labels>
<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>
<due/>
<votes>0</votes>
<watches>0</watches>
<timeoriginalestimate seconds="43200">12h</timeoriginalestimate>
<timeestimate seconds="43200">12h</timeestimate>
<comments>
<comment id="10249" author="dmiller" created="Tue, 20 Dec 2011 09:49:53 -0500"><p>Attachment: Res_After_Archive.docx</p></comment>
</comments>
<attachments>
<attachment id="10103" name="Res_After_Archive.docx" size="86345" author="dmiller" created="Tue, 20 Dec 2011 09:51:19 -0500"/></attachments>
<subtasks>
</subtasks>
<customfields>
<customfield id="customfield_10407" key="com.atlassian.jira.plugin.system.customfieldtypes:userpicker"><customfieldname>Developer</customfieldname>
<customfieldvalues>
<customfieldvalue>djones</customfieldvalue>
</customfieldvalues>
</customfield>
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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* 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
*/
@Component
@Named("customfield")
@Singleton
public class CustomfieldJIRAFieldDisplayer implements JIRAFieldDisplayer
{
@Override
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();
}
break;
}
}
return result;
}
}
I modified the TableJiraDisplayer.java - (checking for the "customfield" field parameter)
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