mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
This is a very rudimentary version of a WCM Workflow that uses
Workflow packages. It's hooked up to the sumbit single file action in the top level website screen in an exceedingly awkard way. The UI doesn't complain about anything, nor does it display the contents of the package. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4099 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -406,6 +406,15 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="start-avm-workflow" class="org.alfresco.repo.avm.actions.StartAVMWorkflowAction" parent="action-executer">
|
||||
<property name="workflowService">
|
||||
<ref bean="WorkflowService"/>
|
||||
</property>
|
||||
<property name="personService">
|
||||
<ref bean="personService"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="simple-avm-promote" class="org.alfresco.repo.avm.actions.SimpleAVMPromoteAction" parent="action-executer">
|
||||
<property name="avmSyncService">
|
||||
<ref bean="avmSyncService"/>
|
||||
|
@@ -93,3 +93,8 @@ simple-avm-submit.description=This will submit any newer nodes in the matched it
|
||||
simple-avm-promote.title=Simple Sandbox Promotion
|
||||
simple-avm-promote.description=This promotes any newer nodes in the matched item to the specified target sandbox.
|
||||
simple-avm-promote.target-store.display-label=The name of the target AVM store.
|
||||
|
||||
start-avm-workflow.title=Start a WCM Workflow
|
||||
start-avm-workflow.description=Starts a workflow expecting an AVM workflow package
|
||||
start-avm-workflow.store-name.display-label=Store name for start task
|
||||
start-avm-workflow.workflow-name.display-label=The name of the WCM workflow to invoke.
|
||||
|
@@ -75,10 +75,11 @@ wcmwf_submit.workflow.description=Submit Web Content
|
||||
|
||||
wcmwf_submitmodel.type.wcmwf_startSubmit.title=Submit Web Content
|
||||
wcmwf_submitmodel.type.wcmwf_startSubmit.description=Have colleague review changes
|
||||
wcmwf_submitmodel.property.wcmwf_submitDueDate.description=Task Due Date
|
||||
wcmwf_submitmodel.association.wcmwf_assignee.title=Asignee
|
||||
wcmwf_submitmodel.association.wcmwf_assignee.description=Who's doing the reviewing
|
||||
wcmwf_submitmodel.property.wcmwf_description.title=Task Description
|
||||
wcmwf_submitmodel.property.wcmwf_description.description=Description of what needs to be achieved
|
||||
wcmwf_submitmodel.type.wcmwf_setupSubmit.title=Submit Web Content
|
||||
wcmwf_submitmodel.type.wcmwf_setupSubmit.description=Choose a colleague to review changes
|
||||
wcmwf_submitmodel.type.wcmwf_review.title=Review Content
|
||||
wcmwf_submitmodel.type.wcmwf_review.description=Review Content
|
||||
|
@@ -686,6 +686,20 @@
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
<!-- An aspect to make a node reference another node. Needed to
|
||||
support cross repository references. There is a sys:reference type but
|
||||
that is awkard for AVM Nodes which are less flexible as to type. -->
|
||||
<aspect name="cm:referencesnode">
|
||||
<title>References Node</title>
|
||||
<properties>
|
||||
<property name="cm:noderef">
|
||||
<title>Node Reference</title>
|
||||
<type>d:noderef</type>
|
||||
<mandatory>true</mandatory>
|
||||
</property>
|
||||
</properties>
|
||||
</aspect>
|
||||
|
||||
</aspects>
|
||||
|
||||
</model>
|
||||
|
@@ -9,16 +9,27 @@
|
||||
|
||||
<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="wcmwf:assignee"/>
|
||||
<variable name="description" access="write" mapped-name="wcmwf:description"/>
|
||||
<variable name="storeName" access="write" mapped-name="wcmwf:storeName"/>
|
||||
<variable name="package" access="write" mapped-name="bpm:package"/>
|
||||
<variable name="workflowcontext" access="write" mapped-name="bpm:context"/>
|
||||
</controller>
|
||||
</task>
|
||||
<transition name="" to="review"/>
|
||||
</start-state>
|
||||
</task-node>
|
||||
|
||||
<swimlane name="assignee">
|
||||
<assignment actor-id="#{assignee.properties['cm:userName']}"/>
|
||||
@@ -28,13 +39,12 @@
|
||||
<task name="wcmwf:review" swimlane="assignee">
|
||||
<controller>
|
||||
<variable name="description" access="read,required" mapped-name="wcmwf:description"/>
|
||||
<variable name="storeName" access="read,required" mapped-name="wcmwf:storeName"/>
|
||||
<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.AVMSubmitHandler"/>
|
||||
<transition name="Approve" to="end">
|
||||
<action class="org.alfresco.repo.avm.wf.AVMSubmitPackageHandler"/>
|
||||
</transition>
|
||||
</task-node>
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
</imports>
|
||||
|
||||
<namespaces>
|
||||
<namespace uri="http://www/alfresco.org/model/wcmwf/1.0" prefix="wcmwf"/>
|
||||
<namespace uri="http://www.alfresco.org/model/wcmwf/1.0" prefix="wcmwf"/>
|
||||
</namespaces>
|
||||
|
||||
<types>
|
||||
@@ -21,28 +21,20 @@
|
||||
<title>Description</title>
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
|
||||
<property name="wcmwf:storeName">
|
||||
<title>Sandbox Store Name</title>
|
||||
<type>d:text</type>
|
||||
</property>
|
||||
</properties>
|
||||
</type>
|
||||
|
||||
<type name="wcmwf:startSubmit">
|
||||
<title>Submit Web Content</title>
|
||||
<parent>wcmwf:baseSubmitTask</parent>
|
||||
</type>
|
||||
|
||||
<properties>
|
||||
<property name="wcmwf:submitDueDate">
|
||||
<title>Due Date</title>
|
||||
<type>d:date</type>
|
||||
</property>
|
||||
</properties>
|
||||
|
||||
<type name="wcmwf:setupSubmit">
|
||||
<title>Submit Web Content</title>
|
||||
<parent>wcmwf:baseSubmitTask</parent>
|
||||
<associations>
|
||||
<association name="wcmwf:assignee">
|
||||
<title>Assignee</title>
|
||||
<title>The Reviewer</title>
|
||||
<source>
|
||||
<mandatory>false</mandatory>
|
||||
<many>false</many>
|
||||
|
@@ -190,6 +190,9 @@ public interface ContentModel
|
||||
public static final QName PROP_HITS = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "hits");
|
||||
public static final QName PROP_COUNTER = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "counter");
|
||||
|
||||
// referencesnode aspect
|
||||
public static final QName ASPECT_REFERENCES_NODE = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "referencesnode");
|
||||
public static final QName PROP_NODE_REF = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "noderef");
|
||||
|
||||
//
|
||||
// Application Model Definitions
|
||||
|
@@ -4,20 +4,27 @@
|
||||
package org.alfresco.repo.avm.actions;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.workflow.WorkflowModel;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowPath;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTask;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* This action knows how to start an AVM specific workflow.
|
||||
@@ -25,8 +32,9 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public class StartAVMWorkflowAction extends ActionExecuterAbstractBase
|
||||
{
|
||||
private static Logger fgLogger = Logger.getLogger(StartAVMWorkflowAction.class);
|
||||
|
||||
public static final String NAME = "start-avm-workflow";
|
||||
public static final String PARAM_STORE_NAME = "store-name";
|
||||
public static final String PARAM_WORKFLOW_NAME = "workflow-name";
|
||||
|
||||
/**
|
||||
@@ -34,6 +42,11 @@ public class StartAVMWorkflowAction extends ActionExecuterAbstractBase
|
||||
*/
|
||||
private WorkflowService fWorkflowService;
|
||||
|
||||
/**
|
||||
* Reference to person service.
|
||||
*/
|
||||
private PersonService fPersonService;
|
||||
|
||||
/**
|
||||
* Set the workflow service.
|
||||
* @param service The workflow service.
|
||||
@@ -43,6 +56,15 @@ public class StartAVMWorkflowAction extends ActionExecuterAbstractBase
|
||||
fWorkflowService = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the person service.
|
||||
* @param service The person service.
|
||||
*/
|
||||
public void setPersonService(PersonService service)
|
||||
{
|
||||
fPersonService = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
@@ -61,11 +83,42 @@ public class StartAVMWorkflowAction extends ActionExecuterAbstractBase
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
String workflowName = (String)action.getParameterValue(PARAM_WORKFLOW_NAME);
|
||||
String storeName = (String)action.getParameterValue(PARAM_STORE_NAME);
|
||||
WorkflowDefinition def = fWorkflowService.getDefinitionByName(name);
|
||||
NodeRef workflowPackage = fWorkflowService.createPackage(actionedUponNodeRef);
|
||||
WorkflowDefinition def = fWorkflowService.getDefinitionByName(workflowName);
|
||||
Map<QName, Serializable> wfParams = new HashMap<QName, Serializable>();
|
||||
wfParams.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage);
|
||||
wfParams.put(WorkflowModel.ASSOC_PACKAGE, actionedUponNodeRef);
|
||||
// ArrayList<NodeRef> assigneeList = new ArrayList<NodeRef>();
|
||||
// assigneeList.add(fPersonService.getPerson("admin"));
|
||||
// wfParams.put(QName.createQName("http://www.alfresco.org/model/wcmwf/1.0", "assignee"),
|
||||
// assigneeList);
|
||||
wfParams.put(QName.createQName("http://www.alfresco.org/model/wcmwf/1.0", "description"),
|
||||
"This performs a submit.");
|
||||
wfParams.put(WorkflowModel.PROP_CONTEXT, actionedUponNodeRef);
|
||||
for (QName name : wfParams.keySet())
|
||||
{
|
||||
fgLogger.error(name);
|
||||
fgLogger.error(wfParams.get(name).getClass());
|
||||
fgLogger.error(wfParams.get(name));
|
||||
}
|
||||
WorkflowPath path = fWorkflowService.startWorkflow(def.id, wfParams);
|
||||
if (path != null)
|
||||
{
|
||||
fgLogger.error("Workflow path is not null.");
|
||||
// extract the start task
|
||||
List<WorkflowTask> tasks = fWorkflowService.getTasksForWorkflowPath(path.id);
|
||||
fgLogger.error(tasks.size() + " tasks.");
|
||||
if (tasks.size() == 1)
|
||||
{
|
||||
WorkflowTask startTask = tasks.get(0);
|
||||
|
||||
if (startTask.state == WorkflowTaskState.IN_PROGRESS)
|
||||
{
|
||||
fgLogger.error("Calling End Task.");
|
||||
// end the start task to trigger the first 'proper'
|
||||
// task in the workflow
|
||||
fWorkflowService.endTask(startTask.id, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,10 +128,6 @@ public class StartAVMWorkflowAction extends ActionExecuterAbstractBase
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_STORE_NAME,
|
||||
DataTypeDefinition.TEXT,
|
||||
true,
|
||||
getParamDisplayLabel(PARAM_STORE_NAME)));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_WORKFLOW_NAME,
|
||||
DataTypeDefinition.TEXT,
|
||||
true,
|
||||
|
@@ -2,12 +2,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.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;
|
||||
@@ -55,30 +60,37 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
|
||||
*/
|
||||
public void execute(ExecutionContext executionContext) throws Exception
|
||||
{
|
||||
String srcStoreName = (String)executionContext.getContextInstance().getVariable("storeName");
|
||||
NodeRef pkg = (NodeRef)executionContext.getContextInstance().getVariable("package");
|
||||
String webSiteName =
|
||||
fAVMService.getStoreProperty(srcStoreName, QName.createQName(null, ".website.name")).getStringValue();
|
||||
String stagingName = webSiteName + "-staging";
|
||||
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();
|
||||
Pair<Integer, String> childPath = AVMNodeConverter.ToAVMVersionPath(childRef);
|
||||
List<Pair<Integer, String>> possiblePaths =
|
||||
fAVMService.getPathsInStoreHead(fAVMService.lookup(childPath.getFirst(), childPath.getSecond()),
|
||||
srcStoreName);
|
||||
Pair<Integer, String> actualPath = possiblePaths.get(0);
|
||||
String [] pathParts = actualPath.getSecond().split(":");
|
||||
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, srcStoreName + ":" + pathParts[1],
|
||||
-1, stagingName + ":" + pathParts[1],
|
||||
new AVMDifference(-1, avmPath,
|
||||
-1, stagingName + ":" + storePath[1],
|
||||
AVMDifference.NEWER);
|
||||
diffs.add(diff);
|
||||
storesHit.put(storePath[0], stagingName);
|
||||
}
|
||||
fAVMSyncService.update(diffs, true, true, false, false);
|
||||
fAVMSyncService.flatten(srcStoreName + ":/appBase",
|
||||
stagingName + ":/appBase");
|
||||
for (Map.Entry<String, String> entry : storesHit.entrySet())
|
||||
{
|
||||
fAVMSyncService.flatten(entry.getKey() + ":/appBase",
|
||||
entry.getValue() + ":/appBase");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user