ACE-3095 - Patch patch.eol-wcmwf fails if wf engine is disabled.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@87857 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Stefan Kopf
2014-10-13 12:40:21 +00:00
parent c8a6a9847c
commit a98be4b880
3 changed files with 50 additions and 18 deletions

View File

@@ -131,6 +131,7 @@ patch.groupMembersAsIdentifiers.description=Reindex usr:authorityContainer membe
patch.genericWorkflow.result.deployed=Re-deployed {0} workflows. patch.genericWorkflow.result.deployed=Re-deployed {0} workflows.
patch.genericWorkflow.result.undeployed=Undeployed {0} workflows. patch.genericWorkflow.result.undeployed=Undeployed {0} workflows.
patch.genericWorkflow.property_required=At least one of the properties ''{0}'' or ''{1}'' must be set on this patch: {2} patch.genericWorkflow.property_required=At least one of the properties ''{0}'' or ''{1}'' must be set on this patch: {2}
patch.genericWorkflow.error_engine_deactivated=\nDefinition ''{0}'' cannot be undeployed as the ''{1}'' engine is disabled
patch.ReadmeTemplate.description=Deployed ReadMe Template patch.ReadmeTemplate.description=Deployed ReadMe Template
patch.webScriptsReadme.description=Applied ReadMe template to Web Scripts folders patch.webScriptsReadme.description=Applied ReadMe template to Web Scripts folders

View File

@@ -18,16 +18,19 @@
*/ */
package org.alfresco.repo.admin.patch.impl; package org.alfresco.repo.admin.patch.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import org.springframework.extensions.surf.util.I18NUtil;
import org.alfresco.repo.admin.patch.AbstractPatch; import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.workflow.BPMEngineRegistry;
import org.alfresco.repo.workflow.WorkflowDeployer; import org.alfresco.repo.workflow.WorkflowDeployer;
import org.alfresco.service.cmr.admin.PatchException; import org.alfresco.service.cmr.admin.PatchException;
import org.alfresco.service.cmr.workflow.WorkflowAdminService;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.extensions.surf.util.I18NUtil;
/** /**
* Generic patch that re-deploys a workflow definition * Generic patch that re-deploys a workflow definition
@@ -39,6 +42,7 @@ public class GenericWorkflowPatch extends AbstractPatch implements ApplicationCo
private static final String MSG_DEPLOYED = "patch.genericWorkflow.result.deployed"; private static final String MSG_DEPLOYED = "patch.genericWorkflow.result.deployed";
private static final String MSG_UNDEPLOYED = "patch.genericWorkflow.result.undeployed"; private static final String MSG_UNDEPLOYED = "patch.genericWorkflow.result.undeployed";
private static final String ERR_PROPERTY_REQUIRED = "patch.genericWorkflow.property_required"; private static final String ERR_PROPERTY_REQUIRED = "patch.genericWorkflow.property_required";
private static final String MSG_ERROR_ENGINE_DEACTIVATED = "patch.genericWorkflow.error_engine_deactivated";
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
private List<Properties> workflowDefinitions; private List<Properties> workflowDefinitions;
@@ -88,6 +92,7 @@ public class GenericWorkflowPatch extends AbstractPatch implements ApplicationCo
protected String applyInternal() throws Exception protected String applyInternal() throws Exception
{ {
WorkflowDeployer deployer = (WorkflowDeployer)applicationContext.getBean("workflowPatchDeployer"); WorkflowDeployer deployer = (WorkflowDeployer)applicationContext.getBean("workflowPatchDeployer");
WorkflowAdminService workflowAdminService = (WorkflowAdminService)applicationContext.getBean("workflowAdminService");
if(workflowDefinitions != null) if(workflowDefinitions != null)
{ {
@@ -100,9 +105,23 @@ public class GenericWorkflowPatch extends AbstractPatch implements ApplicationCo
} }
int undeployed = 0; int undeployed = 0;
StringBuilder errorMessages = new StringBuilder();
if(undeployWorkflowNames != null) if(undeployWorkflowNames != null)
{ {
undeployed = deployer.undeploy(undeployWorkflowNames); List<String> undeployableWorkflows = new ArrayList<String>(undeployWorkflowNames);
for(String workflowName : undeployWorkflowNames)
{
String engineId = BPMEngineRegistry.getEngineId(workflowName);
if (workflowAdminService.isEngineEnabled(engineId))
{
undeployableWorkflows.add(workflowName);
}
else
{
errorMessages.append(I18NUtil.getMessage(MSG_ERROR_ENGINE_DEACTIVATED, workflowName, engineId));
}
}
undeployed = deployer.undeploy(undeployableWorkflows);
} }
// done // done
@@ -119,6 +138,10 @@ public class GenericWorkflowPatch extends AbstractPatch implements ApplicationCo
} }
msg.append(I18NUtil.getMessage(MSG_UNDEPLOYED, undeployed)); msg.append(I18NUtil.getMessage(MSG_UNDEPLOYED, undeployed));
} }
if(errorMessages.length() > 0)
{
msg.append(errorMessages);
}
return msg.toString(); return msg.toString();
} }

View File

@@ -456,6 +456,9 @@ public class WorkflowDeployer extends AbstractLifecycleBean
{ {
int undeployed = 0; int undeployed = 0;
for(String workflowName : workflowNames) for(String workflowName : workflowNames)
{
String engineId = BPMEngineRegistry.getEngineId(workflowName);
if (workflowAdminService.isEngineEnabled(engineId))
{ {
// Undeploy the workflow definition - all versions in JBPM // Undeploy the workflow definition - all versions in JBPM
List<WorkflowDefinition> defs = workflowService.getAllDefinitionsByName(workflowName); List<WorkflowDefinition> defs = workflowService.getAllDefinitionsByName(workflowName);
@@ -478,6 +481,11 @@ public class WorkflowDeployer extends AbstractLifecycleBean
} }
} }
} }
else
{
logger.debug("Workflow deployer: Definition '" + workflowName + "' cannot be undeployed as the '" + engineId + "' engine is disabled");
}
}
return undeployed; return undeployed;
} }