I've got this piece of code where I'm trying to update the due date field of an issue on IssueEvent
@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
Long eventTypeId = issueEvent.getEventTypeId();
MutableIssue issue = (MutableIssue)issueEvent.getIssue();
GregorianCalendar calendar=new GregorianCalendar(2017,7,13,1,13,13);
issue.setDueDate(new Timestamp(calendar.getTimeInMillis()));
IssueService issueService=ComponentAccessor.getIssueService();
if(issueService!=null)
System.out.println("Issue service is not null");
User user=ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser();
if (user!=null)
System.out.println("The logged in user is "+user.getName());
IssueInputParameters inputParameters=issueService.newIssueInputParameters();
inputParameters.setRetainExistingValuesWhenParameterNotProvided(true);
IssueService.UpdateValidationResult validationResult=issueService.validateUpdate(user,issue.getId(),inputParameters);
issueService.update(user,validationResult);
System.out.println("Issue type:"+issue.getIssueTypeObject().getName());
}
For some reason, I get NoSuchMethod exception when execution reaches to the following line:
IssueService.UpdateValidationResult validationResult=issueService.validateUpdate(user,issue.getId(),inputParameters);
I've also tried to use IssueManager to update issue but I get the same exception for "IssueManager.updateIssue" method. What am I doing wrong?
Community moderators have prevented the ability to post new answers.
You are passing the wrong argument to valiDateUpdate. You should be passing an ApplicationUser object instead of the old User object. Try passing ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() instead.
But that validateUpdate method does not accept ApplicationUser argument, it accepts only User. And even if it accepted, what relation can it have to the NoSuchMethod exception?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What version of JIRA are you on?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From what I see, the method only accepts ApplicationUser. Hence the error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe you have a different version in your pom? Or your IDE playing with you?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, Jobin, you are absolutely right. In the pom, it is
<jira.version>6.0.4</jira.version>.
In fact I downloaded the sample listener plugin from Bitbucket and tried to run it against 7.2.6 I did this because with my own plugin I was getting "Plugin not in valid state..." error. It seems the spring version needs to be set correctly. In the tutorial, for the spring-framework dependency, it says "use the version used by your UPM". Do you happen to know where I can see what spring-framework version the UPM uses, and where I can find that version. Thanks a lot ahead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.