cancel
Showing results for 
Search instead for 
Did you mean: 

startableByUser not returning results

ykphuah
Champ in-the-making
Champ in-the-making
I am trying to make use of the candidateStartUser field in the process definition, to be able to filter the deployed processes that can be started by a user, I have tried the following but it doesn't return any process definitions:


ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
if (processEngine == null) {
    logger.error("Could not start the Activiti Engine");
    return;
}

RepositoryService repositoryService = processEngine.getRepositoryService();
FormService formService = processEngine.getFormService();
TaskService taskService = processEngine.getTaskService();
IdentityService identityService = processEngine.getIdentityService();

// tried to create a new user using identity service, but still no impact
User kermit = identityService.newUser("kermit");
logger.info("Created kermit user:id=" + kermit.getId());
identityService.saveUser(kermit);

// tried setting authenticated user id as well, no impact
identityService.setAuthenticatedUserId("kermit");

DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();

try {
    InputStream is = new FileInputStream(new File("C:/Users/Yee_Keat/Development/Adama/MyProcess.bpmn"));
    deploymentBuilder.addInputStream("MyProcess", is);
    Deployment deployment = deploymentBuilder.deploy();
    logger.info("Deployed:id=" + deployment.getId() + ",name=" + deployment.getName());
    is.close();
} catch (IOException e) {
    logger.error("failed to deploy", e);
} catch (ActivitiException e) {
    logger.error("failed to deploy", e);
}

List<ProcessDefinition> startableByKermit = repositoryService.createProcessDefinitionQuery().startableByUser(kermit.getId()).list();

// expecting to see some results from here, as my file have candidateStartUser=kermit configured
logger.info("processes that can be started by kermit = " + startableByKermit.size());
for (ProcessDefinition p : processDefinitions) {
    logger.info("Process Definition:id=" + p.getId() + ",name=" + p.getName());
}
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Could you have a look on org.activiti.examples.bpmn.authorization.StartAuthorizationTest in activiti source. There are an examples of the query.

Regards
Martin

ykphuah
Champ in-the-making
Champ in-the-making
Thanks, I figure out the issue myself, this line:

deploymentBuilder.addInputStream("MyProcess", is);

The MyProcess need to have the .bpmn20.xml extension, if not it is not deployed. And yeah, I did look at the StartAuthorizationTest and found out about this.

Thanks!