mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Addition of "submitted" aspect to items submitted for web site review.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4620 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -36,6 +36,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.model.WCMAppModel;
|
import org.alfresco.model.WCMAppModel;
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
|
import org.alfresco.repo.avm.wf.AVMSubmittedAspect;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.workflow.WorkflowModel;
|
import org.alfresco.repo.workflow.WorkflowModel;
|
||||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
@@ -97,6 +98,9 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
/** AVM Browse Bean reference */
|
/** AVM Browse Bean reference */
|
||||||
protected AVMBrowseBean avmBrowseBean;
|
protected AVMBrowseBean avmBrowseBean;
|
||||||
|
|
||||||
|
/** AVM Submitted Aspect reference */
|
||||||
|
protected AVMSubmittedAspect avmSubmittedAspect;
|
||||||
|
|
||||||
/** Workflow service bean reference */
|
/** Workflow service bean reference */
|
||||||
protected WorkflowService workflowService;
|
protected WorkflowService workflowService;
|
||||||
|
|
||||||
@@ -116,6 +120,14 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
this.avmSyncService = avmSyncService;
|
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.
|
* @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<AVMDifference> diffs = new ArrayList<AVMDifference>(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())
|
if (LOGGER.isDebugEnabled())
|
||||||
LOGGER.debug("starting workflow " + wd + " with parameters " + parameters);
|
LOGGER.debug("starting workflow " + wd + " with parameters " + parameters);
|
||||||
|
|
||||||
// start the workflow to get access to the start task
|
// 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)
|
if (path != null)
|
||||||
{
|
{
|
||||||
// extract the start task
|
// extract the start task
|
||||||
@@ -417,6 +372,69 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
|
|
||||||
if (startTask.state == WorkflowTaskState.IN_PROGRESS)
|
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<AVMDifference> diffs = new ArrayList<AVMDifference>(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
|
// end the start task to trigger the first 'proper' task in the workflow
|
||||||
this.workflowService.endTask(startTask.id, null);
|
this.workflowService.endTask(startTask.id, null);
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,7 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.model.WCMAppModel;
|
import org.alfresco.model.WCMAppModel;
|
||||||
import org.alfresco.repo.avm.AVMDAOs;
|
import org.alfresco.repo.avm.AVMDAOs;
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
|
import org.alfresco.repo.avm.wf.AVMSubmittedAspect;
|
||||||
import org.alfresco.repo.workflow.WorkflowModel;
|
import org.alfresco.repo.workflow.WorkflowModel;
|
||||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
@@ -80,6 +81,7 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
private List<UIListItem> workflowItems;
|
private List<UIListItem> workflowItems;
|
||||||
|
|
||||||
protected AVMService avmService;
|
protected AVMService avmService;
|
||||||
|
protected AVMSubmittedAspect avmSubmittedAspect;
|
||||||
protected AVMBrowseBean avmBrowseBean;
|
protected AVMBrowseBean avmBrowseBean;
|
||||||
protected WorkflowService workflowService;
|
protected WorkflowService workflowService;
|
||||||
protected AVMSyncService avmSyncService;
|
protected AVMSyncService avmSyncService;
|
||||||
@@ -93,6 +95,14 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
this.avmService = avmService;
|
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.
|
* @param avmSyncService The AVMSyncService to set.
|
||||||
*/
|
*/
|
||||||
@@ -189,18 +199,9 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
|
|
||||||
if (params != null)
|
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
|
// start the workflow to get access to the start task
|
||||||
WorkflowDefinition wfDef = workflowService.getDefinitionByName(workflowName);
|
WorkflowDefinition wfDef = workflowService.getDefinitionByName(workflowName);
|
||||||
WorkflowPath path = this.workflowService.startWorkflow(wfDef.id, params);
|
WorkflowPath path = this.workflowService.startWorkflow(wfDef.id, null);
|
||||||
if (path != null)
|
if (path != null)
|
||||||
{
|
{
|
||||||
// extract the start task
|
// extract the start task
|
||||||
@@ -211,6 +212,18 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
|
|
||||||
if (startTask.state == WorkflowTaskState.IN_PROGRESS)
|
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
|
// end the start task to trigger the first 'proper' task in the workflow
|
||||||
this.workflowService.endTask(startTask.id, null);
|
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
|
* 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.
|
* submission are pushed into the layer and the package constructed around it.
|
||||||
*
|
*
|
||||||
|
* @param workflowInstanceId workflow instance id
|
||||||
* @return Reference to the package
|
* @return Reference to the package
|
||||||
*/
|
*/
|
||||||
private NodeRef createWorkflowPackage()
|
private NodeRef createWorkflowPackage(String workflowInstanceId)
|
||||||
{
|
{
|
||||||
List<ItemWrapper> items = getSubmitItems();
|
List<ItemWrapper> items = getSubmitItems();
|
||||||
|
|
||||||
@@ -563,6 +577,7 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
String packagesPath = AVMWorkflowUtil.createAVMLayeredPackage(this.avmService, stagingPath);
|
String packagesPath = AVMWorkflowUtil.createAVMLayeredPackage(this.avmService, stagingPath);
|
||||||
|
|
||||||
// construct diffs for selected items for submission
|
// construct diffs for selected items for submission
|
||||||
|
// mark selected items for submission
|
||||||
String sandboxPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getSandbox());
|
String sandboxPath = AVMConstants.buildAVMStoreRootPath(this.avmBrowseBean.getSandbox());
|
||||||
List<AVMDifference> diffs = new ArrayList<AVMDifference>(this.submitItems.size());
|
List<AVMDifference> diffs = new ArrayList<AVMDifference>(this.submitItems.size());
|
||||||
for (ItemWrapper wrapper : this.submitItems)
|
for (ItemWrapper wrapper : this.submitItems)
|
||||||
@@ -571,6 +586,7 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
String destPath = packagesPath + wrapper.getPath();
|
String destPath = packagesPath + wrapper.getPath();
|
||||||
AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER);
|
AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER);
|
||||||
diffs.add(diff);
|
diffs.add(diff);
|
||||||
|
avmSubmittedAspect.markSubmitted(-1, srcPath, workflowInstanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write changes to layer so files are marked as modified
|
// write changes to layer so files are marked as modified
|
||||||
|
@@ -2132,6 +2132,10 @@
|
|||||||
<property-name>avmSyncService</property-name>
|
<property-name>avmSyncService</property-name>
|
||||||
<value>#{AVMSyncService}</value>
|
<value>#{AVMSyncService}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>avmSubmittedAspect</property-name>
|
||||||
|
<value>#{AVMSubmittedAspect}</value>
|
||||||
|
</managed-property>
|
||||||
<managed-property>
|
<managed-property>
|
||||||
<property-name>avmBrowseBean</property-name>
|
<property-name>avmBrowseBean</property-name>
|
||||||
<value>#{AVMBrowseBean}</value>
|
<value>#{AVMBrowseBean}</value>
|
||||||
@@ -2791,6 +2795,10 @@
|
|||||||
<property-name>avmBrowseBean</property-name>
|
<property-name>avmBrowseBean</property-name>
|
||||||
<value>#{AVMBrowseBean}</value>
|
<value>#{AVMBrowseBean}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>avmSubmittedAspect</property-name>
|
||||||
|
<value>#{AVMSubmittedAspect}</value>
|
||||||
|
</managed-property>
|
||||||
<managed-property>
|
<managed-property>
|
||||||
<property-name>workflowService</property-name>
|
<property-name>workflowService</property-name>
|
||||||
<value>#{WorkflowService}</value>
|
<value>#{WorkflowService}</value>
|
||||||
|
Reference in New Issue
Block a user