AnsweredAssumed Answered

Performance of workflowService.getPackageContents

Question asked by the_magic_zebra on Oct 31, 2012

I'm part of a team of developers who are working on a custom Alfresco 3.3.4 web script that checks to see if a content node is currently locked and within a submission workflow. Our custom Java implementation does all the work by leveraging the service calls "queryTasks" and "getPackageContents" on WorkflowService. We then simply expose our Java implementation to the web script and make the call there. The idea of the script is to gather all review tasks via "queryTasks", then loop over the tasks and collect their packageContents.

This seems to get the job done, however I'm seeing some really bad performance. Specifically, the call to workflowService.getPackageContents(). Our Alfresco is presently home to a whopping 13 tasks (yes, sarcasm). The number of files tied up to those tasks amounts to about 44. The query to retrieve the tasks is plenty fast, but we're seeing "getPackageContents"  take somewhere around 20 seconds to complete.

Here is the method we've tested: (note that the code "this.impl" simply returns a pointer to an already instantiated object that implements WorkflowService)

public List<String> getAllReviewTaskResourcePaths() {
  WorkflowTaskQuery query = new WorkflowTaskQuery();
  QName name = QName.createQName("wcmwf:reviewTask");


  // Query for all review tasks
  List<WorkflowTask> queriedTasks = this.impl.queryTasks(query);
  ArrayList<NodeRef> allResources = new ArrayList<NodeRef>();

  // Collect all resources
  for (WorkflowTask task : queriedTasks) {
    List<NodeRef> resourcesForTask = this.impl.getPackageContents(;

  // Collect and format the paths of all resources for all tasks
  List<String> allResourcePaths = new ArrayList<String>();
  for (NodeRef nodeRef : allResources) {
    String nodeRefString = nodeRef.toString();
    // Cut off the extra section of this string
    nodeRefString = nodeRefString.substring(nodeRefString.indexOf(";"));

  return allResourcePaths;

As stated above, the bottleneck in this code is in the section that iterates over each task returned by "queryTasks" and asks for its package contents. The other loop below just performs some String operations for formatting, then returns the new List with formatted nodeRefs.

I've tried many other things as a workaround, such as WorkflowService's "getWorkflowsForContent", but that method never returns anything even though there is one active workflow for the content we pass in. There's also apparently an "activeWorkflows"' attribute on each node that we can execute in our JavaScript, but it always returns an empty list.

And now, to the point…

Is there any way to speed up the performance of the above script without having to tweak JVM or MySQL settings? Or rather, are there any other ways to complete the lookup we're attempting?