mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.1.N (5.1.1) to HEAD (5.1)
120414 arebegea: Merged 5.0.N (5.0.4) to 5.1.N (5.1.1) 120386 abozianu: Merged DEV to 5.0.N (5.0.4) 120352 abozianu: MNT-14411 : Re-created user can't cancel created task - fix and unit test git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123619 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,13 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.web.scripts.workflow;
|
package org.alfresco.repo.web.scripts.workflow;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.workflow.WorkflowConstants;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowTask;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
@@ -120,19 +124,40 @@ public class WorkflowInstanceDelete extends AbstractWorkflowWebscript
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
String ownerName = null;
|
||||||
|
// Determine if the current user is the initiator of the workflow.
|
||||||
|
// Get the username of the initiator.
|
||||||
NodeRef initiator = wi.getInitiator();
|
NodeRef initiator = wi.getInitiator();
|
||||||
// determine if the current user is the initiator of the workflow
|
if (initiator != null && nodeService.exists(initiator))
|
||||||
if (initiator != null)
|
|
||||||
{
|
{
|
||||||
// get the username of the initiator
|
ownerName = (String) nodeService.getProperty(initiator, ContentModel.PROP_USERNAME);
|
||||||
String userName = (String)nodeService.getProperty(initiator, ContentModel.PROP_USERNAME);
|
}
|
||||||
|
else
|
||||||
// if the current user started the workflow allow the cancel action
|
{
|
||||||
if (currentUserName.equals(userName))
|
/*
|
||||||
|
* Fix for MNT-14411 : Re-created user can't cancel created task.
|
||||||
|
* If owner value can't be found on workflow properties
|
||||||
|
* because initiator nodeRef no longer exists get owner from
|
||||||
|
* initiatorhome nodeRef owner property.
|
||||||
|
*/
|
||||||
|
WorkflowTask startTask = workflowService.getStartTask(wi.getId());
|
||||||
|
Map<QName, Serializable> props = startTask.getProperties();
|
||||||
|
ownerName = (String) props.get(ContentModel.PROP_OWNER);
|
||||||
|
if (ownerName == null)
|
||||||
{
|
{
|
||||||
canEnd = true;
|
NodeRef initiatorHomeNodeRef = (NodeRef) props.get(QName.createQName("", WorkflowConstants.PROP_INITIATOR_HOME));
|
||||||
|
if (initiatorHomeNodeRef != null)
|
||||||
|
{
|
||||||
|
ownerName = (String) nodeService.getProperty(initiatorHomeNodeRef, ContentModel.PROP_OWNER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the current user started the workflow allow the cancel action
|
||||||
|
if (currentUserName.equals(ownerName))
|
||||||
|
{
|
||||||
|
canEnd = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return canEnd;
|
return canEnd;
|
||||||
}
|
}
|
||||||
|
@@ -1270,6 +1270,38 @@ public abstract class AbstractWorkflowRestApiTest extends BaseWebScriptTest
|
|||||||
sendRequest(new DeleteRequest(URL_WORKFLOW_INSTANCES + "/" + instanceId), Status.STATUS_NOT_FOUND);
|
sendRequest(new DeleteRequest(URL_WORKFLOW_INSTANCES + "/" + instanceId), Status.STATUS_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testWorkflowInstanceDeleteAsRecreatedUser() throws Exception
|
||||||
|
{
|
||||||
|
// Create task as USER1 and assign it to another user
|
||||||
|
personManager.setUser(USER1);
|
||||||
|
WorkflowDefinition adhocDef = workflowService.getDefinitionByName(getAdhocWorkflowDefinitionName());
|
||||||
|
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
|
||||||
|
params.put(WorkflowModel.ASSOC_ASSIGNEE, personManager.get(USER2));
|
||||||
|
Date dueDate = new Date();
|
||||||
|
params.put(WorkflowModel.PROP_DUE_DATE, dueDate);
|
||||||
|
params.put(WorkflowModel.PROP_PRIORITY, 1);
|
||||||
|
params.put(WorkflowModel.ASSOC_PACKAGE, packageRef);
|
||||||
|
params.put(WorkflowModel.PROP_CONTEXT, packageRef);
|
||||||
|
|
||||||
|
WorkflowPath adhocPath = workflowService.startWorkflow(adhocDef.getId(), params);
|
||||||
|
|
||||||
|
// Check the workflow was created
|
||||||
|
assertNotNull(workflowService.getWorkflowById(adhocPath.getInstance().getId()));
|
||||||
|
|
||||||
|
// Delete USER1
|
||||||
|
personManager.deletePerson(USER1);
|
||||||
|
|
||||||
|
// Recreate USER1
|
||||||
|
personManager.createPerson(USER1);
|
||||||
|
|
||||||
|
// Delete workflow
|
||||||
|
personManager.setUser(USER1);
|
||||||
|
sendRequest(new DeleteRequest(URL_WORKFLOW_INSTANCES + "/" + adhocPath.getInstance().getId()), Status.STATUS_OK);
|
||||||
|
|
||||||
|
// Check the workflow was deleted
|
||||||
|
assertNull(workflowService.getWorkflowById(adhocPath.getInstance().getId()));
|
||||||
|
}
|
||||||
|
|
||||||
public void testReviewProcessFlow() throws Exception
|
public void testReviewProcessFlow() throws Exception
|
||||||
{
|
{
|
||||||
// Approve path
|
// Approve path
|
||||||
|
Reference in New Issue
Block a user