mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
Merged SHA-SIMP-1 (5.1.0) to HEAD (5.1)
105016: SHA-935: Repository Invite Flow Changes - Added new invitation-add-direct.bpmn20.xml workflow - Added bootstrapping of new workflow - Changed InvitationServiceImpl to allow setting of workflows used - Added configuration of workflows used in invitationService bean - Added repository properties for default workflows - Changed InvitationServiceImpl.getWorkflowDefinition to take an enum argument - Changed abstract testNominatedInvitationExistingUser to accommodate both current and new invite flows - Added test of new flow to Activiti test git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@110788 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -201,6 +201,14 @@
|
|||||||
<prop key="mimetype">text/xml</prop>
|
<prop key="mimetype">text/xml</prop>
|
||||||
<prop key="redeploy">false</prop>
|
<prop key="redeploy">false</prop>
|
||||||
</props>
|
</props>
|
||||||
|
|
||||||
|
<!-- Activiti add site users service workflow definition -->
|
||||||
|
<props>
|
||||||
|
<prop key="engineId">activiti</prop>
|
||||||
|
<prop key="location">alfresco/workflow/invitation-add-direct.bpmn20.xml</prop>
|
||||||
|
<prop key="mimetype">text/xml</prop>
|
||||||
|
<prop key="redeploy">false</prop>
|
||||||
|
</props>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
<property name="models">
|
<property name="models">
|
||||||
|
@@ -21,6 +21,9 @@
|
|||||||
<ref bean="policyComponent" />
|
<ref bean="policyComponent" />
|
||||||
</property>
|
</property>
|
||||||
<property name="sysAdminParams" ref="sysAdminParams"/>
|
<property name="sysAdminParams" ref="sysAdminParams"/>
|
||||||
|
<property name="nominatedInvitationWorkflowId" value="${site.invite.nominated.workflowId}"/>
|
||||||
|
<property name="nominatedInvitationExternalWorkflowId" value="${site.invite.nominatedExternal.workflowId}"/>
|
||||||
|
<property name="moderatedInvitationWorkflowId" value="${site.invite.moderated.workflowId}"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Site service security bean -->
|
<!-- Site service security bean -->
|
||||||
|
@@ -769,6 +769,12 @@ deployment.service.targetLockTimeout=3600000
|
|||||||
#Invitation Service
|
#Invitation Service
|
||||||
# Should send emails as part of invitation process.
|
# Should send emails as part of invitation process.
|
||||||
notification.email.siteinvite=true
|
notification.email.siteinvite=true
|
||||||
|
# Moderated invite Activiti workflow
|
||||||
|
site.invite.moderated.workflowId=activiti$activitiInvitationModerated
|
||||||
|
# Add intneral users Activiti workflow (use activiti$activitiInvitationNominated to revert to requiring accept of invite for internal users)
|
||||||
|
site.invite.nominated.workflowId=activiti$activitiInvitationNominatedAddDirect
|
||||||
|
# Add external users Activiti workflow
|
||||||
|
site.invite.nominatedExternal.workflowId=activiti$activitiInvitationNominated
|
||||||
|
|
||||||
# Replication Service
|
# Replication Service
|
||||||
replication.enabled=false
|
replication.enabled=false
|
||||||
|
44
config/alfresco/workflow/invitation-add-direct.bpmn20.xml
Normal file
44
config/alfresco/workflow/invitation-add-direct.bpmn20.xml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
|
||||||
|
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
|
||||||
|
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
|
||||||
|
expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://alfresco.org/workflows/internal">
|
||||||
|
|
||||||
|
<process isExecutable="true" id="activitiInvitationNominatedAddDirect" name="Add user activiti invitation process">
|
||||||
|
|
||||||
|
<startEvent id="start" activiti:formKey="inwf:inviteToSiteTask" />
|
||||||
|
|
||||||
|
<!-- TODO: SHA-944: Change Order of Email Send to Be After Adding Site -->
|
||||||
|
<sequenceFlow id="flow1" sourceRef="start" targetRef="sendInvite" />
|
||||||
|
|
||||||
|
<serviceTask id="sendInvite" name="Send Invite" activiti:delegateExpression="${SendNominatedInviteDelegate}" />
|
||||||
|
|
||||||
|
<sequenceFlow id="flow2" sourceRef="sendInvite" targetRef="accepted" />
|
||||||
|
|
||||||
|
<serviceTask id="accepted" name="Accepted" activiti:delegateExpression="${AcceptNominatedInviteDelegate}" />
|
||||||
|
<sequenceFlow id="flow3" sourceRef="accepted" targetRef="inviteAccepted" />
|
||||||
|
|
||||||
|
<userTask id="inviteAccepted" name="Invitation Accepted"
|
||||||
|
activiti:formKey="inwf:acceptInviteTask" >
|
||||||
|
<extensionElements>
|
||||||
|
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
|
||||||
|
<activiti:field name="script">
|
||||||
|
<activiti:string>
|
||||||
|
if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
|
||||||
|
</activiti:string>
|
||||||
|
</activiti:field>
|
||||||
|
</activiti:taskListener>
|
||||||
|
</extensionElements>
|
||||||
|
<humanPerformer>
|
||||||
|
<resourceAssignmentExpression>
|
||||||
|
<formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
|
||||||
|
</resourceAssignmentExpression>
|
||||||
|
</humanPerformer>
|
||||||
|
</userTask>
|
||||||
|
|
||||||
|
<sequenceFlow id="flow4" sourceRef="inviteAccepted" targetRef="end" />
|
||||||
|
|
||||||
|
<endEvent id="end" />
|
||||||
|
</process>
|
||||||
|
|
||||||
|
</definitions>
|
@@ -126,6 +126,19 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
|
|
||||||
// Property determining whether emails should be sent.
|
// Property determining whether emails should be sent.
|
||||||
private boolean sendEmails = true;
|
private boolean sendEmails = true;
|
||||||
|
|
||||||
|
private enum InvitationWorkflowType { NOMINATED, NOMINATED_EXTERNAL, MODERATED };
|
||||||
|
|
||||||
|
// The nominated invite workflow definition to use for internal users
|
||||||
|
private String nominatedInvitationWorkflowId =
|
||||||
|
WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_ADD_DIRECT;
|
||||||
|
// The nominated invite workflow definition to use for external users
|
||||||
|
private String nominatedInvitationExternalWorkflowId =
|
||||||
|
WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_INVITE;
|
||||||
|
// The nominated invite workflow definition to use for internal users
|
||||||
|
private String moderatedInvitationWorkflowId =
|
||||||
|
WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the policy component
|
* Set the policy component
|
||||||
*
|
*
|
||||||
@@ -136,6 +149,36 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
this.policyComponent = policyComponent;
|
this.policyComponent = policyComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the nominated invite activiti workflow definition for internal users
|
||||||
|
*
|
||||||
|
* @param nominatedInvitationWorkflowId
|
||||||
|
*/
|
||||||
|
public void setNominatedInvitationWorkflowId(String nominatedInvitationWorkflowId)
|
||||||
|
{
|
||||||
|
this.nominatedInvitationWorkflowId = nominatedInvitationWorkflowId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the nominated invite activiti workflow definition for external users
|
||||||
|
*
|
||||||
|
* @param nominatedInvitationExternalWorkflowId
|
||||||
|
*/
|
||||||
|
public void setNominatedInvitationExternalWorkflowId(String nominatedInvitationExternalWorkflowId)
|
||||||
|
{
|
||||||
|
this.nominatedInvitationExternalWorkflowId = nominatedInvitationExternalWorkflowId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the moderated invite activiti workflow definition
|
||||||
|
*
|
||||||
|
* @param moderatedInvitationWorkflowId
|
||||||
|
*/
|
||||||
|
public void setModeratedInvitationWorkflowId(String moderatedInvitationWorkflowId)
|
||||||
|
{
|
||||||
|
this.moderatedInvitationWorkflowId = moderatedInvitationWorkflowId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that all necessary properties and services have been provided.
|
* Checks that all necessary properties and services have been provided.
|
||||||
*/
|
*/
|
||||||
@@ -170,7 +213,8 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
{
|
{
|
||||||
List<String> ret = new ArrayList<String>(3);
|
List<String> ret = new ArrayList<String>(3);
|
||||||
ret.add(WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME);
|
ret.add(WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME);
|
||||||
ret.add(WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI);
|
ret.add(WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_ADD_DIRECT);
|
||||||
|
ret.add(WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_INVITE);
|
||||||
ret.add(WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME);
|
ret.add(WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME);
|
||||||
ret.add(WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI);
|
ret.add(WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI);
|
||||||
// old deprecated invitation workflow.
|
// old deprecated invitation workflow.
|
||||||
@@ -1214,7 +1258,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
|
|
||||||
// get the moderated workflow
|
// get the moderated workflow
|
||||||
|
|
||||||
WorkflowDefinition wfDefinition = getWorkflowDefinition(false);
|
WorkflowDefinition wfDefinition = getWorkflowDefinition(InvitationWorkflowType.MODERATED);
|
||||||
return (ModeratedInvitation) startWorkflow(wfDefinition, workflowProps);
|
return (ModeratedInvitation) startWorkflow(wfDefinition, workflowProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1375,8 +1419,10 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
//
|
//
|
||||||
// Start the invite workflow with inviter, invitee and site properties
|
// Start the invite workflow with inviter, invitee and site properties
|
||||||
//
|
//
|
||||||
|
|
||||||
WorkflowDefinition wfDefinition = getWorkflowDefinition(true);
|
InvitationWorkflowType type =
|
||||||
|
created ? InvitationWorkflowType.NOMINATED_EXTERNAL : InvitationWorkflowType.NOMINATED;
|
||||||
|
WorkflowDefinition wfDefinition = getWorkflowDefinition(type);
|
||||||
|
|
||||||
// Get invitee person NodeRef to add as assignee
|
// Get invitee person NodeRef to add as assignee
|
||||||
NodeRef inviteeNodeRef = personService.getPerson(inviteeUserName);
|
NodeRef inviteeNodeRef = personService.getPerson(inviteeUserName);
|
||||||
@@ -1489,12 +1535,24 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return Activiti workflow definition unless Activiti engine is disabled.
|
* Return Activiti workflow definition unless Activiti engine is disabled.
|
||||||
* @param isNominated TODO
|
* @param type the workflow type
|
||||||
* @return WorkflowDefinition
|
* @return WorkflowDefinition
|
||||||
*/
|
*/
|
||||||
private WorkflowDefinition getWorkflowDefinition(boolean isNominated)
|
private WorkflowDefinition getWorkflowDefinition(InvitationWorkflowType type)
|
||||||
{
|
{
|
||||||
String workflowName = isNominated ? getNominatedDefinitionName() : getModeratedDefinitionName();
|
String workflowName = null;
|
||||||
|
if (type == InvitationWorkflowType.MODERATED)
|
||||||
|
{
|
||||||
|
workflowName = getModeratedDefinitionName();
|
||||||
|
}
|
||||||
|
else if (type == InvitationWorkflowType.NOMINATED_EXTERNAL)
|
||||||
|
{
|
||||||
|
workflowName = getNominatedExternalDefinitionName();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
workflowName = getNominatedDefinitionName();
|
||||||
|
}
|
||||||
WorkflowDefinition definition = workflowService.getDefinitionByName(workflowName);
|
WorkflowDefinition definition = workflowService.getDefinitionByName(workflowName);
|
||||||
if (definition == null)
|
if (definition == null)
|
||||||
{
|
{
|
||||||
@@ -1509,26 +1567,39 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
{
|
{
|
||||||
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||||
{
|
{
|
||||||
return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI;
|
return nominatedInvitationWorkflowId;
|
||||||
}
|
}
|
||||||
else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||||
{
|
{
|
||||||
return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME;
|
return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("None of the Workflow engines supported by teh InvitationService are currently enabled!");
|
throw new IllegalStateException("None of the Workflow engines supported by the InvitationService are currently enabled!");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getNominatedExternalDefinitionName()
|
||||||
|
{
|
||||||
|
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||||
|
{
|
||||||
|
return nominatedInvitationExternalWorkflowId;
|
||||||
|
}
|
||||||
|
else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||||
|
{
|
||||||
|
return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("None of the Workflow engines supported by the InvitationService are currently enabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getModeratedDefinitionName()
|
private String getModeratedDefinitionName()
|
||||||
{
|
{
|
||||||
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||||
{
|
{
|
||||||
return WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI;
|
return moderatedInvitationWorkflowId;
|
||||||
}
|
}
|
||||||
else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||||
{
|
{
|
||||||
return WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME;
|
return WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("None of the Workflow engines supported by teh InvitationService are currently enabled!");
|
throw new IllegalStateException("None of the Workflow engines supported by the InvitationService are currently enabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -34,7 +34,8 @@ public interface WorkflowModelNominatedInvitation
|
|||||||
|
|
||||||
// workflow definition name
|
// workflow definition name
|
||||||
public static final String WORKFLOW_DEFINITION_NAME = "jbpm$inwf:invitation-nominated";
|
public static final String WORKFLOW_DEFINITION_NAME = "jbpm$inwf:invitation-nominated";
|
||||||
public static final String WORKFLOW_DEFINITION_NAME_ACTIVITI = "activiti$activitiInvitationNominated";
|
public static final String WORKFLOW_DEFINITION_NAME_ACTIVITI_INVITE = "activiti$activitiInvitationNominated";
|
||||||
|
public static final String WORKFLOW_DEFINITION_NAME_ACTIVITI_ADD_DIRECT = "activiti$activitiInvitationNominatedAddDirect";
|
||||||
|
|
||||||
// tasks
|
// tasks
|
||||||
public static final QName WF_TASK_INVITE_TO_SITE = QName.createQName(NAMESPACE_URI, "inviteToSiteTask");
|
public static final QName WF_TASK_INVITE_TO_SITE = QName.createQName(NAMESPACE_URI, "inviteToSiteTask");
|
||||||
|
@@ -704,12 +704,28 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Nominated Invitation (for existing user, USER_ONE) read it.
|
* If requireAcceptance=true skip to C1
|
||||||
* search for it cancel it search for it again (and fail to find it) Create
|
*
|
||||||
* a Nominated Invitation read it. search for it reject it Create a
|
* A1. Create a Nominated Invitation (for existing user, USER_ONE)
|
||||||
* Nominated Invitation read it. accept it
|
* A2. Read it
|
||||||
|
* A3. Search for it.
|
||||||
|
* A4. Cancel it
|
||||||
|
* A5. Search for it again (and fail to find it)
|
||||||
|
*
|
||||||
|
* B1. Create a Nominated Invitation
|
||||||
|
* B2. Read it
|
||||||
|
* B3. Search for it
|
||||||
|
* B4. Reject it
|
||||||
|
*
|
||||||
|
* C1. Create a Nominated Invitation
|
||||||
|
* C2. Read it
|
||||||
|
* C3. Accept it
|
||||||
|
* C4. Verify ACL
|
||||||
|
*
|
||||||
|
* @param requireAcceptance true if a workflow requiring acceptance is being used
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void testNominatedInvitationExistingUser() throws Exception
|
protected void testNominatedInvitationExistingUser(boolean requireAcceptance) throws Exception
|
||||||
{
|
{
|
||||||
String inviteeUserName = USER_ONE;
|
String inviteeUserName = USER_ONE;
|
||||||
String inviteeEmail = USER_ONE_EMAIL;
|
String inviteeEmail = USER_ONE_EMAIL;
|
||||||
@@ -725,98 +741,103 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri
|
|||||||
|
|
||||||
authenticationComponent.setCurrentUser(USER_MANAGER);
|
authenticationComponent.setCurrentUser(USER_MANAGER);
|
||||||
|
|
||||||
NominatedInvitation nominatedInvitation = invitationService.inviteNominated(inviteeUserName, resourceType,
|
if (requireAcceptance)
|
||||||
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
{
|
||||||
|
NominatedInvitation nominatedInvitation = invitationService.inviteNominated(inviteeUserName, resourceType,
|
||||||
assertNotNull("nominated invitation is null", nominatedInvitation);
|
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
||||||
String inviteId = nominatedInvitation.getInviteId();
|
|
||||||
assertEquals("user name wrong", inviteeUserName, nominatedInvitation.getInviteeUserName());
|
assertNotNull("nominated invitation is null", nominatedInvitation);
|
||||||
assertEquals("resource type name wrong", resourceType, nominatedInvitation.getResourceType());
|
String inviteId = nominatedInvitation.getInviteId();
|
||||||
assertEquals("resource name wrong", resourceName, nominatedInvitation.getResourceName());
|
assertEquals("user name wrong", inviteeUserName, nominatedInvitation.getInviteeUserName());
|
||||||
assertEquals("role name wrong", inviteeRole, nominatedInvitation.getRoleName());
|
assertEquals("resource type name wrong", resourceType, nominatedInvitation.getResourceType());
|
||||||
assertEquals("server path wrong", serverPath, nominatedInvitation.getServerPath());
|
assertEquals("resource name wrong", resourceName, nominatedInvitation.getResourceName());
|
||||||
assertEquals("accept URL wrong", acceptUrl, nominatedInvitation.getAcceptUrl());
|
assertEquals("role name wrong", inviteeRole, nominatedInvitation.getRoleName());
|
||||||
assertEquals("reject URL wrong", rejectUrl, nominatedInvitation.getRejectUrl());
|
assertEquals("server path wrong", serverPath, nominatedInvitation.getServerPath());
|
||||||
|
assertEquals("accept URL wrong", acceptUrl, nominatedInvitation.getAcceptUrl());
|
||||||
// These values should be read from the person record
|
assertEquals("reject URL wrong", rejectUrl, nominatedInvitation.getRejectUrl());
|
||||||
assertEquals("first name wrong", inviteeFirstName, nominatedInvitation.getInviteeFirstName());
|
|
||||||
assertEquals("last name wrong", inviteeLastName, nominatedInvitation.getInviteeLastName());
|
// These values should be read from the person record
|
||||||
assertEquals("email name wrong", inviteeEmail, nominatedInvitation.getInviteeEmail());
|
assertEquals("first name wrong", inviteeFirstName, nominatedInvitation.getInviteeFirstName());
|
||||||
|
assertEquals("last name wrong", inviteeLastName, nominatedInvitation.getInviteeLastName());
|
||||||
/**
|
assertEquals("email name wrong", inviteeEmail, nominatedInvitation.getInviteeEmail());
|
||||||
* Now we have an invitation get it and check the details have been
|
|
||||||
* returned correctly.
|
/**
|
||||||
*/
|
* Now we have an invitation get it and check the details have been
|
||||||
NominatedInvitation invitation = (NominatedInvitation) invitationService.getInvitation(inviteId);
|
* returned correctly.
|
||||||
|
*/
|
||||||
assertNotNull("invitation is null", invitation);
|
NominatedInvitation invitation = (NominatedInvitation) invitationService.getInvitation(inviteId);
|
||||||
assertEquals("invite id wrong", inviteId, invitation.getInviteId());
|
|
||||||
assertEquals("user name wrong", inviteeUserName, nominatedInvitation.getInviteeUserName());
|
assertNotNull("invitation is null", invitation);
|
||||||
assertEquals("resource type name wrong", resourceType, invitation.getResourceType());
|
assertEquals("invite id wrong", inviteId, invitation.getInviteId());
|
||||||
assertEquals("resource name wrong", resourceName, invitation.getResourceName());
|
assertEquals("user name wrong", inviteeUserName, nominatedInvitation.getInviteeUserName());
|
||||||
assertEquals("role name wrong", inviteeRole, invitation.getRoleName());
|
assertEquals("resource type name wrong", resourceType, invitation.getResourceType());
|
||||||
assertEquals("server path wrong", serverPath, invitation.getServerPath());
|
assertEquals("resource name wrong", resourceName, invitation.getResourceName());
|
||||||
assertEquals("accept URL wrong", acceptUrl, invitation.getAcceptUrl());
|
assertEquals("role name wrong", inviteeRole, invitation.getRoleName());
|
||||||
assertEquals("reject URL wrong", rejectUrl, invitation.getRejectUrl());
|
assertEquals("server path wrong", serverPath, invitation.getServerPath());
|
||||||
|
assertEquals("accept URL wrong", acceptUrl, invitation.getAcceptUrl());
|
||||||
// These values should have been read from the DB
|
assertEquals("reject URL wrong", rejectUrl, invitation.getRejectUrl());
|
||||||
assertEquals("first name wrong", inviteeFirstName, invitation.getInviteeFirstName());
|
|
||||||
assertEquals("last name wrong", inviteeLastName, invitation.getInviteeLastName());
|
// These values should have been read from the DB
|
||||||
assertEquals("email name wrong", inviteeEmail, invitation.getInviteeEmail());
|
assertEquals("first name wrong", inviteeFirstName, invitation.getInviteeFirstName());
|
||||||
|
assertEquals("last name wrong", inviteeLastName, invitation.getInviteeLastName());
|
||||||
/**
|
assertEquals("email name wrong", inviteeEmail, invitation.getInviteeEmail());
|
||||||
* Search for the new invitation
|
|
||||||
*/
|
/**
|
||||||
List<Invitation> invitations = invitationService.listPendingInvitationsForResource(resourceType, resourceName);
|
* Search for the new invitation
|
||||||
assertTrue("invitations is empty", !invitations.isEmpty());
|
*/
|
||||||
|
List<Invitation> invitations = invitationService.listPendingInvitationsForResource(resourceType, resourceName);
|
||||||
NominatedInvitation firstInvite = (NominatedInvitation) invitations.get(0);
|
assertTrue("invitations is empty", !invitations.isEmpty());
|
||||||
assertEquals("invite id wrong", inviteId, firstInvite.getInviteId());
|
|
||||||
assertEquals("first name wrong", inviteeFirstName, firstInvite.getInviteeFirstName());
|
NominatedInvitation firstInvite = (NominatedInvitation) invitations.get(0);
|
||||||
assertEquals("last name wrong", inviteeLastName, firstInvite.getInviteeLastName());
|
assertEquals("invite id wrong", inviteId, firstInvite.getInviteId());
|
||||||
assertEquals("user name wrong", inviteeUserName, firstInvite.getInviteeUserName());
|
assertEquals("first name wrong", inviteeFirstName, firstInvite.getInviteeFirstName());
|
||||||
|
assertEquals("last name wrong", inviteeLastName, firstInvite.getInviteeLastName());
|
||||||
/**
|
assertEquals("user name wrong", inviteeUserName, firstInvite.getInviteeUserName());
|
||||||
* Now cancel the invitation
|
|
||||||
*/
|
/**
|
||||||
NominatedInvitation canceledInvitation = (NominatedInvitation) invitationService.cancel(inviteId);
|
* Now cancel the invitation
|
||||||
assertEquals("invite id wrong", inviteId, canceledInvitation.getInviteId());
|
*/
|
||||||
assertEquals("first name wrong", inviteeFirstName, canceledInvitation.getInviteeFirstName());
|
NominatedInvitation canceledInvitation = (NominatedInvitation) invitationService.cancel(inviteId);
|
||||||
assertEquals("last name wrong", inviteeLastName, canceledInvitation.getInviteeLastName());
|
assertEquals("invite id wrong", inviteId, canceledInvitation.getInviteId());
|
||||||
assertEquals("user name wrong", inviteeUserName, canceledInvitation.getInviteeUserName());
|
assertEquals("first name wrong", inviteeFirstName, canceledInvitation.getInviteeFirstName());
|
||||||
|
assertEquals("last name wrong", inviteeLastName, canceledInvitation.getInviteeLastName());
|
||||||
/**
|
assertEquals("user name wrong", inviteeUserName, canceledInvitation.getInviteeUserName());
|
||||||
* Do the query again - should no longer find anything
|
|
||||||
*/
|
/**
|
||||||
List<Invitation> it2 = invitationService.listPendingInvitationsForResource(resourceType, resourceName);
|
* Do the query again - should no longer find anything
|
||||||
assertTrue("invitations is not empty", it2.isEmpty());
|
*/
|
||||||
|
List<Invitation> it2 = invitationService.listPendingInvitationsForResource(resourceType, resourceName);
|
||||||
/**
|
assertTrue("invitations is not empty", it2.isEmpty());
|
||||||
* Now invite and reject
|
|
||||||
*/
|
/**
|
||||||
NominatedInvitation secondInvite = invitationService.inviteNominated(inviteeUserName, resourceType,
|
* Now invite and reject
|
||||||
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
*/
|
||||||
|
NominatedInvitation secondInvite = invitationService.inviteNominated(inviteeUserName, resourceType,
|
||||||
NominatedInvitation rejectedInvitation = (NominatedInvitation) invitationService.cancel(secondInvite
|
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
||||||
.getInviteId());
|
|
||||||
assertEquals("invite id wrong", secondInvite.getInviteId(), rejectedInvitation.getInviteId());
|
NominatedInvitation rejectedInvitation = (NominatedInvitation) invitationService.cancel(secondInvite
|
||||||
assertEquals("user name wrong", inviteeUserName, rejectedInvitation.getInviteeUserName());
|
.getInviteId());
|
||||||
|
assertEquals("invite id wrong", secondInvite.getInviteId(), rejectedInvitation.getInviteId());
|
||||||
List<Invitation> it3 = invitationService.listPendingInvitationsForResource(resourceType, resourceName);
|
assertEquals("user name wrong", inviteeUserName, rejectedInvitation.getInviteeUserName());
|
||||||
assertTrue("invitations is not empty", it3.isEmpty());
|
|
||||||
|
List<Invitation> it3 = invitationService.listPendingInvitationsForResource(resourceType, resourceName);
|
||||||
|
assertTrue("invitations is not empty", it3.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Now invite and accept
|
* Now invite and accept
|
||||||
*/
|
*/
|
||||||
NominatedInvitation thirdInvite = invitationService.inviteNominated(inviteeUserName, resourceType,
|
NominatedInvitation thirdInvite = invitationService.inviteNominated(inviteeUserName, resourceType,
|
||||||
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
||||||
|
if (requireAcceptance)
|
||||||
NominatedInvitation acceptedInvitation = (NominatedInvitation) invitationService.accept(thirdInvite
|
{
|
||||||
.getInviteId(), thirdInvite.getTicket());
|
NominatedInvitation acceptedInvitation = (NominatedInvitation) invitationService.accept(thirdInvite
|
||||||
assertEquals("invite id wrong", thirdInvite.getInviteId(), acceptedInvitation.getInviteId());
|
.getInviteId(), thirdInvite.getTicket());
|
||||||
assertEquals("first name wrong", inviteeFirstName, acceptedInvitation.getInviteeFirstName());
|
assertEquals("invite id wrong", thirdInvite.getInviteId(), acceptedInvitation.getInviteId());
|
||||||
assertEquals("last name wrong", inviteeLastName, acceptedInvitation.getInviteeLastName());
|
assertEquals("first name wrong", inviteeFirstName, acceptedInvitation.getInviteeFirstName());
|
||||||
assertEquals("user name wrong", inviteeUserName, acceptedInvitation.getInviteeUserName());
|
assertEquals("last name wrong", inviteeLastName, acceptedInvitation.getInviteeLastName());
|
||||||
|
assertEquals("user name wrong", inviteeUserName, acceptedInvitation.getInviteeUserName());
|
||||||
|
}
|
||||||
|
|
||||||
List<Invitation> it4 = invitationService.listPendingInvitationsForResource(resourceType, resourceName);
|
List<Invitation> it4 = invitationService.listPendingInvitationsForResource(resourceType, resourceName);
|
||||||
assertTrue("invitations is not empty", it4.isEmpty());
|
assertTrue("invitations is not empty", it4.isEmpty());
|
||||||
@@ -828,6 +849,13 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri
|
|||||||
assertEquals("role name wrong", inviteeRole, roleName);
|
assertEquals("role name wrong", inviteeRole, roleName);
|
||||||
siteService.removeMembership(resourceName, inviteeUserName);
|
siteService.removeMembership(resourceName, inviteeUserName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNominatedInvitationExistingUser() throws Exception
|
||||||
|
{
|
||||||
|
this.invitationServiceImpl.setNominatedInvitationWorkflowId(
|
||||||
|
WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_INVITE);
|
||||||
|
testNominatedInvitationExistingUser(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a moderated invitation Get it Search for it Cancel it Create a
|
* Create a moderated invitation Get it Search for it Cancel it Create a
|
||||||
|
@@ -116,4 +116,11 @@ public class ActivitiInvitationServiceImplTests extends AbstractInvitationServic
|
|||||||
// Disable Jbpm and enable Activiti
|
// Disable Jbpm and enable Activiti
|
||||||
workflowAdminService.setEnabledEngines(Arrays.asList(ActivitiConstants.ENGINE_ID));
|
workflowAdminService.setEnabledEngines(Arrays.asList(ActivitiConstants.ENGINE_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testAddExistingUser() throws Exception
|
||||||
|
{
|
||||||
|
this.invitationServiceImpl.setNominatedInvitationWorkflowId(
|
||||||
|
WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_ADD_DIRECT);
|
||||||
|
testNominatedInvitationExistingUser(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user