diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java index 5a9d394294..def073c299 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java @@ -36,6 +36,7 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMAppModel; import org.alfresco.repo.avm.AVMNodeConverter; +import org.alfresco.repo.avm.wf.AVMSubmittedAspect; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; @@ -97,6 +98,9 @@ public class CreateWebContentWizard extends BaseContentWizard /** AVM Browse Bean reference */ protected AVMBrowseBean avmBrowseBean; + /** AVM Submitted Aspect reference */ + protected AVMSubmittedAspect avmSubmittedAspect; + /** Workflow service bean reference */ protected WorkflowService workflowService; @@ -116,6 +120,14 @@ public class CreateWebContentWizard extends BaseContentWizard this.avmSyncService = avmSyncService; } + /** + * @param avmSubmittedAspect The AVM Submitted Aspect to set. + */ + public void setAvmSubmittedAspect(AVMSubmittedAspect avmSubmittedAspect) + { + this.avmSubmittedAspect = avmSubmittedAspect; + } + /** * @param workflowService The WorkflowService to set. */ @@ -345,68 +357,11 @@ public class CreateWebContentWizard extends BaseContentWizard } } - if (LOGGER.isDebugEnabled()) - LOGGER.debug("creating workflow package"); - - // create package paths (layered to user sandbox area as target) - String stagingPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getStagingStore()); - String packagesPath = AVMWorkflowUtil.createAVMLayeredPackage(this.avmService, stagingPath); - - List diffs = new ArrayList(8); - // construct diffs for selected items for submission - String webapp = this.avmBrowseBean.getWebapp(); - String sandboxPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getSandbox()); - if (form) - { - // collect diffs for form data instance and all renditions - for (Rendition rendition : this.getRenditions()) - { - String renditionPath = AVMNodeConverter.ToAVMVersionPath(rendition.getNodeRef()).getSecond(); - int webappIndex = renditionPath.indexOf('/' + webapp); - renditionPath = renditionPath.substring(webappIndex); - String srcPath = sandboxPath + renditionPath; - String destPath = packagesPath + renditionPath; - AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER); - diffs.add(diff); - } - String instancePath = AVMNodeConverter.ToAVMVersionPath(this.formInstanceData.getNodeRef()).getSecond(); - int webappIndex = instancePath.indexOf('/' + webapp); - instancePath = instancePath.substring(webappIndex); - String srcPath = sandboxPath + instancePath; - String destPath = packagesPath + instancePath; - AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER); - diffs.add(diff); - } - else - { - // diff for txt or html content - int webappIndex = this.createdPath.indexOf('/' + webapp); - String itemPath = this.createdPath.substring(webappIndex); - String srcPath = sandboxPath + itemPath; - String destPath = packagesPath + itemPath; - AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER); - diffs.add(diff); - } - - // write changes to layer so files are marked as modified - this.avmSyncService.update(diffs, null, true, true, false, false, null, null); - - // convert package to workflow package - AVMNodeDescriptor packageDesc = this.avmService.lookup(-1, packagesPath); - NodeRef packageNodeRef = this.workflowService.createPackage( - AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath())); - this.nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true); - parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef); - // TODO: capture label and comment? - parameters.put(AVMWorkflowUtil.PROP_LABEL, form ? this.formInstanceData.getName() : this.fileName); - parameters.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMConstants.buildAVMStoreRootPath( - this.avmBrowseBean.getSandbox())); - if (LOGGER.isDebugEnabled()) LOGGER.debug("starting workflow " + wd + " with parameters " + parameters); // start the workflow to get access to the start task - WorkflowPath path = this.workflowService.startWorkflow(wd.id, parameters); + WorkflowPath path = this.workflowService.startWorkflow(wd.id, null); if (path != null) { // extract the start task @@ -417,6 +372,69 @@ public class CreateWebContentWizard extends BaseContentWizard if (startTask.state == WorkflowTaskState.IN_PROGRESS) { + if (LOGGER.isDebugEnabled()) + LOGGER.debug("creating workflow package"); + + // create package paths (layered to user sandbox area as target) + String stagingPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getStagingStore()); + String packagesPath = AVMWorkflowUtil.createAVMLayeredPackage(this.avmService, stagingPath); + + List diffs = new ArrayList(8); + // construct diffs for selected items for submission + String webapp = this.avmBrowseBean.getWebapp(); + String sandboxPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getSandbox()); + if (form) + { + // collect diffs for form data instance and all renditions + for (Rendition rendition : this.getRenditions()) + { + String renditionPath = AVMNodeConverter.ToAVMVersionPath(rendition.getNodeRef()).getSecond(); + int webappIndex = renditionPath.indexOf('/' + webapp); + renditionPath = renditionPath.substring(webappIndex); + String srcPath = sandboxPath + renditionPath; + String destPath = packagesPath + renditionPath; + AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER); + diffs.add(diff); + avmSubmittedAspect.markSubmitted(-1, srcPath, path.instance.id); + } + String instancePath = AVMNodeConverter.ToAVMVersionPath(this.formInstanceData.getNodeRef()).getSecond(); + int webappIndex = instancePath.indexOf('/' + webapp); + instancePath = instancePath.substring(webappIndex); + String srcPath = sandboxPath + instancePath; + String destPath = packagesPath + instancePath; + AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER); + diffs.add(diff); + avmSubmittedAspect.markSubmitted(-1, srcPath, path.instance.id); + } + else + { + // diff for txt or html content + int webappIndex = this.createdPath.indexOf('/' + webapp); + String itemPath = this.createdPath.substring(webappIndex); + String srcPath = sandboxPath + itemPath; + String destPath = packagesPath + itemPath; + AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER); + diffs.add(diff); + avmSubmittedAspect.markSubmitted(-1, srcPath, path.instance.id); + } + + // write changes to layer so files are marked as modified + this.avmSyncService.update(diffs, null, true, true, false, false, null, null); + + // convert package to workflow package + AVMNodeDescriptor packageDesc = this.avmService.lookup(-1, packagesPath); + NodeRef packageNodeRef = this.workflowService.createPackage( + AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath())); + this.nodeService.setProperty(packageNodeRef, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, true); + parameters.put(WorkflowModel.ASSOC_PACKAGE, packageNodeRef); + // TODO: capture label and comment? + parameters.put(AVMWorkflowUtil.PROP_LABEL, form ? this.formInstanceData.getName() : this.fileName); + parameters.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMConstants.buildAVMStoreRootPath( + this.avmBrowseBean.getSandbox())); + + // update start task with submit parameters + this.workflowService.updateTask(startTask.id, parameters, null, null); + // end the start task to trigger the first 'proper' task in the workflow this.workflowService.endTask(startTask.id, null); } diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java index 44045f36b4..bd3af95144 100644 --- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java @@ -34,6 +34,7 @@ import org.alfresco.model.ContentModel; import org.alfresco.model.WCMAppModel; import org.alfresco.repo.avm.AVMDAOs; import org.alfresco.repo.avm.AVMNodeConverter; +import org.alfresco.repo.avm.wf.AVMSubmittedAspect; import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMService; @@ -80,6 +81,7 @@ public class SubmitDialog extends BaseDialogBean private List workflowItems; protected AVMService avmService; + protected AVMSubmittedAspect avmSubmittedAspect; protected AVMBrowseBean avmBrowseBean; protected WorkflowService workflowService; protected AVMSyncService avmSyncService; @@ -93,6 +95,14 @@ public class SubmitDialog extends BaseDialogBean this.avmService = avmService; } + /** + * @param avmSubmittedAspect The AVM Submitted Aspect to set. + */ + public void setAvmSubmittedAspect(AVMSubmittedAspect avmSubmittedAspect) + { + this.avmSubmittedAspect = avmSubmittedAspect; + } + /** * @param avmSyncService The AVMSyncService to set. */ @@ -189,18 +199,9 @@ public class SubmitDialog extends BaseDialogBean if (params != null) { - // create container for our avm workflow package - NodeRef workflowPackage = createWorkflowPackage(); - params.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage); - - // add submission parameters - params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, getComment()); - params.put(AVMWorkflowUtil.PROP_LABEL, getLabel()); - params.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getSandbox())); - // start the workflow to get access to the start task WorkflowDefinition wfDef = workflowService.getDefinitionByName(workflowName); - WorkflowPath path = this.workflowService.startWorkflow(wfDef.id, params); + WorkflowPath path = this.workflowService.startWorkflow(wfDef.id, null); if (path != null) { // extract the start task @@ -211,6 +212,18 @@ public class SubmitDialog extends BaseDialogBean if (startTask.state == WorkflowTaskState.IN_PROGRESS) { + // create container for our avm workflow package + NodeRef workflowPackage = createWorkflowPackage(path.instance.id); + params.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage); + + // add submission parameters + params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, getComment()); + params.put(AVMWorkflowUtil.PROP_LABEL, getLabel()); + params.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getSandbox())); + + // update start task with submit parameters + this.workflowService.updateTask(startTask.id, params, null, null); + // end the start task to trigger the first 'proper' task in the workflow this.workflowService.endTask(startTask.id, null); } @@ -552,9 +565,10 @@ public class SubmitDialog extends BaseDialogBean * Construct a workflow package as a layered directory over the staging sandbox. The items for * submission are pushed into the layer and the package constructed around it. * + * @param workflowInstanceId workflow instance id * @return Reference to the package */ - private NodeRef createWorkflowPackage() + private NodeRef createWorkflowPackage(String workflowInstanceId) { List items = getSubmitItems(); @@ -563,6 +577,7 @@ public class SubmitDialog extends BaseDialogBean String packagesPath = AVMWorkflowUtil.createAVMLayeredPackage(this.avmService, stagingPath); // construct diffs for selected items for submission + // mark selected items for submission String sandboxPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getSandbox()); List diffs = new ArrayList(this.submitItems.size()); for (ItemWrapper wrapper : this.submitItems) @@ -571,6 +586,7 @@ public class SubmitDialog extends BaseDialogBean String destPath = packagesPath + wrapper.getPath(); AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER); diffs.add(diff); + avmSubmittedAspect.markSubmitted(-1, srcPath, workflowInstanceId); } // write changes to layer so files are marked as modified diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 44e93f46fc..0aab1fa59a 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -2132,6 +2132,10 @@ avmSyncService #{AVMSyncService} + + avmSubmittedAspect + #{AVMSubmittedAspect} + avmBrowseBean #{AVMBrowseBean} @@ -2791,6 +2795,10 @@ avmBrowseBean #{AVMBrowseBean} + + avmSubmittedAspect + #{AVMSubmittedAspect} + workflowService #{WorkflowService}