Expand my Community achievements bar.

SOLVED

Programmatically finding out if workflow has completed

Avatar

Level 5

Hi all,

I have a use case where I need an Java client app to get info if a workflow has been completed.

I want to do this using the JCR so where can I got in on CRXDE to get archives, instances, failures and such.

/etc/workflow/instances/ ????

 

Thanks All!

1 Accepted Solution

Avatar

Correct answer by
Level 10

JCR nodes only give you workflow models - not running status, etc. 

You need to use the Workflow API. However - you cannot use this API from outside of AEM. A Java client cannot use it, You need to use it within AEM.

So what you have to  do is write an AEM Sling servlet that uses the Workflow API to get workflow info. Then return the info as part of a GET request. ie - place it in JSON or XML. 

Now you can write a Java client app that can communicate with the Sling Servlets via GET requests. The Java app will get the JSON or XML and display it. 

We have a community article that will help you with the Java Client interacting with AEM. In this example, the Java client interacts with AEM via a HTTP POST operation.

https://helpx.adobe.com/experience-manager/using/post_files.html

In your example - you may want to perform GET requests. 

View solution in original post

6 Replies

Avatar

Level 10

Hey - is your requirement a separate Java client app that is running outside of AEM? 

Avatar

Level 10

The API you would use to perform this use case is https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/adobe/granite/workflow/exec/Workflow.html. Look at all of the classes in this Javadoc. You use this API in a Sling Servlet or an AEM service.  

Avatar

Level 5

smacdonald2008 wrote...

Hey - is your requirement a separate Java client app that is running outside of AEM? 

 


Yes it would be. Is there no way of getting this info from nodes and nodes property?

I'll take a look at that API.

Thanks!

Avatar

Correct answer by
Level 10

JCR nodes only give you workflow models - not running status, etc. 

You need to use the Workflow API. However - you cannot use this API from outside of AEM. A Java client cannot use it, You need to use it within AEM.

So what you have to  do is write an AEM Sling servlet that uses the Workflow API to get workflow info. Then return the info as part of a GET request. ie - place it in JSON or XML. 

Now you can write a Java client app that can communicate with the Sling Servlets via GET requests. The Java app will get the JSON or XML and display it. 

We have a community article that will help you with the Java Client interacting with AEM. In this example, the Java client interacts with AEM via a HTTP POST operation.

https://helpx.adobe.com/experience-manager/using/post_files.html

In your example - you may want to perform GET requests. 

Avatar

Level 3

yeah , "/etc/workflow/instances" node has all the workflow instances (archived,running etc.). 

If you read the "status" proeprty, will get to know workflow status(COMPLETED/RUNNING/ABORTED).

      /etc/workflow/instances/server0/2016-01-13_9/model_XXX/@status

Avatar

Level 10

Will - our Workflow Eng stated: 

"Always better to use API.  It’s only an implementation detail that it’s stored in the repo."