Skip to main content

Monitor OpenWFE in Magnolia

Posted by rah003 on March 3, 2009 at 2:27 PM PST

Over last couple of months more people have been asking about the workflow. Probably most often asked question is whether or not it is possible to monitor running workflow instances from within Magnolia. The response to this question have always been along the lines: yes, you can monitor the workflows, but no, you can't do so from within the admin interface of Magnolia. OpenWFE provides tools to monitor the workflows, since the tool is separate Java Swing client, it is not possible to integrate it in Magnolia's web interface.

Personally, I always thought that it should be quite simple to show some basic status since OpenWFE already stores all the work items inside of Magnolia's repository. Last weekend I decided to give it a shot and see just how much of the status I can show in just few hours without spending days to develop such functionality. Here's what I've came up with.

While all the workflow status is already stored in Magnolia, it is too coarse to obtain useful status info without diving into the values of OpenWFE work items themselves. The work items consist of XML, so I used swingx-ws library to work with this XML. My choice of this library was influenced by the fact that it allows me to manipulate and search the xml without having to configure anything and I can use xpath to access the nodes of interest straight away. Plus I know the library quite well, but really any library that can parse xml will do the job here.

First to add the status page to Magnolia's admin interface, we need to register it. Create new content node in config://modules/admininterface/config/menu/tools and call it workflowStatus. Define following node data for it:

label=Workflow Status

Define the page itself: Create new content node under config:/modules/yourmodule/pages and call it flowStatus and add to this node new node data class with value

All that remains is to create the class and freemarker template

The will retrieve existing workitems and parse out the interesting info

    public List getFlowList() throws RepositoryException {
        HierarchyManager hm = MgnlContext.getHierarchyManager("Expressions");
        if (!hm.getRoot().hasContent("owfe")) {
            return Collections.EMPTY_LIST;
        Collection flows = hm.getContent("owfe").getChildren();
        for (Iterator iterator = flows.iterator(); iterator.hasNext();) {
          // ... parse and extract like
          String lastMod = doc.getElement("/bean/field[@name='appliedWorkitem']/bean/field[@name='lastModified']/primitive").getTextContent();
          // and so on ... see the full code listing

and WorkflowStatusPage.html will just display info about each item of interest found.

          [#list flows as item]
              [#if item.lastParticipant?has_content]
                New workflow
              ${item.flowName}, started by <b>${this.getUser(item.attributes.activator)!"unknown"}</b> with assigned id ${}<br/>
                :: ${item.lastModified!""} User <b>${this.getUser(item.attributes.userName)!"unknown"}</b> has <b>
                [#if item.attributes.action?has_content] 
                  requested activation
                 </b> the <b>${item.attributes.pathSelected!""}</b>
              [#if item.attributes.recursive?has_content && item.attributes.recursive == 'true']
                including sub-pages
              [#if item.attributes.comment?has_content]
                :: Comment by ${this.getUser(item.attributes.userName)}: <pre>${item.attributes.comment}</pre><br/>
              [#if item.attributes.assignTo?has_content]
                :: Item has been re-assigned to <b>${this.getUser(item.attributes.assignTo)}</b><br/>

And that is really all to it. We now have a workflow status displayed in the admin interface. You can see the result in the image below. Of course the above will work with the default workflow only, and you would need to customize the templates to display info about your specific workflow. To do so, you would perhaps have different snippet to render based on what workflow you are dealing with and include it dynamically based on the value of {$item.flowName}. You might even be able to extract more details for such custom workflows. In any case the above should be enough to get anyone started on displaying the running workflow status in the Magnolia.




Related Topics >>


Excellent! Process Visibility is what makes BPM sexy.