cancel
Showing results for 
Search instead for 
Did you mean: 

how to invoke Rest API from a worflow

davidedge
Champ in-the-making
Champ in-the-making
Hi everyone,
I'm new in Alfresco and I have to develop a custom workflow with Activiti.
One of the requirement of it is a tag-search in Alfresco repository (server side).
Could i use the restful api GET /alfresco/service/api/tags/{store_type}/{store_id}/{tag}/nodes?
How to invoke this API in my activiti service task? I need an example for learning.
3 REPLIES 3

kaynezhang
World-Class Innovator
World-Class Innovator
No, you don't need to (although you can) use restful api in Activiti.
Javascript api or java api is just ok.

davidedge
Champ in-the-making
Champ in-the-making
How can i use java API?
An example please..

kaynezhang
World-Class Innovator
World-Class Innovator
1.Write a java servcie class that implement org.activiti.engine.delegate.JavaDelegate

public class YourJavaDelegate implements JavaDelegate {
  public void execute(DelegateExecution execution) throws Exception {
   // todo
  }
}

2.In your method ,get alfresco ServcieRegistry bean

public void execute(DelegateExecution execution) throws Exception {
   // todo
   ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
   ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
   // get node servcie/tagging service from registy
   // do what you want to do.
}


3. config your java servcie class in bmpn xml file

<serviceTask id="javaService"
             name="Your Java Service Task"
             activiti:class="com.your.company.YourJavaDelegate" />