diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/action/running-action.delete.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/action/running-action.delete.desc.xml
new file mode 100644
index 0000000000..93d3be358d
--- /dev/null
+++ b/config/alfresco/templates/webscripts/org/alfresco/repository/action/running-action.delete.desc.xml
@@ -0,0 +1,8 @@
+
+ Cancel a Running Action
+ Requests the cancellation of a currently running action.
+ /api/running-action/{action_tracking_id}
+
+ admin
+ required
+
diff --git a/config/alfresco/web-scripts-application-context.xml b/config/alfresco/web-scripts-application-context.xml
index feb3a3b18a..4e6f921c56 100644
--- a/config/alfresco/web-scripts-application-context.xml
+++ b/config/alfresco/web-scripts-application-context.xml
@@ -913,6 +913,12 @@
parent="abstractActionWebScript">
+
+
+
+
.
+ */
+package org.alfresco.repo.web.scripts.action;
+
+import java.util.Map;
+
+import org.alfresco.service.cmr.action.ExecutionDetails;
+import org.alfresco.service.cmr.action.ExecutionSummary;
+import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.WebScriptException;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+/**
+ * @author Nick Burch
+ * @since 3.4
+ */
+public class RunningActionDelete extends AbstractActionWebscript
+{
+ @Override
+ protected Map buildModel(
+ RunningActionModelBuilder modelBuilder, WebScriptRequest req,
+ Status status, Cache cache) {
+ // Which action did they ask for?
+ String actionTrackingId =
+ req.getServiceMatch().getTemplateVars().get("action_tracking_id");
+
+ // Check it exists
+ ExecutionSummary action =
+ getSummaryFromKey(actionTrackingId);
+ if(action == null) {
+ throw new WebScriptException(
+ Status.STATUS_NOT_FOUND,
+ "No Running Action found with that tracking id"
+ );
+ }
+
+ ExecutionDetails details =
+ actionTrackingService.getExecutionDetails(action);
+ if(details == null) {
+ throw new WebScriptException(
+ Status.STATUS_NOT_FOUND,
+ "No Running Action found with that tracking id"
+ );
+ }
+
+ // Request the cancel
+ actionTrackingService.requestActionCancellation(action);
+
+ // Report it cancelled
+ throw new WebScriptException(
+ Status.STATUS_GONE,
+ "Action cancellation requested"
+ );
+ }
+}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/web/scripts/action/RunningActionRestApiTest.java b/source/java/org/alfresco/repo/web/scripts/action/RunningActionRestApiTest.java
index 510dd279db..c5381531ed 100644
--- a/source/java/org/alfresco/repo/web/scripts/action/RunningActionRestApiTest.java
+++ b/source/java/org/alfresco/repo/web/scripts/action/RunningActionRestApiTest.java
@@ -473,6 +473,54 @@ public class RunningActionRestApiTest extends BaseWebScriptTest
assertEquals("/" + URL_RUNNING_ACTION + key1, jsonRD.get("details"));
}
+ public void testRunningActionCancel() throws Exception
+ {
+ Response response;
+
+
+ // Not allowed if you're not an admin
+ AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getGuestUserName());
+ response = sendRequest(new DeleteRequest(URL_RUNNING_ACTION + "MadeUp"), Status.STATUS_UNAUTHORIZED);
+ assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
+
+ AuthenticationUtil.setFullyAuthenticatedUser(USER_NORMAL);
+ response = sendRequest(new DeleteRequest(URL_RUNNING_ACTION + "MadeUp"), Status.STATUS_UNAUTHORIZED);
+ assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
+
+
+ // If not found, you get a 404
+ AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
+ response = sendRequest(new DeleteRequest(URL_RUNNING_ACTION + "MadeUp"), Status.STATUS_NOT_FOUND);
+ assertEquals(Status.STATUS_NOT_FOUND, response.getStatus());
+
+
+ // Create one
+ ReplicationDefinition rd = replicationService.createReplicationDefinition("Test1", "Testing");
+ replicationService.saveReplicationDefinition(rd);
+ actionTrackingService.recordActionExecuting(rd);
+ String id = rd.getId();
+ String instance = Integer.toString( ((ActionImpl)rd).getExecutionInstance() );
+ String key = "replicationActionExecutor=" + id + "=" + instance;
+
+ assertEquals(false, actionTrackingService.isCancellationRequested(rd));
+
+
+ // Request it to cancel
+ response = sendRequest(new DeleteRequest(URL_RUNNING_ACTION + key), Status.STATUS_GONE);
+ assertEquals(Status.STATUS_GONE, response.getStatus());
+
+
+ // Check it was cancelled
+ assertEquals(true, actionTrackingService.isCancellationRequested(rd));
+
+
+ // Request again - no change
+ response = sendRequest(new DeleteRequest(URL_RUNNING_ACTION + key), Status.STATUS_GONE);
+ assertEquals(Status.STATUS_GONE, response.getStatus());
+
+ assertEquals(true, actionTrackingService.isCancellationRequested(rd));
+ }
+
@Override
protected void setUp() throws Exception