7 Replies Latest reply on May 11, 2012 1:06 AM by TC ONG

    New Local human task service in JBPM5.2

    Zeliang Huang Newbie

      Hi Guys,

       

      I am so excited to read this in the jBPM5.2 release note. Thanks for the all hardwork from the JBPM development team.

      Human task service

      local task service: a local implementation of the task service that runs locally, next to the process engine, and (re)uses the same transaction of the core engine

      I had downloaded the 5.2 release and tried to set this up but couldn't figure out where is the new local human task service in the human-task module. Can someone direct me to the correct location of the new handler?

       

      thanks

       


        • 3. Re: New Local human task service in JBPM5.2
          Zeliang Huang Newbie

          thanks guys.

           

          I have got this error when I try to start a new process instance.  This is my code.  Any solution to this?

           

          factory = Persistence.createEntityManagerFactory("org.jbpm.task");

          TaskService tService = new TaskService(factory,SystemEventListenerFactory.getSystemEventListener())

          TaskServiceSession tSession = tService.createSession();

           

          org.jbpm.task.TaskService client = new org.jbpm.task.service.local.LocalTaskService(tSession);

          SyncWSHumanTaskHandler handler = new SyncWSHumanTaskHandler(client,    session);

          handler.connect();

           

           

           

          java.lang.reflect.InvocationTargetException

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

              at java.lang.reflect.Method.invoke(Method.java:585)

              at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)

              at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)

              at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)

              at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)

              at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)

              at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)

              at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)

              at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)

              at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)

              at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)

              at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)

              at iwork.common.web.ControllerServlet.service(ControllerServlet.java:70)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

              at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:223)

              at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

              at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)

              at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)

              at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)

              at iwork.common.web.TransactionCheckFilter.doFilter(TransactionCheckFilter.java:49)

              at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)

              at iwork.common.web.RequestLoggingFilter.doFilter(RequestLoggingFilter.java:176)

              at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)

              at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3243)

              at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

              at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)

              at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2003)

              at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1909)

              at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359)

              at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)

              at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)

          Caused by: java.lang.NoSuchMethodError: org.jbpm.task.service.TaskServiceSession.getService()Lorg/jbpm/task/service/TaskService;

              at org.jbpm.task.service.local.LocalTaskService.registerForEvent(LocalTaskService.java:188)

              at org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler.registerTaskEvents(SyncWSHumanTaskHandler.java:115)

              at org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler.connect(SyncWSHumanTaskHandler.java:103)

              ... 35 more

          • 4. Re: New Local human task service in JBPM5.2
            Zeliang Huang Newbie

            Hi the error the gone after undeploy and redeploy my application to weblogic server. I think the jbpm5.1 jar were cached by weblogic somewhere.  It was not an jBPM issue.

             

            The SyncWSHumanTaskHandler is working like a charm ~!

             

             

            Btw, for those who is interested to use the same core engine transaction for your human task. You need to set the transactionType in your java code.

             

            TaskServiceSession tSession = newTaskService().createSession();
            tSession.setTransactionType("local-JTA");
            • 5. Re: New Local human task service in JBPM5.2
              Thomas Nakken Newbie

              Hi

               

              Have you managed to deploy jbpm5.1 or jpbm 5.2 to weblogic? If so can you give me some hints? We are struggeling with jpbm5.1 on WLS 10.3.4. Can create HumanTasks but fails when we try to get them. If you can share your prersistance.xml and the code for setting up the task server I would be happy:)

              • 6. Re: New Local human task service in JBPM5.2
                TC ONG Newbie

                Demian Calcaprina wrote:

                 

                I thinks this test shows it:

                https://github.com/droolsjbpm/jbpm/blob/master/jbpm-human-task/src/test/java/org/jbpm/process/workitem/wsht/local/sync/WSHumanTaskHandlerLocalSyncTest.java

                 

                Thanks

                 

                Demian

                The file is no longer in Github... any where else I can find it?

                • 7. Re: New Local human task service in JBPM5.2
                  TC ONG Newbie
                  /**
                   * Copyright 2010 JBoss Inc
                   *
                   * Licensed under the Apache License, Version 2.0 (the "License");
                   * you may not use this file except in compliance with the License.
                   * You may obtain a copy of the License at
                   *
                   *      http://www.apache.org/licenses/LICENSE-2.0
                   *
                   * Unless required by applicable law or agreed to in writing, software
                   * distributed under the License is distributed on an "AS IS" BASIS,
                   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                   * See the License for the specific language governing permissions and
                   * limitations under the License.
                   */
                  package org.jbpm.process.workitem.wsht.local.sync;
                  
                  import org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler;
                  import org.jbpm.process.workitem.wsht.sync.WSHumanTaskHandlerBaseSyncTest;
                  import org.jbpm.task.service.TaskServer;
                  import org.jbpm.task.service.local.LocalTaskService;
                  
                  public class WSHumanTaskHandlerLocalSyncTest extends WSHumanTaskHandlerBaseSyncTest {
                  
                      private TaskServer server;
                  
                      @Override
                      protected void setUp() throws Exception {
                          super.setUp();
                         
                          setClient(new LocalTaskService(taskService));
                          
                          setHandler(new SyncWSHumanTaskHandler(getClient(), ksession));
                      }
                  
                      protected void tearDown() throws Exception {
                          ((SyncWSHumanTaskHandler) getHandler()).dispose();
                          getClient().disconnect();
                          super.tearDown();
                      }
                  }

                   

                  /**
                   * Copyright 2010 JBoss Inc
                   *
                   * Licensed under the Apache License, Version 2.0 (the "License");
                   * you may not use this file except in compliance with the License.
                   * You may obtain a copy of the License at
                   *
                   *      http://www.apache.org/licenses/LICENSE-2.0
                   *
                   * Unless required by applicable law or agreed to in writing, software
                   * distributed under the License is distributed on an "AS IS" BASIS,
                   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                   * See the License for the specific language governing permissions and
                   * limitations under the License.
                   */
                  package org.jbpm.process.workitem.wsht.sync;
                  
                  import java.io.ByteArrayInputStream;
                  import java.io.ByteArrayOutputStream;
                  import java.io.ObjectInputStream;
                  import java.io.ObjectOutputStream;
                  import java.util.ArrayList;
                  import java.util.HashMap;
                  import java.util.List;
                  import java.util.Map;
                  
                  import org.drools.process.instance.impl.WorkItemImpl;
                  import org.drools.runtime.process.WorkItemHandler;
                  import org.drools.runtime.process.WorkItemManager;
                  import org.jbpm.process.workitem.wsht.MyObject;
                  import org.jbpm.process.workitem.wsht.SyncWSHumanTaskHandler;
                  import org.jbpm.task.AccessType;
                  import org.jbpm.task.BaseTest;
                  import org.jbpm.task.Status;
                  import org.jbpm.task.Task;
                  import org.jbpm.task.TaskService;
                  import org.jbpm.task.TestStatefulKnowledgeSession;
                  import org.jbpm.task.query.TaskSummary;
                  import org.jbpm.task.service.ContentData;
                  import org.jbpm.task.service.PermissionDeniedException;
                  import org.jbpm.task.utils.OnErrorAction;
                  
                  public abstract class WSHumanTaskHandlerBaseSyncTest extends BaseTest {
                  
                      private static final int DEFAULT_WAIT_TIME = 5000;
                      private static final int MANAGER_COMPLETION_WAIT_TIME = DEFAULT_WAIT_TIME;
                      private static final int MANAGER_ABORT_WAIT_TIME = DEFAULT_WAIT_TIME;
                      private TaskService client;
                      private WorkItemHandler handler;
                      protected TestStatefulKnowledgeSession ksession = new TestStatefulKnowledgeSession();
                  
                      public void setClient(TaskService client) {
                          this.client = client;
                      }
                  
                      public TaskService getClient() {
                          return client;
                      }
                  
                      public void testTask() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          workItem.setProcessInstanceId(10);
                          handler.executeWorkItem(workItem, manager);
                  
                          
                          List tasks = client.getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary task = tasks.get(0);
                          assertEquals("TaskName", task.getName());
                          assertEquals(10, task.getPriority());
                          assertEquals("Comment", task.getDescription());
                          assertEquals(Status.Reserved, task.getStatus());
                          assertEquals("Darth Vader", task.getActualOwner().getId());
                          assertEquals(10, task.getProcessInstanceId());
                  
                          client.start(task.getId(), "Darth Vader");
                          client.complete(task.getId(), "Darth Vader", null);
                  
                          assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
                      }
                  
                      public void testTaskMultipleActors() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader, Dalai Lama");
                          getHandler().executeWorkItem(workItem, manager);
                  
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary task = tasks.get(0);
                          assertEquals("TaskName", task.getName());
                          assertEquals(10, task.getPriority());
                          assertEquals("Comment", task.getDescription());
                          assertEquals(Status.Ready, task.getStatus());
                  
                          getClient().claim(task.getId(), "Darth Vader");
                  
                          getClient().start(task.getId(), "Darth Vader");
                  
                          getClient().complete(task.getId(), "Darth Vader", null);
                          
                          assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
                      }
                  
                      public void testTaskGroupActors() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("GroupId", "Crusaders");
                          getHandler().executeWorkItem(workItem, manager);
                  
                          
                          List groupIds = new ArrayList();
                          groupIds.add("Crusaders");
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner(null, groupIds, "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary taskSummary = tasks.get(0);
                          assertEquals("TaskName", taskSummary.getName());
                          assertEquals(10, taskSummary.getPriority());
                          assertEquals("Comment", taskSummary.getDescription());
                          assertEquals(Status.Ready, taskSummary.getStatus());
                  
                          PermissionDeniedException denied = null;
                          try {
                              getClient().claim(taskSummary.getId(), "Darth Vader");
                          } catch (PermissionDeniedException e) {
                              denied = e;
                          }
                  
                          assertNotNull("Should get permissed denied exception", denied);
                  
                          //Check if the parent task is InProgress
                          
                          
                          Task task = getClient().getTask(taskSummary.getId());
                          assertEquals(Status.Ready, task.getTaskData().getStatus());
                      }
                  
                      public void testTaskSingleAndGroupActors() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task One");
                          workItem.setParameter("TaskName", "TaskNameOne");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("GroupId", "Crusaders");
                          getHandler().executeWorkItem(workItem, manager);
                    
                  
                          workItem = new WorkItemImpl();
                          workItem.setName("Human Task Two");
                          workItem.setParameter("TaskName", "TaskNameTwo");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          getHandler().executeWorkItem(workItem, manager);
                  
                          
                          List groupIds = new ArrayList();
                          groupIds.add("Crusaders");
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", groupIds, "en-UK");
                          assertEquals(2, tasks.size());
                      }
                  
                      public void testTaskFail() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          getHandler().executeWorkItem(workItem, manager);
                  
                          
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary task = tasks.get(0);
                          assertEquals("TaskName", task.getName());
                          assertEquals(10, task.getPriority());
                          assertEquals("Comment", task.getDescription());
                          assertEquals(Status.Reserved, task.getStatus());
                          assertEquals("Darth Vader", task.getActualOwner().getId());
                  
                          getClient().start(task.getId(), "Darth Vader");
                          
                          getClient().fail(task.getId(), "Darth Vader", null);
                          
                          assertTrue(manager.waitTillAborted(MANAGER_ABORT_WAIT_TIME));
                      }
                  
                      public void testTaskSkip() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          getHandler().executeWorkItem(workItem, manager);
                  
                          
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary task = tasks.get(0);
                          assertEquals("TaskName", task.getName());
                          assertEquals(10, task.getPriority());
                          assertEquals("Comment", task.getDescription());
                          assertEquals(Status.Reserved, task.getStatus());
                          assertEquals("Darth Vader", task.getActualOwner().getId());
                  
                          getClient().skip(task.getId(), "Darth Vader");
                          
                          assertTrue(manager.waitTillAborted(MANAGER_ABORT_WAIT_TIME));
                      }
                      
                      public void testTaskExit() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          getHandler().executeWorkItem(workItem, manager);
                          
                          Task task = getClient().getTaskByWorkItemId(workItem.getId());
                  
                          getClient().exit(task.getId(), "Administrator");
                          
                          task = getClient().getTaskByWorkItemId(workItem.getId());
                          assertEquals("TaskName", task.getNames().get(0).getText());
                          assertEquals(10, task.getPriority());
                          assertEquals("Comment", task.getDescriptions().get(0).getText());
                          assertEquals(Status.Exited, task.getTaskData().getStatus());
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(0, tasks.size());
                      }
                      
                      public void testTaskExitNonAdministrator() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          getHandler().executeWorkItem(workItem, manager);
                          
                          Task task = getClient().getTaskByWorkItemId(workItem.getId());
                  
                          try {
                              getClient().exit(task.getId(), "Darth Vader");
                              fail("Should not allow to exit task for non administrators");
                          } catch (PermissionDeniedException e) {
                              
                          }
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary taskSummary = tasks.get(0);
                          assertEquals("TaskName", taskSummary.getName());
                          assertEquals(10, taskSummary.getPriority());
                          assertEquals("Comment", taskSummary.getDescription());
                          assertEquals(Status.Reserved, taskSummary.getStatus());
                          assertEquals("Darth Vader", taskSummary.getActualOwner().getId());
                      }
                  
                      public void testTaskAbortSkippable() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          getHandler().executeWorkItem(workItem, manager);
                  
                          
                  
                          getHandler().abortWorkItem(workItem, manager);
                  
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(0, tasks.size());
                      }
                  
                      public void testTaskAbortNotSkippable() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          workItem.setParameter("Skippable", "false");
                          getHandler().executeWorkItem(workItem, manager);
                  
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                  
                          getHandler().abortWorkItem(workItem, manager);
                  
                          // aborting work item will exit task and not skip it
                          tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(0, tasks.size());
                      }
                  
                      public void testTaskData() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          workItem.setParameter("Content", "This is the content");
                          getHandler().executeWorkItem(workItem, manager);
                  
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary taskSummary = tasks.get(0);
                          assertEquals("TaskName", taskSummary.getName());
                          assertEquals(10, taskSummary.getPriority());
                          assertEquals("Comment", taskSummary.getDescription());
                          assertEquals(Status.Reserved, taskSummary.getStatus());
                          assertEquals("Darth Vader", taskSummary.getActualOwner().getId());
                          
                          Task task = getClient().getTask(taskSummary.getId());
                          assertEquals(AccessType.Inline, task.getTaskData().getDocumentAccessType());
                          assertEquals(task.getTaskData().getProcessSessionId(), TestStatefulKnowledgeSession.testSessionId);
                          long contentId = task.getTaskData().getDocumentContentId();
                          assertTrue(contentId != -1);
                          
                          ByteArrayInputStream bis = new ByteArrayInputStream(getClient().getContent(contentId).getContent());
                          ObjectInputStream in = new ObjectInputStream(bis);
                          Object data = in.readObject();
                          in.close();
                          assertEquals("This is the content", data);
                  
                          getClient().start(task.getId(), "Darth Vader");
                         
                          ContentData result = new ContentData();
                          result.setAccessType(AccessType.Inline);
                          result.setType("java.lang.String");
                          ByteArrayOutputStream bos = new ByteArrayOutputStream();
                          ObjectOutputStream out = new ObjectOutputStream(bos);
                          out.writeObject("This is the result");
                          out.close();
                          result.setContent(bos.toByteArray());
                          getClient().complete(task.getId(), "Darth Vader", result);
                          
                          assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
                          Map results = manager.getResults();
                          assertNotNull(results);
                          assertEquals("Darth Vader", results.get("ActorId"));
                          assertEquals("This is the result", results.get("Result"));
                      }
                  
                      public void testTaskDataAutomaticMapping() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          MyObject myObject = new MyObject("MyObjectValue");
                          workItem.setParameter("MyObject", myObject);
                          Map mapParameter = new HashMap();
                          mapParameter.put("MyObjectInsideTheMap", myObject);
                          workItem.setParameter("MyMap", mapParameter);
                          workItem.setParameter("MyObject", myObject);
                  
                          getHandler().executeWorkItem(workItem, manager);
                  
                         
                  
                         
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary taskSummary = tasks.get(0);
                          assertEquals("TaskName", taskSummary.getName());
                          assertEquals(10, taskSummary.getPriority());
                          assertEquals("Comment", taskSummary.getDescription());
                          assertEquals(Status.Reserved, taskSummary.getStatus());
                          assertEquals("Darth Vader", taskSummary.getActualOwner().getId());
                  
                  
                  
                          
                          
                          Task task = getClient().getTask(taskSummary.getId());
                          assertEquals(AccessType.Inline, task.getTaskData().getDocumentAccessType());
                          long contentId = task.getTaskData().getDocumentContentId();
                          assertTrue(contentId != -1);
                          
                          
                          ByteArrayInputStream bis = new ByteArrayInputStream(getClient().getContent(contentId).getContent());
                          ObjectInputStream in = new ObjectInputStream(bis);
                          Map data = (Map) in.readObject();
                          in.close();
                          //Checking that the input parameters are being copied automatically if the Content Element doesn't exist
                          assertEquals("MyObjectValue", ((MyObject) data.get("MyObject")).getValue());
                          assertEquals("10", data.get("Priority"));
                          assertEquals("MyObjectValue", ((MyObject) ((Map) data.get("MyMap")).get("MyObjectInsideTheMap")).getValue());
                  
                          getClient().start(task.getId(), "Darth Vader");
                  
                          ContentData result = new ContentData();
                          result.setAccessType(AccessType.Inline);
                          result.setType("java.lang.String");
                          ByteArrayOutputStream bos = new ByteArrayOutputStream();
                          ObjectOutputStream out = new ObjectOutputStream(bos);
                          out.writeObject("This is the result");
                          out.close();
                          result.setContent(bos.toByteArray());
                          getClient().complete(task.getId(), "Darth Vader", result);
                  
                          assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
                          Map results = manager.getResults();
                          assertNotNull(results);
                          assertEquals("Darth Vader", results.get("ActorId"));
                          assertEquals("This is the result", results.get("Result"));
                      }
                      
                      public void testTaskCreateFailedWithLog() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          if (handler instanceof SyncWSHumanTaskHandler) {
                              ((SyncWSHumanTaskHandler) handler).setAction(OnErrorAction.LOG);
                          }
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "DoesNotExist");
                          workItem.setProcessInstanceId(10);
                          
                          
                          handler.executeWorkItem(workItem, manager);
                          assertFalse(manager.isAborted());
                      }
                      
                      public void testTaskCreateFailedWithAbort() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          if (handler instanceof SyncWSHumanTaskHandler) {
                              ((SyncWSHumanTaskHandler) handler).setAction(OnErrorAction.ABORT);
                          }
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "DoesNotExist");
                          workItem.setProcessInstanceId(10);
                          
                          
                          handler.executeWorkItem(workItem, manager);
                          assertTrue(manager.isAborted());
                      }
                      
                      public void testTaskCreateFailedWithRethrow() throws Exception {
                          TestWorkItemManager manager = new TestWorkItemManager();
                          if (handler instanceof SyncWSHumanTaskHandler) {
                              ((SyncWSHumanTaskHandler) handler).setAction(OnErrorAction.RETHROW);
                          }
                          ksession.setWorkItemManager(manager);
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskName");
                          workItem.setParameter("Comment", "Comment");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "DoesNotExist");
                          workItem.setProcessInstanceId(10);
                          
                          try {
                              handler.executeWorkItem(workItem, manager);
                              fail("Should fail due to OnErroAction set to rethrow");
                          } catch (Exception e) {
                              // do nothing
                              
                          }
                      }
                  
                      public void TODOtestOnAllSubTasksEndParentEndStrategy() throws Exception {
                  
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          //Create the parent task
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskNameParent");
                          workItem.setParameter("Comment", "CommentParent");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          //Set the subtask policy
                          workItem.setParameter("SubTaskStrategies", "OnAllSubTasksEndParentEnd");
                          getHandler().executeWorkItem(workItem, manager);
                  
                  
                          //Test if the task is succesfully created
                          
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary task = tasks.get(0);
                          assertEquals("TaskNameParent", task.getName());
                          assertEquals(10, task.getPriority());
                          assertEquals("CommentParent", task.getDescription());
                          assertEquals(Status.Reserved, task.getStatus());
                          assertEquals("Darth Vader", task.getActualOwner().getId());
                  
                          //Create the child task
                          workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskNameChild1");
                          workItem.setParameter("Comment", "CommentChild1");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          workItem.setParameter("ParentId", task.getId());
                          getHandler().executeWorkItem(workItem, manager);
                  
                    
                          //Create the child task2
                          workItem = new WorkItemImpl();
                          workItem.setName("Human Task2");
                          workItem.setParameter("TaskName", "TaskNameChild2");
                          workItem.setParameter("Comment", "CommentChild2");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          workItem.setParameter("ParentId", task.getId());
                          getHandler().executeWorkItem(workItem, manager);
                  
                     
                          //Start the parent task
                          getClient().start(task.getId(), "Darth Vader");
                          
                          //Check if the parent task is InProgress
                          
                          
                          Task parentTask = getClient().getTask(task.getId());
                          assertEquals(Status.InProgress, parentTask.getTaskData().getStatus());
                          assertEquals(users.get("darth"), parentTask.getTaskData().getActualOwner());
                  
                          //Get all the subtask created for the parent task based on the potential owner
                          
                          
                          List subTasks = getClient().getSubTasksAssignedAsPotentialOwner(parentTask.getId(), "Darth Vader", "en-UK");
                          assertEquals(2, subTasks.size());
                          TaskSummary subTaskSummary1 = subTasks.get(0);
                          TaskSummary subTaskSummary2 = subTasks.get(1);
                          assertNotNull(subTaskSummary1);
                          assertNotNull(subTaskSummary2);
                  
                          //Starting the sub task 1
                          getClient().start(subTaskSummary1.getId(), "Darth Vader");
                          
                          //Starting the sub task 2
                          getClient().start(subTaskSummary2.getId(), "Darth Vader");
                          
                          //Check if the child task 1 is InProgress
                          Task subTask1 = getClient().getTask(subTaskSummary1.getId());
                          assertEquals(Status.InProgress, subTask1.getTaskData().getStatus());
                          assertEquals(users.get("darth"), subTask1.getTaskData().getActualOwner());
                  
                          //Check if the child task 2 is InProgress
                          
                          
                          Task subTask2 = getClient().getTask(subTaskSummary2.getId());
                          assertEquals(Status.InProgress, subTask2.getTaskData().getStatus());
                          assertEquals(users.get("darth"), subTask2.getTaskData().getActualOwner());
                  
                          // Complete the child task 1
                          getClient().complete(subTask1.getId(), "Darth Vader", null);
                          
                          // Complete the child task 2
                          getClient().complete(subTask2.getId(), "Darth Vader", null);
                         
                          //Check if the child task 1 is Completed
                  
                         
                          
                          subTask1 = getClient().getTask(subTask1.getId());
                          assertEquals(Status.Completed, subTask1.getTaskData().getStatus());
                          assertEquals(users.get("darth"), subTask1.getTaskData().getActualOwner());
                  
                          //Check if the child task 2 is Completed
                          subTask2 = getClient().getTask(subTask2.getId());
                          assertEquals(Status.Completed, subTask2.getTaskData().getStatus());
                          assertEquals(users.get("darth"), subTask2.getTaskData().getActualOwner());
                  
                          // Check is the parent task is Complete
                          parentTask = getClient().getTask(parentTask.getId());
                          assertEquals(Status.Completed, parentTask.getTaskData().getStatus());
                          assertEquals(users.get("darth"), parentTask.getTaskData().getActualOwner());
                  
                          assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
                      }
                  
                      public void TODOtestOnParentAbortAllSubTasksEndStrategy() throws Exception {
                  
                          TestWorkItemManager manager = new TestWorkItemManager();
                          ksession.setWorkItemManager(manager);
                          //Create the parent task
                          WorkItemImpl workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskNameParent");
                          workItem.setParameter("Comment", "CommentParent");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          //Set the subtask policy
                          workItem.setParameter("SubTaskStrategies", "OnParentAbortAllSubTasksEnd");
                          getHandler().executeWorkItem(workItem, manager);
                  
                  
                          //Test if the task is succesfully created
                          
                          
                          List tasks = getClient().getTasksAssignedAsPotentialOwner("Darth Vader", "en-UK");
                          assertEquals(1, tasks.size());
                          TaskSummary task = tasks.get(0);
                          assertEquals("TaskNameParent", task.getName());
                          assertEquals(10, task.getPriority());
                          assertEquals("CommentParent", task.getDescription());
                          assertEquals(Status.Reserved, task.getStatus());
                          assertEquals("Darth Vader", task.getActualOwner().getId());
                  
                          //Create the child task
                          workItem = new WorkItemImpl();
                          workItem.setName("Human Task");
                          workItem.setParameter("TaskName", "TaskNameChild1");
                          workItem.setParameter("Comment", "CommentChild1");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          workItem.setParameter("ParentId", task.getId());
                          getHandler().executeWorkItem(workItem, manager);
                  
                          //Create the child task2
                          workItem = new WorkItemImpl();
                          workItem.setName("Human Task2");
                          workItem.setParameter("TaskName", "TaskNameChild2");
                          workItem.setParameter("Comment", "CommentChild2");
                          workItem.setParameter("Priority", "10");
                          workItem.setParameter("ActorId", "Darth Vader");
                          workItem.setParameter("ParentId", task.getId());
                          getHandler().executeWorkItem(workItem, manager);
                  
                          //Start the parent task
                          getClient().start(task.getId(), "Darth Vader");
                  
                          //Check if the parent task is InProgress
                          Task parentTask = getClient().getTask(task.getId());
                          assertEquals(Status.InProgress, parentTask.getTaskData().getStatus());
                          assertEquals(users.get("darth"), parentTask.getTaskData().getActualOwner());
                  
                          //Get all the subtask created for the parent task based on the potential owner
                          
                          
                          List subTasks = getClient().getSubTasksAssignedAsPotentialOwner(parentTask.getId(), "Darth Vader", "en-UK");
                          assertEquals(2, subTasks.size());
                          TaskSummary subTaskSummary1 = subTasks.get(0);
                          TaskSummary subTaskSummary2 = subTasks.get(1);
                          assertNotNull(subTaskSummary1);
                          assertNotNull(subTaskSummary2);
                  
                          //Starting the sub task 1
                          getClient().start(subTaskSummary1.getId(), "Darth Vader");
                          
                          //Starting the sub task 2
                          getClient().start(subTaskSummary2.getId(), "Darth Vader");
                          
                          //Check if the child task 1 is InProgress
                          
                          
                          Task subTask1 = getClient().getTask(subTaskSummary1.getId());
                          assertEquals(Status.InProgress, subTask1.getTaskData().getStatus());
                          assertEquals(users.get("darth"), subTask1.getTaskData().getActualOwner());
                  
                          //Check if the child task 2 is InProgress
                          
                          
                          Task subTask2 = getClient().getTask(subTaskSummary2.getId());
                          assertEquals(Status.InProgress, subTask2.getTaskData().getStatus());
                          assertEquals(users.get("darth"), subTask2.getTaskData().getActualOwner());
                  
                          // Complete the parent task
                          getClient().skip(parentTask.getId(), "Darth Vader");
                          
                          //Check if the child task 1 is Completed
                          
                          
                          subTask1 = getClient().getTask(subTaskSummary1.getId());
                          assertEquals(Status.Completed, subTask1.getTaskData().getStatus());
                          assertEquals(users.get("darth"), subTask1.getTaskData().getActualOwner());
                  
                          //Check if the child task 2 is Completed
                          
                          
                          subTask2 = getClient().getTask(subTaskSummary2.getId());
                          assertEquals(Status.Completed, subTask2.getTaskData().getStatus());
                          assertEquals(users.get("darth"), subTask2.getTaskData().getActualOwner());
                  
                          assertTrue(manager.waitTillCompleted(MANAGER_COMPLETION_WAIT_TIME));
                      }
                  
                      public void setHandler(WorkItemHandler handler) {
                          this.handler = handler;
                      }
                  
                      public WorkItemHandler getHandler() {
                          return handler;
                      }
                  
                      private class TestWorkItemManager implements WorkItemManager {
                  
                          private volatile boolean completed;
                          private volatile boolean aborted;
                          private volatile Map results;
                  
                          public synchronized boolean waitTillCompleted(long time) {
                              if (!isCompleted()) {
                                  try {
                                      wait(time);
                                  } catch (InterruptedException e) {
                                      // swallow and return state of completed
                                  }
                              }
                  
                              return isCompleted();
                          }
                  
                          public synchronized boolean waitTillAborted(long time) {
                              if (!isAborted()) {
                                  try {
                                      wait(time);
                                  } catch (InterruptedException e) {
                                      // swallow and return state of aborted
                                  }
                              }
                  
                              return isAborted();
                          }
                  
                          public void abortWorkItem(long id) {
                              setAborted(true);
                          }
                  
                          public synchronized boolean isAborted() {
                              return aborted;
                          }
                  
                          private synchronized void setAborted(boolean aborted) {
                              this.aborted = aborted;
                              notifyAll();
                          }
                  
                          public void completeWorkItem(long id, Map results) {
                              this.results = results;
                              setCompleted(true);
                          }
                  
                          private synchronized void setCompleted(boolean completed) {
                              this.completed = completed;
                              notifyAll();
                          }
                  
                          public synchronized boolean isCompleted() {
                              return completed;
                          }
                  
                          public Map getResults() {
                              return results;
                          }
                  
                          public void registerWorkItemHandler(String workItemName, WorkItemHandler handler) {
                          }
                      }
                  }