cancel
Showing results for 
Search instead for 
Did you mean: 

suspend/activate workflow instance

amrorabi
Champ in-the-making
Champ in-the-making
Hello, Activiti engine has a service to suspend/activate a workflow instance (as mentioned below), Does Alfresco propagate this service by its Rest/webscript APIs ?


Activiti service to suspend/activate a workflow instance:
—————–
PUT runtime/process-instances/{processInstanceId}

Request response body (suspend):

{
   "action":"suspend"
}

Request response body (activate):

{
   "action":"activate"
}

Thanks in advance
7 REPLIES 7

romschn
Star Collaborator
Star Collaborator
There is an out-of-the-box webscript available to cancel/delete a workflow instance.
You may want to take a look at all the out-of-the-box webscripts available related to workflow at following location - tomcat\webapps\alfresco\WEB-INF\classes\alfresco\templates\webscripts\org\alfresco\repository\workflow.

amrorabi
Champ in-the-making
Champ in-the-making
Thanks Ramesh, but deleting/canceling is a different concept than suspending.

We can reactivate suspended workflow, but we cann't reactivate canceled/delete one.

romschn
Star Collaborator
Star Collaborator
Out-of-the-box it is not available as a webscript. However, I think there should be an option to suspend a workflowtask of a workflow. I will have to look into the code to point you that option if it is available.

amrorabi
Champ in-the-making
Champ in-the-making
Thanks sir, I appreciate that and waiting for your update (if any)

romschn
Star Collaborator
Star Collaborator
Below is how you can suspend the workflow task and resume the suspended workflow task.There are methods available. I have not explored what the method does actually.
You can write a custom webscript and have following implemented into it.

      String engineId = BPMEngineRegistry.getEngineId(taskId);
      TaskComponent component = getTaskComponent(engineId); // refer workflowServiceImpl for implmentation of getTaskComponent method
      component.suspendTask(taskId); // to suspend a workflow task
      component.startTask(taskId); //to start a suspended a workflow task task

Hope this helps. I have not tried this implementing locally.

amrorabi
Champ in-the-making
Champ in-the-making
I used the following code, but it throws unsupported operation exception

<code>

public class SuspendTaskWebScript extends DeclarativeWebScript
{

org.springframework.context.ApplicationContext applicationContext = ApplicationContextHelper.getApplicationContext();      

BPMEngineRegistry registry = (BPMEngineRegistry)applicationContext.getBean("bpm_engineRegistry");

String engineId = BPMEngineRegistry.getEngineId(taskId);
TaskComponent task = registry.getTaskComponent(engineId);
task.suspendTask(taskId);    //line 65

}


Exception:
———-
Caused by: java.lang.UnsupportedOperationException
        at org.alfresco.repo.workflow.activiti.ActivitiWorkflowEngine.suspendTask(ActivitiWorkflowEngine.java:2146)
        at bh.gov.cio.crms.workflow.statistics.SuspendTaskWebScript.executeImpl(SuspendTaskWebScript.java:65)
        at org.springframework.extensions.webscripts.DeclarativeWebScript.executeImpl(DeclarativeWebScript.java:221)
        at org.springframework.extensions.webscripts.DeclarativeWebScript.executeImpl(DeclarativeWebScript.java:235)
        at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)
        … 23 more

romschn
Star Collaborator
Star Collaborator
Yeah, looking at ActivitiWorkflowEngine.java it appears that implementation for this method is not provided and that is the reason it is not working for you.
There must be some reason why the implementation is not provided and i have no idea about it. I am not sure if this is in the roadmap or not going ahead.
Hope this helps.