Using CQLSearchService in PreMigrationChecks


I’m looking into searching for content using CQL within PreMigrationChecks but have trouble getting it to work. My use case is that I want to find if there are any pages using a certain macro, something like this:

this.cqlSearchService.searchContent(cql, new SimplePageRequest(0, 100)).getResults();

I’ve implemented PreMigrationCheckRepository from the examples provided in the docs, but trying to use the CQLSearchService within my checks gives me this error:

PermissionException: Not permitted to use confluence : null

I guess there is no authenticated user context when this is executed. Is there anyway around this? Or are there any other approaches I can take if I want to execute a CQL search within these checks?

Hi @Ande,

Thanks for your question. Here’s a similar post but for Jira

and another for Confluence

But the issue is the same, when running the pre-migration check there’s no logged in user running in the thread. To run the CQL you need an admin user so they can access all the pages, including restricted ones.