Working implementation of basic WCM submit workflow.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4444 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2006-11-27 11:47:20 +00:00
parent a2a543684b
commit f721bc3e07
9 changed files with 175 additions and 161 deletions

View File

@@ -156,12 +156,6 @@
<bean id="workflowBootstrap" parent="workflowDeployer">
<property name="workflowDefinitions">
<list>
<props>
<prop key="engineId">jbpm</prop>
<prop key="location">alfresco/workflow/wcmSubmit.xml</prop>
<prop key="mimetype">text/xml</prop>
<prop key="redeploy">false</prop>
</props>
<props>
<prop key="engineId">jbpm</prop>
<prop key="location">alfresco/workflow/review_processdefinition.xml</prop>
@@ -174,6 +168,12 @@
<prop key="mimetype">text/xml</prop>
<prop key="redeploy">false</prop>
</props>
<props>
<prop key="engineId">jbpm</prop>
<prop key="location">alfresco/workflow/submit_processdefinition.xml</prop>
<prop key="mimetype">text/xml</prop>
<prop key="redeploy">false</prop>
</props>
</list>
</property>
<property name="models">

View File

@@ -1,15 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Registration of new models -->
<bean id="wcmwf.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/workflow/wcmSubmitModel.xml</value>
</list>
</property>
</bean>
</beans>

View File

@@ -29,6 +29,9 @@
<bean id="workflowInterpreter" class="org.alfresco.repo.workflow.WorkflowInterpreter">
<property name="workflowService" ref="WorkflowService"/>
<property name="AVMService" ref="AVMService"/>
<property name="AVMSyncService" ref="AVMSyncService"/>
<property name="nodeService" ref="NodeService"/>
<property name="namespaceService" ref="namespaceService"/>
<property name="personService" ref="PersonService"/>
</bean>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This describes a process for submitting changed content in a user -->
<!-- sandbox, via an approver, to the staging sandbox. -->
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:submit">
<swimlane name="initiator"/>
<start-state name="start">
<task name="wf:submitWebContentTask" swimlane="initiator"/>
<transition name="" to="review"/>
</start-state>
<swimlane name="assignee">
<assignment actor-id="#{bpm_assignee.properties['cm:userName']}"/>
</swimlane>
<task-node name="review">
<task name="wf:reviewTask" swimlane="assignee"/>
<transition name="Approve" to="end">
<action class="org.alfresco.repo.avm.wf.AVMSubmitPackageHandler"/>
</transition>
</task-node>
<end-state name="end"/>
</process-definition>

View File

@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This describes a process for submitting changed content in a user -->
<!-- sandbox, via an approver, to the staging sandbox. -->
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wcmwf:submit">
<swimlane name="initiator"/>
<start-state name="start">
<task name="wcmwf:startSubmit" swimlane="initiator">
<controller>
<!-- <variable name="assignee" access="write" mapped-name="wcmwf:assignee"/> -->
<!-- <variable name="description" access="write" mapped-name="wcmwf:description"/> -->
<variable name="package" access="write" mapped-name="bpm:package"/>
<variable name="workflowcontext" access="write" mapped-name="bpm:context"/>
</controller>
</task>
<transition name="" to="setup"/>
</start-state>
<task-node name="setup">
<task name="wcmwf:setupSubmit" swimlane="initiator">
<controller>
<variable name="assignee" access="write" mapped-name="bpm:assignee"/>
<variable name="description" access="write" mapped-name="wcmwf:description"/>
<variable name="package" access="write" mapped-name="bpm:package"/>
<variable name="workflowcontext" access="write" mapped-name="bpm:context"/>
</controller>
</task>
<transition name="" to="review"/>
</task-node>
<swimlane name="assignee">
<assignment actor-id="#{bpm_assignee.properties['cm:userName']}"/>
</swimlane>
<task-node name="review">
<task name="wcmwf:review" swimlane="assignee">
<controller>
<variable name="description" access="read,required" mapped-name="wcmwf:description"/>
<variable name="package" access="read,required" mapped-name="bpm:package"/>
<variable name="workflowcontext" access="read,required" mapped-name="bpm:context"/>
</controller>
</task>
<transition name="Approve" to="end">
<action class="org.alfresco.repo.avm.wf.AVMSubmitPackageHandler"/>
</transition>
</task-node>
<end-state name="end"/>
</process-definition>

