Programmatically finding out if workflow has completed | Community
Skip to main content
TheBigRed
Level 4
March 1, 2016
Solved

Programmatically finding out if workflow has completed

  • March 1, 2016
  • 6 replies
  • 2792 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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. 

6 replies

smacdonald2008
Level 10
March 1, 2016

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

smacdonald2008
Level 10
March 1, 2016

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.  

TheBigRed
TheBigRedAuthor
Level 4
March 1, 2016

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!

smacdonald2008
smacdonald2008Accepted solution
Level 10
March 1, 2016

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. 

Level 3
March 2, 2016

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

smacdonald2008
Level 10
March 2, 2016

Will - our Workflow Eng stated: 

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