. Files in the submit dialog list are now matched against the regular expressions provided for web project workflow definitions

. Configuring the workflow file match regular expression has been moved into the Configure Workflow screen

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4569 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-12-11 16:07:10 +00:00
parent c102cc20d6
commit bedaafd781
6 changed files with 133 additions and 8 deletions

View File

@@ -63,13 +63,16 @@ import org.apache.commons.logging.LogFactory;
*/
public class CreateWebsiteWizard extends BaseWizardBean
{
private static final String COMPONENT_FORMLIST = "form-list";
private static final String COMPONENT_WORKFLOWLIST = "workflow-list";
private static final String MSG_DESCRIPTION = "description";
private static final String MSG_NAME = "name";
private static final String MSG_USERROLES = "create_website_summary_users";
private static final String MSG_FORM_SUMMARY = "website_form_summary";
private static final String MSG_NONE = "value_not_set";
private static final String COMPONENT_FORMLIST = "form-list";
private static final String COMPONENT_WORKFLOWLIST = "workflow-list";
private static final String MATCH_DEFAULT = ".*";
private static final String WEBAPP_DEFAULT = "ROOT";
@@ -661,7 +664,8 @@ public class CreateWebsiteWizard extends BaseWizardBean
if (index != -1)
{
WorkflowDefinition workflow = (WorkflowDefinition)this.workflowsList.get(index).getValue();
this.workflows.add(new WorkflowWrapper(workflow.getName(), workflow.getTitle(), workflow.getDescription()));
this.workflows.add(new WorkflowWrapper(
workflow.getName(), workflow.getTitle(), workflow.getDescription(), MATCH_DEFAULT));
}
}
@@ -946,6 +950,13 @@ public class CreateWebsiteWizard extends BaseWizardBean
private Map<QName, Serializable> params;
public WorkflowWrapper(String name, String title, String description)
{
this.name = name;
this.title = title;
this.description = description;
}
public WorkflowWrapper(String name, String title, String description, String filenamePattern)
{
this.name = name;
this.title = title;

View File

@@ -16,13 +16,18 @@
*/
package org.alfresco.web.bean.wcm;
import java.text.MessageFormat;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import javax.faces.context.FacesContext;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.TransientNode;
@@ -39,8 +44,12 @@ import org.apache.commons.logging.LogFactory;
*/
public class FormWorkflowDialog extends BaseDialogBean
{
private static final String MSG_ERROR_FILENAME_PATTERN = "error_filename_pattern";
private static final Log logger = LogFactory.getLog(FormWorkflowDialog.class);
private String filenamePattern;
protected WorkflowService workflowService;
protected CreateWebsiteWizard websiteWizard;
protected TransientNode workflowNode;
@@ -62,6 +71,29 @@ public class FormWorkflowDialog extends BaseDialogBean
this.websiteWizard = wizard;
}
/**
* @return Returns the filename pattern.
*/
public String getFilenamePattern()
{
if (this.filenamePattern == null)
{
this.filenamePattern = getActionWorkflow().getFilenamePattern();
}
return this.filenamePattern;
}
/**
* @param filenamePattern The filename pattern to set.
*/
public void setFilenamePattern(String filenamePattern)
{
if (this.filenamePattern != null && this.filenamePattern.length() != 0)
{
this.filenamePattern = filenamePattern;
}
}
/**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#init(java.util.Map)
*/
@@ -70,6 +102,7 @@ public class FormWorkflowDialog extends BaseDialogBean
{
super.init(parameters);
this.filenamePattern = null;
this.workflowNode = null;
WorkflowWrapper workflow = getActionWorkflow();
if (workflow != null && workflow.getParams() != null)
@@ -86,11 +119,29 @@ public class FormWorkflowDialog extends BaseDialogBean
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// push serialized params back into workflow object
if (this.workflowNode != null)
{
getActionWorkflow().setParams( WorkflowUtil.prepareTaskParams(this.workflowNode) );
getActionWorkflow().setType(this.workflowNode.getType());
// push serialized params back into workflow object
WorkflowWrapper wf = getActionWorkflow();
wf.setParams(WorkflowUtil.prepareTaskParams(this.workflowNode));
wf.setType(this.workflowNode.getType());
if (this.filenamePattern != null && this.filenamePattern.length() != 0)
{
// check the filename pattern compiles and display an error if a problem occurs
try
{
Pattern.compile(this.filenamePattern);
}
catch (PatternSyntaxException pax)
{
throw new AlfrescoRuntimeException(
MessageFormat.format(
Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_FILENAME_PATTERN),
pax.getMessage()), pax);
}
wf.setFilenamePattern(this.filenamePattern);
}
}
return outcome;
}

View File

@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import javax.faces.context.FacesContext;
@@ -287,13 +288,38 @@ public class SubmitDialog extends BaseDialogBean
NodeRef websiteRef = this.avmBrowseBean.getWebsite().getNodeRef();
List<ChildAssociationRef> webWorkflowRefs = this.nodeService.getChildAssocs(
websiteRef, WCMAppModel.ASSOC_WEBWORKFLOWDEFAULTS, RegexQNamePattern.MATCH_ALL);
List<FormWorkflowWrapper> workflowMatchers = new ArrayList<FormWorkflowWrapper>(webWorkflowRefs.size());
for (ChildAssociationRef ref : webWorkflowRefs)
{
NodeRef wfDefaultsRef = ref.getChildRef();
String wfName = (String)this.nodeService.getProperty(wfDefaultsRef, WCMAppModel.PROP_WORKFLOW_NAME);
Map<QName, Serializable> params = (Map<QName, Serializable>)AVMWorkflowUtil.deserializeWorkflowParams(
wfDefaultsRef);
this.workflows.add(new FormWorkflowWrapper(wfName, params));
String matchPattern = (String)this.nodeService.getProperty(
wfDefaultsRef, WCMAppModel.PROP_FILENAMEPATTERN);
if (matchPattern != null)
{
// add to temp list with the file name pattern
workflowMatchers.add(new FormWorkflowWrapper(wfName, params, matchPattern));
}
}
// perform match on each submitted file against available workflows
for (ItemWrapper wrapper : this.submitItems)
{
String path = wrapper.getPath();
for (int i=0; i<workflowMatchers.size(); i++)
{
// see if the file path matches this workflow path pattern
if (workflowMatchers.get(i).matchesPath(path) == true)
{
// found a match - remove the workflow from the list of ones to check
this.workflows.add(workflowMatchers.get(i));
workflowMatchers.remove(i);
}
}
// if all workflows are matched, there is no need to continue looping
if (workflowMatchers.size() == 0) break;
}
// build a UI item for each available workflow
@@ -531,13 +557,36 @@ public class SubmitDialog extends BaseDialogBean
{
public String Name;
public Map<QName, Serializable> Params;
private Pattern filenamePattern;
FormWorkflowWrapper(String name, Map<QName, Serializable> params)
{
this.Name = name;
this.Params = params;
}
FormWorkflowWrapper(String name, Map<QName, Serializable> params, String filenamePattern)
{
this.Name = name;
this.Params = params;
if (filenamePattern != null)
{
this.filenamePattern = Pattern.compile(filenamePattern);
}
}
boolean matchesPath(String path)
{
if (filenamePattern != null)
{
return filenamePattern.matcher(path).matches();
}
else
{
return false;
}
}
@Override
public int hashCode()
{