View File

@@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<model name="wcmwf:submitmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm"/>
</imports>
<namespaces>
<namespace uri="http://www.alfresco.org/model/wcmwf/1.0" prefix="wcmwf"/>
</namespaces>
<types>
<type name="wcmwf:baseSubmitTask">
<parent>bpm:workflowTask</parent>
<properties>
<property name="wcmwf:description">
<title>Description</title>
<type>d:text</type>
</property>
</properties>
</type>
<type name="wcmwf:startSubmit">
<title>Submit Web Content</title>
<parent>wcmwf:baseSubmitTask</parent>
<mandatory-aspects>
<aspect>bpm:assignee</aspect>
</mandatory-aspects>
</type>
<type name="wcmwf:setupSubmit">
<title>Submit Web Content</title>
<parent>wcmwf:baseSubmitTask</parent>
</type>
<type name="wcmwf:review">
<title>Review</title>
<parent>wcmwf:baseSubmitTask</parent>
</type>
</types>
</model>

View File

@@ -66,6 +66,23 @@
<type name="wf:completedAdhocTask">
<parent>bpm:workflowTask</parent>
</type>
<!-- -->
<!-- WCM Tasks -->
<!-- -->
<type name="wf:submitWebContentTask">
<parent>bpm:startTask</parent>
<properties>
<property name="wf:from">
<type>d:text</type>
</property>
</properties>
<mandatory-aspects>
<aspect>bpm:assignee</aspect>
</mandatory-aspects>
</type>
</types>

View File

@@ -1,23 +1,17 @@
package org.alfresco.repo.avm.wf;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.workflow.jbpm.JBPMNode;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncException;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
@@ -60,38 +54,48 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
*/
public void execute(ExecutionContext executionContext) throws Exception
{
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("package")).getNodeRef();
List<ChildAssociationRef> children = fNodeService.getChildAssocs(pkg);
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
Map<String, String> storesHit = new HashMap<String, String>();
for (ChildAssociationRef child : children)
{
NodeRef childRef = child.getChildRef();
if (!fNodeService.hasAspect(childRef, ContentModel.ASPECT_REFERENCES_NODE))
{
throw new AVMSyncException("Package node does not have cm:referencesnode.");
}
NodeRef toSubmit = (NodeRef)fNodeService.getProperty(childRef, ContentModel.PROP_NODE_REF);
Pair<Integer, String> versionPath = AVMNodeConverter.ToAVMVersionPath(toSubmit);
String avmPath = versionPath.getSecond();
String [] storePath = avmPath.split(":");
String websiteName = fAVMService.getStoreProperty(storePath[0],
QName.createQName(null, ".website.name")).
getStringValue();
String stagingName = websiteName + "-staging";
AVMDifference diff =
new AVMDifference(-1, avmPath,
-1, stagingName + ":" + storePath[1],
AVMDifference.NEWER);
diffs.add(diff);
storesHit.put(storePath[0], stagingName);
}
// TODO fix update comments if needed.
fAVMSyncService.update(diffs, true, true, false, false, null, null);
for (Map.Entry<String, String> entry : storesHit.entrySet())
{
fAVMSyncService.flatten(entry.getKey() + ":/appBase",
entry.getValue() + ":/appBase");
}
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
String targetPath = pkgDesc.getIndirection();
List<AVMDifference> diff = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath);
fAVMSyncService.update(diff, true, true, false, false, null, null);
String from = (String)executionContext.getContextInstance().getVariable("wf_from");
fAVMSyncService.flatten(from, targetPath);
// List<ChildAssociationRef> children = fNodeService.getChildAssocs(pkg);
// List<AVMDifference> diffs = new ArrayList<AVMDifference>();
// Map<String, String> storesHit = new HashMap<String, String>();
// for (ChildAssociationRef child : children)
// {
// NodeRef childRef = child.getChildRef();
// if (!fNodeService.hasAspect(childRef, ContentModel.ASPECT_REFERENCES_NODE))
// {
// throw new AVMSyncException("Package node does not have cm:referencesnode.");
// }
// NodeRef toSubmit = (NodeRef)fNodeService.getProperty(childRef, ContentModel.PROP_NODE_REF);
// Pair<Integer, String> versionPath = AVMNodeConverter.ToAVMVersionPath(toSubmit);
// String avmPath = versionPath.getSecond();
// String [] storePath = avmPath.split(":");
// String websiteName = fAVMService.getStoreProperty(storePath[0],
// QName.createQName(null, ".website.name")).
// getStringValue();
// String stagingName = websiteName + "-staging";
// AVMDifference diff =
// new AVMDifference(-1, avmPath,
// -1, stagingName + ":" + storePath[1],
// AVMDifference.NEWER);
// diffs.add(diff);
// storesHit.put(storePath[0], stagingName);
// }
// // TODO fix update comments if needed.
// fAVMSyncService.update(diffs, true, true, false, false, null, null);
// for (Map.Entry<String, String> entry : storesHit.entrySet())
// {
// fAVMSyncService.flatten(entry.getKey() + ":/appBase",
// entry.getValue() + ":/appBase");
// }
}
}

