ACE-2171 - EOL: WCM and related JBPM workflow definition removal

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@87752 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Stefan Kopf
2014-10-10 14:33:33 +00:00
parent 37309f11d7
commit 36c3cb3a04
6 changed files with 94 additions and 10 deletions

View File

@@ -24,6 +24,7 @@ import java.util.Properties;
import org.springframework.extensions.surf.util.I18NUtil;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.workflow.WorkflowDeployer;
import org.alfresco.service.cmr.admin.PatchException;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -36,9 +37,12 @@ import org.springframework.context.ApplicationContextAware;
public class GenericWorkflowPatch extends AbstractPatch implements ApplicationContextAware
{
private static final String MSG_DEPLOYED = "patch.genericWorkflow.result.deployed";
private static final String MSG_UNDEPLOYED = "patch.genericWorkflow.result.undeployed";
private static final String ERR_PROPERTY_REQUIRED = "patch.genericWorkflow.property_required";
private ApplicationContext applicationContext;
private List<Properties> workflowDefinitions;
private List<String> undeployWorkflowNames;
/* (non-Javadoc)
@@ -59,11 +63,24 @@ public class GenericWorkflowPatch extends AbstractPatch implements ApplicationCo
{
this.workflowDefinitions = workflowDefinitions;
}
/**
* Sets the Workflow Names to be undeployed
*
* @param workflowDefinitions
*/
public void setUndeployWorkflowNames(List<String> undeployWorkflowNames)
{
this.undeployWorkflowNames = undeployWorkflowNames;
}
@Override
protected void checkProperties()
{
checkPropertyNotNull(workflowDefinitions, "workflowDefinitions");
if ( (workflowDefinitions == null) && (undeployWorkflowNames == null) )
{
throw new PatchException(ERR_PROPERTY_REQUIRED, "workflowDefinitions", "undeployWorkflowNames", this);
}
super.checkProperties();
}
@@ -72,15 +89,37 @@ public class GenericWorkflowPatch extends AbstractPatch implements ApplicationCo
{
WorkflowDeployer deployer = (WorkflowDeployer)applicationContext.getBean("workflowPatchDeployer");
for (Properties props : workflowDefinitions)
if(workflowDefinitions != null)
{
props.put(WorkflowDeployer.REDEPLOY, "true");
for (Properties props : workflowDefinitions)
{
props.put(WorkflowDeployer.REDEPLOY, "true");
}
deployer.setWorkflowDefinitions(workflowDefinitions);
deployer.init();
}
int undeployed = 0;
if(undeployWorkflowNames != null)
{
undeployed = deployer.undeploy(undeployWorkflowNames);
}
deployer.setWorkflowDefinitions(workflowDefinitions);
deployer.init();
// done
return I18NUtil.getMessage(MSG_DEPLOYED, workflowDefinitions.size());
StringBuilder msg = new StringBuilder();
if(workflowDefinitions != null)
{
msg.append(I18NUtil.getMessage(MSG_DEPLOYED, workflowDefinitions.size()));
}
if(undeployWorkflowNames != null)
{
if(msg.length() > 0)
{
msg.append(' ');
}
msg.append(I18NUtil.getMessage(MSG_UNDEPLOYED, undeployed));
}
return msg.toString();
}
}

View File

@@ -452,6 +452,35 @@ public class WorkflowDeployer extends AbstractLifecycleBean
}
}
public int undeploy(List<String> workflowNames)
{
int undeployed = 0;
for(String workflowName : workflowNames)
{
// Undeploy the workflow definition - all versions in JBPM
List<WorkflowDefinition> defs = workflowService.getAllDefinitionsByName(workflowName);
if(defs.size() > 0)
{
undeployed++;
}
for (WorkflowDefinition def: defs)
{
if (logger.isDebugEnabled())
{
logger.debug("Undeploying workflow '" + workflowName + "' ...");
}
workflowService.undeployDefinition(def.getId());
if (logger.isDebugEnabled())
{
logger.debug("... undeployed '" + def.getId() + "' v" + def.getVersion());
}
}
}
return undeployed;
}
@Override
protected void onBootstrap(ApplicationEvent event)
{