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

@@ -182,6 +182,8 @@ patch.imap.clear.old.messages.description.cleared=Old IMAP message templates hav
patch.groupMembersAsIdentifiers.description=Reindex usr:authorityContainer members as identifiers patch.groupMembersAsIdentifiers.description=Reindex usr:authorityContainer members as identifiers
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.property_required=At least one of the properties ''{0}'' or ''{1}'' must be set on this patch: {2}
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
@@ -463,3 +465,4 @@ patch.db-V5.0-upgrade-to-activiti-5.16.2.result=Activiti tables updated
patch.solrFacets.root.description=Creates the solr facets root folder in the Data Dictionary patch.solrFacets.root.description=Creates the solr facets root folder in the Data Dictionary
patch.eol-wcmwf.description=Undeploys deprecated WCMWF Workflows

View File

@@ -3386,4 +3386,20 @@
<value>classpath:alfresco/dbscripts/create/${db.script.dialect}/AlfrescoCreate-ContentUrlEncryptionTables.sql</value> <value>classpath:alfresco/dbscripts/create/${db.script.dialect}/AlfrescoCreate-ContentUrlEncryptionTables.sql</value>
</property> </property>
</bean> </bean>
<bean id="patch.eol-wcmwf" class="org.alfresco.repo.admin.patch.impl.GenericWorkflowPatch" parent="baseWorkflowPatch" >
<property name="id"><value>patch.eol-wcmwf</value></property>
<property name="description"><value>patch.eol-wcmwf.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>8007</value></property>
<property name="targetSchema"><value>8008</value></property>
<property name="undeployWorkflowNames">
<list>
<value>jbpm$wcmwf:submit</value>
<value>jbpm$wcmwf:submitdirect</value>
<value>jbpm$wcmwf:changerequest</value>
</list>
</property>
</bean>
</beans> </beans>

View File

@@ -146,9 +146,6 @@
</fieldset> </fieldset>
<!-- <!--
JBPM ids for debug.... JBPM ids for debug....
id=jbpm$4,name=jbpm$wcmwf:changerequest,version=1,title=Change Request
id=jbpm$3,name=jbpm$wcmwf:submit,version=1,title=Web Site Submission
id=jbpm$5,name=jbpm$wcmwf:submitdirect,version=1,title=Web Site Submission (Direct)
id=jbpm$2,name=jbpm$wf:adhoc,version=1,title=Adhoc Task id=jbpm$2,name=jbpm$wf:adhoc,version=1,title=Adhoc Task
id=jbpm$6,name=jbpm$wf:invite,version=1,title=Site Invite id=jbpm$6,name=jbpm$wf:invite,version=1,title=Site Invite
id=jbpm$1,name=jbpm$wf:review,version=1,title=Review & Approve id=jbpm$1,name=jbpm$wf:review,version=1,title=Review & Approve

View File

@@ -23,4 +23,4 @@ version.build=r@scm-revision@-b@build-number@
# Schema number # Schema number
version.schema=8007 version.schema=8008

View File

@@ -24,6 +24,7 @@ import java.util.Properties;
import org.springframework.extensions.surf.util.I18NUtil; 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.WorkflowDeployer; import org.alfresco.repo.workflow.WorkflowDeployer;
import org.alfresco.service.cmr.admin.PatchException;
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;
@@ -36,9 +37,12 @@ import org.springframework.context.ApplicationContextAware;
public class GenericWorkflowPatch extends AbstractPatch implements ApplicationContextAware public class GenericWorkflowPatch extends AbstractPatch implements ApplicationContextAware
{ {
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 ERR_PROPERTY_REQUIRED = "patch.genericWorkflow.property_required";
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
private List<Properties> workflowDefinitions; private List<Properties> workflowDefinitions;
private List<String> undeployWorkflowNames;
/* (non-Javadoc) /* (non-Javadoc)
@@ -60,10 +64,23 @@ public class GenericWorkflowPatch extends AbstractPatch implements ApplicationCo
this.workflowDefinitions = workflowDefinitions; this.workflowDefinitions = workflowDefinitions;
} }
/**
* Sets the Workflow Names to be undeployed
*
* @param workflowDefinitions
*/
public void setUndeployWorkflowNames(List<String> undeployWorkflowNames)
{
this.undeployWorkflowNames = undeployWorkflowNames;
}
@Override @Override
protected void checkProperties() protected void checkProperties()
{ {
checkPropertyNotNull(workflowDefinitions, "workflowDefinitions"); if ( (workflowDefinitions == null) && (undeployWorkflowNames == null) )
{
throw new PatchException(ERR_PROPERTY_REQUIRED, "workflowDefinitions", "undeployWorkflowNames", this);
}
super.checkProperties(); super.checkProperties();
} }
@@ -72,15 +89,37 @@ public class GenericWorkflowPatch extends AbstractPatch implements ApplicationCo
{ {
WorkflowDeployer deployer = (WorkflowDeployer)applicationContext.getBean("workflowPatchDeployer"); WorkflowDeployer deployer = (WorkflowDeployer)applicationContext.getBean("workflowPatchDeployer");
if(workflowDefinitions != null)
{
for (Properties props : workflowDefinitions) for (Properties props : workflowDefinitions)
{ {
props.put(WorkflowDeployer.REDEPLOY, "true"); props.put(WorkflowDeployer.REDEPLOY, "true");
} }
deployer.setWorkflowDefinitions(workflowDefinitions); deployer.setWorkflowDefinitions(workflowDefinitions);
deployer.init(); deployer.init();
}
int undeployed = 0;
if(undeployWorkflowNames != null)
{
undeployed = deployer.undeploy(undeployWorkflowNames);
}
// done // 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 @Override
protected void onBootstrap(ApplicationEvent event) protected void onBootstrap(ApplicationEvent event)
{ {