mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
converted new rule/run action wizard to new framework
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2734 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -44,10 +44,10 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.context.UIContextService;
|
||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||
import org.alfresco.web.bean.actions.BaseActionWizard;
|
||||
import org.alfresco.web.bean.repository.MapNode;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wizard.NewRuleWizard;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.Utils.URLMode;
|
||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
@@ -489,25 +489,25 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
|
||||
// put the workflow properties in a separate map for use by the JSP
|
||||
this.workflowProperties = new HashMap<String, Serializable>(7);
|
||||
this.workflowProperties.put(NewRuleWizard.PROP_APPROVE_STEP_NAME,
|
||||
this.workflowProperties.put(BaseActionWizard.PROP_APPROVE_STEP_NAME,
|
||||
approveStepName);
|
||||
this.workflowProperties.put(NewRuleWizard.PROP_APPROVE_ACTION,
|
||||
this.workflowProperties.put(BaseActionWizard.PROP_APPROVE_ACTION,
|
||||
approveMove ? "move" : "copy");
|
||||
this.workflowProperties.put(NewRuleWizard.PROP_APPROVE_FOLDER, approveFolder);
|
||||
this.workflowProperties.put(BaseActionWizard.PROP_APPROVE_FOLDER, approveFolder);
|
||||
|
||||
if (rejectStepName == null || rejectMove == null || rejectFolder == null)
|
||||
{
|
||||
this.workflowProperties.put(NewRuleWizard.PROP_REJECT_STEP_PRESENT, "no");
|
||||
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_STEP_PRESENT, "no");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.workflowProperties.put(NewRuleWizard.PROP_REJECT_STEP_PRESENT,
|
||||
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_STEP_PRESENT,
|
||||
"yes");
|
||||
this.workflowProperties.put(NewRuleWizard.PROP_REJECT_STEP_NAME,
|
||||
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_STEP_NAME,
|
||||
rejectStepName);
|
||||
this.workflowProperties.put(NewRuleWizard.PROP_REJECT_ACTION,
|
||||
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_ACTION,
|
||||
rejectMove ? "move" : "copy");
|
||||
this.workflowProperties.put(NewRuleWizard.PROP_REJECT_FOLDER,
|
||||
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_FOLDER,
|
||||
rejectFolder);
|
||||
}
|
||||
}
|
||||
@@ -553,11 +553,11 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
|
||||
// set the approve step name
|
||||
updateProps.put(ContentModel.PROP_APPROVE_STEP,
|
||||
this.workflowProperties.get(NewRuleWizard.PROP_APPROVE_STEP_NAME));
|
||||
this.workflowProperties.get(BaseActionWizard.PROP_APPROVE_STEP_NAME));
|
||||
|
||||
// specify whether the approve step will copy or move the content
|
||||
boolean approveMove = true;
|
||||
String approveAction = (String)this.workflowProperties.get(NewRuleWizard.PROP_APPROVE_ACTION);
|
||||
String approveAction = (String)this.workflowProperties.get(BaseActionWizard.PROP_APPROVE_ACTION);
|
||||
if (approveAction != null && approveAction.equals("copy"))
|
||||
{
|
||||
approveMove = false;
|
||||
@@ -566,12 +566,12 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
|
||||
// create node ref representation of the destination folder
|
||||
updateProps.put(ContentModel.PROP_APPROVE_FOLDER,
|
||||
this.workflowProperties.get(NewRuleWizard.PROP_APPROVE_FOLDER));
|
||||
this.workflowProperties.get(BaseActionWizard.PROP_APPROVE_FOLDER));
|
||||
|
||||
// determine whether there should be a reject step
|
||||
boolean requireReject = true;
|
||||
String rejectStepPresent = (String)this.workflowProperties.get(
|
||||
NewRuleWizard.PROP_REJECT_STEP_PRESENT);
|
||||
BaseActionWizard.PROP_REJECT_STEP_PRESENT);
|
||||
if (rejectStepPresent != null && rejectStepPresent.equals("no"))
|
||||
{
|
||||
requireReject = false;
|
||||
@@ -581,12 +581,12 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
{
|
||||
// set the reject step name
|
||||
updateProps.put(ContentModel.PROP_REJECT_STEP,
|
||||
this.workflowProperties.get(NewRuleWizard.PROP_REJECT_STEP_NAME));
|
||||
this.workflowProperties.get(BaseActionWizard.PROP_REJECT_STEP_NAME));
|
||||
|
||||
// specify whether the reject step will copy or move the content
|
||||
boolean rejectMove = true;
|
||||
String rejectAction = (String)this.workflowProperties.get(
|
||||
NewRuleWizard.PROP_REJECT_ACTION);
|
||||
BaseActionWizard.PROP_REJECT_ACTION);
|
||||
if (rejectAction != null && rejectAction.equals("copy"))
|
||||
{
|
||||
rejectMove = false;
|
||||
@@ -595,7 +595,7 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
|
||||
// create node ref representation of the destination folder
|
||||
updateProps.put(ContentModel.PROP_REJECT_FOLDER,
|
||||
this.workflowProperties.get(NewRuleWizard.PROP_REJECT_FOLDER));
|
||||
this.workflowProperties.get(BaseActionWizard.PROP_REJECT_FOLDER));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,93 @@
|
||||
package org.alfresco.web.bean.actions;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.web.app.Application;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Run Action" wizard.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class RunActionWizard extends BaseActionWizard
|
||||
{
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// execute each action added in the wizard
|
||||
for (Map<String, Serializable> actionParams : this.allActionsProperties)
|
||||
{
|
||||
// use the base class version of buildActionParams(), but for this we need
|
||||
// to setup the currentActionProperties and action variables
|
||||
String actionName = (String)actionParams.get(PROP_ACTION_NAME);
|
||||
this.action = actionName;
|
||||
this.currentActionProperties = actionParams;
|
||||
Map<String, Serializable> repoActionParams = buildActionParams();
|
||||
|
||||
// add the action to the rule
|
||||
Action action = this.actionService.createAction(actionName);
|
||||
action.setParameterValues(repoActionParams);
|
||||
|
||||
// execute the action on the current document node
|
||||
this.actionService.executeAction(action, this.browseBean.getDocument().getNodeRef());
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
// reset the current document properties/aspects in case we have changed them
|
||||
// during the execution of the custom action
|
||||
this.browseBean.getDocument().reset();
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getErrorMessageId()
|
||||
{
|
||||
return "error_actions";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
// create the summary using all the actions
|
||||
StringBuilder actionsSummary = new StringBuilder();
|
||||
for (Map<String, Serializable> props : this.allActionsProperties)
|
||||
{
|
||||
actionsSummary.append(props.get(PROP_ACTION_SUMMARY));
|
||||
actionsSummary.append("<br/>");
|
||||
}
|
||||
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
|
||||
return buildSummary(
|
||||
new String[] {bundle.getString("actions")},
|
||||
new String[] {actionsSummary.toString()});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getNextButtonDisabled()
|
||||
{
|
||||
return (this.allActionsDataModel.getRowCount() == 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return (this.allActionsDataModel.getRowCount() == 0);
|
||||
}
|
||||
}
|
@@ -23,8 +23,6 @@ import org.alfresco.web.ui.common.Utils;
|
||||
*/
|
||||
public abstract class BaseDialogBean implements IDialogBean
|
||||
{
|
||||
protected static final String ERROR_ID = "error_generic";
|
||||
|
||||
// services common to most dialogs
|
||||
protected BrowseBean browseBean;
|
||||
protected NavigationBean navigator;
|
||||
@@ -177,6 +175,14 @@ public abstract class BaseDialogBean implements IDialogBean
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The error message lookup id
|
||||
*/
|
||||
protected String getErrorMessageId()
|
||||
{
|
||||
return "error_generic";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted exception string for the given exception
|
||||
*
|
||||
@@ -186,7 +192,7 @@ public abstract class BaseDialogBean implements IDialogBean
|
||||
protected String formatErrorMessage(Throwable exception)
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), ERROR_ID),
|
||||
FacesContext.getCurrentInstance(), getErrorMessageId()),
|
||||
exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
811
source/java/org/alfresco/web/bean/rules/CreateRuleWizard.java
Normal file
811
source/java/org/alfresco/web/bean/rules/CreateRuleWizard.java
Normal file
@@ -0,0 +1,811 @@
|
||||
package org.alfresco.web.bean.rules;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.model.DataModel;
|
||||
import javax.faces.model.ListDataModel;
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import org.alfresco.config.Config;
|
||||
import org.alfresco.config.ConfigElement;
|
||||
import org.alfresco.config.ConfigService;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.evaluator.CompareMimeTypeEvaluator;
|
||||
import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
|
||||
import org.alfresco.repo.action.evaluator.HasAspectEvaluator;
|
||||
import org.alfresco.repo.action.evaluator.InCategoryEvaluator;
|
||||
import org.alfresco.repo.action.evaluator.IsSubTypeEvaluator;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.action.ActionConditionDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.rule.Rule;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.rule.RuleType;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.actions.BaseActionWizard;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Create Rule" wizard
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class CreateRuleWizard extends BaseActionWizard
|
||||
{
|
||||
public static final String PROP_CONDITION_NAME = "conditionName";
|
||||
public static final String PROP_CONDITION_SUMMARY = "conditionSummary";
|
||||
public static final String PROP_CONDITION_NOT = "notcondition";
|
||||
|
||||
protected RuleService ruleService;
|
||||
protected RulesBean rulesBean;
|
||||
|
||||
private List<SelectItem> modelTypes;
|
||||
private List<SelectItem> mimeTypes;
|
||||
private List<SelectItem> types;
|
||||
private List<SelectItem> conditions;
|
||||
|
||||
protected Map<String, Serializable> currentConditionProperties;
|
||||
protected List<Map<String, Serializable>> allConditionsProperties;
|
||||
|
||||
protected DataModel allConditionsDataModel;
|
||||
|
||||
protected String title;
|
||||
protected String description;
|
||||
protected String type;
|
||||
protected String condition;
|
||||
protected boolean runInBackground;
|
||||
protected boolean applyToSubSpaces;
|
||||
protected boolean editingCondition;
|
||||
|
||||
protected static final String CONDITION_PAGES_LOCATION = "/jsp/rules/";
|
||||
|
||||
private static final Log logger = LogFactory.getLog(CreateRuleWizard.class);
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
this.title = null;
|
||||
this.description = null;
|
||||
this.type = "inbound";
|
||||
this.condition = null;
|
||||
this.applyToSubSpaces = false;
|
||||
this.runInBackground = false;
|
||||
this.conditions = null;
|
||||
|
||||
this.allConditionsProperties = new ArrayList<Map<String, Serializable>>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
// get hold of the space the rule will apply to and make sure
|
||||
// it is actionable
|
||||
Node currentSpace = this.browseBean.getActionSpace();
|
||||
|
||||
// create the new rule
|
||||
Rule rule = this.ruleService.createRule(this.getType());
|
||||
|
||||
// setup the rule
|
||||
outcome = setupRule(context, rule, outcome);
|
||||
|
||||
// Save the rule
|
||||
this.ruleService.saveRule(currentSpace.getNodeRef(), rule);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Added rule '" + this.title + "'");
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getNextButtonDisabled()
|
||||
{
|
||||
// TODO: Allow the next button state to be configured so that
|
||||
// wizard implementations don't have to worry about
|
||||
// checking step numbers
|
||||
|
||||
boolean disabled = true;
|
||||
int step = Application.getWizardManager().getCurrentStep();
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
disabled = (this.allConditionsDataModel == null ||
|
||||
this.allConditionsDataModel.getRowCount() == 0);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
disabled = (this.allActionsDataModel == null ||
|
||||
this.allActionsDataModel.getRowCount() == 0);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
disabled = (this.title == null || this.title.length() == 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
if (this.allActionsDataModel != null &&
|
||||
this.allActionsDataModel.getRowCount() > 0 &&
|
||||
this.allConditionsDataModel != null &&
|
||||
this.allConditionsDataModel.getRowCount() > 0 &&
|
||||
this.title != null && this.title.length() > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
// create the summary using all the conditions
|
||||
StringBuilder conditionsSummary = new StringBuilder();
|
||||
for (Map<String, Serializable> props : this.allConditionsProperties)
|
||||
{
|
||||
conditionsSummary.append(props.get(PROP_CONDITION_SUMMARY));
|
||||
conditionsSummary.append("<br/>");
|
||||
}
|
||||
|
||||
// create the summary using all the actions
|
||||
StringBuilder actionsSummary = new StringBuilder();
|
||||
for (Map<String, Serializable> props : this.allActionsProperties)
|
||||
{
|
||||
actionsSummary.append(props.get(PROP_ACTION_SUMMARY));
|
||||
actionsSummary.append("<br/>");
|
||||
}
|
||||
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
|
||||
String backgroundYesNo = this.runInBackground ? bundle.getString("yes") : bundle.getString("no");
|
||||
String subSpacesYesNo = this.applyToSubSpaces ? bundle.getString("yes") : bundle.getString("no");
|
||||
|
||||
return buildSummary(
|
||||
new String[] {bundle.getString("rule_type"), bundle.getString("name"), bundle.getString("description"),
|
||||
bundle.getString("apply_to_sub_spaces"), bundle.getString("run_in_background"),
|
||||
bundle.getString("conditions"), bundle.getString("actions")},
|
||||
new String[] {this.type, this.title, this.description, subSpacesYesNo, backgroundYesNo,
|
||||
conditionsSummary.toString(), actionsSummary.toString()});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getErrorMessageId()
|
||||
{
|
||||
return "error_rule";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the given rule using the current state of the wizard
|
||||
*
|
||||
* @param context FacesContext
|
||||
* @param rule The rule to setup
|
||||
* @param outcome The default outcome
|
||||
* @return The outcome
|
||||
*/
|
||||
protected String setupRule(FacesContext context, Rule rule, String outcome)
|
||||
{
|
||||
// setup the rule and add it to the space
|
||||
rule.setTitle(this.title);
|
||||
rule.setDescription(this.description);
|
||||
rule.applyToChildren(this.applyToSubSpaces);
|
||||
rule.setExecuteAsynchronously(this.runInBackground);
|
||||
|
||||
// add all the conditions to the rule
|
||||
for (Map<String, Serializable> condParams : this.allConditionsProperties)
|
||||
{
|
||||
Map<String, Serializable> repoCondParams = buildConditionParams(condParams);
|
||||
|
||||
// add the condition to the rule
|
||||
ActionCondition condition = this.actionService.createActionCondition(
|
||||
(String)condParams.get(PROP_CONDITION_NAME));
|
||||
condition.setParameterValues(repoCondParams);
|
||||
|
||||
// specify whether the condition result should be inverted
|
||||
Boolean not = (Boolean)condParams.get(PROP_CONDITION_NOT);
|
||||
condition.setInvertCondition(((Boolean)not).booleanValue());
|
||||
|
||||
rule.addActionCondition(condition);
|
||||
}
|
||||
|
||||
// add all the actions to the rule
|
||||
for (Map<String, Serializable> actionParams : this.allActionsProperties)
|
||||
{
|
||||
// use the base class version of buildActionParams(), but for this we need
|
||||
// to setup the currentActionProperties and action variables
|
||||
String actionName = (String)actionParams.get(PROP_ACTION_NAME);
|
||||
this.action = actionName;
|
||||
this.currentActionProperties = actionParams;
|
||||
Map<String, Serializable> repoActionParams = buildActionParams();
|
||||
|
||||
// add the action to the rule
|
||||
Action action = this.actionService.createAction(actionName);
|
||||
action.setParameterValues(repoActionParams);
|
||||
rule.addAction(action);
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* Returns the properties for all the conditions as a JSF DataModel
|
||||
*
|
||||
* @return JSF DataModel representing the condition properties
|
||||
*/
|
||||
public DataModel getAllConditionsDataModel()
|
||||
{
|
||||
if (this.allConditionsDataModel == null)
|
||||
{
|
||||
this.allConditionsDataModel = new ListDataModel();
|
||||
}
|
||||
|
||||
this.allConditionsDataModel.setWrappedData(this.allConditionsProperties);
|
||||
|
||||
return this.allConditionsDataModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the types available in the repository
|
||||
*
|
||||
* @return List of SelectItem objects
|
||||
*/
|
||||
public List<SelectItem> getModelTypes()
|
||||
{
|
||||
if (this.modelTypes == null)
|
||||
{
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
ConfigService svc = Application.getConfigService(context);
|
||||
Config wizardCfg = svc.getConfig("Action Wizards");
|
||||
if (wizardCfg != null)
|
||||
{
|
||||
ConfigElement typesCfg = wizardCfg.getConfigElement("types");
|
||||
if (typesCfg != null)
|
||||
{
|
||||
this.modelTypes = new ArrayList<SelectItem>();
|
||||
for (ConfigElement child : typesCfg.getChildren())
|
||||
{
|
||||
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
|
||||
|
||||
// get the display label from config
|
||||
String label = Utils.getDisplayLabel(context, child);
|
||||
|
||||
// if there wasn't a client based label try and get it from the dictionary
|
||||
if (label == null)
|
||||
{
|
||||
TypeDefinition typeDef = this.dictionaryService.getType(idQName);
|
||||
if (typeDef != null)
|
||||
{
|
||||
label = typeDef.getTitle();
|
||||
}
|
||||
else
|
||||
{
|
||||
label = idQName.getLocalName();
|
||||
}
|
||||
}
|
||||
|
||||
this.modelTypes.add(new SelectItem(idQName.toString(), label));
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(this.modelTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Could not find types configuration element");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("Could not find Action Wizards configuration section");
|
||||
}
|
||||
}
|
||||
|
||||
return this.modelTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of mime types in the system
|
||||
*
|
||||
* @return List of mime types
|
||||
*/
|
||||
public List<SelectItem> getMimeTypes()
|
||||
{
|
||||
if (this.mimeTypes == null)
|
||||
{
|
||||
this.mimeTypes = new ArrayList<SelectItem>(50);
|
||||
|
||||
Map<String, String> mimeTypes = mimetypeService.getDisplaysByMimetype();
|
||||
for (String mimeType : mimeTypes.keySet())
|
||||
{
|
||||
this.mimeTypes.add(new SelectItem(mimeType, mimeTypes.get(mimeType)));
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the values
|
||||
QuickSort sorter = new QuickSort(this.mimeTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
}
|
||||
|
||||
return this.mimeTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the list of selectable conditions
|
||||
*/
|
||||
public List<SelectItem> getConditions()
|
||||
{
|
||||
if (this.conditions == null)
|
||||
{
|
||||
List<ActionConditionDefinition> ruleConditions = this.actionService.getActionConditionDefinitions();
|
||||
this.conditions = new ArrayList<SelectItem>(ruleConditions.size());
|
||||
for (ActionConditionDefinition ruleConditionDef : ruleConditions)
|
||||
{
|
||||
// add to SelectItem list
|
||||
this.conditions.add(new SelectItem(ruleConditionDef.getName(),
|
||||
ruleConditionDef.getTitle()));
|
||||
}
|
||||
|
||||
// make sure the list is sorted by the label
|
||||
QuickSort sorter = new QuickSort(this.conditions, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||
sorter.sort();
|
||||
|
||||
// add the "Select a condition" entry at the beginning of the list
|
||||
this.conditions.add(0, new SelectItem("null",
|
||||
Application.getMessage(FacesContext.getCurrentInstance(), "select_a_condition")));
|
||||
}
|
||||
|
||||
return this.conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the types of rules that can be defined
|
||||
*/
|
||||
public List<SelectItem> getTypes()
|
||||
{
|
||||
if (this.types == null)
|
||||
{
|
||||
List<RuleType> ruleTypes = this.ruleService.getRuleTypes();
|
||||
this.types = new ArrayList<SelectItem>(ruleTypes.size());
|
||||
for (RuleType ruleType : ruleTypes)
|
||||
{
|
||||
this.types.add(new SelectItem(ruleType.getName(), ruleType.getDisplayLabel()));
|
||||
}
|
||||
}
|
||||
|
||||
return this.types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Gets the condition settings
|
||||
*/
|
||||
public Map<String, Serializable> getConditionProperties()
|
||||
{
|
||||
return this.currentConditionProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the description.
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description The description to set.
|
||||
*/
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the title.
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title The title to set.
|
||||
*/
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether the rule should run in the background
|
||||
*/
|
||||
public boolean getRunInBackground()
|
||||
{
|
||||
return this.runInBackground;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param runInBackground Sets whether the rule should run in the background
|
||||
*/
|
||||
public void setRunInBackground(boolean runInBackground)
|
||||
{
|
||||
this.runInBackground = runInBackground;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether the rule should be applied to sub spaces i.e. if it gets inherited
|
||||
*/
|
||||
public boolean getApplyToSubSpaces()
|
||||
{
|
||||
return this.applyToSubSpaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param applyToSubSpaces Sets whether the rule will get applied to sub spaces
|
||||
*/
|
||||
public void setApplyToSubSpaces(boolean applyToSubSpaces)
|
||||
{
|
||||
this.applyToSubSpaces = applyToSubSpaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the type.
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type The type to set
|
||||
*/
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the selected condition
|
||||
*/
|
||||
public String getCondition()
|
||||
{
|
||||
return this.condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param condition Sets the selected condition
|
||||
*/
|
||||
public void setCondition(String condition)
|
||||
{
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Action event handlers
|
||||
|
||||
/**
|
||||
* Displays the settings page for the current condition being added (if required)
|
||||
*/
|
||||
public void promptForConditionValues()
|
||||
{
|
||||
// set the flag to show we are creating a new condition
|
||||
this.editingCondition = false;
|
||||
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
this.returnViewId = context.getViewRoot().getViewId();
|
||||
String viewId = calculateConditionViewId(this.condition);
|
||||
|
||||
HashMap<String, Serializable> condProps = new HashMap<String, Serializable>(3);
|
||||
condProps.put(PROP_CONDITION_NAME, this.condition);
|
||||
|
||||
if ("no-condition".equals(this.condition))
|
||||
{
|
||||
condProps.put(PROP_CONDITION_SUMMARY, Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), "condition_no_condition"));
|
||||
condProps.put(PROP_CONDITION_NOT, Boolean.FALSE);
|
||||
this.allConditionsProperties.add(condProps);
|
||||
|
||||
// come back to the same page we're on now
|
||||
viewId = this.returnViewId;
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Add 'no-condition' condition to list");
|
||||
}
|
||||
else if (this.condition != null)
|
||||
{
|
||||
this.currentConditionProperties = condProps;
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Added '" + this.condition + "' condition to list");
|
||||
}
|
||||
|
||||
// reset the selected condition drop down
|
||||
this.condition = null;
|
||||
|
||||
// go to the page to collect the settings
|
||||
goToPage(context, viewId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the context for editing existing condition values
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void editCondition()
|
||||
{
|
||||
// use the built in JSF support for retrieving the object for the
|
||||
// row that was clicked by the user
|
||||
Map conditionToEdit = (Map)this.allConditionsDataModel.getRowData();
|
||||
this.condition = (String)conditionToEdit.get(PROP_CONDITION_NAME);
|
||||
this.currentConditionProperties = conditionToEdit;
|
||||
|
||||
// set the flag to show we are editing a condition
|
||||
this.editingCondition = true;
|
||||
|
||||
// remember the page we're on
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
this.returnViewId = context.getViewRoot().getViewId();
|
||||
|
||||
// refresh the wizard
|
||||
goToPage(context, calculateConditionViewId(this.condition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the condition just setup by the user to the list of conditions for the rule
|
||||
*/
|
||||
public void addCondition()
|
||||
{
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
String summary = buildConditionSummary(this.currentConditionProperties);
|
||||
|
||||
if (summary != null)
|
||||
{
|
||||
this.currentConditionProperties.put(PROP_CONDITION_SUMMARY, summary);
|
||||
}
|
||||
|
||||
if (this.editingCondition)
|
||||
{
|
||||
this.condition = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.allConditionsProperties.add(this.currentConditionProperties);
|
||||
}
|
||||
|
||||
// refresh the wizard
|
||||
goToPage(context, this.returnViewId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the requested condition from the list
|
||||
*/
|
||||
public void removeCondition()
|
||||
{
|
||||
// use the built in JSF support for retrieving the object for the
|
||||
// row that was clicked by the user
|
||||
Map conditionToRemove = (Map)this.allConditionsDataModel.getRowData();
|
||||
this.allConditionsProperties.remove(conditionToRemove);
|
||||
|
||||
// reset the action drop down
|
||||
this.condition = null;
|
||||
|
||||
// refresh the wizard
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
goToPage(context, context.getViewRoot().getViewId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the addition of the condition
|
||||
*/
|
||||
public void cancelAddCondition()
|
||||
{
|
||||
if (this.editingCondition)
|
||||
{
|
||||
this.condition = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentConditionProperties.clear();
|
||||
}
|
||||
|
||||
// refresh the wizard
|
||||
goToPage(FacesContext.getCurrentInstance(), this.returnViewId);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Service Injection
|
||||
|
||||
/**
|
||||
* @param ruleService Sets the rule service to use
|
||||
*/
|
||||
public void setRuleService(RuleService ruleService)
|
||||
{
|
||||
this.ruleService = ruleService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the RulesBean instance to be used by the wizard in edit mode
|
||||
*
|
||||
* @param rulesBean The RulesBean
|
||||
*/
|
||||
public void setRulesBean(RulesBean rulesBean)
|
||||
{
|
||||
this.rulesBean = rulesBean;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper methods
|
||||
|
||||
/**
|
||||
* Builds the Map of properties for the given condition in the format the repo is expecting
|
||||
*
|
||||
* @param params The Map of properties built from the UI
|
||||
* @return The Map the repo is expecting
|
||||
*/
|
||||
protected Map<String, Serializable> buildConditionParams(Map<String, Serializable> params)
|
||||
{
|
||||
Map<String, Serializable> repoParams = new HashMap<String, Serializable>(params.size());
|
||||
|
||||
String condName = (String)params.get(PROP_CONDITION_NAME);
|
||||
if (ComparePropertyValueEvaluator.NAME.equals(condName))
|
||||
{
|
||||
repoParams.put(ComparePropertyValueEvaluator.PARAM_VALUE, params.get(PROP_CONTAINS_TEXT));
|
||||
}
|
||||
else if (InCategoryEvaluator.NAME.equals(condName))
|
||||
{
|
||||
// put the selected category in the condition params
|
||||
repoParams.put(InCategoryEvaluator.PARAM_CATEGORY_VALUE, params.get(PROP_CATEGORY));
|
||||
|
||||
// add the classifiable aspect
|
||||
repoParams.put(InCategoryEvaluator.PARAM_CATEGORY_ASPECT, ContentModel.ASPECT_GEN_CLASSIFIABLE);
|
||||
}
|
||||
else if (IsSubTypeEvaluator.NAME.equals(condName))
|
||||
{
|
||||
// add the model type
|
||||
repoParams.put(IsSubTypeEvaluator.PARAM_TYPE, QName.createQName((String)params.get(PROP_MODEL_TYPE)));
|
||||
}
|
||||
else if (HasAspectEvaluator.NAME.equals(condName))
|
||||
{
|
||||
// add the aspect
|
||||
repoParams.put(HasAspectEvaluator.PARAM_ASPECT, QName.createQName((String)params.get(PROP_ASPECT)));
|
||||
}
|
||||
else if (CompareMimeTypeEvaluator.NAME.equals(condName))
|
||||
{
|
||||
repoParams.put(CompareMimeTypeEvaluator.PARAM_VALUE, params.get(PROP_MIMETYPE));
|
||||
}
|
||||
|
||||
return repoParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a summary string for the given condition parameters
|
||||
*
|
||||
* @return The summary or null if a summary could not be built
|
||||
*/
|
||||
protected String buildConditionSummary(Map<String, Serializable> props)
|
||||
{
|
||||
String summaryResult = null;
|
||||
|
||||
String condName = (String)props.get(PROP_CONDITION_NAME);
|
||||
if (condName != null)
|
||||
{
|
||||
StringBuilder summary = new StringBuilder();
|
||||
|
||||
String msgId = "condition_" + condName.replace('-', '_');
|
||||
|
||||
// JSF is putting the boolean into the map as a Boolean object so we
|
||||
// need to handle that - adding a converter doesn't seem to help!
|
||||
Boolean not = (Boolean)props.get(PROP_CONDITION_NOT);
|
||||
if (not.booleanValue())
|
||||
{
|
||||
msgId = msgId + "_not";
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Looking up condition summary string: " + msgId);
|
||||
|
||||
summary.append(Application.getMessage(FacesContext.getCurrentInstance(), msgId));
|
||||
summary.append(" ");
|
||||
|
||||
// define a summary to be added for each condition
|
||||
if (InCategoryEvaluator.NAME.equals(condName))
|
||||
{
|
||||
String name = Repository.getNameForNode(this.nodeService, (NodeRef)props.get(PROP_CATEGORY));
|
||||
summary.append("'").append(name).append("'");
|
||||
}
|
||||
else if (ComparePropertyValueEvaluator.NAME.equals(condName))
|
||||
{
|
||||
summary.append("'");
|
||||
summary.append(props.get(PROP_CONTAINS_TEXT));
|
||||
summary.append("'");
|
||||
}
|
||||
else if (IsSubTypeEvaluator.NAME.equals(condName))
|
||||
{
|
||||
// find the label used by looking through the SelectItem list
|
||||
String typeName = (String)props.get(PROP_MODEL_TYPE);
|
||||
for (SelectItem item : this.getModelTypes())
|
||||
{
|
||||
if (item.getValue().equals(typeName))
|
||||
{
|
||||
summary.append("'").append(item.getLabel()).append("'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (HasAspectEvaluator.NAME.equals(condName))
|
||||
{
|
||||
// find the label used by looking through the SelectItem list
|
||||
String aspectName = (String)props.get(PROP_ASPECT);
|
||||
for (SelectItem item : this.getAspects())
|
||||
{
|
||||
if (item.getValue().equals(aspectName))
|
||||
{
|
||||
summary.append("'").append(item.getLabel()).append("'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CompareMimeTypeEvaluator.NAME.equals(condName))
|
||||
{
|
||||
String mimetype = (String)props.get(PROP_MIMETYPE);
|
||||
for (SelectItem item : this.getMimeTypes())
|
||||
{
|
||||
if (item.getValue().equals(mimetype))
|
||||
{
|
||||
summary.append("'").append(item.getLabel()).append("'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
summaryResult = summary.toString();
|
||||
}
|
||||
|
||||
return summaryResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the viewId for the given condition id
|
||||
*
|
||||
* @param conditionId The id of the condition to generate the view id for
|
||||
* @return The view id
|
||||
*/
|
||||
protected String calculateConditionViewId(String conditionId)
|
||||
{
|
||||
return CONDITION_PAGES_LOCATION + conditionId + ".jsp";
|
||||
}
|
||||
}
|
310
source/java/org/alfresco/web/bean/rules/EditRuleWizard.java
Normal file
310
source/java/org/alfresco/web/bean/rules/EditRuleWizard.java
Normal file
@@ -0,0 +1,310 @@
|
||||
package org.alfresco.web.bean.rules;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.action.evaluator.CompareMimeTypeEvaluator;
|
||||
import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
|
||||
import org.alfresco.repo.action.evaluator.HasAspectEvaluator;
|
||||
import org.alfresco.repo.action.evaluator.InCategoryEvaluator;
|
||||
import org.alfresco.repo.action.evaluator.IsSubTypeEvaluator;
|
||||
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
|
||||
import org.alfresco.repo.action.executer.CheckInActionExecuter;
|
||||
import org.alfresco.repo.action.executer.CheckOutActionExecuter;
|
||||
import org.alfresco.repo.action.executer.CopyActionExecuter;
|
||||
import org.alfresco.repo.action.executer.ImageTransformActionExecuter;
|
||||
import org.alfresco.repo.action.executer.ImporterActionExecuter;
|
||||
import org.alfresco.repo.action.executer.LinkCategoryActionExecuter;
|
||||
import org.alfresco.repo.action.executer.MailActionExecuter;
|
||||
import org.alfresco.repo.action.executer.MoveActionExecuter;
|
||||
import org.alfresco.repo.action.executer.RemoveFeaturesActionExecuter;
|
||||
import org.alfresco.repo.action.executer.SimpleWorkflowActionExecuter;
|
||||
import org.alfresco.repo.action.executer.SpecialiseTypeActionExecuter;
|
||||
import org.alfresco.repo.action.executer.TransformActionExecuter;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.rule.Rule;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Bean implementation for the "Edit Rule" wizard
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class EditRuleWizard extends CreateRuleWizard
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(EditRuleWizard.class);
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// get hold of the space the rule will apply to and make sure
|
||||
// it is actionable
|
||||
Node currentSpace = browseBean.getActionSpace();
|
||||
|
||||
// get the existing rule
|
||||
Rule rule = this.rulesBean.getCurrentRule();
|
||||
|
||||
// remove all the conditions and actions from the current rule
|
||||
rule.removeAllActionConditions();
|
||||
rule.removeAllActions();
|
||||
|
||||
// re-setup the rule
|
||||
outcome = setupRule(context, rule, outcome);
|
||||
|
||||
// Save the rule
|
||||
this.ruleService.saveRule(currentSpace.getNodeRef(), rule);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Updated rule '" + this.title + "'");
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
// get hold of the current rule details
|
||||
Rule rule = this.rulesBean.getCurrentRule();
|
||||
|
||||
if (rule == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to locate the current rule");
|
||||
}
|
||||
|
||||
// populate the bean with current values
|
||||
this.type = rule.getRuleTypeName();
|
||||
this.title = rule.getTitle();
|
||||
this.description = rule.getDescription();
|
||||
this.applyToSubSpaces = rule.isAppliedToChildren();
|
||||
this.runInBackground = rule.getExecuteAsychronously();
|
||||
|
||||
// populate the conditions list with maps of properties representing each condition
|
||||
List<ActionCondition> conditions = rule.getActionConditions();
|
||||
for (ActionCondition condition : conditions)
|
||||
{
|
||||
Map<String, Serializable> params = populateCondition(condition);
|
||||
this.allConditionsProperties.add(params);
|
||||
}
|
||||
|
||||
List<Action> actions = rule.getActions();
|
||||
for (Action action : actions)
|
||||
{
|
||||
// use the base class version of populateActionFromProperties(),
|
||||
// but for this we need to setup the currentActionProperties and
|
||||
// action variables
|
||||
this.currentActionProperties = new HashMap<String, Serializable>(3);
|
||||
this.action = action.getActionDefinitionName();
|
||||
populateAction(action.getParameterValues());
|
||||
|
||||
// also add the name and summary
|
||||
this.currentActionProperties.put(PROP_ACTION_NAME, this.action);
|
||||
// generate the summary
|
||||
this.currentActionProperties.put(PROP_ACTION_SUMMARY,
|
||||
buildActionSummary(this.currentActionProperties));
|
||||
|
||||
// add the populated currentActionProperties to the list
|
||||
this.allActionsProperties.add(this.currentActionProperties);
|
||||
}
|
||||
|
||||
// reset the current action
|
||||
this.action = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates a Map of properties the wizard is expecting for the given condition
|
||||
*
|
||||
* @param condition The condition to build the map for
|
||||
*/
|
||||
protected Map<String, Serializable> populateCondition(ActionCondition condition)
|
||||
{
|
||||
// find out what the condition is called
|
||||
Map<String, Serializable> condProps = new HashMap<String, Serializable>(3);
|
||||
String name = condition.getActionConditionDefinitionName();
|
||||
condProps.put(PROP_CONDITION_NAME, name);
|
||||
|
||||
// add the appropriate properties
|
||||
Map<String, Serializable> repoCondProps = condition.getParameterValues();
|
||||
if (name.equals(ComparePropertyValueEvaluator.NAME))
|
||||
{
|
||||
condProps.put(PROP_CONTAINS_TEXT, (String)repoCondProps.get(ComparePropertyValueEvaluator.PARAM_VALUE));
|
||||
}
|
||||
else if (name.equals(InCategoryEvaluator.NAME))
|
||||
{
|
||||
NodeRef catNodeRef = (NodeRef)repoCondProps.get(InCategoryEvaluator.PARAM_CATEGORY_VALUE);
|
||||
condProps.put(PROP_CATEGORY, catNodeRef);
|
||||
}
|
||||
else if (name.equals(IsSubTypeEvaluator.NAME))
|
||||
{
|
||||
condProps.put(PROP_MODEL_TYPE, ((QName)repoCondProps.get(IsSubTypeEvaluator.PARAM_TYPE)).toString());
|
||||
}
|
||||
else if (name.equals(HasAspectEvaluator.NAME))
|
||||
{
|
||||
condProps.put(PROP_ASPECT, ((QName)repoCondProps.get(HasAspectEvaluator.PARAM_ASPECT)).toString());
|
||||
}
|
||||
else if (name.equals(CompareMimeTypeEvaluator.NAME))
|
||||
{
|
||||
condProps.put(PROP_MIMETYPE, repoCondProps.get(CompareMimeTypeEvaluator.PARAM_VALUE));
|
||||
}
|
||||
|
||||
// specify whether the condition result should be inverted
|
||||
condProps.put(PROP_CONDITION_NOT, Boolean.valueOf(condition.getInvertCondition()));
|
||||
|
||||
// generate the summary
|
||||
condProps.put(PROP_CONDITION_SUMMARY, buildConditionSummary(condProps));
|
||||
|
||||
return condProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the actionProperties member variable with correct props for the current action
|
||||
* using the supplied property map.
|
||||
*
|
||||
* @param actionProps Map to retrieve props appropriate to the current action from
|
||||
*/
|
||||
protected void populateAction(Map<String, Serializable> actionProps)
|
||||
{
|
||||
if (this.action.equals(AddFeaturesActionExecuter.NAME))
|
||||
{
|
||||
QName aspect = (QName)actionProps.get(AddFeaturesActionExecuter.PARAM_ASPECT_NAME);
|
||||
this.currentActionProperties.put(PROP_ASPECT, aspect.toString());
|
||||
}
|
||||
else if (this.action.equals(RemoveFeaturesActionExecuter.NAME))
|
||||
{
|
||||
QName aspect = (QName)actionProps.get(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME);
|
||||
this.currentActionProperties.put(PROP_ASPECT, aspect.toString());
|
||||
}
|
||||
else if (this.action.equals(CopyActionExecuter.NAME))
|
||||
{
|
||||
NodeRef destNodeRef = (NodeRef)actionProps.get(CopyActionExecuter.PARAM_DESTINATION_FOLDER);
|
||||
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
|
||||
}
|
||||
else if (this.action.equals(MoveActionExecuter.NAME))
|
||||
{
|
||||
NodeRef destNodeRef = (NodeRef)actionProps.get(MoveActionExecuter.PARAM_DESTINATION_FOLDER);
|
||||
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
|
||||
}
|
||||
else if (this.action.equals(SimpleWorkflowActionExecuter.NAME))
|
||||
{
|
||||
String approveStep = (String)actionProps.get(SimpleWorkflowActionExecuter.PARAM_APPROVE_STEP);
|
||||
Boolean approveMove = (Boolean)actionProps.get(SimpleWorkflowActionExecuter.PARAM_APPROVE_MOVE);
|
||||
NodeRef approveFolderNode = (NodeRef)actionProps.get(
|
||||
SimpleWorkflowActionExecuter.PARAM_APPROVE_FOLDER);
|
||||
|
||||
String rejectStep = (String)actionProps.get(SimpleWorkflowActionExecuter.PARAM_REJECT_STEP);
|
||||
Boolean rejectMove = (Boolean)actionProps.get(SimpleWorkflowActionExecuter.PARAM_REJECT_MOVE);
|
||||
NodeRef rejectFolderNode = (NodeRef)actionProps.get(
|
||||
SimpleWorkflowActionExecuter.PARAM_REJECT_FOLDER);
|
||||
|
||||
this.currentActionProperties.put(PROP_APPROVE_STEP_NAME, approveStep);
|
||||
this.currentActionProperties.put(PROP_APPROVE_ACTION, approveMove ? "move" : "copy");
|
||||
this.currentActionProperties.put(PROP_APPROVE_FOLDER, approveFolderNode);
|
||||
|
||||
if (rejectStep == null && rejectMove == null && rejectFolderNode == null)
|
||||
{
|
||||
this.currentActionProperties.put(PROP_REJECT_STEP_PRESENT, "no");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentActionProperties.put(PROP_REJECT_STEP_PRESENT, "yes");
|
||||
this.currentActionProperties.put(PROP_REJECT_STEP_NAME, rejectStep);
|
||||
this.currentActionProperties.put(PROP_REJECT_ACTION, rejectMove ? "move" : "copy");
|
||||
this.currentActionProperties.put(PROP_REJECT_FOLDER, rejectFolderNode);
|
||||
}
|
||||
}
|
||||
else if (this.action.equals(LinkCategoryActionExecuter.NAME))
|
||||
{
|
||||
NodeRef catNodeRef = (NodeRef)actionProps.get(LinkCategoryActionExecuter.PARAM_CATEGORY_VALUE);
|
||||
this.currentActionProperties.put(PROP_CATEGORY, catNodeRef);
|
||||
}
|
||||
else if (this.action.equals(CheckOutActionExecuter.NAME))
|
||||
{
|
||||
NodeRef destNodeRef = (NodeRef)actionProps.get(CheckOutActionExecuter.PARAM_DESTINATION_FOLDER);
|
||||
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
|
||||
}
|
||||
else if (this.action.equals(CheckInActionExecuter.NAME))
|
||||
{
|
||||
String checkDesc = (String)actionProps.get(CheckInActionExecuter.PARAM_DESCRIPTION);
|
||||
this.currentActionProperties.put(PROP_CHECKIN_DESC, checkDesc);
|
||||
|
||||
Boolean minorChange = (Boolean)actionProps.get(CheckInActionExecuter.PARAM_MINOR_CHANGE);
|
||||
this.currentActionProperties.put(PROP_CHECKIN_MINOR, minorChange);
|
||||
}
|
||||
else if (this.action.equals(TransformActionExecuter.NAME))
|
||||
{
|
||||
String transformer = (String)actionProps.get(TransformActionExecuter.PARAM_MIME_TYPE);
|
||||
this.currentActionProperties.put(PROP_TRANSFORMER, transformer);
|
||||
|
||||
NodeRef destNodeRef = (NodeRef)actionProps.get(CopyActionExecuter.PARAM_DESTINATION_FOLDER);
|
||||
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
|
||||
}
|
||||
else if (this.action.equals(ImageTransformActionExecuter.NAME))
|
||||
{
|
||||
String transformer = (String)actionProps.get(TransformActionExecuter.PARAM_MIME_TYPE);
|
||||
this.currentActionProperties.put(PROP_IMAGE_TRANSFORMER, transformer);
|
||||
|
||||
String options = (String)actionProps.get(ImageTransformActionExecuter.PARAM_CONVERT_COMMAND);
|
||||
this.currentActionProperties.put(PROP_TRANSFORM_OPTIONS, options != null ? options : "");
|
||||
|
||||
NodeRef destNodeRef = (NodeRef)actionProps.get(CopyActionExecuter.PARAM_DESTINATION_FOLDER);
|
||||
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
|
||||
}
|
||||
else if (this.action.equals(MailActionExecuter.NAME))
|
||||
{
|
||||
String subject = (String)actionProps.get(MailActionExecuter.PARAM_SUBJECT);
|
||||
this.currentActionProperties.put(PROP_SUBJECT, subject);
|
||||
|
||||
String message = (String)actionProps.get(MailActionExecuter.PARAM_TEXT);
|
||||
this.currentActionProperties.put(PROP_MESSAGE, message);
|
||||
|
||||
// handle single email or multiple authority recipients
|
||||
String to = (String)actionProps.get(MailActionExecuter.PARAM_TO);
|
||||
if (to != null)
|
||||
{
|
||||
this.currentActionProperties.put(PROP_TO, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<String> recipients = (List<String>)actionProps.get(MailActionExecuter.PARAM_TO_MANY);
|
||||
if (recipients != null && recipients.size() != 0)
|
||||
{
|
||||
// rebuild the list of RecipientWrapper objects from the stored action
|
||||
for (String authority : recipients)
|
||||
{
|
||||
this.emailRecipients.add(
|
||||
new RecipientWrapper(displayLabelForAuthority(authority), authority));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NodeRef templateRef = (NodeRef)actionProps.get(MailActionExecuter.PARAM_TEMPLATE);
|
||||
if (templateRef != null)
|
||||
{
|
||||
this.currentActionProperties.put(PROP_TEMPLATE, templateRef.getId());
|
||||
this.usingTemplate = templateRef.getId();
|
||||
}
|
||||
}
|
||||
else if (this.action.equals(ImporterActionExecuter.NAME))
|
||||
{
|
||||
NodeRef destNodeRef = (NodeRef)actionProps.get(ImporterActionExecuter.PARAM_DESTINATION_FOLDER);
|
||||
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
|
||||
}
|
||||
else if (this.action.equals(SpecialiseTypeActionExecuter.NAME) == true)
|
||||
{
|
||||
QName specialiseType = (QName)actionProps.get(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME);
|
||||
this.currentActionProperties.put(PROP_OBJECT_TYPE, specialiseType.toString());
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,9 +14,8 @@
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean;
|
||||
package org.alfresco.web.bean.rules;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -25,14 +24,13 @@ import java.util.Map;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionCondition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.rule.Rule;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.context.IContextListener;
|
||||
import org.alfresco.web.app.context.UIContextService;
|
||||
import org.alfresco.web.bean.BrowseBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
@@ -17,7 +17,7 @@ public class CreateSpaceDialog extends CreateSpaceWizard
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), "new_space");
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), "create_space");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -682,7 +682,7 @@ public class CreateSpaceWizard extends BaseWizardBean
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), "error_space"),
|
||||
((FileExistsException)exception).getExisting().getName());
|
||||
exception.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,236 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.web.bean.wizard;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Handler class used by the New Action Wizard
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class NewActionWizard extends BaseActionWizard
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(NewActionWizard.class);
|
||||
|
||||
private static final String ERROR = "error_action";
|
||||
|
||||
// TODO: retrieve these from the config service
|
||||
private static final String WIZARD_TITLE_ID = "create_action_title";
|
||||
private static final String WIZARD_DESC_ID = "create_action_desc";
|
||||
private static final String STEP1_TITLE_ID = "create_action_step1_title";
|
||||
private static final String STEP2_TITLE_ID = "create_action_step2_title";
|
||||
private static final String FINISH_INSTRUCTION_ID = "create_action_finish_instruction";
|
||||
|
||||
/**
|
||||
* Deals with the finish button being pressed
|
||||
*
|
||||
* @return outcome
|
||||
*/
|
||||
public String finish()
|
||||
{
|
||||
String outcome = FINISH_OUTCOME;
|
||||
|
||||
UserTransaction tx = null;
|
||||
|
||||
try
|
||||
{
|
||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
||||
tx.begin();
|
||||
|
||||
// build the action params map based on the selected action instance
|
||||
Map<String, Serializable> actionParams = buildActionParams();
|
||||
|
||||
// build the action to execute
|
||||
Action action = this.actionService.createAction(getAction());
|
||||
action.setParameterValues(actionParams);
|
||||
|
||||
// execute the action on the current document node
|
||||
this.actionService.executeAction(action, this.browseBean.getDocument().getNodeRef());
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Executed action '" + this.action +
|
||||
"' with action params of " +
|
||||
this.currentActionProperties);
|
||||
}
|
||||
|
||||
// reset the current document properties/aspects in case we have changed them
|
||||
// during the execution of the custom action
|
||||
this.browseBean.getDocument().reset();
|
||||
|
||||
// commit the transaction
|
||||
tx.commit();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), ERROR), e.getMessage()), e);
|
||||
outcome = null;
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardDescription()
|
||||
*/
|
||||
public String getWizardDescription()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardTitle()
|
||||
*/
|
||||
public String getWizardTitle()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepDescription()
|
||||
*/
|
||||
public String getStepDescription()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepTitle()
|
||||
*/
|
||||
public String getStepTitle()
|
||||
{
|
||||
String stepTitle = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_TITLE_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepTitle = "";
|
||||
}
|
||||
}
|
||||
|
||||
return stepTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepInstructions()
|
||||
*/
|
||||
public String getStepInstructions()
|
||||
{
|
||||
String stepInstruction = null;
|
||||
|
||||
switch (this.currentStep)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), FINISH_INSTRUCTION_ID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), DEFAULT_INSTRUCTION_ID);
|
||||
}
|
||||
}
|
||||
|
||||
return stepInstruction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the summary data for the wizard.
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
String summaryAction = this.actionService.getActionDefinition(
|
||||
this.action).getTitle();
|
||||
|
||||
return buildSummary(
|
||||
new String[] {"Action"},
|
||||
new String[] {summaryAction});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.wizard.AbstractWizardBean#determineOutcomeForStep(int)
|
||||
*/
|
||||
protected String determineOutcomeForStep(int step)
|
||||
{
|
||||
String outcome = null;
|
||||
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
outcome = "action";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
outcome = this.action;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
outcome = "summary";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
outcome = CANCEL_OUTCOME;
|
||||
}
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user