API for querying issues from multiple projects

I need to query all issues from multiple Jira projects and prepare statistics in my custom plugin. What is preferable API for doing it? I’ve found SearchService, but it requires ApplicationUser instance to process searching. Also I see that Active Objects API working with DB, but as documentation says here Active ObjectsA plugin can access only the data that belongs to it, not data belonging to other plugins or to the host products.” and AO examples persist custom objects, but not issues. Can issues be queried via AO?

Can I schedule some sort of background job to be processed inside Jira Server (updating statistics etc.)? Or should I use Jira REST API instead and do processing outside Jira Server and then grab the result from external API?

You should use SearchService, proper pagination, and the method searchOverrideSecurity(ApplicationUser applicationUser, Query query, PagerFilter pagerFilter).

I’d probably create a fake user by calling ApplicationUsers.from(new ImmutableUser(-1, userNameOrKey, userNameOrKey, “?”, false)) which is how the UserManager class creates unknown users.

I believe this approach would be robust.

@sfbehnke thanks, I’ll try this approach.

I think, you should be pass null to user parameter.

1 Like

@a.belostotskiy thanks, searchOverrideSecurity works fine with null-user

1 Like

Thanks, I got too complicated really fast didn’t I. Thanks for the solution. :smiley: