I implement the TaskListener, i gotr the exception while task being created.
code are
long workflowTaskId=0l;
long compId=0l;
@Override
public void notify(DelegateTask arg0) {
// TODO Auto-generated method stub
workflowTaskId=Long.parseLong(arg0.getId());
compId=Long.parseLong(arg0.getTenantId());
System.out.println("Company ID "+compId);
System.out.println("%%%%%%%Activiti Working*****************"+ arg0.getProcessInstanceId()+" "+arg0.getName()+arg0.getId());
getMethod();
}
private void getMethod(){
try{
Company company = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
//compId = company.getGroup().getGroupId();
}catch(PortalException e){}
catch (SystemException se) {
// TODO: handle exception
}
try{
System.out.println("workflowTaskId "+workflowTaskId);
System.out.println(WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId));
System.out.println(WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId).getOptionalAttributes());
System.out.println(WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId).getOptionalAttributes().get("entryClassPK"));
String classPk= WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId).getOptionalAttributes().get("entryClassPK").toString();
System.out.println("classPk "+classPk);
long fileEntryId=DLFileVersionLocalServiceUtil.getFileVersion(Long.parseLong(classPk)).getFileEntryId();
System.out.println("fileEntryId "+fileEntryId);
String name=DLFileVersionLocalServiceUtil.getFileVersion(Long.parseLong(classPk)).getTitle();
System.out.println("name "+name);
long chapfoldId=DLFileVersionLocalServiceUtil.getFileVersion(Long.parseLong(classPk)).getFolderId();
System.out.println("chapfoldId "+chapfoldId);
long bkfoldId=DLFolderLocalServiceUtil.fetchFolder(chapfoldId).getParentFolderId();
System.out.println("MytaskcreateListener Called \nworkflowTaskId "+workflowTaskId+"\nclassPk "+classPk+"\nfileEntryId "+fileEntryId+"\tname " +name+"\tbook "+bkfoldId );
}catch(PortalException p){}
catch (SystemException see) {
// TODO: handle exception
}
}
}
event : create
the Bpmn's xml code
<userTask id="usertask1" name="Update Due Date" activiti:candidateGroups="Administrator,Power User">
<extensionElements>
<activiti:taskListener event="create" class="com.library.model.listeners.MyTaskCreateListener" />
</extensionElements>
</userTask>
String classPk= WorkflowTaskManagerUtil.getWorkflowTask(compId, workflowTaskId).getOptionalAttributes().get("entryClassPK").toString();
The above mentioned line make NPE, and give warning is cannot find taskId
The populated workflowTaskId is a valid id, its confirmed
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.