<!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="https://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;">
Re: Could not getting tasks for business administrators through task client
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/swiderski.maciej">Maciej Swiderski</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/778258#778258">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>No, it fact the problem was that you used getTasksAssignedAsPotentialOwner method instead of one dedicated to get tasks assigned as business user, see in bold:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p>tom sebastian wrote:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This was my class.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>public class BusinessAdminTest {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>          private static final long DEFAULT_WAIT_TIME = 10000l;</p><p>          private TaskClient client;</p><p>          private WorkItemManager manager;</p><p>          private String ipAddress="192.168.1.111";</p><p>          private int port=9123;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>          private void createClient() {</p><p>                    if (client == null) {</p><p>                              client = new TaskClient(new MinaTaskClientConnector("com.task.BusinessAdminTest",</p><p>                                                                                                    new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));</p><p>                              boolean connected = client.connect(ipAddress, port);</p><p>                              if (!connected) {</p><p>                                        throw new IllegalArgumentException("Could not connect task client");</p><p>                              }</p><p>                    }</p><p>          }</p><p>          public void test() throws Throwable{</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    // Create the task</p><p>                    //assumed testGroup contain 'Mary','John' users</p><p>                    Task task1 = createTask("TaskName", "Comment","Tom","testGroup");</p><p>                    BlockingTaskOperationResponseHandler operationResponseHandler = new BlockingTaskOperationResponseHandler();</p><p>                    client.addTask(task1, null, null);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    Thread.sleep(500);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    // Test if the task is successfully created</p><p>                    BlockingTaskSummaryResponseHandler responseHandler = new BlockingTaskSummaryResponseHandler();</p><p>                    client.getTasksAssignedAsPotentialOwner("Tom", "en-UK",</p><p>                                        responseHandler);</p><p>                    responseHandler.waitTillDone(DEFAULT_WAIT_TIME);</p><p>                    List tasks = responseHandler.getResults();</p><p>                    if(tasks!=null){</p><p>                              System.out.println(tasks.size());</p><p>                              TaskSummary summary=(TaskSummary) tasks.get(0);</p><p>                              System.out.println(summary.getStatus().toString());//will be 'Ready'</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    }</p><p>                    //Try to get task as business administrator</p><p>                    responseHandler = new BlockingTaskSummaryResponseHandler();</p><p>                 <strong>   client.getTasksAssignedAsPotentialOwner("administrator", "en-UK",</strong></p><p><strong>                                        responseHandler);</strong></p><p>                    responseHandler.waitTillDone(DEFAULT_WAIT_TIME);</p><p>                    tasks = responseHandler.getResults();</p><p>                    if(tasks!=null){// according to WS specification, we expect to get task </p><p>                              System.out.println(tasks.size());</p><p>                              TaskSummary summary=(TaskSummary) tasks.get(0);</p><p>                              System.out.println(summary.getStatus().toString());</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>          }</p><p>          public TaskClient getClient() {</p><p>                    return client;</p><p>          }</p><p>          public void setClient(TaskClient client) {</p><p>                    this.client = client;</p><p>          }</p><p>          private Task createTask(String taskName, String comment, String actorId,String groupId) {</p><p>                    Task task = new Task();</p><p>                    if (taskName != null) {</p><p>                              List names = new ArrayList();</p><p>                              names.add(new I18NText("en-UK", taskName));</p><p>                              task.setNames(names);</p><p>                    }</p><p>                    if (comment != null) {</p><p>                              List descriptions = new ArrayList();</p><p>                              descriptions.add(new I18NText("en-UK", comment));</p><p>                              task.setDescriptions(descriptions);</p><p>                              List subjects = new ArrayList();</p><p>                              subjects.add(new I18NText("en-UK", comment));</p><p>                              task.setSubjects(subjects);</p><p>                    }</p><p>                    task.setPriority(10);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    TaskData taskData = new TaskData();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    PeopleAssignments assignments = new PeopleAssignments();</p><p>                    List potentialOwners = new ArrayList();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    if (actorId != null && actorId.trim().length() > 0) {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                                        potentialOwners.add(new User(actorId.trim()));</p><p>                              }</p><p>                    if (groupId != null && groupId.trim().length() > 0) {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                                        potentialOwners.add(new Group(groupId.trim()));</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    } </p><p>                    // Set the first user as creator ID??? hmmm might be wrong</p><p>                              if (potentialOwners.size() > 0) {</p><p>                                        taskData.setCreatedBy((User) potentialOwners.get(0));</p><p>                              }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    assignments.setPotentialOwners(potentialOwners);</p><p>                    List businessAdministrators = new ArrayList();</p><p>                    businessAdministrators.add(new User("administrator"));</p><p>                    assignments.setBusinessAdministrators(businessAdministrators);</p><p>                    task.setPeopleAssignments(assignments);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    taskData.setSkipable(true);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    task.setTaskData(taskData);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>                    return task;</p><p>          }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>          public void setManager(WorkItemManager manager) {</p><p>                    this.manager = manager;</p><p>          }</p><p>          public WorkItemManager getManager() {</p><p>                    return manager;</p><p>          }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>          public static void main(String[] a){</p><p>                    BusinessAdminTest baTest = new BusinessAdminTest();</p><p>                    baTest.createClient();</p><p>                    try {</p><p>                              baTest.test();</p><p>                    } catch (Throwable e) {</p><p>                              // TODO Auto-generated catch block</p><p>                              e.printStackTrace();</p><p>                    }</p><p>          }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>When i run this ,the output was(the first 2 lines indicate the number of tasks and its status as potential owner, while the remaining as business admin for the same task)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>1</p><p>Ready</p><p>0</p><p>java.lang.IndexOutOfBoundsException: Index: 0, Size: 0</p></blockquote></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/778258#778258">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://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>