Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I add a (project) component while creating an issue using the JAVA-API?

Steve Gerstner [bridgingIT]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

Hi @all,

 

I create an Issue via the JIRA-JAVA-API (a little bit old school)...

Everything works fine, but I can't add components, maybe someone knows, what is wrong....

MutableIssue issue = issueFactory.getIssue();
...
ProjectComponent component = null;
component = ComponentAccessor.getProjectComponentManager().find(cid);
issue.getComponentObjects().add(component);                        
...
im.createIssueObject(user.getDirectoryUser(), issue);

The code above is a little bit simplified...

While debugging, the component object is exactly what I want and what I expected.

But, everything is set fine but not the component which is not set...

 

So... Any ideas?

 

Regards

Steve

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

Hi Steve!

I think you need to use setComponentObjects:

component = ComponentAccessor.getProjectComponentManager().find(cid);
issue.setComponentObjects(issue.getComponentObjects().add(component));
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

The javadoc says nothing what getComponentObjects returns when there is no components and I just thought that it might return null. Anyway you will discover this while testing :-)

Steve Gerstner [bridgingIT]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

Thanks, I should go looking for some glasses :D

TAGS
AUG Leaders

Atlassian Community Events