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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

RemoteIssueLinkCreateEvent doesn't have id when custom jira listener catches it Edited

Hi Community,

Could you please help with issue below? Did you face this problem?

Now we are implementing custom listener for our system, listener must catch moments when user create/delete remote issue links on local server and noticed that object of RemoteIssueLinkCreateEvent doesn't have id when listener catches it. We suppose this is a bug, but we didn't find bug ticket for this.

Also we noticed that jira has another such event RemoteIssueLinkUICreateEvent and it's working well, because RemoteIssueLinkCreateEvent has id and we can work with this. But we cannot use it because it works just in case user creates remote link by jira UI, so such way cannot catch moment when user creates remote links by rest api http://localhost:8080/rest/api/latest/issue/TEST-1018/remotelink .

We use JIRA server with version: 8.2.1

Below you can find an example how we test of catching such events:

public class RemoteIssueLinksListener extends AbstractIssueEventListener
{

private final RemoteIssueLinkManager remoteIssueLinkManager;

public RemoteIssueLinksListener(RemoteIssueLinkManager remoteIssueLinkManager, JiraAuthenticationContext jiraAuthenticationContext)
{
this.remoteIssueLinkManager = remoteIssueLinkManager;
this.jiraAuthenticationContext = jiraAuthenticationContext;
}

@EventListener
public void onCreateRemoteIssueLinkEvent(RemoteIssueLinkCreateEvent remoteIssueLinkCreateEvent)
{
LOG.error("Create - TEST");
LOG.error("Create -: "+ remoteIssueLinkCreateEvent.getRemoteIssueLinkId());
LOG.error("Create -: "+ remoteIssueLinkCreateEvent.getGlobalId());

LOG.error("TEST: "+ (remoteIssueLinkManager == null));
Long id = remoteIssueLinkCreateEvent.getRemoteIssueLinkId();
LOG.error("id: "+ id);

RemoteIssueLink remoteIssueLink = remoteIssueLinkManager.getRemoteIssueLink(id);
LOG.error("Link: "+ (remoteIssueLink == null));
}

@EventListener
public void onCreateUiRemoteIssueLinkEvent(RemoteIssueLinkUICreateEvent remoteIssueLinkUiCreateEvent) {
LOG.error("Create UI - TEST");
LOG.error("Create UI -: "+ remoteIssueLinkUiCreateEvent.getRemoteIssueLinkId());
LOG.error("Create UI-: "+ remoteIssueLinkUiCreateEvent.getGlobalId());

LOG.error("TEST: UI"+ (remoteIssueLinkManager == null));
Long id = remoteIssueLinkUiCreateEvent.getRemoteIssueLinkId();
LOG.error("id: "+ id);

RemoteIssueLink remoteIssueLink = remoteIssueLinkManager.getRemoteIssueLink(id);
LOG.error("Link: "+ (remoteIssueLink == null));

}
}

3 answers

i'm too looking solve this problem....

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.link.RemoteIssueLinkCreateEvent
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.link.RemoteIssueLink
import com.atlassian.jira.issue.link.RemoteIssueLinkManager

if(event instanceof RemoteIssueLinkCreateEvent) {
RemoteIssueLinkManager rm = ComponentAccessor.getComponent(RemoteIssueLinkManager.class)
IssueManager im = ComponentAccessor.getIssueManager()

RemoteIssueLinkCreateEvent event = (RemoteIssueLinkCreateEvent) event

List<RemoteIssueLink> links = rm.findRemoteIssueLinksByGlobalIds([event.globalId])

for (RemoteIssueLink link : links) {
Issue issue = im.getIssueObject(557230)
log.error(issue.key)
}
}






Like that you get issue object

@Vladimir Kibe , Hi, we thought about the solution you have suggested, but we investigated this issue and got root cause of issue is a bug in DefaultRemoteIssueLinkManager in Jira sources (8,2.1) in function createRemoteIssueLink. 

...
eventPublisher
.publish(new RemoteIssueLinkCreateEvent(remoteIssueLink)) 
... 

 "remoteIssueLink" is temporary object that used for creating remote link in DB of Jira and it also doesn't contain id of remote link.

We got from Atlassian Support answer, that they don't support support such developing request from clients, so we was forced to fix bug ourself. Below you can find we fixed this issue in soruces

...
eventPublisher
.publish(new RemoteIssueLinkCreateEvent(created));
...

 "created" is object that was generated after creating new remote link in jira db.

Also if you like this fix and you have access to jira sources, you can find below article from Atlassian How to compile jira sources

https://developer.atlassian.com/server/jira/platform/building-jira-from-source/

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

3,894 views 11 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you