From a71b9e4191a3f0be35b558762407c38b1cdb9a76 Mon Sep 17 00:00:00 2001 From: David Caruana Date: Tue, 15 May 2007 17:43:50 +0000 Subject: [PATCH] WCM Content Launch: - submit process now allows for delayed submissions (launch date may be entered during submit) - in case of delayed submission, initiator is sent "submission pending" task with actions for cancelling submission and submitting now. On launch date, submission is made, removing "pending" task from initiator. - approved task is now submitted task Fixes to jBPM Timers: - fix to ensure task is ended when associated timer is fired - fix to ensure Alfresco transaction is active when triggered node action is executed git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5687 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../workflow/submit_processdefinition.xml | 51 ++++++++-- .../workflow/wcm-workflow-messages.properties | 10 ++ config/alfresco/workflow/wcmWorkflowModel.xml | 33 ++++++- .../workflow/jbpm/AlfrescoJobExecutor.java | 83 ++++++++++++++++ .../jbpm/AlfrescoJobExecutorThread.java | 97 +++++++++++++++++++ .../alfresco/repo/workflow/jbpm/jbpm.cfg.xml | 2 +- .../jbpmresources/test_timers.xml | 14 ++- 7 files changed, 280 insertions(+), 10 deletions(-) create mode 100644 source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJobExecutor.java create mode 100644 source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJobExecutorThread.java diff --git a/config/alfresco/workflow/submit_processdefinition.xml b/config/alfresco/workflow/submit_processdefinition.xml index f32aaf9a9a..4e8c752b48 100644 --- a/config/alfresco/workflow/submit_processdefinition.xml +++ b/config/alfresco/workflow/submit_processdefinition.xml @@ -111,22 +111,59 @@ - - - - + + #{wcmwf_approveCnt == wcmwf_reviewerCnt} - + + + + #{wcmwf_launchDate != null} + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/alfresco/workflow/wcm-workflow-messages.properties b/config/alfresco/workflow/wcm-workflow-messages.properties index d5de053868..54f07190ac 100644 --- a/config/alfresco/workflow/wcm-workflow-messages.properties +++ b/config/alfresco/workflow/wcm-workflow-messages.properties @@ -14,6 +14,10 @@ wcmwf_submit.node.parallelreview.transition.reject.title=Reject wcmwf_submit.node.parallelreview.transition.reject.description=Reject wcmwf_submit.node.parallelreview.transition.approve.title=Approve wcmwf_submit.node.parallelreview.transition.approve.description=Approve +wcmwf_submit.node.submitpending.transition.cancel.title=Abort Submission +wcmwf_submit.node.submitpending.transition.cancel.description=Abort Submission +wcmwf_submit.node.submitpending.transition.launch.title=Submit Now +wcmwf_submit.node.submitpending.transition.launch.description=Submit Now # Submit Task Definitions @@ -25,6 +29,12 @@ wcmwf_workflowmodel.type.wcmwf_rejectedTask.title=Rejected wcmwf_workflowmodel.type.wcmwf_rejectedTask.description=Rejected wcmwf_workflowmodel.type.wcmwf_approvedTask.title=Approved wcmwf_workflowmodel.type.wcmwf_approvedTask.description=Approved +wcmwf_workflowmodel.type.wcmwf_submittedTask.title=Submitted +wcmwf_workflowmodel.type.wcmwf_submittedTask.description=Submitted +wcmwf_workflowmodel.type.wcmwf_submitpendingTask.title=Submission Pending +wcmwf_workflowmodel.type.wcmwf_submitpendingTask.description=Submission Pending +wcmwf_workflowmodel.type.wcmwf_submitcancelledTask.title=Submission Aborted +wcmwf_workflowmodel.type.wcmwf_submitcancelledTask.description=Submission Aborted wcmwf_workflowmodel.property.wcmwf_reviewType.title=Type of Review wcmwf_workflowmodel.property.wcmwf_reviewType.description=Serial or parallel review diff --git a/config/alfresco/workflow/wcmWorkflowModel.xml b/config/alfresco/workflow/wcmWorkflowModel.xml index c3c7a232c8..d11b343552 100644 --- a/config/alfresco/workflow/wcmWorkflowModel.xml +++ b/config/alfresco/workflow/wcmWorkflowModel.xml @@ -96,7 +96,38 @@ - + + wcmwf:workflowTask + + bpm:assignees + wcmwf:reviewType + wcmwf:reviewInfo + wcmwf:submission + + + + + wcmwf:workflowTask + + bpm:assignees + wcmwf:reviewType + wcmwf:reviewInfo + wcmwf:submission + + + + + wcmwf:workflowTask + + bpm:assignees + wcmwf:reviewType + wcmwf:reviewInfo + wcmwf:submission + + + + + wcmwf:workflowTask bpm:assignees diff --git a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJobExecutor.java b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJobExecutor.java new file mode 100644 index 0000000000..4b28a82f60 --- /dev/null +++ b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJobExecutor.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2005-2007 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 org.alfresco.service.ServiceRegistry; +import org.alfresco.service.transaction.TransactionService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jbpm.job.executor.JobExecutor; +import org.springframework.beans.factory.access.BeanFactoryLocator; +import org.springframework.beans.factory.access.BeanFactoryReference; +import org.springmodules.workflow.jbpm31.JbpmFactoryLocator; + + +/** + * jBPM Job Executor + * + * @author davidc + */ +public class AlfrescoJobExecutor extends JobExecutor +{ + private static final long serialVersionUID = -4576396495395482111L; + + private static Log log = LogFactory.getLog(JobExecutor.class); + private TransactionService transactionService; + + + /** + * Constructor + */ + public AlfrescoJobExecutor() + { + BeanFactoryLocator factoryLocator = new JbpmFactoryLocator(); + BeanFactoryReference factory = factoryLocator.useBeanFactory(null); + transactionService = (TransactionService)factory.getFactory().getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName()); + } + + /** + * Gets Transaction Service + * + * @return transaction service + */ + public TransactionService getTransactionService() + { + return transactionService; + } + + /* (non-Javadoc) + * @see org.jbpm.job.executor.JobExecutor#startThread() + */ + @SuppressWarnings("unchecked") + protected synchronized void startThread() + { + String threadName = getNextThreadName(); + Thread thread = new AlfrescoJobExecutorThread(threadName, this, getJbpmConfiguration(), getIdleInterval(), getMaxIdleInterval(), getMaxLockTime(), getHistoryMaxSize()); + getThreads().put(threadName, thread); + log.debug("starting new job executor thread '" + threadName + "'"); + thread.start(); + } + +} diff --git a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJobExecutorThread.java b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJobExecutorThread.java new file mode 100644 index 0000000000..0a680f7d6b --- /dev/null +++ b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoJobExecutorThread.java @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2005-2007 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 org.alfresco.repo.transaction.TransactionUtil; +import org.jbpm.JbpmConfiguration; +import org.jbpm.job.Job; +import org.jbpm.job.executor.JobExecutorThread; + + +/** + * Alfresco Job Executor Thread + * + * @author davidc + */ +public class AlfrescoJobExecutorThread extends JobExecutorThread +{ + private AlfrescoJobExecutor alfrescoJobExecutor; + + /** + * Constructor + * + * @param name + * @param jobExecutor + * @param jbpmConfiguration + * @param idleInterval + * @param maxIdleInterval + * @param maxLockTime + * @param maxHistory + */ + public AlfrescoJobExecutorThread(String name, AlfrescoJobExecutor jobExecutor, JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval, long maxLockTime, int maxHistory) + { + super(name, jobExecutor, jbpmConfiguration, idleInterval, maxIdleInterval, maxLockTime, maxHistory); + this.alfrescoJobExecutor = jobExecutor; + } + + /* (non-Javadoc) + * @see org.jbpm.job.executor.JobExecutorThread#executeJob(org.jbpm.job.Job) + */ + @Override + protected void executeJob(Job job) + { + TransactionUtil.executeInUserTransaction(alfrescoJobExecutor.getTransactionService(), new TransactionJob(job)); + } + + /** + * Helper class for holding Job reference + * + * @author davidc + */ + private class TransactionJob implements TransactionUtil.TransactionWork + { + private Job job; + + /** + * Constructor + * + * @param job + */ + public TransactionJob(Job job) + { + this.job = job; + } + + /* (non-Javadoc) + * @see org.alfresco.repo.transaction.TransactionUtil.TransactionWork#doWork() + */ + public Object doWork() throws Throwable + { + AlfrescoJobExecutorThread.super.executeJob(job); + return null; + } + } + +} 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 294f651124..cebd0f5951 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/jbpm.cfg.xml +++ b/source/java/org/alfresco/repo/workflow/jbpm/jbpm.cfg.xml @@ -25,7 +25,7 @@ - + diff --git a/source/test-resources/jbpmresources/test_timers.xml b/source/test-resources/jbpmresources/test_timers.xml index 4f0b13cab3..d128f0c76b 100644 --- a/source/test-resources/jbpmresources/test_timers.xml +++ b/source/test-resources/jbpmresources/test_timers.xml @@ -35,9 +35,21 @@ - + + + + + + + + + + \ No newline at end of file