AnsweredAssumed Answered

Assing a task to a group using JAVA APIs

Question asked by vijay on Jun 18, 2008
Latest reply on Jun 18, 2008 by kukeltje

         I am using JAVA APIs to initiate a workflow and assign a task to a group called 'Analyst' which I have already created in the GUI.While doing so I am getting the following exception

Pooled actors value 'Analyst' is invalid

although I am able to assign a task to a single assignee.

When the workflow is kicked off,we are passing some parameters to the workflow node as

parameters.put(WorkflowModel.ASSOC_POOLED_ACTORS, "Analyst");

However while passing a single assignee as parameter in the above line like

parameters.put(WorkflowModel.ASSOC_ASSIGNEE, "admin");

the workflow gets initiated successfully.

As per my guess this is where I am making a mistake.However I have no idea how to resolve it.Any suggestions will be greatly appreciated.Thanks in advance

I have installed Alfresco 2.9B version on Windows XP and using MySQL database.

I have attached the code below

* Copyright (C) 2005-2007 Alfresco Software Limited.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception.  You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
package org.alfresco.sample;

import java.util.HashMap;
import java.util.Map;
import org.alfresco.service.cmr.dictionary.*;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
import org.alfresco.service.cmr.workflow.*;
import java.util.*;

* Simple client example demonstrating the use of the Alfresco Foundation Java APIs.
* The client creates a content node in the "Company Home" folder.  The content
* may be viewed and operated on within the Alfresco Web Client.  Note: the web client
* will need to be re-started after executing this sample to see the changes in
* effect.
* This client demonstrates the "Embedded Repository" deployment option as described
* in the Alfresco Respotiory Architecture docucment -
public class sampleworkflow
   static ServiceRegistry sr=null;

    public static void main(String[] args)
        // initialise app content
        ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
        // get registry of services
        final ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
        // use TransactionWork to wrap service calls in a user transaction
        TransactionService transactionService = serviceRegistry.getTransactionService();
        RetryingTransactionCallback<Object> exampleWork = new RetryingTransactionCallback<Object>()
            public Object execute() throws Exception
            {   try{
            catch(Exception e){
                return null;

    public static void doExample(ServiceRegistry serviceRegistry) throws Exception
                // authenticate
        AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
        authenticationService.authenticate("admin", "admin".toCharArray());
        // create a workflow service
        WorkflowService workflowService = serviceRegistry.getWorkflowService();         
        List a=workflowService.getAllDefinitions();     
        Iterator i=a.iterator();
        String wid="";
           WorkflowDefinition wd=(WorkflowDefinition);
           System.out.println("workflow name—–>";

         // Create a workflow node reference
      NodeRef workflowNodeRef = workflowService.createPackage(null);
        //Finally kick the workflow off.
        Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
        parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowNodeRef);
        parameters.put(WorkflowModel.ASSOC_POOLED_ACTORS, "Analyst");
        parameters.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, new Date(System.currentTimeMillis() ));
        parameters.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "group task");
        parameters.put(QName.createQName("claim_refno"), "22");
       WorkflowPath path = workflowService.startWorkflow(wid, parameters);
        System.out.println("initiated successfully");
        Set user_list=serviceRegistry.getPersonService().getAllPeople();
        Iterator itr=user_list.iterator();
         NodeRef usr=(NodeRef);

         AuthorityService as=serviceRegistry.getAuthorityService();
        Set<String> users = as.getAllAuthorities(AuthorityType.USER);
        for (String userAuth : users){

        WorkflowTaskQuery query = new WorkflowTaskQuery();
        List<WorkflowTask> tasks = workflowService.queryTasks(query);
           // create a list of transient nodes to represents
           for (WorkflowTask task : tasks)
              System.out.println("Task name—>";
              WorkflowTaskDefinition wdef=task.definition;
              System.out.println("map size———–>"+wdef.metadata.getDefaultValues().size());
                   Set s=m.keySet();
                   Iterator it=s.iterator();
                      QName key=(QName);
                     // System.out.println("key——–>"+ m.get(key));
                      //Serializable pd=(Serializable)m.get(key);
                      System.out.println("Key"+ key.getLocalName());