diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml
index 2e6730bd7a..e2b3b4bd95 100644
--- a/config/alfresco/bootstrap-context.xml
+++ b/config/alfresco/bootstrap-context.xml
@@ -174,6 +174,7 @@
+
diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-ACT.xml b/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-ACT.xml
index 85bb316799..138d67e4e6 100644
--- a/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-ACT.xml
+++ b/config/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-ACT.xml
@@ -1241,6 +1241,12 @@
END_TIME_
+
+
+ PROC_INST_ID_
+ ACT_ID_
+
+
diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-ACT.xml b/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-ACT.xml
index a13e6be1ab..5af28e4337 100644
--- a/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-ACT.xml
+++ b/config/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-ACT.xml
@@ -163,6 +163,12 @@
start_time_
+
+
+ proc_inst_id_
+ act_id_
+
+
diff --git a/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/add-activti-index-historic-activity.sql b/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/add-activti-index-historic-activity.sql
new file mode 100644
index 0000000000..6c211a94a5
--- /dev/null
+++ b/config/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/add-activti-index-historic-activity.sql
@@ -0,0 +1,23 @@
+--
+-- Title: Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
+-- Database: Generic
+-- Since: V4.2 Schema 6022
+-- Author: Frederik Heremans
+--
+-- Please contact support@alfresco.com if you need assistance with the upgrade.
+--
+
+-- Add index to historic activity table
+create index ACT_IDX_HI_ACT_INST_PROCINST on ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_); --(optional)
+
+--
+-- Record script finish
+--
+DELETE FROM alf_applied_patch WHERE id = 'patch.db-V4.2-add-activti-index-historic-activity';
+INSERT INTO alf_applied_patch
+ (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
+ VALUES
+ (
+ 'patch.db-V4.2-add-activti-index-historic-activity', 'Additional index created on ACT_HI_ACTINST',
+ 0, 6021, -1, 6022, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
+ );
\ No newline at end of file
diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties
index af3422b363..a721c90a2b 100644
--- a/config/alfresco/messages/patch-service.properties
+++ b/config/alfresco/messages/patch-service.properties
@@ -488,4 +488,5 @@ patch.increaseColumnSizeActiviti.description=ALF-14983 : Upgrade scripts to incr
patch.removeColumnActiviti.description=ALF-16038 : DB2: Upgrade script to remove ALFUSER.ACT_HI_ACTINST.OWNER_
patch.renameConstraintActiviti.description=ALF-15828 : DB2: Upgrade script to rename ACT_HI_PROCINST.PROC_INST_ID_ index
-patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
\ No newline at end of file
+patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
+patch.addActivtiIndexHistoricActivity.description=Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
\ No newline at end of file
diff --git a/config/alfresco/messages/patch-service_de.properties b/config/alfresco/messages/patch-service_de.properties
index a024453f50..cd07c4913d 100755
--- a/config/alfresco/messages/patch-service_de.properties
+++ b/config/alfresco/messages/patch-service_de.properties
@@ -487,4 +487,5 @@ patch.show.audit.success=show_audit.ftl was updated successfully
patch.increaseColumnSizeActiviti.description=ALF-14983 : Upgrade scripts to increase column sizes for Activiti
patch.removeColumnActiviti.description=ALF-16038 : DB2: Upgrade script to remove ALFUSER.ACT_HI_ACTINST.OWNER_
-patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
\ No newline at end of file
+patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
+patch.addActivtiIndexHistoricActivity.description=Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
\ No newline at end of file
diff --git a/config/alfresco/messages/patch-service_es.properties b/config/alfresco/messages/patch-service_es.properties
index a024453f50..cd07c4913d 100755
--- a/config/alfresco/messages/patch-service_es.properties
+++ b/config/alfresco/messages/patch-service_es.properties
@@ -487,4 +487,5 @@ patch.show.audit.success=show_audit.ftl was updated successfully
patch.increaseColumnSizeActiviti.description=ALF-14983 : Upgrade scripts to increase column sizes for Activiti
patch.removeColumnActiviti.description=ALF-16038 : DB2: Upgrade script to remove ALFUSER.ACT_HI_ACTINST.OWNER_
-patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
\ No newline at end of file
+patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
+patch.addActivtiIndexHistoricActivity.description=Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
\ No newline at end of file
diff --git a/config/alfresco/messages/patch-service_fr.properties b/config/alfresco/messages/patch-service_fr.properties
index a024453f50..cd07c4913d 100755
--- a/config/alfresco/messages/patch-service_fr.properties
+++ b/config/alfresco/messages/patch-service_fr.properties
@@ -487,4 +487,5 @@ patch.show.audit.success=show_audit.ftl was updated successfully
patch.increaseColumnSizeActiviti.description=ALF-14983 : Upgrade scripts to increase column sizes for Activiti
patch.removeColumnActiviti.description=ALF-16038 : DB2: Upgrade script to remove ALFUSER.ACT_HI_ACTINST.OWNER_
-patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
\ No newline at end of file
+patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
+patch.addActivtiIndexHistoricActivity.description=Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
\ No newline at end of file
diff --git a/config/alfresco/messages/patch-service_it.properties b/config/alfresco/messages/patch-service_it.properties
index a024453f50..cd07c4913d 100755
--- a/config/alfresco/messages/patch-service_it.properties
+++ b/config/alfresco/messages/patch-service_it.properties
@@ -487,4 +487,5 @@ patch.show.audit.success=show_audit.ftl was updated successfully
patch.increaseColumnSizeActiviti.description=ALF-14983 : Upgrade scripts to increase column sizes for Activiti
patch.removeColumnActiviti.description=ALF-16038 : DB2: Upgrade script to remove ALFUSER.ACT_HI_ACTINST.OWNER_
-patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
\ No newline at end of file
+patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
+patch.addActivtiIndexHistoricActivity.description=Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
\ No newline at end of file
diff --git a/config/alfresco/messages/patch-service_ja.properties b/config/alfresco/messages/patch-service_ja.properties
index a024453f50..cd07c4913d 100755
--- a/config/alfresco/messages/patch-service_ja.properties
+++ b/config/alfresco/messages/patch-service_ja.properties
@@ -487,4 +487,5 @@ patch.show.audit.success=show_audit.ftl was updated successfully
patch.increaseColumnSizeActiviti.description=ALF-14983 : Upgrade scripts to increase column sizes for Activiti
patch.removeColumnActiviti.description=ALF-16038 : DB2: Upgrade script to remove ALFUSER.ACT_HI_ACTINST.OWNER_
-patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
\ No newline at end of file
+patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
+patch.addActivtiIndexHistoricActivity.description=Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
\ No newline at end of file
diff --git a/config/alfresco/messages/patch-service_nl.properties b/config/alfresco/messages/patch-service_nl.properties
index a024453f50..cd07c4913d 100755
--- a/config/alfresco/messages/patch-service_nl.properties
+++ b/config/alfresco/messages/patch-service_nl.properties
@@ -487,4 +487,5 @@ patch.show.audit.success=show_audit.ftl was updated successfully
patch.increaseColumnSizeActiviti.description=ALF-14983 : Upgrade scripts to increase column sizes for Activiti
patch.removeColumnActiviti.description=ALF-16038 : DB2: Upgrade script to remove ALFUSER.ACT_HI_ACTINST.OWNER_
-patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
\ No newline at end of file
+patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
+patch.addActivtiIndexHistoricActivity.description=Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
\ No newline at end of file
diff --git a/config/alfresco/messages/patch-service_ru.properties b/config/alfresco/messages/patch-service_ru.properties
index a024453f50..cd07c4913d 100755
--- a/config/alfresco/messages/patch-service_ru.properties
+++ b/config/alfresco/messages/patch-service_ru.properties
@@ -487,4 +487,5 @@ patch.show.audit.success=show_audit.ftl was updated successfully
patch.increaseColumnSizeActiviti.description=ALF-14983 : Upgrade scripts to increase column sizes for Activiti
patch.removeColumnActiviti.description=ALF-16038 : DB2: Upgrade script to remove ALFUSER.ACT_HI_ACTINST.OWNER_
-patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
\ No newline at end of file
+patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
+patch.addActivtiIndexHistoricActivity.description=Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
\ No newline at end of file
diff --git a/config/alfresco/messages/patch-service_zh_CN.properties b/config/alfresco/messages/patch-service_zh_CN.properties
index a024453f50..cd07c4913d 100755
--- a/config/alfresco/messages/patch-service_zh_CN.properties
+++ b/config/alfresco/messages/patch-service_zh_CN.properties
@@ -487,4 +487,5 @@ patch.show.audit.success=show_audit.ftl was updated successfully
patch.increaseColumnSizeActiviti.description=ALF-14983 : Upgrade scripts to increase column sizes for Activiti
patch.removeColumnActiviti.description=ALF-16038 : DB2: Upgrade script to remove ALFUSER.ACT_HI_ACTINST.OWNER_
-patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
\ No newline at end of file
+patch.upgradeToActiviti5-10.description=Upgraded Activiti tables to 5.10 version
+patch.addActivtiIndexHistoricActivity.description=Additional index for activiti on historic activity (PROC_INST_ID_ and ACTIVITY_ID_)
\ No newline at end of file
diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml
index ebac8debb0..b63443dc13 100644
--- a/config/alfresco/patch/patch-services-context.xml
+++ b/config/alfresco/patch/patch-services-context.xml
@@ -3423,4 +3423,15 @@
+
+
+
+
+
+
+
+ classpath:alfresco/dbscripts/upgrade/4.2/${db.script.dialect}/add-activti-index-historic-activity.sql
+
+
+
diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties
index e3cc3f112b..bccbdb2178 100644
--- a/config/alfresco/version.properties
+++ b/config/alfresco/version.properties
@@ -19,4 +19,4 @@ version.build=@build-number@
# Schema number
-version.schema=6021
+version.schema=6022
diff --git a/source/java/org/alfresco/repo/workflow/AbstractMultitenantWorkflowTest.java b/source/java/org/alfresco/repo/workflow/AbstractMultitenantWorkflowTest.java
index 64f3875b8e..a3f713a3d0 100644
--- a/source/java/org/alfresco/repo/workflow/AbstractMultitenantWorkflowTest.java
+++ b/source/java/org/alfresco/repo/workflow/AbstractMultitenantWorkflowTest.java
@@ -54,7 +54,7 @@ import org.junit.Test;
*/
public abstract class AbstractMultitenantWorkflowTest extends BaseSpringTest
{
- private static final String XML = MimetypeMap.MIMETYPE_XML;
+ protected static final String XML = MimetypeMap.MIMETYPE_XML;
public static final String DEFAULT_ADMIN_PW = "admin";
private final static QName ADHOC_TASK = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "adhocTask");
@@ -64,15 +64,15 @@ public abstract class AbstractMultitenantWorkflowTest extends BaseSpringTest
private TenantAdminService tenantAdminService;
- private TenantService tenantService;
+ protected TenantService tenantService;
- private ServiceRegistry serviceRegistry;
+ protected ServiceRegistry serviceRegistry;
- private WorkflowService workflowService;
- private PersonService personService;
+ protected WorkflowService workflowService;
+ protected PersonService personService;
- private String user1;
- private String user2;
+ protected String user1;
+ protected String user2;
private WorkflowTestHelper wfTestHelper;
@@ -250,7 +250,7 @@ public abstract class AbstractMultitenantWorkflowTest extends BaseSpringTest
return definition;
}
- private InputStream getInputStream(String resource)
+ protected InputStream getInputStream(String resource)
{
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
return classLoader.getResourceAsStream(resource);
diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiMultitenantWorkflowTest.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiMultitenantWorkflowTest.java
index c7b9cb0e31..c568644097 100644
--- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiMultitenantWorkflowTest.java
+++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiMultitenantWorkflowTest.java
@@ -19,7 +19,14 @@
package org.alfresco.repo.workflow.activiti;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.workflow.AbstractMultitenantWorkflowTest;
+import org.alfresco.service.cmr.workflow.WorkflowDefinition;
+import org.alfresco.service.cmr.workflow.WorkflowDeployment;
import org.alfresco.service.namespace.QName;
/**
@@ -29,6 +36,10 @@ import org.alfresco.service.namespace.QName;
*/
public class ActivitiMultitenantWorkflowTest extends AbstractMultitenantWorkflowTest
{
+ private static final String CALLACTIVITY_SUBPROCESS_LOCATION = "activiti/test-callactivity-subprocess.bpmn20.xml";
+ private static final String CALLACTIVITY_MAINPROCESS_LOCATION = "activiti/test-callactivity-main.bpmn20.xml";
+
+
@Override
protected String getEngine()
{
@@ -52,5 +63,31 @@ public class ActivitiMultitenantWorkflowTest extends AbstractMultitenantWorkflow
{
return "activiti$activitiAdhoc";
}
-
+
+
+ /**
+ * ALF-15939: Call-activity should be multi-tenant aware.
+ */
+ public void testSubProcessCallActivity() throws Exception
+ {
+ // Run as User1 so tenant domain 1
+ AuthenticationUtil.setFullyAuthenticatedUser(user1);
+
+ // Deploy called sub-process on tenant domain 1
+ InputStream input = getInputStream(CALLACTIVITY_SUBPROCESS_LOCATION);
+ WorkflowDeployment deployment = workflowService.deployDefinition(getEngine(), input, XML);
+
+ // Deploy called main-process on tenant domain 1
+ input = getInputStream(CALLACTIVITY_MAINPROCESS_LOCATION);
+ deployment = workflowService.deployDefinition(getEngine(), input, XML);
+ WorkflowDefinition mainProcessDefinition = deployment.getDefinition();
+
+ // Start a process, which immediately tries to call the sub-process before returning control to thread
+ try {
+ workflowService.startWorkflow(mainProcessDefinition.getId(), new HashMap());
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail("No exception was expected while running process, but got: " + e.toString());
+ }
+ }
}
diff --git a/source/java/org/alfresco/repo/workflow/activiti/AlfrescoBpmnParseListener.java b/source/java/org/alfresco/repo/workflow/activiti/AlfrescoBpmnParseListener.java
index a1caf65e12..8014459ecc 100644
--- a/source/java/org/alfresco/repo/workflow/activiti/AlfrescoBpmnParseListener.java
+++ b/source/java/org/alfresco/repo/workflow/activiti/AlfrescoBpmnParseListener.java
@@ -22,6 +22,7 @@ import java.util.List;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.TaskListener;
+import org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.parser.BpmnParseListener;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
@@ -139,7 +140,17 @@ public class AlfrescoBpmnParseListener implements BpmnParseListener
@Override
public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity)
{
- // Nothing to do here
+ if (tenantService.isEnabled())
+ {
+ ActivityBehavior activityBehavior = activity.getActivityBehavior();
+ if(activityBehavior instanceof CallActivityBehavior)
+ {
+ CallActivityBehavior callActivity = (CallActivityBehavior) activityBehavior;
+
+ // Make name of process-definition to be called aware of the current tenant
+ callActivity.setProcessDefinitonKey(tenantService.getName(callActivity.getProcessDefinitonKey()));
+ }
+ }
}
@Override
diff --git a/source/test-resources/activiti/test-callactivity-main.bpmn20.xml b/source/test-resources/activiti/test-callactivity-main.bpmn20.xml
new file mode 100644
index 0000000000..4b4ac6b787
--- /dev/null
+++ b/source/test-resources/activiti/test-callactivity-main.bpmn20.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/source/test-resources/activiti/test-callactivity-subprocess.bpmn20.xml b/source/test-resources/activiti/test-callactivity-subprocess.bpmn20.xml
new file mode 100644
index 0000000000..122ad1ebc4
--- /dev/null
+++ b/source/test-resources/activiti/test-callactivity-subprocess.bpmn20.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file