diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 5354175164..89573f29d7 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -156,12 +156,6 @@ - - jbpm - alfresco/workflow/wcmSubmit.xml - text/xml - false - jbpm alfresco/workflow/review_processdefinition.xml @@ -174,6 +168,12 @@ text/xml false + + jbpm + alfresco/workflow/submit_processdefinition.xml + text/xml + false + diff --git a/config/alfresco/extension/wcmwf-model-context.xml b/config/alfresco/extension/wcmwf-model-context.xml deleted file mode 100644 index 8454147ec9..0000000000 --- a/config/alfresco/extension/wcmwf-model-context.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - alfresco/workflow/wcmSubmitModel.xml - - - - - diff --git a/config/alfresco/workflow-context.xml b/config/alfresco/workflow-context.xml index ae0f4a3ece..e99cb2bde0 100644 --- a/config/alfresco/workflow-context.xml +++ b/config/alfresco/workflow-context.xml @@ -29,6 +29,9 @@ + + + diff --git a/config/alfresco/workflow/submit_processdefinition.xml b/config/alfresco/workflow/submit_processdefinition.xml new file mode 100644 index 0000000000..6cb9eff197 --- /dev/null +++ b/config/alfresco/workflow/submit_processdefinition.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/alfresco/workflow/wcmSubmit.xml b/config/alfresco/workflow/wcmSubmit.xml deleted file mode 100644 index 7a1e52d4ec..0000000000 --- a/config/alfresco/workflow/wcmSubmit.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/alfresco/workflow/wcmSubmitModel.xml b/config/alfresco/workflow/wcmSubmitModel.xml deleted file mode 100644 index 84019cd2df..0000000000 --- a/config/alfresco/workflow/wcmSubmitModel.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - bpm:workflowTask - - - - Description - d:text - - - - - - - - Submit Web Content - wcmwf:baseSubmitTask - - bpm:assignee - - - - - Submit Web Content - wcmwf:baseSubmitTask - - - - Review - wcmwf:baseSubmitTask - - - \ No newline at end of file diff --git a/config/alfresco/workflow/workflowModel.xml b/config/alfresco/workflow/workflowModel.xml index 30dbf7b625..015c704708 100644 --- a/config/alfresco/workflow/workflowModel.xml +++ b/config/alfresco/workflow/workflowModel.xml @@ -66,6 +66,23 @@ bpm:workflowTask + + + + + + + + bpm:startTask + + + d:text + + + + bpm:assignee + + diff --git a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java index 1335b4586f..1011be69ac 100644 --- a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java +++ b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java @@ -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 children = fNodeService.getChildAssocs(pkg); - List diffs = new ArrayList(); - Map storesHit = new HashMap(); - 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 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 entry : storesHit.entrySet()) - { - fAVMSyncService.flatten(entry.getKey() + ":/appBase", - entry.getValue() + ":/appBase"); - } + NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef(); + Pair pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg); + + AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond()); + String targetPath = pkgDesc.getIndirection(); + List 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 children = fNodeService.getChildAssocs(pkg); +// List diffs = new ArrayList(); +// Map storesHit = new HashMap(); +// 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 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 entry : storesHit.entrySet()) +// { +// fAVMSyncService.flatten(entry.getKey() + ":/appBase", +// entry.getValue() + ":/appBase"); +// } } } diff --git a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java index 90eda03c7d..3a9059fb16 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowInterpreter.java @@ -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 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";