cancel
Showing results for 
Search instead for 
Did you mean: 

REST: how to check if an user can start a process

f_lombardo
Champ in-the-making
Champ in-the-making
Hi all,

using REST API, I'd like to query process definition instances to see items the current user can start, i.e. instances wihich have attributes "Candidate start user" or "Candidate start groups" compatible with the current user.

(I see that the /process-definitions API doesn't return the "Candidate" information)

Thanks in advance.

Bye

Franco
4 REPLIES 4

f_lombardo
Champ in-the-making
Champ in-the-making
Well, I did it this way

public class ProcessDefinitionsResource extends SecuredResource {
 
  Map<String, QueryProperty> properties = new HashMap<String, QueryProperty>();
 
  public ProcessDefinitionsResource() {
    properties.put("id", ProcessDefinitionQueryProperty.PROCESS_DEFINITION_ID);
    properties.put("key", ProcessDefinitionQueryProperty.PROCESS_DEFINITION_KEY);
    properties.put("version", ProcessDefinitionQueryProperty.PROCESS_DEFINITION_VERSION);
    properties.put("deploymentId", ProcessDefinitionQueryProperty.DEPLOYMENT_ID);
    properties.put("name", ProcessDefinitionQueryProperty.PROCESS_DEFINITION_NAME);
    properties.put("category", ProcessDefinitionQueryProperty.PROCESS_DEFINITION_CATEGORY);
  }
 
  @Get
  public DataResponse getProcessDefinitions() {
    if(authenticate() == false) return null;

    ProcessDefinitionQuery processDefinitionQuery =
        ActivitiUtil.getRepositoryService().createProcessDefinitionQuery();
   
    String startableByUser = getQuery().getValues("startableByUser");
    if (startableByUser != null) {
      processDefinitionQuery.startableByUser(startableByUser);
    }
   
    DataResponse response =
        new ProcessDefinitionsPaginateList().paginateList(getQuery(),
                                                          processDefinitionQuery,
                                                          "id",
                                                          properties);
    return response;
  }
}

I'm guessing if you could include this implementation in the next release of Activiti.

Thanks.

Bye

Franco

meyerd
Champ on-the-rise
Champ on-the-rise
Hi f_lombardo,

while we are always very happy to get feature requests, if you want to see them included in the project, the best way is usually to provide a JIRA and / or githup pull request.

f_lombardo
Champ in-the-making
Champ in-the-making
I'll be glad to do that. Could you give me any pointer on how to create a JIRA/githup pull request?

Thak you very much.

Bye.

Franco

f_lombardo
Champ in-the-making
Champ in-the-making
I created https://jira.codehaus.org/browse/ACT-1451

Thank you very much.

Bye

Franco