ALF-10117: JBPM workflows should be hidden.

A new property "system.workflow.jbpm.definitions.visible" has been added, set to false by default. This means that when the JBPM engine is enabled (the default for upgrades) in-flight workflows can continue but the JBPM definitions will not be returned and therefore hide them from the UI preventing new instances from being created.

If customers want to show the JBPM workflows again all is required is to set the "system.workflow.jbpm.definitions.visible" property to true.

The Workflow MBean has also been updated to expose the new property and the Workflow admin console now displays the value.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30356 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2011-09-08 21:49:35 +00:00
parent af956b0064
commit 5f14a5105b
11 changed files with 166 additions and 70 deletions

View File

@@ -54,6 +54,7 @@ import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.workflow.WorkflowAdminService;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowDeployment;
import org.alfresco.service.cmr.workflow.WorkflowException;
@@ -126,6 +127,7 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
protected AuthorityDAO authorityDAO;
protected JbpmTemplate jbpmTemplate;
protected SearchService unprotectedSearchService;
protected WorkflowAdminService workflowAdminService;
// Company Home
protected StoreRef companyHomeStore;
@@ -281,6 +283,15 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
this.unprotectedSearchService = unprotectedSearchService;
}
/**
* Sets the Workflow Admin Service
*
* @param workflowAdminService
*/
public void setWorkflowAdminService(WorkflowAdminService workflowAdminService)
{
this.workflowAdminService = workflowAdminService;
}
//
// Workflow Definition...
@@ -403,42 +414,49 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
@SuppressWarnings("unchecked")
public List<WorkflowDefinition> getDefinitions()
{
try
if (workflowAdminService.isJBPMWorkflowDefinitionsVisible())
{
return (List<WorkflowDefinition>)jbpmTemplate.execute(new JbpmCallback()
try
{
public Object doInJbpm(JbpmContext context)
return (List<WorkflowDefinition>)jbpmTemplate.execute(new JbpmCallback()
{
GraphSession graphSession = context.getGraphSession();
List<ProcessDefinition> processDefs = graphSession.findLatestProcessDefinitions();
List<WorkflowDefinition> workflowDefs = new ArrayList<WorkflowDefinition>(processDefs.size());
for (ProcessDefinition processDef : processDefs)
{
if (tenantService.isEnabled())
{
try
{
tenantService.checkDomain(processDef.getName());
public Object doInJbpm(JbpmContext context)
{
GraphSession graphSession = context.getGraphSession();
List<ProcessDefinition> processDefs = graphSession.findLatestProcessDefinitions();
List<WorkflowDefinition> workflowDefs = new ArrayList<WorkflowDefinition>(processDefs.size());
for (ProcessDefinition processDef : processDefs)
{
if (tenantService.isEnabled())
{
try
{
tenantService.checkDomain(processDef.getName());
}
catch (RuntimeException re)
{
// deliberately skip this one - due to domain
// mismatch
continue;
}
}
catch (RuntimeException re)
{
// deliberately skip this one - due to domain
// mismatch
continue;
}
WorkflowDefinition workflowDef = createWorkflowDefinition(processDef);
workflowDefs.add(workflowDef);
}
WorkflowDefinition workflowDef = createWorkflowDefinition(processDef);
workflowDefs.add(workflowDef);
return workflowDefs;
}
return workflowDefs;
}
});
});
}
catch (JbpmException e)
{
String msg = messageService.getMessage(ERR_GET_WORKFLOW_DEF);
throw new WorkflowException(msg, e);
}
}
catch(JbpmException e)
else
{
String msg = messageService.getMessage(ERR_GET_WORKFLOW_DEF);
throw new WorkflowException(msg, e);
return Collections.<WorkflowDefinition>emptyList();
}
}
@@ -451,42 +469,49 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
@SuppressWarnings("unchecked")
public List<WorkflowDefinition> getAllDefinitions()
{
try
if (workflowAdminService.isJBPMWorkflowDefinitionsVisible())
{
return (List<WorkflowDefinition>)jbpmTemplate.execute(new JbpmCallback()
try
{
public Object doInJbpm(JbpmContext context)
return (List<WorkflowDefinition>)jbpmTemplate.execute(new JbpmCallback()
{
GraphSession graphSession = context.getGraphSession();
List<ProcessDefinition> processDefs = graphSession.findAllProcessDefinitions();
List<WorkflowDefinition> workflowDefs = new ArrayList<WorkflowDefinition>(processDefs.size());
for (ProcessDefinition processDef : processDefs)
public Object doInJbpm(JbpmContext context)
{
if (tenantService.isEnabled())
{
try
{
tenantService.checkDomain(processDef.getName());
GraphSession graphSession = context.getGraphSession();
List<ProcessDefinition> processDefs = graphSession.findAllProcessDefinitions();
List<WorkflowDefinition> workflowDefs = new ArrayList<WorkflowDefinition>(processDefs.size());
for (ProcessDefinition processDef : processDefs)
{
if (tenantService.isEnabled())
{
try
{
tenantService.checkDomain(processDef.getName());
}
catch (RuntimeException re)
{
// deliberately skip this one - due to domain
// mismatch
continue;
}
}
catch (RuntimeException re)
{
// deliberately skip this one - due to domain
// mismatch
continue;
}
WorkflowDefinition workflowDef = createWorkflowDefinition(processDef);
workflowDefs.add(workflowDef);
}
WorkflowDefinition workflowDef = createWorkflowDefinition(processDef);
workflowDefs.add(workflowDef);
return workflowDefs;
}
return workflowDefs;
}
});
});
}
catch (JbpmException e)
{
String msg = messageService.getMessage(ERR_GET_WORKFLOW_DEF);
throw new WorkflowException(msg, e);
}
}
catch(JbpmException e)
else
{
String msg = messageService.getMessage(ERR_GET_WORKFLOW_DEF);
throw new WorkflowException(msg, e);
return Collections.<WorkflowDefinition>emptyList();
}
}

View File

@@ -32,11 +32,13 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.workflow.BPMEngineRegistry;
import org.alfresco.repo.workflow.TaskComponent;
import org.alfresco.repo.workflow.WorkflowAdminServiceImpl;
import org.alfresco.repo.workflow.WorkflowComponent;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.repo.workflow.WorkflowPackageComponent;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.workflow.WorkflowAdminService;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowDeployment;
import org.alfresco.service.cmr.workflow.WorkflowException;
@@ -68,6 +70,7 @@ public class JBPMEngineTest extends BaseAlfrescoSpringTest
private WorkflowPackageComponent packageComponent;
private PersonService personService;
private WorkflowDefinition testWorkflowDef;
private WorkflowAdminServiceImpl workflowAdminService;
private NodeRef person1;
private NodeRef person2;
private NodeRef person3;
@@ -86,7 +89,11 @@ public class JBPMEngineTest extends BaseAlfrescoSpringTest
BPMEngineRegistry registry = (BPMEngineRegistry)applicationContext.getBean("bpm_engineRegistry");
workflowComponent = registry.getWorkflowComponent(JBPMEngine.ENGINE_ID);
taskComponent = registry.getTaskComponent(JBPMEngine.ENGINE_ID);
packageComponent = (WorkflowPackageComponent)applicationContext.getBean("workflowPackageImpl");
packageComponent = (WorkflowPackageComponent)applicationContext.getBean("workflowPackageImpl");
// for the purposes of the tests make sure JBPM workflow definitions are visible
this.workflowAdminService = (WorkflowAdminServiceImpl) applicationContext.getBean("workflowAdminService");
this.workflowAdminService.setJBPMWorkflowDefinitionsVisible(true);
// deploy test process messages
I18NUtil.registerResourceBundle("jbpmresources/test-messages");
@@ -558,7 +565,32 @@ public class JBPMEngineTest extends BaseAlfrescoSpringTest
assertEquals(WorkflowTaskState.IN_PROGRESS, tasks1.get(0).getState());
WorkflowTask updatedTask = taskComponent.endTask(tasks1.get(0).getId(), null);
assertNotNull(updatedTask);
}
}
public void testWorkflowDefinitionVisibility()
{
// retrieve workflow definitions
List<WorkflowDefinition> defs = workflowComponent.getDefinitions();
List<WorkflowDefinition> allDefs = workflowComponent.getAllDefinitions();
// make sure both lists are populated (only if the JBPM engine is enabled)
if (workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
{
assertFalse(defs.isEmpty());
assertFalse(allDefs.isEmpty());
}
// turn off workflow definition visibility
this.workflowAdminService.setJBPMWorkflowDefinitionsVisible(false);
// retrieve workflow definitions again
defs = workflowComponent.getDefinitions();
allDefs = workflowComponent.getAllDefinitions();
// ensure the list of workflow definitions are empty
assertTrue(defs.isEmpty());
assertTrue(allDefs.isEmpty());
}
// public void testAssignTaskVariablesWithScript() throws Exception
// {