Workflow Notificatoins:

* Email notifications sent asynchronously
  * Activiti pooled tasks now work correctly



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29812 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2011-08-17 04:59:49 +00:00
parent 20b9d8a3ed
commit 348cc9831f
2 changed files with 42 additions and 2 deletions

View File

@@ -143,6 +143,9 @@ public abstract class WorkflowNotificationUtils
notificationContext.addTo(assignedAuthority); notificationContext.addTo(assignedAuthority);
} }
// Indicate that we want to execute the notification asynchronously
notificationContext.setAsyncNotification(true);
// Send email notification // Send email notification
services.getNotificationService().sendNotification(EMailNotificationProvider.NAME, notificationContext); services.getNotificationService().sendNotification(EMailNotificationProvider.NAME, notificationContext);
} }

View File

@@ -19,11 +19,15 @@
package org.alfresco.repo.workflow.activiti.tasklistener; package org.alfresco.repo.workflow.activiti.tasklistener;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.delegate.DelegateTask; import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener; import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.form.FormData; import org.activiti.engine.form.FormData;
import org.activiti.engine.impl.form.TaskFormHandler; import org.activiti.engine.impl.form.TaskFormHandler;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity; import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.IdentityLinkEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity; import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.alfresco.repo.workflow.WorkflowNotificationUtils; import org.alfresco.repo.workflow.WorkflowNotificationUtils;
import org.alfresco.repo.workflow.activiti.ActivitiConstants; import org.alfresco.repo.workflow.activiti.ActivitiConstants;
@@ -73,6 +77,7 @@ public class TaskCreateListener implements TaskListener
Boolean value = (Boolean)executionEntity.getVariable(WorkflowNotificationUtils.PROP_SEND_EMAIL_NOTIFICATIONS); Boolean value = (Boolean)executionEntity.getVariable(WorkflowNotificationUtils.PROP_SEND_EMAIL_NOTIFICATIONS);
if (Boolean.TRUE.equals(value) == true) if (Boolean.TRUE.equals(value) == true)
{ {
// Get the workflow package node
NodeRef workflowPackage = null; NodeRef workflowPackage = null;
ActivitiScriptNode scriptNode = (ActivitiScriptNode)executionEntity.getVariable(WorkflowNotificationUtils.PROP_PACKAGE); ActivitiScriptNode scriptNode = (ActivitiScriptNode)executionEntity.getVariable(WorkflowNotificationUtils.PROP_PACKAGE);
if (scriptNode != null) if (scriptNode != null)
@@ -80,6 +85,38 @@ public class TaskCreateListener implements TaskListener
workflowPackage = scriptNode.getNodeRef(); workflowPackage = scriptNode.getNodeRef();
} }
// Determine whether the task is pooled or not
String[] authorities = null;
boolean isPooled = false;
if (task.getAssignee() == null)
{
// Task is pooled
isPooled = true;
// Get the pool of user/groups for this task
List<IdentityLinkEntity> identities = ((TaskEntity)task).getIdentityLinks();
List<String> temp = new ArrayList<String>(identities.size());
for (IdentityLinkEntity item : identities)
{
String group = item.getGroupId();
if (group != null)
{
temp.add(group);
}
String user = item.getUserId();
if (user != null)
{
temp.add(user);
}
}
authorities = temp.toArray(new String[temp.size()]);
}
else
{
// Get the assigned user or group
authorities = new String[]{task.getAssignee()};
}
// Send email notification // Send email notification
WorkflowNotificationUtils.sendWorkflowAssignedNotificationEMail( WorkflowNotificationUtils.sendWorkflowAssignedNotificationEMail(
services, services,
@@ -89,8 +126,8 @@ public class TaskCreateListener implements TaskListener
task.getDueDate(), task.getDueDate(),
Integer.valueOf(task.getPriority()), Integer.valueOf(task.getPriority()),
workflowPackage, workflowPackage,
new String[]{task.getAssignee()}, authorities,
(task.getAssignee() == null)); isPooled);
} }
} }