mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Finished refactoring InvitationServiceImpl to use Activiti worklfow engine.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30084 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
<type name="imwf:moderatedInvitationSubmitTask">
|
<type name="imwf:moderatedInvitationSubmitTask">
|
||||||
<parent>bpm:startTask</parent>
|
<parent>bpm:startTask</parent>
|
||||||
<mandatory-aspects>
|
<mandatory-aspects>
|
||||||
<aspect>bpm:assignee</aspect>
|
|
||||||
<aspect>bpm:groupAssignee</aspect>
|
<aspect>bpm:groupAssignee</aspect>
|
||||||
<aspect>imwf:moderatedInvitationStats</aspect>
|
<aspect>imwf:moderatedInvitationStats</aspect>
|
||||||
</mandatory-aspects>
|
</mandatory-aspects>
|
||||||
@@ -40,7 +39,6 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<property name="imwf:reviewOutcome">
|
<property name="imwf:reviewOutcome">
|
||||||
<type>d:text</type>
|
<type>d:text</type>
|
||||||
<default>reject</default>
|
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint name="imwf:reviewOutcomeOptions"
|
<constraint name="imwf:reviewOutcomeOptions"
|
||||||
type="LIST">
|
type="LIST">
|
||||||
@@ -56,8 +54,7 @@
|
|||||||
</properties>
|
</properties>
|
||||||
<overrides>
|
<overrides>
|
||||||
<property name="bpm:outcomePropertyName">
|
<property name="bpm:outcomePropertyName">
|
||||||
<default>{http://www.alfresco.org/model/workflow/invite/moderated/1.0}reviewOutcome
|
<default>{http://www.alfresco.org/model/workflow/invite/moderated/1.0}reviewOutcome</default>
|
||||||
</default>
|
|
||||||
</property>
|
</property>
|
||||||
</overrides>
|
</overrides>
|
||||||
<mandatory-aspects>
|
<mandatory-aspects>
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
<activiti:field name="script">
|
<activiti:field name="script">
|
||||||
<activiti:string>
|
<activiti:string>
|
||||||
execution.setVariable('imwf_reviewOutcome', task.getVariable('imwf_reviewOutcome'));
|
execution.setVariable('imwf_reviewOutcome', task.getVariable('imwf_reviewOutcome'));
|
||||||
|
execution.setVariable('imwf_reviewer', person.properties.userName);
|
||||||
</activiti:string>
|
</activiti:string>
|
||||||
</activiti:field>
|
</activiti:field>
|
||||||
</activiti:taskListener>
|
</activiti:taskListener>
|
||||||
@@ -44,7 +45,7 @@
|
|||||||
<exclusiveGateway id="reviewDecision" name="Review Decision" />
|
<exclusiveGateway id="reviewDecision" name="Review Decision" />
|
||||||
|
|
||||||
<sequenceFlow id="flow3" sourceRef="reviewDecision" targetRef="approved">
|
<sequenceFlow id="flow3" sourceRef="reviewDecision" targetRef="approved">
|
||||||
<conditionExpression xsi:type="tFormalExpression">${imwf_reviewOutcome == 'Approve'}</conditionExpression>
|
<conditionExpression xsi:type="tFormalExpression">${imwf_reviewOutcome=='approve'}</conditionExpression>
|
||||||
</sequenceFlow>
|
</sequenceFlow>
|
||||||
|
|
||||||
<serviceTask id="approved" name="Approved" activiti:delegateExpression="${ApproveModeratedInviteDelegate}" />
|
<serviceTask id="approved" name="Approved" activiti:delegateExpression="${ApproveModeratedInviteDelegate}" />
|
||||||
|
@@ -57,16 +57,55 @@
|
|||||||
|
|
||||||
<sequenceFlow id="flow7" sourceRef="inviteGateway" targetRef="cancelled" />
|
<sequenceFlow id="flow7" sourceRef="inviteGateway" targetRef="cancelled" />
|
||||||
|
|
||||||
|
|
||||||
<serviceTask id="accepted" name="Accepted" activiti:delegateExpression="${AcceptNominatedInviteDelegate}" />
|
<serviceTask id="accepted" name="Accepted" activiti:delegateExpression="${AcceptNominatedInviteDelegate}" />
|
||||||
<sequenceFlow id="flow6" sourceRef="accepted" targetRef="end" />
|
<sequenceFlow id="flow6" sourceRef="accepted" targetRef="inviteAccepted" />
|
||||||
|
|
||||||
<serviceTask id="rejected" name="Rejected" activiti:delegateExpression="${RejectNominatedInviteDelegate}" />
|
<serviceTask id="rejected" name="Rejected" activiti:delegateExpression="${RejectNominatedInviteDelegate}" />
|
||||||
<sequenceFlow id="flow8" sourceRef="rejected" targetRef="end" />
|
<sequenceFlow id="flow8" sourceRef="rejected" targetRef="inviteRejected" />
|
||||||
|
|
||||||
<serviceTask id="cancelled" name="Cancelled" activiti:delegateExpression="${CancelNominatedInviteDelegate}" />
|
<serviceTask id="cancelled" name="Cancelled" activiti:delegateExpression="${CancelNominatedInviteDelegate}" />
|
||||||
<sequenceFlow id="flow9" sourceRef="cancelled" targetRef="end" />
|
<sequenceFlow id="flow9" sourceRef="cancelled" targetRef="end" />
|
||||||
|
|
||||||
|
<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.properties.userName}</formalExpression>
|
||||||
|
</resourceAssignmentExpression>
|
||||||
|
</humanPerformer>
|
||||||
|
</userTask>
|
||||||
|
|
||||||
|
<sequenceFlow id="flow10" sourceRef="inviteAccepted" targetRef="end" />
|
||||||
|
|
||||||
|
<userTask id="inviteRejected" name="Invitation Rejected"
|
||||||
|
activiti:formKey="inwf:rejectInviteTask" >
|
||||||
|
<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.properties.userName}</formalExpression>
|
||||||
|
</resourceAssignmentExpression>
|
||||||
|
</humanPerformer>
|
||||||
|
</userTask>
|
||||||
|
|
||||||
|
<sequenceFlow id="flow11" sourceRef="inviteRejected" targetRef="end" />
|
||||||
|
|
||||||
<endEvent id="end" />
|
<endEvent id="end" />
|
||||||
</process>
|
</process>
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
package org.alfresco.repo.invitation;
|
package org.alfresco.repo.invitation;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -31,12 +32,15 @@ import org.alfresco.repo.management.subsystems.ApplicationContextFactory;
|
|||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
|
import org.alfresco.repo.workflow.WorkflowAdminServiceImpl;
|
||||||
|
import org.alfresco.repo.workflow.activiti.ActivitiConstants;
|
||||||
|
import org.alfresco.repo.workflow.jbpm.JBPMEngine;
|
||||||
import org.alfresco.service.cmr.invitation.Invitation;
|
import org.alfresco.service.cmr.invitation.Invitation;
|
||||||
|
import org.alfresco.service.cmr.invitation.Invitation.ResourceType;
|
||||||
import org.alfresco.service.cmr.invitation.InvitationSearchCriteria;
|
import org.alfresco.service.cmr.invitation.InvitationSearchCriteria;
|
||||||
import org.alfresco.service.cmr.invitation.InvitationService;
|
import org.alfresco.service.cmr.invitation.InvitationService;
|
||||||
import org.alfresco.service.cmr.invitation.ModeratedInvitation;
|
import org.alfresco.service.cmr.invitation.ModeratedInvitation;
|
||||||
import org.alfresco.service.cmr.invitation.NominatedInvitation;
|
import org.alfresco.service.cmr.invitation.NominatedInvitation;
|
||||||
import org.alfresco.service.cmr.invitation.Invitation.ResourceType;
|
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.cmr.site.SiteInfo;
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
@@ -48,19 +52,20 @@ import org.springframework.util.ReflectionUtils;
|
|||||||
/**
|
/**
|
||||||
* Unit tests of Invitation Service
|
* Unit tests of Invitation Service
|
||||||
*/
|
*/
|
||||||
public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpringTest
|
||||||
{
|
{
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
private AuthenticationComponent authenticationComponent;
|
protected AuthenticationComponent authenticationComponent;
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
private InvitationService invitationService;
|
protected InvitationService invitationService;
|
||||||
private MailActionExecuter mailService;
|
private MailActionExecuter mailService;
|
||||||
private boolean startSendEmails;
|
private boolean startSendEmails;
|
||||||
private InvitationServiceImpl invitationServiceImpl;
|
protected InvitationServiceImpl invitationServiceImpl;
|
||||||
|
protected WorkflowAdminServiceImpl workflowAdminService;
|
||||||
|
|
||||||
private final static String SITE_SHORT_NAME_INVITE = "InvitationTest";
|
protected final static String SITE_SHORT_NAME_INVITE = "InvitationTest";
|
||||||
private final static String SITE_SHORT_NAME_RED = "InvitationTestRed";
|
protected final static String SITE_SHORT_NAME_RED = "InvitationTestRed";
|
||||||
private final static String SITE_SHORT_NAME_BLUE = "InvitationTestBlue";
|
protected final static String SITE_SHORT_NAME_BLUE = "InvitationTestBlue";
|
||||||
public final static String PERSON_FIRSTNAME = "InvitationFirstName123";
|
public final static String PERSON_FIRSTNAME = "InvitationFirstName123";
|
||||||
public final static String PERSON_FIRSTNAME_SPACES = "Invitation First\tName\n1\r2\r\n3";
|
public final static String PERSON_FIRSTNAME_SPACES = "Invitation First\tName\n1\r2\r\n3";
|
||||||
public final static String PERSON_LASTNAME = "InvitationLastName123";
|
public final static String PERSON_LASTNAME = "InvitationLastName123";
|
||||||
@@ -91,9 +96,15 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
this.personService = (PersonService) this.applicationContext.getBean("PersonService");
|
this.personService = (PersonService) this.applicationContext.getBean("PersonService");
|
||||||
this.authenticationComponent = (AuthenticationComponent) this.applicationContext
|
this.authenticationComponent = (AuthenticationComponent) this.applicationContext
|
||||||
.getBean("authenticationComponent");
|
.getBean("authenticationComponent");
|
||||||
this.invitationServiceImpl = (InvitationServiceImpl) this.applicationContext.getBean("invitationService");
|
this.invitationServiceImpl = (InvitationServiceImpl) applicationContext.getBean("invitationService");
|
||||||
|
this.workflowAdminService = (WorkflowAdminServiceImpl)applicationContext.getBean(WorkflowAdminServiceImpl.NAME);
|
||||||
|
|
||||||
this.startSendEmails = invitationServiceImpl.isSendEmails();
|
this.startSendEmails = invitationServiceImpl.isSendEmails();
|
||||||
|
|
||||||
|
// Check both workflow engines are active.
|
||||||
|
assertTrue(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID));
|
||||||
|
assertTrue(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID));
|
||||||
|
|
||||||
invitationServiceImpl.setSendEmails(true);
|
invitationServiceImpl.setSendEmails(true);
|
||||||
|
|
||||||
// TODO MER 20/11/2009 Bodge - turn off email sending to prevent errors
|
// TODO MER 20/11/2009 Bodge - turn off email sending to prevent errors
|
||||||
@@ -139,6 +150,10 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
@Override
|
@Override
|
||||||
protected void onTearDownInTransaction() throws Exception
|
protected void onTearDownInTransaction() throws Exception
|
||||||
{
|
{
|
||||||
|
// Make sure both workflow engines are enabled.
|
||||||
|
workflowAdminService.setActivitiEngineEnabled(true);
|
||||||
|
workflowAdminService.setJbpmEngineEnabled(true);
|
||||||
|
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
invitationServiceImpl.setSendEmails(startSendEmails);
|
invitationServiceImpl.setSendEmails(startSendEmails);
|
||||||
siteService.deleteSite(SITE_SHORT_NAME_INVITE);
|
siteService.deleteSite(SITE_SHORT_NAME_INVITE);
|
||||||
@@ -170,7 +185,9 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
*/
|
*/
|
||||||
public void testNominatedInvitationNewUser() throws Exception
|
public void testNominatedInvitationNewUser() throws Exception
|
||||||
{
|
{
|
||||||
Date startDate = new java.util.Date();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.SECOND, -1);
|
||||||
|
Date startDate = calendar.getTime();
|
||||||
|
|
||||||
String inviteeFirstName = PERSON_FIRSTNAME;
|
String inviteeFirstName = PERSON_FIRSTNAME;
|
||||||
String inviteeLastName = PERSON_LASTNAME;
|
String inviteeLastName = PERSON_LASTNAME;
|
||||||
@@ -200,8 +217,8 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
// sentInviteDate should be set to today
|
// sentInviteDate should be set to today
|
||||||
{
|
{
|
||||||
Date sentDate = nominatedInvitation.getSentInviteDate();
|
Date sentDate = nominatedInvitation.getSentInviteDate();
|
||||||
assertTrue("sentDate wrong - too early", sentDate.after(startDate));
|
assertTrue("sentDate wrong - too early. Start Date: " +startDate +"\nSent Date: "+sentDate, sentDate.after(startDate));
|
||||||
assertTrue("sentDate wrong - too late", sentDate.before(new Date(new Date().getTime() + 1)));
|
assertTrue("sentDate wrong - too lateStart Date: " +startDate +"\nSent Date: "+sentDate, sentDate.before(new Date(new Date().getTime() + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals("resource type name wrong", resourceType, nominatedInvitation.getResourceType());
|
assertEquals("resource type name wrong", resourceType, nominatedInvitation.getResourceType());
|
||||||
@@ -336,7 +353,9 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
*/
|
*/
|
||||||
public void testNominatedInvitationNewUserReject() throws Exception
|
public void testNominatedInvitationNewUserReject() throws Exception
|
||||||
{
|
{
|
||||||
Date startDate = new java.util.Date();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.SECOND, -1);
|
||||||
|
Date startDate = calendar.getTime();
|
||||||
|
|
||||||
String inviteeFirstName = PERSON_FIRSTNAME;
|
String inviteeFirstName = PERSON_FIRSTNAME;
|
||||||
String inviteeLastName = PERSON_LASTNAME;
|
String inviteeLastName = PERSON_LASTNAME;
|
||||||
@@ -365,8 +384,8 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
// sentInviteDate should be set to today
|
// sentInviteDate should be set to today
|
||||||
{
|
{
|
||||||
Date sentDate = nominatedInvitation.getSentInviteDate();
|
Date sentDate = nominatedInvitation.getSentInviteDate();
|
||||||
assertTrue("sentDate wrong - too early", sentDate.after(startDate));
|
assertTrue("sentDate wrong - too earlyStart Date: " +startDate +"\nSent Date: "+sentDate, sentDate.after(startDate));
|
||||||
assertTrue("sentDate wrong - too late", sentDate.before(new Date(new Date().getTime() + 1)));
|
assertTrue("sentDate wrong - too lateStart Date: " +startDate +"\nSent Date: "+sentDate, sentDate.before(new Date(new Date().getTime() + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -555,7 +574,7 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
String acceptUrl = "froob";
|
String acceptUrl = "froob";
|
||||||
String rejectUrl = "marshmallow";
|
String rejectUrl = "marshmallow";
|
||||||
|
|
||||||
this.authenticationComponent.setCurrentUser(USER_MANAGER);
|
authenticationComponent.setCurrentUser(USER_MANAGER);
|
||||||
|
|
||||||
NominatedInvitation nominatedInvitation = invitationService.inviteNominated(inviteeUserName, resourceType,
|
NominatedInvitation nominatedInvitation = invitationService.inviteNominated(inviteeUserName, resourceType,
|
||||||
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
||||||
@@ -657,7 +676,7 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
* Now verify access control list
|
* Now verify access control list
|
||||||
*/
|
*/
|
||||||
String roleName = siteService.getMembersRole(resourceName, inviteeUserName);
|
String roleName = siteService.getMembersRole(resourceName, inviteeUserName);
|
||||||
assertEquals("role name wrong", roleName, inviteeRole);
|
assertEquals("role name wrong", inviteeRole, roleName);
|
||||||
siteService.removeMembership(resourceName, inviteeUserName);
|
siteService.removeMembership(resourceName, inviteeUserName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -748,7 +767,7 @@ public class InvitationServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
* Now verify access control list
|
* Now verify access control list
|
||||||
*/
|
*/
|
||||||
String roleName = siteService.getMembersRole(resourceName, inviteeUserName);
|
String roleName = siteService.getMembersRole(resourceName, inviteeUserName);
|
||||||
assertEquals("role name wrong", roleName, inviteeRole);
|
assertEquals("role name wrong", inviteeRole, roleName);
|
||||||
siteService.removeMembership(resourceName, inviteeUserName);
|
siteService.removeMembership(resourceName, inviteeUserName);
|
||||||
|
|
||||||
}
|
}
|
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.invitation;
|
||||||
|
|
||||||
|
import org.alfresco.repo.site.SiteModel;
|
||||||
|
import org.alfresco.service.cmr.invitation.Invitation;
|
||||||
|
import org.alfresco.service.cmr.invitation.NominatedInvitation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nick Smith
|
||||||
|
* @since 4.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ActivitiInvitationServiceImplTests extends AbstractInvitationServiceImplTest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onSetUpInTransaction() throws Exception
|
||||||
|
{
|
||||||
|
super.onSetUpInTransaction();
|
||||||
|
|
||||||
|
// Add a few Jbpm invitations to check they dont' interfere with Activiti invitations.
|
||||||
|
workflowAdminService.setActivitiEngineEnabled(false);
|
||||||
|
|
||||||
|
String invitee = USER_ONE;
|
||||||
|
Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE;
|
||||||
|
String resourceName = SITE_SHORT_NAME_INVITE;
|
||||||
|
String inviteeRole = SiteModel.SITE_COLLABORATOR;
|
||||||
|
String serverPath = "wibble";
|
||||||
|
String acceptUrl = "froob";
|
||||||
|
String rejectUrl = "marshmallow";
|
||||||
|
|
||||||
|
authenticationComponent.setCurrentUser(USER_MANAGER);
|
||||||
|
|
||||||
|
// Start Nominated Invitation
|
||||||
|
invitationService.inviteNominated(invitee, resourceType,
|
||||||
|
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
||||||
|
|
||||||
|
// Start Moderated Invitation
|
||||||
|
invitationService.inviteModerated("", invitee,
|
||||||
|
resourceType, resourceName, inviteeRole);
|
||||||
|
|
||||||
|
// Disable Jbpm and enable Activiti
|
||||||
|
workflowAdminService.setJbpmEngineEnabled(false);
|
||||||
|
workflowAdminService.setActivitiEngineEnabled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.invitation;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test InvitationService with both engines enabled.
|
||||||
|
* @author Nick Smith
|
||||||
|
* @since 4.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FullInvitationServiceImplTests extends AbstractInvitationServiceImplTest
|
||||||
|
{
|
||||||
|
// See inheited tests.
|
||||||
|
}
|
@@ -38,8 +38,11 @@ import org.alfresco.repo.security.authentication.PasswordGenerator;
|
|||||||
import org.alfresco.repo.security.authentication.UserNameGenerator;
|
import org.alfresco.repo.security.authentication.UserNameGenerator;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
import org.alfresco.repo.workflow.WorkflowModel;
|
import org.alfresco.repo.workflow.WorkflowModel;
|
||||||
|
import org.alfresco.repo.workflow.activiti.ActivitiConstants;
|
||||||
|
import org.alfresco.repo.workflow.jbpm.JBPMEngine;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.invitation.Invitation;
|
import org.alfresco.service.cmr.invitation.Invitation;
|
||||||
|
import org.alfresco.service.cmr.invitation.Invitation.ResourceType;
|
||||||
import org.alfresco.service.cmr.invitation.InvitationException;
|
import org.alfresco.service.cmr.invitation.InvitationException;
|
||||||
import org.alfresco.service.cmr.invitation.InvitationExceptionForbidden;
|
import org.alfresco.service.cmr.invitation.InvitationExceptionForbidden;
|
||||||
import org.alfresco.service.cmr.invitation.InvitationExceptionNotFound;
|
import org.alfresco.service.cmr.invitation.InvitationExceptionNotFound;
|
||||||
@@ -68,6 +71,8 @@ import org.alfresco.service.namespace.NamespaceService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
|
import org.alfresco.util.collections.CollectionUtils;
|
||||||
|
import org.alfresco.util.collections.Function;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
@@ -531,197 +536,174 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
* @param criteria
|
* @param criteria
|
||||||
* @return the list of invitations
|
* @return the list of invitations
|
||||||
*/
|
*/
|
||||||
public List<Invitation> searchInvitation(InvitationSearchCriteria criteria)
|
public List<Invitation> searchInvitation(final InvitationSearchCriteria criteria)
|
||||||
{
|
{
|
||||||
List<Invitation> ret = new ArrayList<Invitation>();
|
List<WorkflowTask> searchResults = new ArrayList<WorkflowTask>();
|
||||||
|
|
||||||
InvitationSearchCriteria.InvitationType toSearch = criteria.getInvitationType();
|
InvitationSearchCriteria.InvitationType toSearch = criteria.getInvitationType();
|
||||||
|
|
||||||
/**
|
|
||||||
* Nominated search below
|
|
||||||
*/
|
|
||||||
if (toSearch == InvitationSearchCriteria.InvitationType.ALL
|
if (toSearch == InvitationSearchCriteria.InvitationType.ALL
|
||||||
|| toSearch == InvitationSearchCriteria.InvitationType.NOMINATED)
|
|| toSearch == InvitationSearchCriteria.InvitationType.NOMINATED)
|
||||||
{
|
{
|
||||||
// query for nominated workflow tasks by given parameters
|
searchResults.addAll(searchNominatedInvitations(criteria));
|
||||||
WorkflowTaskQuery wfTaskQuery = new WorkflowTaskQuery();
|
|
||||||
|
|
||||||
HashMap<QName, Object> wfNominatedQueryProps = new HashMap<QName, Object>(10, 1.0f);
|
|
||||||
|
|
||||||
if (criteria.getInviter() != null)
|
|
||||||
{
|
|
||||||
wfNominatedQueryProps.put(WorkflowModelNominatedInvitation.WF_PROP_INVITER_USER_NAME, criteria
|
|
||||||
.getInviter());
|
|
||||||
}
|
|
||||||
if (criteria.getInvitee() != null)
|
|
||||||
{
|
|
||||||
wfNominatedQueryProps.put(WorkflowModelNominatedInvitation.WF_PROP_INVITEE_USER_NAME, criteria
|
|
||||||
.getInvitee());
|
|
||||||
}
|
|
||||||
if (criteria.getResourceType() != null)
|
|
||||||
{
|
|
||||||
wfNominatedQueryProps.put(WorkflowModelNominatedInvitation.WF_PROP_RESOURCE_TYPE, criteria
|
|
||||||
.getResourceType().toString());
|
|
||||||
}
|
|
||||||
if (criteria.getResourceName() != null)
|
|
||||||
{
|
|
||||||
wfNominatedQueryProps.put(WorkflowModelNominatedInvitation.WF_PROP_RESOURCE_NAME, criteria
|
|
||||||
.getResourceName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// set workflow task query parameters
|
|
||||||
wfTaskQuery.setProcessCustomProps(wfNominatedQueryProps);
|
|
||||||
|
|
||||||
// query only active workflows
|
|
||||||
wfTaskQuery.setActive(Boolean.TRUE);
|
|
||||||
|
|
||||||
// pick up the pending task
|
|
||||||
wfTaskQuery.setTaskState(WorkflowTaskState.IN_PROGRESS);
|
|
||||||
wfTaskQuery.setTaskName(WorkflowModelNominatedInvitation.WF_TASK_INVITE_PENDING);
|
|
||||||
wfTaskQuery.setProcessName(WorkflowModelNominatedInvitation.WF_PROCESS_INVITE);
|
|
||||||
|
|
||||||
// query for invite workflow tasks
|
|
||||||
List<WorkflowTask> wf_invite_tasks = this.workflowService.queryTasks(wfTaskQuery);
|
|
||||||
|
|
||||||
for (WorkflowTask workflowTask : wf_invite_tasks)
|
|
||||||
{
|
|
||||||
// get workflow instance (ID) that pendingInvite task (in query
|
|
||||||
// result set)
|
|
||||||
|
|
||||||
String workflowId = workflowTask.getPath().getInstance().getId();
|
|
||||||
// TODO ALFCOM-2597 workflowTask.properties does not contain
|
|
||||||
// custom process values
|
|
||||||
// NominatedInvitationImpl result = new
|
|
||||||
// NominatedInvitationImpl(workflowTask.properties);
|
|
||||||
// result.setInviteId(workflowId);
|
|
||||||
// ret.add(result);
|
|
||||||
|
|
||||||
Invitation result = getInvitation(workflowId);
|
|
||||||
|
|
||||||
// TODO ALFCOM-2598 records are being returned that do not match
|
|
||||||
// properties
|
|
||||||
Set<QName> keys = wfNominatedQueryProps.keySet();
|
|
||||||
boolean crap = false;
|
|
||||||
for (QName key : keys)
|
|
||||||
{
|
|
||||||
if (key.equals(WorkflowModelNominatedInvitation.WF_PROP_INVITEE_USER_NAME))
|
|
||||||
{
|
|
||||||
Object val1 = wfNominatedQueryProps.get(key);
|
|
||||||
Object val2 = ((NominatedInvitation) result).getInviteeUserName();
|
|
||||||
if (!val1.equals(val2))
|
|
||||||
{
|
|
||||||
// Uh oh ... crap detected
|
|
||||||
crap = true;
|
|
||||||
logger.debug("ALFCOM-2598 key:" + key + "query:" + val1 + "task:" + val2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (key.equals(WorkflowModelNominatedInvitation.WF_PROP_RESOURCE_NAME))
|
|
||||||
{
|
|
||||||
Object val1 = wfNominatedQueryProps.get(key);
|
|
||||||
Object val2 = result.getResourceName();
|
|
||||||
if (!val1.equals(val2))
|
|
||||||
{
|
|
||||||
// Uh oh ... crap detected
|
|
||||||
crap = true;
|
|
||||||
logger.debug("ALFCOM-2598 key:" + key + "query:" + val1 + "task:" + val2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (key.equals(WorkflowModelNominatedInvitation.WF_PROP_RESOURCE_TYPE))
|
|
||||||
{
|
|
||||||
Object val1 = wfNominatedQueryProps.get(key);
|
|
||||||
Object val2 = result.getResourceType().toString();
|
|
||||||
if (!val1.equals(val2))
|
|
||||||
{
|
|
||||||
|
|
||||||
// Uh oh ... crap detected
|
|
||||||
crap = true;
|
|
||||||
logger.debug("ALFCOM-2598 key:" + key + "query:" + val1 + "task:" + val2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!crap)
|
|
||||||
{
|
|
||||||
ret.add(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Moderated search below
|
|
||||||
*/
|
|
||||||
if (toSearch == InvitationSearchCriteria.InvitationType.ALL
|
if (toSearch == InvitationSearchCriteria.InvitationType.ALL
|
||||||
|| toSearch == InvitationSearchCriteria.InvitationType.MODERATED)
|
|| toSearch == InvitationSearchCriteria.InvitationType.MODERATED)
|
||||||
{
|
{
|
||||||
// This is a moderated search
|
searchResults.addAll(searchModeratedInvitations(criteria));
|
||||||
WorkflowTaskQuery wfModeratedTaskQuery = new WorkflowTaskQuery();
|
}
|
||||||
// workflow query properties
|
|
||||||
HashMap<QName, Object> wfQueryModeratedProps = new HashMap<QName, Object>(3, 1.0f);
|
return CollectionUtils.transform(searchResults, new Function<WorkflowTask, Invitation>()
|
||||||
|
{
|
||||||
if (criteria.getInvitee() != null)
|
public Invitation apply(WorkflowTask task)
|
||||||
{
|
{
|
||||||
wfQueryModeratedProps.put(WorkflowModelModeratedInvitation.WF_PROP_INVITEE_USER_NAME, criteria
|
String invitationId = task.getPath().getInstance().getId();
|
||||||
.getInvitee());
|
Invitation invitation = getInvitation(invitationId);
|
||||||
}
|
return invitationMatches(invitation, criteria) ? invitation : null;
|
||||||
if (criteria.getResourceType() != null)
|
|
||||||
{
|
|
||||||
wfQueryModeratedProps.put(WorkflowModelModeratedInvitation.WF_PROP_RESOURCE_TYPE, criteria
|
|
||||||
.getResourceType().toString());
|
|
||||||
}
|
|
||||||
if (criteria.getResourceName() != null)
|
|
||||||
{
|
|
||||||
wfQueryModeratedProps.put(WorkflowModelModeratedInvitation.WF_PROP_RESOURCE_NAME, criteria
|
|
||||||
.getResourceName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set workflow task query parameters
|
});
|
||||||
wfModeratedTaskQuery.setProcessCustomProps(wfQueryModeratedProps);
|
}
|
||||||
|
|
||||||
// Current Review Moderated Tasks
|
/**
|
||||||
wfModeratedTaskQuery.setActive(Boolean.TRUE);
|
* Fix for ALF-2598
|
||||||
wfModeratedTaskQuery.setTaskState(WorkflowTaskState.IN_PROGRESS);
|
* @param invitation
|
||||||
wfModeratedTaskQuery.setTaskName(WorkflowModelModeratedInvitation.WF_REVIEW_TASK);
|
* @param criteria
|
||||||
wfModeratedTaskQuery.setProcessName(WorkflowModelModeratedInvitation.WF_PROCESS_INVITATION_MODERATED);
|
* @return
|
||||||
|
*/
|
||||||
// query for invite workflow tasks
|
private boolean invitationMatches(Invitation invitation, InvitationSearchCriteria criteria)
|
||||||
List<WorkflowTask> wf_moderated_tasks = this.workflowService.queryTasks(wfModeratedTaskQuery);
|
{
|
||||||
|
String invitee = criteria.getInvitee();
|
||||||
for (WorkflowTask workflowTask : wf_moderated_tasks)
|
if(invitee!= null &&
|
||||||
|
false == invitee.equals(invitation.getInviteeUserName()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String inviter = criteria.getInviter();
|
||||||
|
if(inviter!= null)
|
||||||
|
{
|
||||||
|
if (invitation instanceof NominatedInvitation)
|
||||||
{
|
{
|
||||||
// Add moderated invitations
|
NominatedInvitation modInvite = (NominatedInvitation) invitation;
|
||||||
String workflowId = workflowTask.getPath().getInstance().getId();
|
if(inviter.equals(modInvite.getInviterUserName()))
|
||||||
ModeratedInvitationImpl result = new ModeratedInvitationImpl(workflowId, workflowTask.getProperties());
|
|
||||||
|
|
||||||
// TODO ALFCOM-2598 records are being returned that do not match
|
|
||||||
// properties
|
|
||||||
Set<QName> keys = wfQueryModeratedProps.keySet();
|
|
||||||
boolean crap = false;
|
|
||||||
for (QName key : keys)
|
|
||||||
{
|
{
|
||||||
Object val1 = wfQueryModeratedProps.get(key);
|
return false;
|
||||||
Object val2 = workflowTask.getProperties().get(key);
|
|
||||||
if (!val1.equals(val2))
|
|
||||||
{
|
|
||||||
// crap detected
|
|
||||||
crap = true;
|
|
||||||
logger.debug("ALFCOM-2598 key:" + key + "query:" + val1 + "task:" + val2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO END ALFCOM-2598 Work-around
|
|
||||||
if (!crap)
|
|
||||||
{
|
|
||||||
ret.add(result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
String resourceName= criteria.getResourceName();
|
||||||
|
if(resourceName!= null &&
|
||||||
|
false == resourceName.equals(invitation.getResourceName()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<WorkflowTask> searchModeratedInvitations(InvitationSearchCriteria criteria)
|
||||||
|
{
|
||||||
|
WorkflowTaskQuery query = new WorkflowTaskQuery();
|
||||||
|
query.setTaskState(WorkflowTaskState.IN_PROGRESS);
|
||||||
|
|
||||||
|
Map<QName, Object> properties = new HashMap<QName, Object>();
|
||||||
|
String invitee = criteria.getInvitee();
|
||||||
|
if (invitee != null)
|
||||||
|
{
|
||||||
|
properties.put(WorkflowModelModeratedInvitation.WF_PROP_INVITEE_USER_NAME, invitee);
|
||||||
|
}
|
||||||
|
//TODO Uncomment if more than one ResourceType added.
|
||||||
|
// ResourceType resourceType = criteria.getResourceType();
|
||||||
|
// if (resourceType != null)
|
||||||
|
// {
|
||||||
|
// properties.put(WorkflowModelModeratedInvitation.WF_PROP_RESOURCE_TYPE, resourceType.toString());
|
||||||
|
// }
|
||||||
|
String resourceName = criteria.getResourceName();
|
||||||
|
if (resourceName != null)
|
||||||
|
{
|
||||||
|
properties.put(WorkflowModelModeratedInvitation.WF_PROP_RESOURCE_NAME, resourceName);
|
||||||
|
}
|
||||||
|
query.setProcessCustomProps(properties);
|
||||||
|
|
||||||
// End moderated invitation
|
query.setTaskName(WorkflowModelModeratedInvitation.WF_REVIEW_TASK);
|
||||||
|
|
||||||
return ret;
|
// query for invite workflow tasks
|
||||||
|
List<WorkflowTask> results = new ArrayList<WorkflowTask>();
|
||||||
|
if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||||
|
{
|
||||||
|
query.setTaskName(WorkflowModelModeratedInvitation.WF_REVIEW_TASK);
|
||||||
|
List<WorkflowTask> jbpmTasks = this.workflowService.queryTasks(query);
|
||||||
|
if(jbpmTasks !=null)
|
||||||
|
{
|
||||||
|
results.addAll(jbpmTasks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||||
|
{
|
||||||
|
query.setTaskName(WorkflowModelModeratedInvitation.WF_ACTIVITI_REVIEW_TASK);
|
||||||
|
List<WorkflowTask> jbpmTasks = this.workflowService.queryTasks(query);
|
||||||
|
if(jbpmTasks !=null)
|
||||||
|
{
|
||||||
|
results.addAll(jbpmTasks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<WorkflowTask> searchNominatedInvitations(InvitationSearchCriteria criteria)
|
||||||
|
{
|
||||||
|
WorkflowTaskQuery query = new WorkflowTaskQuery();
|
||||||
|
query.setTaskState(WorkflowTaskState.IN_PROGRESS);
|
||||||
|
|
||||||
|
String invitee = criteria.getInvitee();
|
||||||
|
if(invitee != null)
|
||||||
|
{
|
||||||
|
query.setActorId(invitee);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<QName, Object> queryProps = new HashMap<QName, Object>();
|
||||||
|
String inviter = criteria.getInviter();
|
||||||
|
if (inviter != null)
|
||||||
|
{
|
||||||
|
queryProps.put(WorkflowModelNominatedInvitation.WF_PROP_INVITER_USER_NAME, inviter);
|
||||||
|
}
|
||||||
|
String resourceName = criteria.getResourceName();
|
||||||
|
if (resourceName != null)
|
||||||
|
{
|
||||||
|
queryProps.put(WorkflowModelNominatedInvitation.WF_PROP_RESOURCE_NAME, resourceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO uncomment if more ResourceTypes are created.
|
||||||
|
// ResourceType resourceType = criteria.getResourceType();
|
||||||
|
// if (resourceType != null)
|
||||||
|
// {
|
||||||
|
// wfNominatedQueryProps.put(WorkflowModelNominatedInvitation.WF_PROP_RESOURCE_TYPE,
|
||||||
|
// resourceType.name());
|
||||||
|
// }
|
||||||
|
// set workflow task query parameters
|
||||||
|
query.setProcessCustomProps(queryProps);
|
||||||
|
|
||||||
|
List<WorkflowTask> results = new ArrayList<WorkflowTask>();
|
||||||
|
if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||||
|
{
|
||||||
|
query.setTaskName(WorkflowModelNominatedInvitation.WF_TASK_INVITE_PENDING);
|
||||||
|
List<WorkflowTask> jbpmTasks = this.workflowService.queryTasks(query);
|
||||||
|
if(jbpmTasks !=null)
|
||||||
|
{
|
||||||
|
results.addAll(jbpmTasks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||||
|
{
|
||||||
|
query.setTaskName(WorkflowModelNominatedInvitation.WF_TASK_ACTIVIT_INVITE_PENDING);
|
||||||
|
List<WorkflowTask> jbpmTasks = this.workflowService.queryTasks(query);
|
||||||
|
if(jbpmTasks !=null)
|
||||||
|
{
|
||||||
|
results.addAll(jbpmTasks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementation methods below
|
// Implementation methods below
|
||||||
@@ -947,7 +929,6 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
String workflowDescription = generateWorkflowDescription(siteInfo, "invitation.moderated.workflow.description");
|
String workflowDescription = generateWorkflowDescription(siteInfo, "invitation.moderated.workflow.description");
|
||||||
|
|
||||||
Map<QName, Serializable> workflowProps = new HashMap<QName, Serializable>(16);
|
Map<QName, Serializable> workflowProps = new HashMap<QName, Serializable>(16);
|
||||||
workflowProps.put(WorkflowModel.ASSOC_ASSIGNEE, inviteeNodeRef);
|
|
||||||
workflowProps.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, workflowDescription);
|
workflowProps.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, workflowDescription);
|
||||||
workflowProps.put(WorkflowModelModeratedInvitation.ASSOC_GROUP_ASSIGNEE, roleGroup);
|
workflowProps.put(WorkflowModelModeratedInvitation.ASSOC_GROUP_ASSIGNEE, roleGroup);
|
||||||
workflowProps.put(WorkflowModelModeratedInvitation.WF_PROP_INVITEE_COMMENTS, inviteeComments);
|
workflowProps.put(WorkflowModelModeratedInvitation.WF_PROP_INVITEE_COMMENTS, inviteeComments);
|
||||||
@@ -1202,20 +1183,28 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
|||||||
|
|
||||||
private String getNominatedDefinitionName()
|
private String getNominatedDefinitionName()
|
||||||
{
|
{
|
||||||
// if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||||
// {
|
{
|
||||||
// return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI;
|
return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI;
|
||||||
// }
|
}
|
||||||
return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME;
|
else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||||
|
{
|
||||||
|
return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("None of the Workflow engines supported by teh 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 WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI;
|
||||||
// }
|
}
|
||||||
return WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME;
|
else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||||
|
{
|
||||||
|
return WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException("None of the Workflow engines supported by teh InvitationService are currently enabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -53,6 +53,7 @@ import org.alfresco.repo.workflow.WorkflowModel;
|
|||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ActionService;
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
|
import org.alfresco.service.cmr.invitation.Invitation;
|
||||||
import org.alfresco.service.cmr.invitation.InvitationExceptionForbidden;
|
import org.alfresco.service.cmr.invitation.InvitationExceptionForbidden;
|
||||||
import org.alfresco.service.cmr.invitation.InvitationService;
|
import org.alfresco.service.cmr.invitation.InvitationService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -255,11 +256,12 @@ public class InviteHelper implements InitializingBean
|
|||||||
* is still disabled and there are no outstanding pending invites for that invitee.
|
* is still disabled and there are no outstanding pending invites for that invitee.
|
||||||
*
|
*
|
||||||
* @param inviteeUserName
|
* @param inviteeUserName
|
||||||
|
* @param currentInviteId TODO
|
||||||
* @param authenticationservice
|
* @param authenticationservice
|
||||||
* @param personService
|
* @param personService
|
||||||
* @param workflowService
|
* @param workflowService
|
||||||
*/
|
*/
|
||||||
public void deleteAuthenticationIfUnused(final String inviteeUserName)
|
public void deleteAuthenticationIfUnused(final String inviteeUserName, final String currentInviteId)
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||||
{
|
{
|
||||||
@@ -267,8 +269,16 @@ public class InviteHelper implements InitializingBean
|
|||||||
{
|
{
|
||||||
// see if there are any pending invites (invite workflow instances with invitePending task in-progress)
|
// see if there are any pending invites (invite workflow instances with invitePending task in-progress)
|
||||||
// outstanding for given invitee user name
|
// outstanding for given invitee user name
|
||||||
List<WorkflowTask> pendingTasks = findInvitePendingTasks(inviteeUserName);
|
List<Invitation> pendingInvites = invitationService.listPendingInvitationsForInvitee(inviteeUserName);
|
||||||
boolean invitesPending = (pendingTasks != null) && (pendingTasks.size() > 0);
|
boolean invitesPending = CollectionUtils.isEmpty(pendingInvites)==false;
|
||||||
|
if(invitesPending && pendingInvites.size()==1)
|
||||||
|
{
|
||||||
|
Invitation pendingInvite = pendingInvites.get(0);
|
||||||
|
if(pendingInvite.getInviteId().equals(currentInviteId))
|
||||||
|
{
|
||||||
|
invitesPending = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if invitee's user account is still disabled and there are no pending invites outstanding
|
// if invitee's user account is still disabled and there are no pending invites outstanding
|
||||||
// for the invitee, then remove the account and delete the invitee's person node
|
// for the invitee, then remove the account and delete the invitee's person node
|
||||||
@@ -293,7 +303,7 @@ public class InviteHelper implements InitializingBean
|
|||||||
/**
|
/**
|
||||||
* @param executionVariables
|
* @param executionVariables
|
||||||
*/
|
*/
|
||||||
public void cancelInvitation(Map<String, Object> executionVariables)
|
public void cancelInvitation(Map<String, Object> executionVariables, String currentInviteId)
|
||||||
{
|
{
|
||||||
// Get the invitee user name and site short name variables off the execution context
|
// Get the invitee user name and site short name variables off the execution context
|
||||||
String inviteeUserName = (String) executionVariables.get(wfVarInviteeUserName);
|
String inviteeUserName = (String) executionVariables.get(wfVarInviteeUserName);
|
||||||
@@ -312,7 +322,7 @@ public class InviteHelper implements InitializingBean
|
|||||||
// Clean up invitee's user account and person node if they are not in use i.e.
|
// 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
|
// account is still disabled and there are no pending invites outstanding for the
|
||||||
// invitee
|
// invitee
|
||||||
deleteAuthenticationIfUnused(inviteeUserName);
|
deleteAuthenticationIfUnused(inviteeUserName, currentInviteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendNominatedInvitation(Map<String, Object> executionVariables)
|
public void sendNominatedInvitation(Map<String, Object> executionVariables)
|
||||||
|
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.repo.invitation;
|
||||||
|
|
||||||
|
import org.alfresco.repo.site.SiteModel;
|
||||||
|
import org.alfresco.service.cmr.invitation.Invitation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nick Smith
|
||||||
|
* @since 4.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class JbpmInvitationServiceImplTests extends AbstractInvitationServiceImplTest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void onSetUpInTransaction() throws Exception
|
||||||
|
{
|
||||||
|
super.onSetUpInTransaction();
|
||||||
|
|
||||||
|
// Add a few Jbpm invitations to check they dont' interfere with Activiti invitations.
|
||||||
|
workflowAdminService.setJbpmEngineEnabled(false);
|
||||||
|
|
||||||
|
String invitee = USER_ONE;
|
||||||
|
Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE;
|
||||||
|
String resourceName = SITE_SHORT_NAME_INVITE;
|
||||||
|
String inviteeRole = SiteModel.SITE_COLLABORATOR;
|
||||||
|
String serverPath = "wibble";
|
||||||
|
String acceptUrl = "froob";
|
||||||
|
String rejectUrl = "marshmallow";
|
||||||
|
|
||||||
|
authenticationComponent.setCurrentUser(USER_MANAGER);
|
||||||
|
|
||||||
|
// Start Nominated Invitation
|
||||||
|
invitationService.inviteNominated(invitee, resourceType,
|
||||||
|
resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl);
|
||||||
|
|
||||||
|
// Start Moderated Invitation
|
||||||
|
invitationService.inviteModerated("", invitee,
|
||||||
|
resourceType, resourceName, inviteeRole);
|
||||||
|
|
||||||
|
// Disable Jbpm and enable Activiti
|
||||||
|
workflowAdminService.setActivitiEngineEnabled(false);
|
||||||
|
workflowAdminService.setJbpmEngineEnabled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -21,6 +21,7 @@ package org.alfresco.repo.invitation.activiti;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.activiti.engine.delegate.DelegateExecution;
|
import org.activiti.engine.delegate.DelegateExecution;
|
||||||
|
import org.alfresco.repo.workflow.activiti.ActivitiConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activiti delegate that is executed when a invitation request has
|
* Activiti delegate that is executed when a invitation request has
|
||||||
@@ -36,6 +37,7 @@ public class CancelNominatedInviteDelegate extends AbstractInvitationDelegate
|
|||||||
public void execute(DelegateExecution execution) throws Exception
|
public void execute(DelegateExecution execution) throws Exception
|
||||||
{
|
{
|
||||||
Map<String, Object> executionVariables = execution.getVariables();
|
Map<String, Object> executionVariables = execution.getVariables();
|
||||||
inviteHelper.cancelInvitation(executionVariables);
|
String invitationId = ActivitiConstants.ENGINE_ID + "$" + execution.getProcessInstanceId();
|
||||||
|
inviteHelper.cancelInvitation(executionVariables, invitationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,21 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.invitation.activiti;
|
package org.alfresco.repo.invitation.activiti;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.activiti.engine.delegate.DelegateExecution;
|
import org.activiti.engine.delegate.DelegateExecution;
|
||||||
import org.alfresco.repo.action.executer.MailActionExecuter;
|
|
||||||
import org.alfresco.repo.invitation.ModeratedActionReject;
|
import org.alfresco.repo.invitation.ModeratedActionReject;
|
||||||
import org.alfresco.repo.invitation.WorkflowModelModeratedInvitation;
|
|
||||||
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
|
* Activiti delegate that is executed when a invitation-moderated process is reviewed
|
||||||
@@ -46,61 +33,10 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
*/
|
*/
|
||||||
public class RejectModeratedInviteDelegate extends AbstractInvitationDelegate
|
public class RejectModeratedInviteDelegate extends AbstractInvitationDelegate
|
||||||
{
|
{
|
||||||
private static final String REJECT_TEMPLATE = "/alfresco/bootstrap/invite/moderated-reject-email.ftl";
|
|
||||||
private static final Log logger = LogFactory.getLog(RejectModeratedInviteDelegate.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(DelegateExecution execution) throws Exception
|
public void execute(DelegateExecution execution) throws Exception
|
||||||
{
|
{
|
||||||
final ServiceRegistry serviceRegistry = getServiceRegistry();
|
inviteHelper.rejectModeratedInvitation(execution.getVariables());
|
||||||
|
|
||||||
// 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<String, Serializable> model = new HashMap<String, Serializable>(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ package org.alfresco.repo.invitation.activiti;
|
|||||||
|
|
||||||
import org.activiti.engine.delegate.DelegateExecution;
|
import org.activiti.engine.delegate.DelegateExecution;
|
||||||
import org.alfresco.repo.invitation.WorkflowModelNominatedInvitation;
|
import org.alfresco.repo.invitation.WorkflowModelNominatedInvitation;
|
||||||
|
import org.alfresco.repo.workflow.activiti.ActivitiConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activiti delegate that is executed when a invitation request has
|
* Activiti delegate that is executed when a invitation request has
|
||||||
@@ -36,6 +37,7 @@ public class RejectNominatedInviteDelegate extends AbstractInvitationDelegate
|
|||||||
{
|
{
|
||||||
// Get the invitee user name
|
// Get the invitee user name
|
||||||
String inviteeUserName = (String) execution.getVariable(WorkflowModelNominatedInvitation.wfVarInviteeUserName);
|
String inviteeUserName = (String) execution.getVariable(WorkflowModelNominatedInvitation.wfVarInviteeUserName);
|
||||||
inviteHelper.deleteAuthenticationIfUnused(inviteeUserName);
|
String invitationId = ActivitiConstants.ENGINE_ID + "$" + execution.getProcessInstanceId();
|
||||||
|
inviteHelper.deleteAuthenticationIfUnused(inviteeUserName, invitationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,22 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.invitation.site;
|
package org.alfresco.repo.invitation.site;
|
||||||
|
|
||||||
import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarInviteeUserName;
|
|
||||||
import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarResourceName;
|
|
||||||
import static org.alfresco.repo.invitation.WorkflowModelNominatedInvitation.wfVarWorkflowInstanceId;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.workflow.jbpm.JBPMEngine;
|
||||||
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
|
|
||||||
import org.alfresco.service.ServiceRegistry;
|
|
||||||
import org.alfresco.service.cmr.invitation.InvitationExceptionForbidden;
|
|
||||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
|
||||||
import org.jbpm.graph.exe.ExecutionContext;
|
import org.jbpm.graph.exe.ExecutionContext;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains logic that gets executed when
|
* This class contains logic that gets executed when
|
||||||
@@ -53,6 +41,7 @@ public class CancelInviteAction extends AbstractInvitationAction
|
|||||||
public void execute(ExecutionContext executionContext) throws Exception
|
public void execute(ExecutionContext executionContext) throws Exception
|
||||||
{
|
{
|
||||||
Map<String, Object> executionVariables = executionContext.getContextInstance().getVariables();
|
Map<String, Object> executionVariables = executionContext.getContextInstance().getVariables();
|
||||||
inviteHelper.cancelInvitation(executionVariables);
|
String invitationId = JBPMEngine.ENGINE_ID + "$" + executionContext.getContextInstance().getProcessInstance().getId();
|
||||||
|
inviteHelper.cancelInvitation(executionVariables, invitationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,13 +19,8 @@
|
|||||||
package org.alfresco.repo.invitation.site;
|
package org.alfresco.repo.invitation.site;
|
||||||
|
|
||||||
import org.alfresco.repo.invitation.WorkflowModelNominatedInvitation;
|
import org.alfresco.repo.invitation.WorkflowModelNominatedInvitation;
|
||||||
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
|
import org.alfresco.repo.workflow.jbpm.JBPMEngine;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
|
||||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
|
||||||
import org.jbpm.graph.exe.ExecutionContext;
|
import org.jbpm.graph.exe.ExecutionContext;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains logic that gets executed when
|
* This class contains logic that gets executed when
|
||||||
@@ -45,6 +40,7 @@ public class RejectInviteAction extends AbstractInvitationAction
|
|||||||
{
|
{
|
||||||
// get the invitee user name
|
// get the invitee user name
|
||||||
String inviteeUserName = (String) executionContext.getVariable(WorkflowModelNominatedInvitation.wfVarInviteeUserName);
|
String inviteeUserName = (String) executionContext.getVariable(WorkflowModelNominatedInvitation.wfVarInviteeUserName);
|
||||||
inviteHelper.deleteAuthenticationIfUnused(inviteeUserName);
|
String invitationId = JBPMEngine.ENGINE_ID + "$" + executionContext.getContextInstance().getProcessInstance().getId();
|
||||||
|
inviteHelper.deleteAuthenticationIfUnused(inviteeUserName, invitationId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,8 @@ import org.alfresco.service.cmr.workflow.WorkflowAdminService;
|
|||||||
*/
|
*/
|
||||||
public class WorkflowAdminServiceImpl implements WorkflowAdminService
|
public class WorkflowAdminServiceImpl implements WorkflowAdminService
|
||||||
{
|
{
|
||||||
|
public static final String NAME = "workflowAdminService";
|
||||||
|
|
||||||
private boolean jbpmEngineEnabled = true;
|
private boolean jbpmEngineEnabled = true;
|
||||||
private boolean activitiEngineEnabled = true;
|
private boolean activitiEngineEnabled = true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user