I’m trying to get all issues assigned to a particular user. I do the following for that purpose:
ApplicationUser user=ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
JqlClauseBuilder builder= JqlQueryBuilder.newClauseBuilder();
Query query=builder.assigneeUser(user.getName()).buildQuery();
if (searchService!=null)
System.out.println("Search service is not null");
else
System.out.println("Search service is null");
PagerFilter pagerFilter = PagerFilter.getUnlimitedFilter();
SearchResults results=searchService.search(user,query,pagerFilter);//Getting NullPointerException at this point
I’ve AutoWired the SearchService and make sure that it’s not null before invoking the search method on it. What could be the reason for that?
I missed the builder.assigneeUser( user.getName() ) part. Could you do something like assigneeIsCurrentUser() instead?
As far the injecting the JiraAuthenticationContext - it’s better for mocking as well as it helps the performance of the osgi system (instead of doing the osgi objects at runtime in your code, it happens when further up the change. ComponentAccessor(and it’s friends) should really only be used in a worst case scenario where you can’t communicate with Osgi. (Just my opinion ).