diff --git a/config/test/alfresco/jbpm.cfg.xml b/config/test/alfresco/jbpm.cfg.xml new file mode 100644 index 0000000000..ef9e57ff75 --- /dev/null +++ b/config/test/alfresco/jbpm.cfg.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/test/alfresco/test-context.xml b/config/test/alfresco/test-context.xml new file mode 100644 index 0000000000..f765a5cd73 --- /dev/null +++ b/config/test/alfresco/test-context.xml @@ -0,0 +1,24 @@ + + + + + + + + + true + + + + classpath:alfresco/repository.properties + classpath:alfresco/version.properties + classpath:alfresco/domain/transaction.properties + classpath:alfresco/alfresco-shared.properties + file:D:\workspaces/projects/head/data/repository.properties + classpath:test/alfresco/test.properties + + + + + \ No newline at end of file diff --git a/config/test/alfresco/test-database-context.xml b/config/test/alfresco/test-database-context.xml new file mode 100644 index 0000000000..802b0b9ea4 --- /dev/null +++ b/config/test/alfresco/test-database-context.xml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + classpath:test/alfresco/test-hibernate-cfg.properties + + + + true + + + + + + + ${db.driver} + + + ${db.testurl} + + + ${db.username} + + + ${db.password} + + + ${db.pool.initial} + + + ${db.pool.max} + + + ${db.pool.min} + + + ${db.pool.idle} + + + false + + + ${db.txn.isolation} + + + ${db.pool.wait.max} + + + ${db.pool.validate.query} + + + ${db.pool.evict.interval} + + + ${db.pool.evict.idle.min} + + + ${db.pool.validate.borrow} + + + ${db.pool.validate.return} + + + ${db.pool.evict.validate} + + + ${db.pool.abandoned.detect} + + + ${db.pool.abandoned.time} + + + ${db.pool.statements.enable} + + + ${db.pool.statements.max} + + + + + + + + + + true + + + + + + + + + + + + org/jbpm/graph/action/Script.hbm.xml + org/jbpm/db/hibernate.queries.hbm.xml + org/jbpm/graph/def/ProcessDefinition.hbm.xml + org/jbpm/graph/def/Node.hbm.xml + org/jbpm/graph/def/Transition.hbm.xml + org/jbpm/graph/def/Event.hbm.xml + org/jbpm/graph/def/Action.hbm.xml + org/jbpm/graph/def/SuperState.hbm.xml + org/jbpm/graph/def/ExceptionHandler.hbm.xml + org/jbpm/instantiation/Delegation.hbm.xml + org/jbpm/graph/node/StartState.hbm.xml + org/jbpm/graph/node/EndState.hbm.xml + org/jbpm/graph/node/ProcessState.hbm.xml + org/jbpm/graph/node/Decision.hbm.xml + org/jbpm/graph/node/Fork.hbm.xml + org/alfresco/repo/workflow/jbpm/jbpm.Join.hbm.xml + org/jbpm/graph/node/State.hbm.xml + org/jbpm/graph/node/TaskNode.hbm.xml + org/jbpm/context/def/ContextDefinition.hbm.xml + org/jbpm/context/def/VariableAccess.hbm.xml + org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml + org/jbpm/taskmgmt/def/Swimlane.hbm.xml + org/jbpm/taskmgmt/def/Task.hbm.xml + org/jbpm/taskmgmt/def/TaskController.hbm.xml + org/jbpm/module/def/ModuleDefinition.hbm.xml + org/jbpm/bytes/ByteArray.hbm.xml + org/jbpm/file/def/FileDefinition.hbm.xml + org/alfresco/repo/workflow/jbpm/jbpm.CreateTimerAction.hbm.xml + org/jbpm/scheduler/def/CancelTimerAction.hbm.xml + org/jbpm/graph/exe/Comment.hbm.xml + org/jbpm/graph/exe/ProcessInstance.hbm.xml + org/jbpm/graph/exe/Token.hbm.xml + org/jbpm/graph/exe/RuntimeAction.hbm.xml + org/jbpm/module/exe/ModuleInstance.hbm.xml + org/jbpm/context/exe/ContextInstance.hbm.xml + org/jbpm/context/exe/TokenVariableMap.hbm.xml + org/jbpm/context/exe/VariableInstance.hbm.xml + org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml + org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml + org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml + org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml + org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml + org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml + org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml + org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml + org/jbpm/job/Job.hbm.xml + org/jbpm/job/Timer.hbm.xml + org/alfresco/repo/workflow/jbpm/jbpm.Timer.hbm.xml + org/jbpm/job/ExecuteNodeJob.hbm.xml + org/jbpm/job/ExecuteActionJob.hbm.xml + org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml + org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml + org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.hbm.xml + org/jbpm/taskmgmt/exe/PooledActor.hbm.xml + org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml + org/jbpm/logging/log/ProcessLog.hbm.xml + org/jbpm/logging/log/MessageLog.hbm.xml + org/jbpm/logging/log/CompositeLog.hbm.xml + org/jbpm/graph/log/ActionLog.hbm.xml + org/jbpm/graph/log/NodeLog.hbm.xml + org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml + org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml + org/jbpm/graph/log/ProcessStateLog.hbm.xml + org/jbpm/graph/log/SignalLog.hbm.xml + org/jbpm/graph/log/TokenCreateLog.hbm.xml + org/jbpm/graph/log/TokenEndLog.hbm.xml + org/jbpm/graph/log/TransitionLog.hbm.xml + org/jbpm/context/log/VariableLog.hbm.xml + org/jbpm/context/log/VariableCreateLog.hbm.xml + org/jbpm/context/log/VariableDeleteLog.hbm.xml + org/jbpm/context/log/VariableUpdateLog.hbm.xml + org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml + org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml + org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml + org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml + org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml + org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml + org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml + org/jbpm/taskmgmt/log/TaskLog.hbm.xml + org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml + org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml + org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml + org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml + org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml + org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml + org/jbpm/job/CleanUpProcessJob.hbm.xml + + + + + + + + + SYNCHRONIZATION_ALWAYS + + + + + + + diff --git a/config/test/alfresco/test-hibernate-cfg.properties b/config/test/alfresco/test-hibernate-cfg.properties new file mode 100644 index 0000000000..c22bdc7d69 --- /dev/null +++ b/config/test/alfresco/test-hibernate-cfg.properties @@ -0,0 +1,28 @@ +# +# Hibernate configuration +# + +# The Hibernate Dialect: +# As of V3.1, the dialect is automatically detected. +# It is still possible to set the dialect explicitly, for example: +hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect +hibernate.hbm2ddl.auto=update +hibernate.jdbc.use_streams_for_binary=true +hibernate.show_sql=false +hibernate.cache.use_query_cache=true +hibernate.max_fetch_depth=10 +hibernate.cache.provider_class=org.alfresco.repo.cache.InternalEhCacheManagerFactoryBean +hibernate.cache.use_second_level_cache=true +hibernate.default_batch_fetch_size=1 +hibernate.jdbc.batch_size=32 +hibernate.connection.release_mode=auto +hibernate.connection.isolation=2 + +#hibernate.query.substitutions= +#hibernate.jdbc.use_get_generated_keys=false + +# Oracle Schema Distinction: +# See https://issues.alfresco.com/jira/browse/ETHREEOH-680 +# Metadata queries to Oracle have to be limited by schema name +# when multiple instances of Alfresco are installed on an Oracle server. +#hibernate.default_schema= diff --git a/config/test/alfresco/test-workflow-context.xml b/config/test/alfresco/test-workflow-context.xml new file mode 100644 index 0000000000..149ad5ffba --- /dev/null +++ b/config/test/alfresco/test-workflow-context.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/test/alfresco/test.properties b/config/test/alfresco/test.properties new file mode 100644 index 0000000000..8ac58fc005 --- /dev/null +++ b/config/test/alfresco/test.properties @@ -0,0 +1,2 @@ +#DB url for tests. +db.testurl=${db.url}_test \ No newline at end of file diff --git a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java index 5bdc084d9c..96cebe3126 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngine.java @@ -2667,7 +2667,7 @@ public class JBPMEngine extends BPMEngine } catch (RuntimeException re) { - throw new IllegalStateException("Invalid company home path: " + companyHomePath + ": " + re.getMessage()); + throw new IllegalStateException("Invalid company home path: " + companyHomePath + ": " + re.getMessage(), re); } } else diff --git a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineTest.java b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineTest.java index 3a7f265401..da8efaf894 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineTest.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineTest.java @@ -73,7 +73,6 @@ public class JBPMEngineTest extends BaseSpringTest WorkflowPackageComponent packageComponent; WorkflowDefinition testWorkflowDef; NodeRef testNodeRef; - @Override protected void onSetUpInTransaction() throws Exception diff --git a/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineUnitTest.java b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineUnitTest.java new file mode 100644 index 0000000000..1fac4efa36 --- /dev/null +++ b/source/java/org/alfresco/repo/workflow/jbpm/JBPMEngineUnitTest.java @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2005-2009 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ + +package org.alfresco.repo.workflow.jbpm; + +import static org.mockito.Matchers.*; +import static org.mockito.Mockito.*; +import static org.springframework.transaction.TransactionDefinition.*; + +import java.io.IOException; +import java.io.Serializable; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import javax.transaction.NotSupportedException; +import javax.transaction.SystemException; + +import junit.framework.TestCase; + +import org.alfresco.repo.content.MimetypeMap; +import org.alfresco.repo.i18n.MessageService; +import org.alfresco.repo.tenant.TenantService; +import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.dictionary.TypeDefinition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.workflow.WorkflowDefinition; +import org.alfresco.service.cmr.workflow.WorkflowDeployment; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.NamespaceServiceMemoryImpl; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.transaction.SpringAwareUserTransaction; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.core.io.ClassPathResource; +import org.springframework.transaction.PlatformTransactionManager; +import org.springmodules.workflow.jbpm31.JbpmTemplate; + +/** + * JBPMEngine Unit Tests. + * + * @author Nick Smith + */ +public class JBPMEngineUnitTest extends TestCase +{ + private static final NodeRef companyHome = new NodeRef("for://test/home"); + + private static final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext( + new String[] { "classpath:test/alfresco/test-database-context.xml", + "classpath:test/alfresco/test-workflow-context.xml", }); + + private JBPMEngine engine = new JBPMEngine(); + + private WorkflowDefinition testWorkflowDef; + + private SpringAwareUserTransaction transaction; + + public void testStartWorkflowWithoutPackage() throws Exception + { + Map params = new HashMap(); + engine.startWorkflow(testWorkflowDef.getId(), params); + } + + @Override + protected void setUp() throws Exception + { + super.setUp(); + // Mock up various services. + NodeService nodeService = mock(NodeService.class); + TenantService tenantService = makeTenantService(); + NamespaceService namespaceService = makeNamespaceService(); + DictionaryService dictionaryService = makeDictionaryService(); + + // Add services to ServiceRegistry + ServiceRegistry serviceRegistry = mock(ServiceRegistry.class); + when(serviceRegistry.getNodeService()).thenReturn(nodeService); + when(serviceRegistry.getNamespaceService()).thenReturn(namespaceService); + when(serviceRegistry.getDictionaryService()).thenReturn(dictionaryService); + + JbpmTemplate jbpmTemplate = (JbpmTemplate) ctx.getBean("test_jbpm_template"); + // Set up the JBPMEngine. + engine.setJBPMTemplate(jbpmTemplate); + engine.setTenantService(tenantService); + engine.setNodeService(nodeService); + engine.setServiceRegistry(serviceRegistry); + engine.setNamespaceService(namespaceService); + engine.setMessageService(mock(MessageService.class)); + engine.setDictionaryService(dictionaryService); + engine.setEngineId("jbpm_test"); + + // Need to register JBPMEngine with bean factory so WorflowTaskInstance + // can load it. + ctx.getBeanFactory().registerSingleton("test_jbpm_engine", engine); + + // Deploy test workflow process definition to JBPM. + startTransaction(); + deployTestDefinition(); + } + + @SuppressWarnings("unchecked") + private DictionaryService makeDictionaryService() + { + DictionaryService service = mock(DictionaryService.class); + + // DictionaryService.getType(QName) always returns a mock + // TypeDefinition. + TypeDefinition typeDef = mock(TypeDefinition.class); + when(service.getType((QName) any())).thenReturn(typeDef); + + // DictionaryService.getAnonymousType(QName, Collection) + // always returns a mock TypeDefinition + when(service.getAnonymousType((QName) any(),// + (Collection) any()))// + .thenReturn(typeDef); + return service; + } + + private void startTransaction() throws NotSupportedException, SystemException + { + PlatformTransactionManager transactionManager = (PlatformTransactionManager) ctx + .getBean("testTransactionManager"); + transaction = new SpringAwareUserTransaction(transactionManager, false, ISOLATION_DEFAULT, + PROPAGATION_REQUIRED, 1000); + transaction.begin(); + } + + // deploy test process definition + private void deployTestDefinition() throws IOException + { + ClassPathResource processDef = new ClassPathResource( + "jbpmresources/test_processdefinition.xml"); + assertFalse(engine.isDefinitionDeployed(processDef.getInputStream(), + MimetypeMap.MIMETYPE_XML)); + WorkflowDeployment deployment = engine.deployDefinition(processDef.getInputStream(), + MimetypeMap.MIMETYPE_XML); + testWorkflowDef = deployment.definition; + assertNotNull(testWorkflowDef); + assertEquals("jbpm_test$test", testWorkflowDef.name); + assertEquals("1", testWorkflowDef.version); + assertTrue(engine.isDefinitionDeployed(processDef.getInputStream(), + MimetypeMap.MIMETYPE_XML)); + } + + private NamespaceService makeNamespaceService() + { + NamespaceServiceMemoryImpl namespace = new NamespaceServiceMemoryImpl(); + namespace.registerNamespace(NamespaceService.DEFAULT_PREFIX, NamespaceService.DEFAULT_URI); + namespace.registerNamespace("wf", "http://www.alfresco.org/model/bpm/1.0"); + return namespace; + } + + private TenantService makeTenantService() + { + TenantService tenantService = mock(TenantService.class); + + // Tenant Service.isEnabled() returns true. + when(tenantService.isEnabled()).thenReturn(true); + + // TenantService.getRootNode always returns companyHome. + when(tenantService.getRootNode((NodeService) any(),// + (SearchService) any(),// + (NamespaceService) any(),// + anyString(),// + (NodeRef) any()))// + .thenReturn(companyHome); + // Tenant Service.getName(String) will return the input param. + when(tenantService.getName(anyString())).thenAnswer(new Answer() + { + public String answer(InvocationOnMock invocation) throws Throwable + { + return (String) invocation.getArguments()[0]; + } + }); + when(tenantService.getBaseName(anyString())).thenAnswer(new Answer() + { + public String answer(InvocationOnMock invocation) throws Throwable + { + return (String) invocation.getArguments()[0]; + } + }); + return tenantService; + } + + @Override + protected void tearDown() throws Exception + { + super.tearDown(); + try + { + transaction.rollback(); + } + // To prevent rollback exceptions hiding other exceptions int he unit + // test. + catch (Throwable t) + { + System.out.println(t.getStackTrace()); + } + } +} diff --git a/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.hbm.xml b/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.hbm.xml index 8806b04c1c..e040ed2cc0 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.hbm.xml +++ b/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.hbm.xml @@ -6,8 +6,10 @@ - + + + diff --git a/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.java b/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.java index 483b6ddc7a..08fca56c4c 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstance.java @@ -22,6 +22,7 @@ * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" */ + package org.alfresco.repo.workflow.jbpm; import java.io.Serializable; @@ -39,7 +40,6 @@ import org.springframework.beans.factory.access.BeanFactoryLocator; import org.springframework.beans.factory.access.BeanFactoryReference; import org.springmodules.workflow.jbpm31.JbpmFactoryLocator; - /** * Alfresco specific implementation of a jBPM task instance * @@ -49,29 +49,11 @@ public class WorkflowTaskInstance extends TaskInstance { private static final long serialVersionUID = 6824116036569411964L; - /** Alfresco JBPM Engine */ + private String jbpmEngineName = null; + + /** Alfresco JBPM Engine */ private static JBPMEngine jbpmEngine = null; - /** - * Gets the JBPM Engine instance - * - * @return JBPM Engine - */ - private JBPMEngine getJBPMEngine() - { - if (jbpmEngine == null) - { - BeanFactoryLocator factoryLocator = new JbpmFactoryLocator(); - BeanFactoryReference factory = factoryLocator.useBeanFactory(null); - jbpmEngine = (JBPMEngine)factory.getFactory().getBean("jbpm_engine"); - if (jbpmEngine == null) - { - throw new WorkflowException("Failed to retrieve JBPMEngine component"); - } - } - return jbpmEngine; - } - /** * Construct */ @@ -92,13 +74,33 @@ public class WorkflowTaskInstance extends TaskInstance } /** - * Construct + * Sets jbpmEngineName which is used to get the JBPMEngine instance from a + * BeanFactory * - * @param taskName + * @param jbpmEngineName the jbpmEngineName to set */ - public WorkflowTaskInstance(String taskName) + public void setJbpmEngineName(String jbpmEngineName) { - super(taskName); + this.jbpmEngineName = jbpmEngineName; + } + + /** + * Gets the JBPM Engine instance + * + * @return JBPM Engine + */ + private JBPMEngine getJBPMEngine() + { + if (jbpmEngine == null) + { + BeanFactoryLocator factoryLocator = new JbpmFactoryLocator(); + BeanFactoryReference factory = factoryLocator.useBeanFactory(null); + if (jbpmEngineName == null) jbpmEngineName = "jbpm_engine"; + jbpmEngine = (JBPMEngine) factory.getFactory().getBean(jbpmEngineName); + if (jbpmEngine == null) { throw new WorkflowException( + "Failed to retrieve JBPMEngine component"); } + } + return jbpmEngine; } @Override @@ -111,30 +113,34 @@ public class WorkflowTaskInstance extends TaskInstance @Override public void end(Transition transition) { - // Force assignment of task if transition is taken, but no owner has yet been assigned + // Force assignment of task if transition is taken, but no owner has yet + // been assigned if (actorId == null) { actorId = AuthenticationUtil.getFullyAuthenticatedUser(); } - + // Set task properties on completion of task - // NOTE: Set properties first, so they're available during the submission of - // task variables to the process context + // NOTE: Set properties first, so they're available during the + // submission of + // task variables to the process context Map taskProperties = new HashMap(); - Transition outcome = (transition == null) ? token.getNode().getDefaultLeavingTransition() : transition; + Transition outcome = (transition == null) ? token.getNode().getDefaultLeavingTransition() + : transition; if (outcome != null) { taskProperties.put(WorkflowModel.PROP_OUTCOME, outcome.getName()); } taskProperties.put(WorkflowModel.PROP_STATUS, "Completed"); getJBPMEngine().setTaskProperties(this, taskProperties); - + // perform transition super.end(transition); - + if (getTask().getStartState() != null) { - // if ending a start task, push start task properties to process context, if not + // if ending a start task, push start task properties to process + // context, if not // already done getJBPMEngine().setDefaultWorkflowProperties(this); diff --git a/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstanceFactory.java b/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstanceFactory.java index 72c9647c4b..eec5719675 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstanceFactory.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/WorkflowTaskInstanceFactory.java @@ -22,13 +22,13 @@ * the FLOSS exception, and it is also available here: * http://www.alfresco.com/legal/licensing" */ + package org.alfresco.repo.workflow.jbpm; import org.jbpm.graph.exe.ExecutionContext; import org.jbpm.taskmgmt.TaskInstanceFactory; import org.jbpm.taskmgmt.exe.TaskInstance; - /** * jBPM factory for creating Alfresco derived Task Instances * @@ -38,12 +38,26 @@ public class WorkflowTaskInstanceFactory implements TaskInstanceFactory { private static final long serialVersionUID = -8097108150047415711L; + private String jbpmEngineName; - /* (non-Javadoc) - * @see org.jbpm.taskmgmt.TaskInstanceFactory#createTaskInstance(org.jbpm.graph.exe.ExecutionContext) + /** + * @param jbpmEngine the jbpmEngine to set + */ + public void setJbpmEngine(String jbpmEngine) + { + this.jbpmEngineName = jbpmEngine; + } + + /* + * (non-Javadoc) + * @see + * org.jbpm.taskmgmt.TaskInstanceFactory#createTaskInstance(org.jbpm.graph + * .exe.ExecutionContext) */ public TaskInstance createTaskInstance(ExecutionContext executionContext) { - return new WorkflowTaskInstance(); + WorkflowTaskInstance taskInstance = new WorkflowTaskInstance(); + taskInstance.setJbpmEngineName(jbpmEngineName); + return taskInstance; } } diff --git a/source/java/org/alfresco/repo/workflow/jbpm/jbpm.cfg.xml b/source/java/org/alfresco/repo/workflow/jbpm/jbpm.cfg.xml index 5711d2e273..cfc04ab3f1 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/jbpm.cfg.xml +++ b/source/java/org/alfresco/repo/workflow/jbpm/jbpm.cfg.xml @@ -1,47 +1,91 @@ - - - - - - - - - - - - - - - - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - diff --git a/source/java/org/alfresco/service/namespace/NamespaceServiceMemoryImpl.java b/source/java/org/alfresco/service/namespace/NamespaceServiceMemoryImpl.java new file mode 100644 index 0000000000..b6d27cc2ce --- /dev/null +++ b/source/java/org/alfresco/service/namespace/NamespaceServiceMemoryImpl.java @@ -0,0 +1,73 @@ +/* Copyright (C) 2005-2009 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ + +package org.alfresco.service.namespace; + +import java.util.Collection; + +import org.alfresco.util.OneToManyHashBiMap; + +/** + * A basic implementation of the NamespaceService interface intended for use in + * unit tests. This implementation does not persist any changes beyond the + * lifetime of the object. + * + * @author Nick Smith + */ +public class NamespaceServiceMemoryImpl implements NamespaceService +{ + // URI to Prefix map. + private final OneToManyHashBiMap map = new OneToManyHashBiMap(); + + public void registerNamespace(String prefix, String uri) + { + map.putSingleValue(uri, prefix); + } + + public void unregisterNamespace(String prefix) + { + map.removeValue(prefix); + } + + public String getNamespaceURI(String prefix) throws NamespaceException + { + return map.getKey(prefix); + } + + public Collection getPrefixes(String namespaceURI) throws NamespaceException + { + return map.get(namespaceURI); + } + + public Collection getPrefixes() + { + return map.flatValues(); + } + + public Collection getURIs() + { + return map.keySet(); + } + +} \ No newline at end of file diff --git a/source/test-resources/wcm/jbpm.cfg.xml b/source/test-resources/wcm/jbpm.cfg.xml index 7dd162ec07..ef9e57ff75 100644 --- a/source/test-resources/wcm/jbpm.cfg.xml +++ b/source/test-resources/wcm/jbpm.cfg.xml @@ -1,43 +1,83 @@ - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - -