<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Group assignment and action on tasks
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/sasir">Sasi R</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/595376#595376">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Am able to define and assign the groupid tohuman task and able to pull the list of tasks&#160; using TaskClient. Howwever am unable to action further(like release/claim/start/complete) on the items assigned to the group using the member of group as userid.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>How does TaskServer behave in this scenario? Am i missing something here??</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Code Snippet</p><p>*******</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="color: #0000ff;"><strong>For Group Assignment</strong></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="font-size: 10pt;"> </span>&#160;</p><p>MinaTaskServer server;</p><p>EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");<br/>TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());<br/>TaskServiceSession taskSession= taskService.createSession();</p><p>server = new MinaTaskServer(taskService);<br/>Thread thread = new Thread(server);</p><p><div><span style="font-size: 10pt;"><p style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="color: #7f0055; font-size: 10pt;"> </span>&#160;</p></span></div></p><p><span style="font-size: 10pt;"><p><p><div><div><span style="color: #7f0055; font-size: 10pt;">List&lt;OrganizationalEntity&gt; usersList=new ArrayList&lt;OrganizationalEntity&gt;();<span style="font-size: 10pt;"> </span></span></div></div></p><div><span style="color: #7f0055; font-size: 10pt;"> </span></div></p><span style="color: #7f0055; font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><p>usersList.add(<strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">new</strong></strong><span style="font-size: 10pt;"> User(</span><span style="color: #2a00ff; font-size: 10pt;">"sasi"</span><div><span style="font-size: 10pt;">));</span></div></p></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></p></span><p><span style="font-size: 10pt;"><p style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="font-size: 10pt;"> </span>&#160;</p></span><p><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><p>usersList.add(<strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">new</strong></strong><span style="font-size: 10pt;"> User(</span><span style="color: #2a00ff; font-size: 10pt;">"venkat"</span><div><span style="font-size: 10pt;">));</span></div></p></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><p>usersList.add(<strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">new</strong></strong><span style="font-size: 10pt;"> User(</span><span style="color: #2a00ff; font-size: 10pt;">"krisv"</span><div><span style="font-size: 10pt;">));</span></div></p></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"><p>usersList.add(<strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">new</strong></strong><span style="font-size: 10pt;"> User(</span><span style="color: #2a00ff; font-size: 10pt;">"mary"</span><span style="font-size: 10pt;">));</span></p></span></p><p></p><p><div><div><span style="color: #7f0055; font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><p>BPMTaskUserInfo userInfo = <strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">new</strong></strong><div><span style="font-size: 10pt;">BPMTaskUserInfo();</span></div></p></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span></span></div></div></p><div><span style="color: #7f0055; font-size: 10pt;"> </span></div></p></span><span style="color: #7f0055; font-size: 10pt;"><p><span style="font-size: 10pt;"><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>taskService.setUserinfo(userInfo);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><p>userInfo.getGroups().put(<strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">new</strong></strong><span style="font-size: 10pt;"> Group(</span><span style="color: #2a00ff; font-size: 10pt;">"</span><span style="color: #2a00ff; font-size: 10pt; font-family: Courier New;">Group1</span><span style="color: #2a00ff; font-size: 10pt;">"</span><div><span style="font-size: 10pt;">), usersList);</span></div></p></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><span style="font-size: 10pt;"><p>userInfo.getGroups().put(<strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">new</strong></strong><span style="font-size: 10pt;"> Group(</span><span style="color: #2a00ff; font-size: 10pt;">"</span><span style="color: #2a00ff; font-size: 10pt; font-family: Courier New;">Group2</span><span style="color: #2a00ff; font-size: 10pt;">"</span><div><span style="font-size: 10pt;">), usersList);</span></div></p></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><span style="font-size: 10pt;"> </span></span><div><span style="font-size: 10pt;"><p>userInfo.getGroups().put(<strong style="color: #7f0055; font-size: 10pt;"><strong style="color: #7f0055; font-size: 10pt;">new</strong></strong><span style="font-size: 10pt;"> Group(</span><span style="color: #2a00ff; font-size: 10pt;">"</span><span style="color: #2a00ff; font-size: 10pt; font-family: Courier New;">Group3</span><span style="color: #2a00ff; font-size: 10pt;">"</span><span style="font-size: 10pt;">), usersList);</span></p></span></div></p><span style="font-size: 10pt;"><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></span><p><div><span style="font-size: 10pt;"> </span></div></p><span style="font-size: 10pt;"><p><p><span style="font-size: 10pt;"><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></span><span style="font-size: 10pt;"> </span><span style="font-size: 10pt;"> </span></p></p></span><p><p><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a></p><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a><p><a class="jive-link-anchor-small">#</a></p><p><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a><a class="jive-link-anchor-small">#</a></p><a class="jive-link-anchor-small">#</a></p></span></span></span></p><p><p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></p></p><p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p></p><p><span style="color: #0000ff;"><strong>For retrieving tasks</strong></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="color: #0000ff;"><strong> </strong></span>&#160;</p><p>public static void getTasks(StatefulKnowledgeSession ksession){<br/>&#160; WorkItemHandler htHandler = new WSHumanTaskHandler(); <br/>&#160; ksession.getWorkItemManager().registerWorkItemHandler("Human Task", htHandler); </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160; TaskClient client = new TaskClient(new MinaTaskClientConnector("client 1",new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()))); <br/>&#160; boolean isConnected = client.connect("127.0.0.1", 9123); <br/>&#160; <br/>&#160; System.out.println("client conencted :"+isConnected);<br/>&#160; BlockingTaskSummaryResponseHandler summaryHandler = new BlockingTaskSummaryResponseHandler(); <br/>&#160; int timeoutCounter = 0; <br/>&#160; List&lt;TaskSummary&gt; tasks; <br/>&#160; List&lt;String&gt; groups= new ArrayList&lt;String&gt;();<br/>&#160; groups.add("Group1");</p><p>&#160; do { <br/>&#160; client.getTasksAssignedAsPotentialOwner("sasi",groups, "en-UK", summaryHandler); <br/>&#160; tasks = summaryHandler.getResults(); <br/>&#160; <br/>&#160;&#160; TaskSummary task = null;&#160; <br/>&#160;&#160; for (TaskSummary taskSummary : tasks) <br/>&#160;&#160; {&#160;&#160; <br/>&#160;&#160; System.out.println(taskSummary.getId() + " : "&#160;&#160;&#160;&#160; + taskSummary.getName());&#160;&#160; <br/>&#160;&#160;&#160; <br/>&#160;&#160; }<br/>&#160; //wait until the task is registered with the server or timeout expires <br/>&#160; if (timeoutCounter != 0) { <br/>&#160; try {<br/>&#160;&#160; Thread.sleep(10);<br/>&#160; } catch (InterruptedException e) {<br/>&#160;&#160; // TODO Auto-generated catch block<br/>&#160;&#160; e.printStackTrace();<br/>&#160; } <br/>&#160; } <br/>&#160; } while (tasks.isEmpty() &amp;&amp; timeoutCounter++ &lt; 10); <br/>&#160; System.out.println("Tasks size is"+tasks.size()); </p><p>&#160; TaskSummary task = tasks.get(0);<br/>&#160; <br/>&#160; System.out.println("Task details are "+task.getId());<br/>&#160; <br/>&#160; BlockingTaskOperationResponseHandler operationHandler = <br/>&#160;&#160; new BlockingTaskOperationResponseHandler(); <br/>&#160;&#160; client.release(task.getId(), "Administrator", operationHandler); <br/>&#160;&#160; operationHandler.waitTillDone(5000); <br/>&#160;&#160; <br/>&#160;&#160; operationHandler = <br/>&#160;&#160; new BlockingTaskOperationResponseHandler(); <br/>&#160;&#160; client.claim(task.getId(), "sasi", operationHandler); <br/>&#160;&#160; operationHandler.waitTillDone(5000); </p><p>&#160;&#160; operationHandler = <br/>&#160;&#160; new BlockingTaskOperationResponseHandler(); <br/>&#160;&#160; client.start(task.getId(), "sasi", operationHandler); <br/>&#160;&#160; operationHandler.waitTillDone(5000); </p><p>&#160;&#160; operationHandler = <br/>&#160;&#160; new BlockingTaskOperationResponseHandler(); <br/>&#160;&#160; client.complete(task.getId(), "sasi", null, <br/>&#160;&#160; operationHandler); <br/>&#160;&#160; operationHandler.waitTillDone(5000);</p><p>&#160; <br/>&#160;&#160; <br/>}</p><p><br/><span style="color: #0000ff;"><strong>Error:</strong></span></p><p>[2011:03:83 11:03:898:debug] Arguments : [[org.jbpm.task.query.TaskSummary@3585d013, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@7fc4f753">org.jbpm.task.query.TaskSummary@7fc4f753</a>, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@c2579d8d">org.jbpm.task.query.TaskSummary@c2579d8d</a>, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@73ef06e5">org.jbpm.task.query.TaskSummary@73ef06e5</a>, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@2d60e703">org.jbpm.task.query.TaskSummary@2d60e703</a>, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@aa5cc20b">org.jbpm.task.query.TaskSummary@aa5cc20b</a>, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@33aad8e3">org.jbpm.task.query.TaskSummary@33aad8e3</a>, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@105b609b">org.jbpm.task.query.TaskSummary@105b609b</a>, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@9a153a13">org.jbpm.task.query.TaskSummary@9a153a13</a>, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@2398c26b">org.jbpm.task.query.TaskSummary@2398c26b</a>, <a class="" href="http://community.jboss.org/mailto:org.jbpm.task.query.TaskSummary@63ece17b">org.jbpm.task.query.TaskSummary@63ece17b</a>]]<br/>5105 : Event-Ready-Task<br/>9905 : Event-Ready-Task<br/>3755 : Event-Ready-Task<br/>4355 : Event-Ready-Task<br/>8705 : Event-Ready-Task<br/>5705 : Event-Ready-Task<br/>6305 : Event-Ready-Task<br/>6905 : Event-Ready-Task<br/>7505 : Event-Ready-Task<br/>8105 : Event-Ready-Task<br/>9305 : Event-Ready-Task<br/>Tasks size is11<br/>Task details are 5105<br/><span style="color: #ff0000;">org.jbpm.task.service.PermissionDeniedException: Server-side Exception: User '[User:'Administrator']' was unable to execution operation 'Release' on task id 5105 due to no 'current status' matchines</span><br/>at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)<br/>at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)<br/>at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)<br/>at java.lang.reflect.Constructor.newInstance(Unknown Source)<br/>at org.jbpm.task.service.responsehandlers.AbstractBaseResponseHandler.createSideException(AbstractBaseResponseHandler.java:74)<br/>at org.jbpm.task.service.responsehandlers.AbstractBlockingResponseHandler.waitTillDone(AbstractBlockingResponseHandler.java:48)<br/>at com.sample.CorporateActionsNewTest.getTasks(CorporateActionsNewTest.java:132)<br/>at com.sample.CorporateActionsNewTest.main(CorporateActionsNewTest.java:60)<br/>[2011:03:83 11:03:37:debug] Message receieved on client : OperationResponse<br/>[2011:03:83 11:03:38:debug] Arguments : [org.jbpm.task.service.PermissionDeniedException: User '[User:'Administrator']' was unable to execution operation 'Release' on task id 5105 due to no 'current status' matchines]</p><p><br/>If i try with Sasi for release</p><p>org.jbpm.task.service.PermissionDeniedException: Server-side Exception: User '[User:'sasi']' was unable to execution operation 'Release' on task id 5105 due to no 'current status' matchines<br/>at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)<br/>at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)<br/>at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)<br/>at java.lang.reflect.Constructor.newInstance(Unknown Source)<br/>at org.jbpm.task.service.responsehandlers.AbstractBaseResponseHandler.createSideException(AbstractBaseResponseHandler.java:74)<br/>at org.jbpm.task.service.responsehandlers.AbstractBlockingResponseHandler.waitTillDone(AbstractBlockingResponseHandler.java:48)[2011:03:83 11:03:626:debug] Message receieved on client : OperationResponse<br/><span style="color: #ff0000;">[2011:03:83 11:03:627:debug] Arguments : [org.jbpm.task.service.PermissionDeniedException: User '[User:'sasi']' was unable to execution operation 'Release' on task id 5105 due to no 'current status' matchines]</span></p><p>at com.sample.CorporateActionsNewTest.getTasks(CorporateActionsNewTest.java:132)<br/>at com.sample.CorporateActionsNewTest.main(CorporateActionsNewTest.java:60)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>5105 task is with 'Ready' status in datasbase</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/595376#595376">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>