diff --git a/config/alfresco/activiti-context.xml b/config/alfresco/activiti-context.xml
index 07dce2a320..1b309ff155 100644
--- a/config/alfresco/activiti-context.xml
+++ b/config/alfresco/activiti-context.xml
@@ -41,7 +41,6 @@
-
diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml
index 40c97a0249..7628cdc330 100644
--- a/config/alfresco/bootstrap-context.xml
+++ b/config/alfresco/bootstrap-context.xml
@@ -377,6 +377,22 @@
text/xml
false
+
+
+
+ activiti
+ alfresco/workflow/invitation-moderated.bpmn20.xml
+ text/xml
+ false
+
+
+
+
+ activiti
+ alfresco/workflow/invitation-nominated.bpmn20.xml
+ text/xml
+ false
+
diff --git a/config/alfresco/workflow/adhoc.bpmn20.xml b/config/alfresco/workflow/adhoc.bpmn20.xml
index b5a712df3f..95c7169308 100644
--- a/config/alfresco/workflow/adhoc.bpmn20.xml
+++ b/config/alfresco/workflow/adhoc.bpmn20.xml
@@ -10,7 +10,6 @@
-
diff --git a/config/alfresco/workflow/invitation-moderated.bpmn20.xml b/config/alfresco/workflow/invitation-moderated.bpmn20.xml
new file mode 100644
index 0000000000..96434fde26
--- /dev/null
+++ b/config/alfresco/workflow/invitation-moderated.bpmn20.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if (typeof bpm_workflowDueDate != 'undefined')
+ task.setVariable('bpm_dueDate', bpm_workflowDueDate);
+ if (typeof bpm_workflowPriority != 'undefined')
+ task.priority = bpm_workflowPriority;
+
+
+
+
+
+
+ execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
+ execution.setVariable('imwf_reviewer'), person.properties.userName);
+
+
+
+
+
+
+ ${bpm_groupAssignee.properties.authorityName}
+
+
+
+
+
+
+
+
+
+
+ ${wf_reviewOutcome == 'Approve'}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/alfresco/workflow/invitation-nominated.bpmn20.xml b/config/alfresco/workflow/invitation-nominated.bpmn20.xml
new file mode 100644
index 0000000000..598962cfea
--- /dev/null
+++ b/config/alfresco/workflow/invitation-nominated.bpmn20.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if (typeof bpm_workflowDueDate != 'undefined')
+ task.setVariable('bpm_dueDate', bpm_workflowDueDate);
+ if (typeof bpm_workflowPriority != 'undefined')
+ task.priority = bpm_workflowPriority;
+
+
+
+
+
+
+ ${bpm_assignee.properties.userName}
+
+
+
+
+
+
+
+
+
+ ${inwf_inviteOutcome == 'accept'}
+
+
+
+ ${inwf_inviteOutcome == 'reject'}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/invitation/AcceptInviteDelegate.java b/source/java/org/alfresco/repo/invitation/AcceptInviteDelegate.java
new file mode 100644
index 0000000000..fa375c7d16
--- /dev/null
+++ b/source/java/org/alfresco/repo/invitation/AcceptInviteDelegate.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.invitation;
+
+import org.activiti.engine.delegate.DelegateExecution;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
+import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
+import org.alfresco.repo.workflow.activiti.BaseJavaDelegate;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.cmr.site.SiteService;
+
+/**
+ * Activiti delegate that is executed when a invitation request has
+ * been accepted.
+ *
+ * @author Frederik Heremans
+ */
+public class AcceptInviteDelegate extends BaseJavaDelegate
+{
+ @Override
+ public void execute(DelegateExecution execution) throws Exception
+ {
+ final ServiceRegistry serviceRegistry = getServiceRegistry();
+ final MutableAuthenticationDao mutableAuthenticationDao = null; // TODO: (MutableAuthenticationDao) factory.getBean("authenticationDao");
+ final SiteService siteService = serviceRegistry.getSiteService();
+
+ final String inviteeUserName = (String) execution.getVariable(WorkflowModelNominatedInvitation.wfVarInviteeUserName);
+ final String siteShortName = (String) execution.getVariable(WorkflowModelNominatedInvitation.wfVarResourceName);
+ final String inviterUserName = (String) execution.getVariable(WorkflowModelNominatedInvitation.wfVarInviterUserName);
+ final String inviteeSiteRole = (String) execution.getVariable(WorkflowModelNominatedInvitation.wfVarRole);
+
+ // If there is already a user account for the invitee and that account
+ // is disabled, then enable the account because he/she has accepted the
+ // site invitation
+ if ((mutableAuthenticationDao.userExists(inviteeUserName))
+ && !(mutableAuthenticationDao.getEnabled(inviteeUserName)))
+ {
+ mutableAuthenticationDao.setEnabled(inviteeUserName, true);
+ }
+
+ // Add Invitee to Site with the site role that the inviter "started" the invite process with
+ AuthenticationUtil.runAs(new RunAsWork()
+ {
+ public Object doWork() throws Exception
+ {
+ siteService.setMembership(siteShortName,
+ inviteeUserName, inviteeSiteRole);
+
+ return null;
+ }
+
+ }, inviterUserName);
+ }
+}
diff --git a/source/java/org/alfresco/repo/invitation/CancelInviteDelegate.java b/source/java/org/alfresco/repo/invitation/CancelInviteDelegate.java
new file mode 100644
index 0000000000..b2ae7fc893
--- /dev/null
+++ b/source/java/org/alfresco/repo/invitation/CancelInviteDelegate.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.invitation;
+
+import org.activiti.engine.delegate.DelegateExecution;
+import org.alfresco.repo.invitation.site.InviteHelper;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
+import org.alfresco.repo.site.SiteModel;
+import org.alfresco.repo.workflow.activiti.BaseJavaDelegate;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.cmr.invitation.InvitationExceptionForbidden;
+import org.alfresco.service.cmr.security.PersonService;
+import org.alfresco.service.cmr.site.SiteService;
+import org.alfresco.service.cmr.workflow.WorkflowService;
+
+/**
+ * Activiti delegate that is executed when a invitation request has
+ * been cancelled.
+ *
+ * @author Frederik Heremans
+ */
+public class CancelInviteDelegate extends BaseJavaDelegate
+{
+ private final String MSG_NOT_SITE_MANAGER = "invitation.cancel.not_site_manager";
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception
+ {
+ // Get the invitee user name and site short name variables off the execution context
+ final String inviteeUserName = (String) execution.getVariable(
+ WorkflowModelNominatedInvitation.wfVarInviteeUserName);
+ final String siteShortName = (String) execution.getVariable(
+ WorkflowModelNominatedInvitation.wfVarResourceName);
+ final String inviteId = (String) execution.getVariable(
+ WorkflowModelNominatedInvitation.wfVarWorkflowInstanceId);
+
+ ServiceRegistry serviceRegistry = getServiceRegistry();
+ WorkflowService workflowService = serviceRegistry.getWorkflowService();
+ PersonService personService = serviceRegistry.getPersonService();
+ SiteService siteService = serviceRegistry.getSiteService();
+ MutableAuthenticationDao mutableAuthenticationDao = null; // TODO: (MutableAuthenticationDao) factory.getBean("authenticationDao");
+
+ String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser();
+ String currentUserSiteRole = siteService.getMembersRole(siteShortName, currentUserName);
+ if ((currentUserSiteRole == null) || (currentUserSiteRole.equals(SiteModel.SITE_MANAGER) == false))
+ {
+ // The current user is not the site manager
+ Object[] args = {currentUserName, inviteId, siteShortName};
+ throw new InvitationExceptionForbidden(MSG_NOT_SITE_MANAGER, args);
+ }
+
+ // Clean up invitee's user account and person node if they are not in use i.e.
+ // account is still disabled and there are no pending invites outstanding for the
+ // invitee
+ InviteHelper.cleanUpStaleInviteeResources(inviteeUserName, mutableAuthenticationDao, personService,
+ workflowService);
+
+ }
+}
diff --git a/source/java/org/alfresco/repo/invitation/ModeratedActionReject.java b/source/java/org/alfresco/repo/invitation/ModeratedActionReject.java
index f3c0bc3bb3..b0c09051e9 100644
--- a/source/java/org/alfresco/repo/invitation/ModeratedActionReject.java
+++ b/source/java/org/alfresco/repo/invitation/ModeratedActionReject.java
@@ -39,6 +39,8 @@ import org.springframework.beans.factory.BeanFactory;
* Note - uses a classpath template, rather than a data dictionary template,
* so behaves slightly differently to many other mail actions, and can't
* currently be localised easily.
+ *
+ * Same behaviour as {@link ModerationRejectDelegate}
*/
public class ModeratedActionReject extends JBPMSpringActionHandler
{
diff --git a/source/java/org/alfresco/repo/invitation/ModerationApproveDelegate.java b/source/java/org/alfresco/repo/invitation/ModerationApproveDelegate.java
new file mode 100644
index 0000000000..d2324c89b2
--- /dev/null
+++ b/source/java/org/alfresco/repo/invitation/ModerationApproveDelegate.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.invitation;
+
+import org.activiti.engine.delegate.DelegateExecution;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
+import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
+import org.alfresco.repo.workflow.activiti.BaseJavaDelegate;
+import org.alfresco.service.cmr.site.SiteService;
+
+/**
+ * Activiti delegate that is executed when a invitation-moderated process is reviewed
+ * and approved.
+ *
+ * @author Frederik Heremans
+ */
+public class ModerationApproveDelegate extends BaseJavaDelegate
+{
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception
+ {
+ final String resourceName = (String)execution.getVariable(WorkflowModelModeratedInvitation.wfVarResourceName);
+ final String inviteeUserName = (String)execution.getVariable(WorkflowModelModeratedInvitation.wfVarInviteeUserName);
+ final String inviteeRole = (String)execution.getVariable(WorkflowModelModeratedInvitation.wfVarInviteeRole);
+ final String reviewer = (String)execution.getVariable(WorkflowModelModeratedInvitation.wfVarReviewer);
+
+ final SiteService siteService = getServiceRegistry().getSiteService();
+
+ // Add invitee to the site
+ AuthenticationUtil.runAs(new RunAsWork()
+ {
+ public Object doWork() throws Exception
+ {
+ // Add the new user to the web site
+ siteService.setMembership(resourceName, inviteeUserName, inviteeRole);
+ return null;
+ }
+
+ }, reviewer);
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/invitation/ModerationRejectDelegate.java b/source/java/org/alfresco/repo/invitation/ModerationRejectDelegate.java
new file mode 100644
index 0000000000..fddfc3715e
--- /dev/null
+++ b/source/java/org/alfresco/repo/invitation/ModerationRejectDelegate.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.invitation;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.activiti.engine.delegate.DelegateExecution;
+import org.alfresco.repo.action.executer.MailActionExecuter;
+import org.alfresco.repo.workflow.activiti.BaseJavaDelegate;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.cmr.action.Action;
+import org.alfresco.service.cmr.action.ActionService;
+import org.alfresco.service.cmr.repository.TemplateService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Activiti delegate that is executed when a invitation-moderated process is reviewed
+ * and rejected.
+ *
+ * Same behaviour as {@link ModeratedActionReject}
+ *
+ * @author Frederik Heremans
+ */
+public class ModerationRejectDelegate extends BaseJavaDelegate
+{
+ private static final String REJECT_TEMPLATE = "/alfresco/bootstrap/invite/moderated-reject-email.ftl";
+ private static final Log logger = LogFactory.getLog(ModerationRejectDelegate.class);
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception
+ {
+ final ServiceRegistry serviceRegistry = getServiceRegistry();
+
+ // Do nothing if emails disabled.
+ if(!serviceRegistry.getInvitationService().isSendEmails())
+ {
+ return;
+ }
+
+ final String resourceType = (String) execution.getVariable(WorkflowModelModeratedInvitation.wfVarResourceType);
+ final String resourceName = (String) execution.getVariable(WorkflowModelModeratedInvitation.wfVarResourceName);
+ final String inviteeUserName = (String) execution.getVariable(WorkflowModelModeratedInvitation.wfVarInviteeUserName);
+ final String inviteeRole = (String) execution.getVariable(WorkflowModelModeratedInvitation.wfVarInviteeRole);
+ final String reviewer = (String) execution.getVariable(WorkflowModelModeratedInvitation.wfVarReviewer);
+ final String reviewComments = (String) execution.getVariable(WorkflowModelModeratedInvitation.wfVarReviewComments);
+
+ final TemplateService templateService = serviceRegistry.getTemplateService();
+ final ActionService actionService = serviceRegistry.getActionService();
+
+ // send email to the invitee if possible - but don't fail the rejection if email cannot be sent
+ try
+ {
+ // Build our model
+ Map model = new HashMap(8, 1.0f);
+ model.put("resourceName", resourceName);
+ model.put("resourceType", resourceType);
+ model.put("inviteeRole", inviteeRole);
+ model.put("reviewComments", reviewComments);
+ model.put("reviewer", reviewer);
+ model.put("inviteeUserName", inviteeUserName);
+
+ // Process the template
+ // Note - because we use a classpath template, rather than a Data Dictionary
+ // one, we can't have the MailActionExecutor do the template for us
+ String emailMsg = templateService.processTemplate("freemarker", REJECT_TEMPLATE, model);
+
+ // Send
+ Action emailAction = actionService.createAction("mail");
+ emailAction.setParameterValue(MailActionExecuter.PARAM_TO, inviteeUserName);
+ emailAction.setParameterValue(MailActionExecuter.PARAM_FROM, reviewer);
+ emailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, "Rejected invitation to web site:" + resourceName);
+ emailAction.setParameterValue(MailActionExecuter.PARAM_TEXT, emailMsg);
+ emailAction.setExecuteAsynchronously(true);
+ actionService.executeAction(emailAction, null);
+ }
+ catch(Exception e)
+ {
+ // Swallow exception
+ logger.error("unable to send reject email", e);
+ }
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/invitation/RejectInviteDelegate.java b/source/java/org/alfresco/repo/invitation/RejectInviteDelegate.java
new file mode 100644
index 0000000000..13a6e94d8b
--- /dev/null
+++ b/source/java/org/alfresco/repo/invitation/RejectInviteDelegate.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.invitation;
+
+import org.activiti.engine.delegate.DelegateExecution;
+import org.alfresco.repo.invitation.site.InviteHelper;
+import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
+import org.alfresco.repo.workflow.activiti.BaseJavaDelegate;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.cmr.security.PersonService;
+import org.alfresco.service.cmr.workflow.WorkflowService;
+
+/**
+ * Activiti delegate that is executed when a invitation request has
+ * been rejected.
+ *
+ * @author Frederik Heremans
+ */
+public class RejectInviteDelegate extends BaseJavaDelegate
+{
+ @Override
+ public void execute(DelegateExecution execution) throws Exception
+ {
+ // Get the invitee user name
+ final String inviteeUserName = (String) execution.getVariable(WorkflowModelNominatedInvitation.wfVarInviteeUserName);
+
+ ServiceRegistry serviceRegistry = getServiceRegistry();
+ WorkflowService workflowService = serviceRegistry.getWorkflowService();
+ PersonService personService = serviceRegistry.getPersonService();
+ MutableAuthenticationDao mutableAuthenticationDao = null; // TODO: (MutableAuthenticationDao) factory.getBean("authenticationDao");
+
+ // Clean up invitee's user account and person node if they are not in use i.e.
+ // account is still disabled and there are no pending invites outstanding for the
+ // invitee
+ InviteHelper.cleanUpStaleInviteeResources(inviteeUserName, mutableAuthenticationDao, personService,
+ workflowService);
+ }
+}
diff --git a/source/java/org/alfresco/repo/invitation/SendInvitationDelegate.java b/source/java/org/alfresco/repo/invitation/SendInvitationDelegate.java
new file mode 100644
index 0000000000..2c145d151c
--- /dev/null
+++ b/source/java/org/alfresco/repo/invitation/SendInvitationDelegate.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.invitation;
+
+import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarAcceptUrl;
+import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarInviteTicket;
+import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarInviteeGenPassword;
+import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarInviteeUserName;
+import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarInviterUserName;
+import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarRejectUrl;
+import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarResourceName;
+import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarRole;
+import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarServerPath;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.activiti.engine.delegate.DelegateExecution;
+import org.alfresco.repo.invitation.site.InviteSender;
+import org.alfresco.repo.jscript.ScriptNode;
+import org.alfresco.repo.workflow.WorkflowModel;
+import org.alfresco.repo.workflow.activiti.BaseJavaDelegate;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.namespace.NamespaceService;
+
+/**
+ * Activiti delegate that is executed when a invitation request has
+ * been sent.
+ *
+ * @author Frederik Heremans
+ */
+public class SendInvitationDelegate extends BaseJavaDelegate
+{
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception
+ {
+ ServiceRegistry serviceRegistry = getServiceRegistry();
+
+ if(serviceRegistry.getInvitationService().isSendEmails())
+ {
+ // TODO: Get hold of beans
+ // Repository repository = (Repository) factory.getBean("repositoryHelper");
+ // MessageService messageService = (MessageService) factory.getBean("messageService");
+ NamespaceService namespaceService = serviceRegistry.getNamespaceService();
+
+ // TODO: revive, once dependencies can be obtained
+ // InviteSender inviteSender = new InviteSender(serviceRegistry, repository, messageService);
+
+ Collection propertyNames = Arrays.asList(wfVarInviteeUserName,//
+ wfVarResourceName,//
+ wfVarInviterUserName,//
+ wfVarInviteeUserName,//
+ wfVarRole,//
+ wfVarInviteeGenPassword,//
+ wfVarResourceName,//
+ wfVarInviteTicket,//
+ wfVarServerPath,//
+ wfVarAcceptUrl,//
+ wfVarRejectUrl,
+ InviteSender.WF_INSTANCE_ID);
+ Map properties = makePropertiesFromContext(execution, propertyNames);
+
+ String packageName = WorkflowModel.ASSOC_PACKAGE.toPrefixString(namespaceService).replace(":", "_");
+ ScriptNode packageNode = (ScriptNode) execution.getVariable(packageName);
+ String packageRef = packageNode.getNodeRef().toString();
+ properties.put(InviteSender.WF_PACKAGE, packageRef);
+
+ String instanceName=WorkflowModel.PROP_WORKFLOW_INSTANCE_ID.toPrefixString(namespaceService).replace(":", "_");
+ String instanceId = (String) execution.getVariable(instanceName);
+ properties.put(InviteSender.WF_INSTANCE_ID, instanceId);
+
+ // TODO: revive, once dependencies can be obtained
+ //inviteSender.sendMail(properties);
+ }
+ }
+
+ private Map makePropertiesFromContext(DelegateExecution execution, Collection propertyNames)
+ {
+ Map props = new HashMap();
+ for (String name : propertyNames)
+ {
+ String value = (String) execution.getVariable(name);
+ props.put(name, value);
+ }
+ return props;
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/workflow/activiti/BaseJavaDelegate.java b/source/java/org/alfresco/repo/workflow/activiti/BaseJavaDelegate.java
new file mode 100644
index 0000000000..4d669814d7
--- /dev/null
+++ b/source/java/org/alfresco/repo/workflow/activiti/BaseJavaDelegate.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.workflow.activiti;
+
+import org.activiti.engine.delegate.JavaDelegate;
+import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
+import org.activiti.engine.impl.context.Context;
+import org.alfresco.service.ServiceRegistry;
+
+/**
+ * Base class for all {@link JavaDelegate} used in Alfresco-context.
+ *
+ * @author Frederik Heremans
+ */
+public abstract class BaseJavaDelegate implements JavaDelegate
+{
+ /**
+ * Get the service-registry from the current Activiti-context.
+ *
+ * @return service registry
+ */
+ protected ServiceRegistry getServiceRegistry()
+ {
+ ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
+ if(config != null)
+ {
+ // Fetch the registry that is injected in the activiti spring-configuration
+ ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
+ if(registry == null)
+ {
+ throw new RuntimeException(
+ "Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" +
+ ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
+ }
+ return registry;
+ }
+ throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context");
+ }
+
+}