View File

@@ -29,9 +29,15 @@ import java.util.List;
import java.util.Map;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowDeployment;
@@ -44,6 +50,7 @@ import org.alfresco.service.cmr.workflow.WorkflowTransition;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.GUID;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ClassPathResource;
@@ -57,6 +64,9 @@ public class WorkflowInterpreter
// Service dependencies
private WorkflowService workflowService;
private NamespaceService namespaceService;
private NodeService nodeService;
private AVMService avmService;
private AVMSyncService avmSyncService;
private PersonService personService;
/**
@@ -111,7 +121,31 @@ public class WorkflowInterpreter
{
this.workflowService = workflowService;
}
/**
* @param nodeService The Node Service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param avmService The AVM Service
*/
public void setAVMService(AVMService avmService)
{
this.avmService = avmService;
}
/**
* @param avmSyncService The AVM Sync Service
*/
public void setAVMSyncService(AVMSyncService avmSyncService)
{
this.avmSyncService = avmSyncService;
}
/**
* @param namespaceService namespaceService
*/
@@ -661,6 +695,49 @@ public class WorkflowInterpreter
}
out.println("set var " + qname + " = " + vars.get(qname));
}
else if (command[2].equals("avmpackage"))
{
// lookup source folder of changes
AVMNodeDescriptor avmSource = avmService.lookup(-1, command[3]);
if (avmSource == null || !avmSource.isDirectory())
{
return command[3] + " must refer to a directory.";
}
// create container for avm workflow packages
String packagesPath = "workflow-system:/packages";
AVMNodeDescriptor packagesDesc = avmService.lookup(-1, packagesPath);
if (packagesDesc == null)
{
avmService.createAVMStore("workflow-system");
avmService.createDirectory("workflow-system:/", "packages");
}
// create package (layered to target, if target is specified)
String packageName = GUID.generate();
String avmSourceIndirection = avmSource.getIndirection();
if (avmSourceIndirection != null)
{
avmService.createLayeredDirectory(avmSourceIndirection, packagesPath, packageName);
List<AVMDifference> diff = avmSyncService.compare(-1, avmSource.getPath(), -1, packagesPath + "/" + packageName);
avmSyncService.update(diff, true, true, false, false, null, null);
}
else
{
// copy source folder to package folder
avmService.copy(-1, avmSource.getPath(), packagesPath, packageName);
}
// convert package to workflow package
AVMNodeDescriptor packageDesc = avmService.lookup(-1, packagesPath + "/" + packageName);
NodeRef packageNodeRef = workflowService.createPackage(AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath()));
nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true);
QName qname = QName.createQName(command[1], namespaceService);
vars.put(qname, packageNodeRef);
out.println("set var " + qname + " = " + vars.get(qname));
}
else
{
return "Syntax Error.\n";