for setting up default permissions I am creating and saving authorizations in the postInit-Method of the SpringBootProcessEnginePlugin:
public class MyProcessEngineConfiguration extends AbstractCamundaConfiguration implements CamundaProcessEngineConfiguration {
private final Logger logger = getLogger(WebAppSecurityConfig.class.getName());
@Override
public void postInit(SpringProcessEngineConfiguration configuration) {
// lines omitted
setupPermissions(configuration.getAuthorizationService());
}
This works if the database has already been created. But during the first startup in a test run, the database tables are not yet created when postInit method runs and setupPermissions fails.
Is it possible to run code after the database tables have been created?
The way to do something like that is to jump into the ProcessEngine’s lifecylce creation, instead of Spring’s. To do so, create a ProcessEnginePlugin implementation and add your initialisation to the postProcessEngineBuild method that passes you the engine that was built (the others give you the configuration). At that point you’re gauranteed that not only the tables are in place, but you can use the ProcessEngine’s services to work with them.