merge into HEAD from BRANCHES/V1.3

svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@2980 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@2981 .


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3015 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-06-02 11:47:33 +00:00
parent 2f45ae8d88
commit e17290f94d
30 changed files with 1862 additions and 1020 deletions

View File

@@ -224,6 +224,33 @@
<transformer name="image/jpeg"/> <transformer name="image/jpeg"/>
<transformer name="image/png"/> <transformer name="image/png"/>
</image-transformers> </image-transformers>
<!-- The classes used to handle actions -->
<action-handlers>
<handler name="add-features" class="org.alfresco.web.bean.actions.handlers.AddFeaturesHandler" />
<handler name="check-in" class="org.alfresco.web.bean.actions.handlers.CheckInHandler" />
<handler name="check-out" class="org.alfresco.web.bean.actions.handlers.CheckOutHandler" />
<handler name="copy" class="org.alfresco.web.bean.actions.handlers.CopyHandler" />
<handler name="import" class="org.alfresco.web.bean.actions.handlers.ImportHandler" />
<handler name="link-category" class="org.alfresco.web.bean.actions.handlers.LinkCategoryHandler" />
<handler name="mail" class="org.alfresco.web.bean.actions.handlers.MailHandler" />
<handler name="move" class="org.alfresco.web.bean.actions.handlers.MoveHandler" />
<handler name="remove-features" class="org.alfresco.web.bean.actions.handlers.RemoveFeaturesHandler" />
<handler name="script" class="org.alfresco.web.bean.actions.handlers.ScriptHandler" />
<handler name="simple-workflow" class="org.alfresco.web.bean.actions.handlers.SimpleWorkflowHandler" />
<handler name="specialise-type" class="org.alfresco.web.bean.actions.handlers.SpecialiseTypeHandler" />
<handler name="transform" class="org.alfresco.web.bean.actions.handlers.TransformHandler" />
<handler name="transform-image" class="org.alfresco.web.bean.actions.handlers.TransformImageHandler" />
</action-handlers>
<!-- The classes used to handle conditions -->
<condition-handlers>
<handler name="compare-mime-type" class="org.alfresco.web.bean.rules.handlers.CompareMimeTypeHandler" />
<handler name="compare-property-value" class="org.alfresco.web.bean.rules.handlers.PropertyValueHandler" />
<handler name="has-aspect" class="org.alfresco.web.bean.rules.handlers.HasAspectHandler" />
<handler name="in-category" class="org.alfresco.web.bean.rules.handlers.InCategoryHandler" />
<handler name="is-subtype" class="org.alfresco.web.bean.rules.handlers.IsSubTypeHandler" />
</condition-handlers>
</config> </config>
<!-- This config sections below hold all the icons choices --> <!-- This config sections below hold all the icons choices -->

View File

@@ -45,14 +45,13 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.app.context.UIContextService; import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.app.servlet.DownloadContentServlet; import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.actions.BaseActionWizard; import org.alfresco.web.bean.actions.handlers.SimpleWorkflowHandler;
import org.alfresco.web.bean.repository.MapNode; import org.alfresco.web.bean.repository.MapNode;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.Utils.URLMode; import org.alfresco.web.ui.common.Utils.URLMode;
import org.alfresco.web.ui.common.component.UIActionLink; import org.alfresco.web.ui.common.component.UIActionLink;
import org.apache.log4j.Logger;
/** /**
* Backing bean providing access to the details of a document * Backing bean providing access to the details of a document
@@ -74,8 +73,6 @@ public class DocumentDetailsBean extends BaseDetailsBean
private static final String MSG_ERROR_UPDATE_SIMPLEWORKFLOW = "error_update_simpleworkflow"; private static final String MSG_ERROR_UPDATE_SIMPLEWORKFLOW = "error_update_simpleworkflow";
private static final String MSG_ERROR_UPDATE_CATEGORY = "error_update_category"; private static final String MSG_ERROR_UPDATE_CATEGORY = "error_update_category";
private static Logger logger = Logger.getLogger(DocumentDetailsBean.class);
protected LockService lockService; protected LockService lockService;
protected CopyService copyService; protected CopyService copyService;
protected VersionService versionService; protected VersionService versionService;
@@ -344,7 +341,6 @@ public class DocumentDetailsBean extends BaseDetailsBean
try try
{ {
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance()); tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
tx.begin(); tx.begin();
@@ -494,25 +490,25 @@ public class DocumentDetailsBean extends BaseDetailsBean
// put the workflow properties in a separate map for use by the JSP // put the workflow properties in a separate map for use by the JSP
this.workflowProperties = new HashMap<String, Serializable>(7); this.workflowProperties = new HashMap<String, Serializable>(7);
this.workflowProperties.put(BaseActionWizard.PROP_APPROVE_STEP_NAME, this.workflowProperties.put(SimpleWorkflowHandler.PROP_APPROVE_STEP_NAME,
approveStepName); approveStepName);
this.workflowProperties.put(BaseActionWizard.PROP_APPROVE_ACTION, this.workflowProperties.put(SimpleWorkflowHandler.PROP_APPROVE_ACTION,
approveMove ? "move" : "copy"); approveMove ? "move" : "copy");
this.workflowProperties.put(BaseActionWizard.PROP_APPROVE_FOLDER, approveFolder); this.workflowProperties.put(SimpleWorkflowHandler.PROP_APPROVE_FOLDER, approveFolder);
if (rejectStepName == null || rejectMove == null || rejectFolder == null) if (rejectStepName == null || rejectMove == null || rejectFolder == null)
{ {
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_STEP_PRESENT, "no"); this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT, "no");
} }
else else
{ {
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_STEP_PRESENT, this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT,
"yes"); "yes");
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_STEP_NAME, this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_STEP_NAME,
rejectStepName); rejectStepName);
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_ACTION, this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_ACTION,
rejectMove ? "move" : "copy"); rejectMove ? "move" : "copy");
this.workflowProperties.put(BaseActionWizard.PROP_REJECT_FOLDER, this.workflowProperties.put(SimpleWorkflowHandler.PROP_REJECT_FOLDER,
rejectFolder); rejectFolder);
} }
} }
@@ -546,7 +542,6 @@ public class DocumentDetailsBean extends BaseDetailsBean
try try
{ {
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance()); tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
tx.begin(); tx.begin();
@@ -558,11 +553,11 @@ public class DocumentDetailsBean extends BaseDetailsBean
// set the approve step name // set the approve step name
updateProps.put(ContentModel.PROP_APPROVE_STEP, updateProps.put(ContentModel.PROP_APPROVE_STEP,
this.workflowProperties.get(BaseActionWizard.PROP_APPROVE_STEP_NAME)); this.workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_STEP_NAME));
// specify whether the approve step will copy or move the content // specify whether the approve step will copy or move the content
boolean approveMove = true; boolean approveMove = true;
String approveAction = (String)this.workflowProperties.get(BaseActionWizard.PROP_APPROVE_ACTION); String approveAction = (String)this.workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_ACTION);
if (approveAction != null && approveAction.equals("copy")) if (approveAction != null && approveAction.equals("copy"))
{ {
approveMove = false; approveMove = false;
@@ -571,12 +566,12 @@ public class DocumentDetailsBean extends BaseDetailsBean
// create node ref representation of the destination folder // create node ref representation of the destination folder
updateProps.put(ContentModel.PROP_APPROVE_FOLDER, updateProps.put(ContentModel.PROP_APPROVE_FOLDER,
this.workflowProperties.get(BaseActionWizard.PROP_APPROVE_FOLDER)); this.workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_FOLDER));
// determine whether there should be a reject step // determine whether there should be a reject step
boolean requireReject = true; boolean requireReject = true;
String rejectStepPresent = (String)this.workflowProperties.get( String rejectStepPresent = (String)this.workflowProperties.get(
BaseActionWizard.PROP_REJECT_STEP_PRESENT); SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT);
if (rejectStepPresent != null && rejectStepPresent.equals("no")) if (rejectStepPresent != null && rejectStepPresent.equals("no"))
{ {
requireReject = false; requireReject = false;
@@ -586,12 +581,12 @@ public class DocumentDetailsBean extends BaseDetailsBean
{ {
// set the reject step name // set the reject step name
updateProps.put(ContentModel.PROP_REJECT_STEP, updateProps.put(ContentModel.PROP_REJECT_STEP,
this.workflowProperties.get(BaseActionWizard.PROP_REJECT_STEP_NAME)); this.workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_STEP_NAME));
// specify whether the reject step will copy or move the content // specify whether the reject step will copy or move the content
boolean rejectMove = true; boolean rejectMove = true;
String rejectAction = (String)this.workflowProperties.get( String rejectAction = (String)this.workflowProperties.get(
BaseActionWizard.PROP_REJECT_ACTION); SimpleWorkflowHandler.PROP_REJECT_ACTION);
if (rejectAction != null && rejectAction.equals("copy")) if (rejectAction != null && rejectAction.equals("copy"))
{ {
rejectMove = false; rejectMove = false;
@@ -600,7 +595,7 @@ public class DocumentDetailsBean extends BaseDetailsBean
// create node ref representation of the destination folder // create node ref representation of the destination folder
updateProps.put(ContentModel.PROP_REJECT_FOLDER, updateProps.put(ContentModel.PROP_REJECT_FOLDER,
this.workflowProperties.get(BaseActionWizard.PROP_REJECT_FOLDER)); this.workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_FOLDER));
} }
else else
{ {

View File

@@ -18,21 +18,8 @@ import javax.faces.model.SelectItem;
import org.alfresco.config.Config; import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigService; import org.alfresco.config.ConfigService;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
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.ScriptActionExecutor;
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.ActionDefinition; import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.AspectDefinition;
@@ -43,10 +30,10 @@ import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthorityService; import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.TemplateSupportBean; import org.alfresco.web.bean.TemplateSupportBean;
import org.alfresco.web.bean.actions.handlers.MailHandler;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.BaseWizardBean; import org.alfresco.web.bean.wizard.BaseWizardBean;
@@ -64,37 +51,9 @@ import org.apache.commons.logging.LogFactory;
*/ */
public abstract class BaseActionWizard extends BaseWizardBean public abstract class BaseActionWizard extends BaseWizardBean
{ {
public static final String PROP_ACTION_NAME = "actionName"; protected static final String PROP_ACTION_NAME = "actionName";
public static final String PROP_ACTION_SUMMARY = "actionSummary"; protected static final String PROP_ACTION_SUMMARY = "actionSummary";
public static final String PROP_CATEGORY = "category"; protected static final String NO_PARAMS_MARKER = "noParamsMarker";
public static final String PROP_ASPECT = "aspect";
public static final String PROP_DESTINATION = "destinationLocation";
public static final String PROP_APPROVE_STEP_NAME = "approveStepName";
public static final String PROP_APPROVE_ACTION = "approveAction";
public static final String PROP_APPROVE_FOLDER = "approveFolder";
public static final String PROP_REJECT_STEP_PRESENT = "rejectStepPresent";
public static final String PROP_REJECT_STEP_NAME = "rejectStepName";
public static final String PROP_REJECT_ACTION = "rejectAction";
public static final String PROP_REJECT_FOLDER = "rejectFolder";
public static final String PROP_CHECKIN_DESC = "checkinDescription";
public static final String PROP_CHECKIN_MINOR = "checkinMinorChange";
public static final String PROP_TRANSFORMER = "transformer";
public static final String PROP_IMAGE_TRANSFORMER = "imageTransformer";
public static final String PROP_TRANSFORM_OPTIONS = "transformOptions";
public static final String PROP_ENCODING = "encoding";
public static final String PROP_MESSAGE = "message";
public static final String PROP_SUBJECT = "subject";
public static final String PROP_TO = "to";
public static final String PROP_FROM = "from";
public static final String PROP_TEMPLATE = "template";
public static final String PROP_OBJECT_TYPE = "objecttype";
public static final String PROP_PROPERTY = "property";
public static final String PROP_CONTAINS_TEXT = "containstext";
public static final String PROP_MODEL_TYPE = "modeltype";
public static final String PROP_MIMETYPE = "mimetype";
public static final String PROP_MODEL_ASPECT = "modelaspect";
public static final String PROP_TYPE_OR_ASPECT = "typeoraspect";
public static final String PROP_SCRIPT = "script";
protected ActionService actionService; protected ActionService actionService;
protected MimetypeService mimetypeService; protected MimetypeService mimetypeService;
@@ -121,11 +80,9 @@ public abstract class BaseActionWizard extends BaseWizardBean
protected Map<String, Serializable> currentActionProperties; protected Map<String, Serializable> currentActionProperties;
protected List<Map<String, Serializable>> allActionsProperties; protected List<Map<String, Serializable>> allActionsProperties;
protected static final String ACTION_PAGES_LOCATION = "/jsp/actions/"; protected Map<String, IHandler> actionHandlers;
private static final Log logger = LogFactory.getLog(BaseActionWizard.class); private static final Log logger = LogFactory.getLog(BaseActionWizard.class);
private static final String IMPORT_ENCODING = "UTF-8";
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Wizard implementation // Wizard implementation
@@ -139,22 +96,15 @@ public abstract class BaseActionWizard extends BaseWizardBean
this.users = null; this.users = null;
this.actions = null; this.actions = null;
this.emailRecipientsDataModel = null; this.emailRecipientsDataModel = null;
this.emailRecipients = new ArrayList<RecipientWrapper>(4);
this.usingTemplate = null; this.usingTemplate = null;
this.emailRecipients = new ArrayList<RecipientWrapper>(4);
this.allActionsProperties = new ArrayList<Map<String, Serializable>>(); this.allActionsProperties = new ArrayList<Map<String, Serializable>>();
this.currentActionProperties = new HashMap<String, Serializable>(3); this.currentActionProperties = new HashMap<String, Serializable>(3);
// default the approve and reject actions initialiseActionHandlers();
this.currentActionProperties.put(PROP_APPROVE_ACTION, "move");
this.currentActionProperties.put(PROP_REJECT_STEP_PRESENT, "yes");
this.currentActionProperties.put(PROP_REJECT_ACTION, "move");
// default the checkin minor change
this.currentActionProperties.put(PROP_CHECKIN_MINOR, new Boolean(true));
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Bean Getters and Setters // Bean Getters and Setters
@@ -528,6 +478,15 @@ public abstract class BaseActionWizard extends BaseWizardBean
return this.imageTransformers; return this.imageTransformers;
} }
/**
* Returns the current list of email recipients
*
* @return List of email recipients
*/
public List<RecipientWrapper> getEmailRecipients()
{
return this.emailRecipients;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Action event handlers // Action event handlers
@@ -542,27 +501,29 @@ public abstract class BaseActionWizard extends BaseWizardBean
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
this.returnViewId = context.getViewRoot().getViewId(); this.returnViewId = context.getViewRoot().getViewId();
String viewId = calculateActionViewId(this.action); String viewId = null;
HashMap<String, Serializable> actionProps = new HashMap<String, Serializable>(3); HashMap<String, Serializable> actionProps = new HashMap<String, Serializable>(3);
actionProps.put(PROP_ACTION_NAME, this.action); actionProps.put(PROP_ACTION_NAME, this.action);
this.currentActionProperties = actionProps; this.currentActionProperties = actionProps;
// determine whether the action being added has any parameters // get the handler for the action, if there isn't one we presume it
ActionDefinition actionDef = this.actionService.getActionDefinition(this.action); // is a no-parameter action
if (actionDef.hasParameterDefinitions()) IHandler handler = this.actionHandlers.get(this.action);
if (handler != null)
{ {
// setup any defaults for the UI and override the viewId if necessary // setup any UI defaults the action may have and get the location of
String overridenViewId = setupUIDefaultsForAction(actionProps); // the JSP used to collect the parameters
if (overridenViewId != null) handler.setupUIDefaults(actionProps);
{ viewId = handler.getJSPPath();
viewId = overridenViewId;
}
} }
else else
{ {
// just add the action to the list and use the title as the summary // just add the action to the list and use the title as the summary
ActionDefinition actionDef = this.actionService.getActionDefinition(this.action);
actionProps.put(PROP_ACTION_SUMMARY, actionDef.getTitle()); actionProps.put(PROP_ACTION_SUMMARY, actionDef.getTitle());
// add the no params marker so we can disable the edit action
actionProps.put(NO_PARAMS_MARKER, "no-params");
this.allActionsProperties.add(actionProps); this.allActionsProperties.add(actionProps);
// come back to the same page we're on now as there are no params to collect // come back to the same page we're on now as there are no params to collect
@@ -595,8 +556,9 @@ public abstract class BaseActionWizard extends BaseWizardBean
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
this.returnViewId = context.getViewRoot().getViewId(); this.returnViewId = context.getViewRoot().getViewId();
// refresh the wizard // go to the action page (as there is an edit option visible,
goToPage(context, calculateActionViewId(this.action)); // there must be a handler for the action so we don't check)
goToPage(context, this.actionHandlers.get(this.action).getJSPPath());
} }
/** /**
@@ -605,7 +567,11 @@ public abstract class BaseActionWizard extends BaseWizardBean
public void addAction() public void addAction()
{ {
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
String summary = buildActionSummary();
// this is called from the actions page so there must be a handler
// present so there's no need to check for null
String summary = this.actionHandlers.get(this.action).generateSummary(
context, this, this.currentActionProperties);
if (summary != null) if (summary != null)
{ {
@@ -709,18 +675,20 @@ public abstract class BaseActionWizard extends BaseWizardBean
*/ */
public void insertTemplate(ActionEvent event) public void insertTemplate(ActionEvent event)
{ {
String template = (String)this.currentActionProperties.get(PROP_TEMPLATE); String template = (String)this.currentActionProperties.get(MailHandler.PROP_TEMPLATE);
if (template != null && template.equals(TemplateSupportBean.NO_SELECTION) == false) if (template != null && template.equals(TemplateSupportBean.NO_SELECTION) == false)
{ {
// get the content of the template so the user can get a basic preview of it // get the content of the template so the user can get a basic preview of it
try try
{ {
NodeRef templateRef = new NodeRef(Repository.getStoreRef(), template); NodeRef templateRef = new NodeRef(Repository.getStoreRef(), template);
ContentService cs = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService(); ContentService cs = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getContentService();
ContentReader reader = cs.getReader(templateRef, ContentModel.PROP_CONTENT); ContentReader reader = cs.getReader(templateRef, ContentModel.PROP_CONTENT);
if (reader != null && reader.exists()) if (reader != null && reader.exists())
{ {
this.currentActionProperties.put(PROP_MESSAGE, reader.getContentString()); this.currentActionProperties.put(MailHandler.PROP_MESSAGE,
reader.getContentString());
usingTemplate = template; usingTemplate = template;
} }
@@ -738,7 +706,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
*/ */
public void discardTemplate(ActionEvent event) public void discardTemplate(ActionEvent event)
{ {
this.currentActionProperties.put(PROP_MESSAGE, ""); this.currentActionProperties.put(MailHandler.PROP_MESSAGE, "");
usingTemplate = null; usingTemplate = null;
} }
@@ -786,7 +754,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Helper methods // Helper methods
protected String displayLabelForAuthority(String authority) public String displayLabelForAuthority(String authority)
{ {
String label = authority; String label = authority;
@@ -804,515 +772,6 @@ public abstract class BaseActionWizard extends BaseWizardBean
return label; return label;
} }
/**
* Sets up any default state required by the UI for collecting the
* action settings. The view id to use for the action UI can also
* be overridden by returing the path to the relevant JSP.
*
* @props The map of properties being used for the current action
* @return An optional overridden JSP to use for action settings collection
*/
protected String setupUIDefaultsForAction(HashMap<String, Serializable> props)
{
String overridenViewId = null;
if (SimpleWorkflowActionExecuter.NAME.equals(this.action))
{
this.currentActionProperties.put("approveAction", "move");
this.currentActionProperties.put("rejectStepPresent", "yes");
this.currentActionProperties.put("rejectAction", "move");
}
else if (CheckInActionExecuter.NAME.equals(this.action))
{
this.currentActionProperties.put(PROP_CHECKIN_MINOR, new Boolean(true));
}
return overridenViewId;
}
/**
* Build the param map for the current Action instance.
* <p>
* Based on the params set by the UI, build the params needed to create the action.
*
* @return param map
*/
protected Map<String, Serializable> buildActionParams()
{
// set up parameters maps for the action
Map<String, Serializable> repoParams = new HashMap<String, Serializable>();
if (AddFeaturesActionExecuter.NAME.equals(this.action))
{
QName aspect = Repository.resolveToQName((String)this.currentActionProperties.get(PROP_ASPECT));
repoParams.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect);
}
else if (RemoveFeaturesActionExecuter.NAME.equals(this.action))
{
QName aspect = Repository.resolveToQName((String)this.currentActionProperties.get(PROP_ASPECT));
repoParams.put(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect);
}
else if (CopyActionExecuter.NAME.equals(this.action))
{
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
repoParams.put(CopyActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the copy
// is performed
repoParams.put(CopyActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoParams.put(CopyActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
}
else if (MoveActionExecuter.NAME.equals(this.action))
{
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
repoParams.put(MoveActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the move
// is performed
repoParams.put(MoveActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoParams.put(MoveActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "move"));
}
else if (SimpleWorkflowActionExecuter.NAME.equals(this.action))
{
// add the approve step name
repoParams.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_STEP,
(String)this.currentActionProperties.get(PROP_APPROVE_STEP_NAME));
// add whether the approve step will copy or move the content
boolean approveMove = true;
String approveAction = (String)this.currentActionProperties.get(PROP_APPROVE_ACTION);
if (approveAction != null && approveAction.equals("copy"))
{
approveMove = false;
}
repoParams.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_MOVE, Boolean.valueOf(approveMove));
// add the destination folder of the content
NodeRef approveDestNodeRef = null;
Object approveDestNode = this.currentActionProperties.get(PROP_APPROVE_FOLDER);
if (approveDestNode instanceof NodeRef)
{
approveDestNodeRef = (NodeRef)approveDestNode;
}
else if (approveDestNode instanceof String)
{
approveDestNodeRef = new NodeRef((String)approveDestNode);
}
repoParams.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_FOLDER, approveDestNodeRef);
// determine whether we have a reject step or not
boolean requireReject = true;
String rejectStepPresent = (String)this.currentActionProperties.get(PROP_REJECT_STEP_PRESENT);
if (rejectStepPresent != null && rejectStepPresent.equals("no"))
{
requireReject = false;
}
if (requireReject)
{
// add the reject step name
repoParams.put(SimpleWorkflowActionExecuter.PARAM_REJECT_STEP,
(String)this.currentActionProperties.get(PROP_REJECT_STEP_NAME));
// add whether the reject step will copy or move the content
boolean rejectMove = true;
String rejectAction = (String)this.currentActionProperties.get(PROP_REJECT_ACTION);
if (rejectAction != null && rejectAction.equals("copy"))
{
rejectMove = false;
}
repoParams.put(SimpleWorkflowActionExecuter.PARAM_REJECT_MOVE, Boolean.valueOf(rejectMove));
// add the destination folder of the content
NodeRef rejectDestNodeRef = null;
Object rejectDestNode = this.currentActionProperties.get(PROP_REJECT_FOLDER);
if (rejectDestNode instanceof NodeRef)
{
rejectDestNodeRef = (NodeRef)rejectDestNode;
}
else if (rejectDestNode instanceof String)
{
rejectDestNodeRef = new NodeRef((String)rejectDestNode);
}
repoParams.put(SimpleWorkflowActionExecuter.PARAM_REJECT_FOLDER, rejectDestNodeRef);
}
}
else if (LinkCategoryActionExecuter.NAME.equals(this.action))
{
// add the classifiable aspect
repoParams.put(LinkCategoryActionExecuter.PARAM_CATEGORY_ASPECT,
ContentModel.ASPECT_GEN_CLASSIFIABLE);
// put the selected category in the action params
NodeRef catNodeRef = (NodeRef)this.currentActionProperties.get(PROP_CATEGORY);
repoParams.put(LinkCategoryActionExecuter.PARAM_CATEGORY_VALUE,
catNodeRef);
}
else if (CheckOutActionExecuter.NAME.equals(this.action))
{
// specify the location the checked out working copy should go
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
repoParams.put(CheckOutActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the
// check out is performed
repoParams.put(CheckOutActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoParams.put(CheckOutActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "checkout"));
}
else if (CheckInActionExecuter.NAME.equals(this.action))
{
// add the description for the checkin to the action params
repoParams.put(CheckInActionExecuter.PARAM_DESCRIPTION,
this.currentActionProperties.get(PROP_CHECKIN_DESC));
// add the minor change flag
repoParams.put(CheckInActionExecuter.PARAM_MINOR_CHANGE,
this.currentActionProperties.get(PROP_CHECKIN_MINOR));
}
else if (TransformActionExecuter.NAME.equals(this.action))
{
// add the transformer to use
repoParams.put(TransformActionExecuter.PARAM_MIME_TYPE,
this.currentActionProperties.get(PROP_TRANSFORMER));
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
repoParams.put(TransformActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the copy
// is performed
repoParams.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoParams.put(TransformActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
}
else if (ImageTransformActionExecuter.NAME.equals(this.action))
{
// add the transformer to use
repoParams.put(ImageTransformActionExecuter.PARAM_MIME_TYPE,
this.currentActionProperties.get(PROP_IMAGE_TRANSFORMER));
// add the options
repoParams.put(ImageTransformActionExecuter.PARAM_CONVERT_COMMAND,
this.currentActionProperties.get(PROP_TRANSFORM_OPTIONS));
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
repoParams.put(TransformActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the copy
// is performed
repoParams.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoParams.put(TransformActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
}
else if (MailActionExecuter.NAME.equals(this.action))
{
// add the person(s) it's going to as a list of authorities
List<String> recipients = new ArrayList<String>(emailRecipients.size());
for (int i=0; i<emailRecipients.size(); i++)
{
RecipientWrapper wrapper = emailRecipients.get(i);
recipients.add(wrapper.authority);
}
repoParams.put(MailActionExecuter.PARAM_TO_MANY, (Serializable)recipients);
// add the actual email text to send
repoParams.put(MailActionExecuter.PARAM_TEXT,
this.currentActionProperties.get(PROP_MESSAGE));
// add the subject for the email
repoParams.put(MailActionExecuter.PARAM_SUBJECT,
this.currentActionProperties.get(PROP_SUBJECT));
// add the from address
String from = Application.getClientConfig(FacesContext.getCurrentInstance()).getFromEmailAddress();
repoParams.put(MailActionExecuter.PARAM_FROM, from);
// add the template if one was selected by the user
if (this.usingTemplate != null)
{
repoParams.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(), this.usingTemplate));
}
}
else if (ImporterActionExecuter.NAME.equals(this.action))
{
// add the encoding
repoParams.put(ImporterActionExecuter.PARAM_ENCODING, IMPORT_ENCODING);
// add the destination for the import
NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
repoParams.put(ImporterActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
}
else if (SpecialiseTypeActionExecuter.NAME.equals(this.action))
{
// add the specialisation type
String objectType = (String)this.currentActionProperties.get(PROP_OBJECT_TYPE);
repoParams.put(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME, QName.createQName(objectType));
}
else if (ScriptActionExecutor.NAME.equals(this.action))
{
// add the selected script noderef to the action properties
String id = (String)this.currentActionProperties.get(PROP_SCRIPT);
NodeRef scriptRef = new NodeRef(Repository.getStoreRef(), id);
repoParams.put(ScriptActionExecutor.PARAM_SCRIPTREF, scriptRef);
repoParams.put(ScriptActionExecutor.PARAM_SPACEREF, this.navigator.getCurrentNode().getNodeRef());
}
return repoParams;
}
/**
* Returns a summary string for the current action
*
* @return The summary or null if a summary could not be built
*/
protected String buildActionSummary()
{
String summary = null;
FacesContext context = FacesContext.getCurrentInstance();
if (AddFeaturesActionExecuter.NAME.equals(this.action))
{
String label = null;
String aspect = (String)this.currentActionProperties.get(PROP_ASPECT);
// find the label used by looking through the SelectItem list
for (SelectItem item : this.getAspects())
{
if (item.getValue().equals(aspect))
{
label = item.getLabel();
break;
}
}
summary = MessageFormat.format(Application.getMessage(context, "action_add_features"),
new Object[] {label});
}
else if (RemoveFeaturesActionExecuter.NAME.equals(this.action))
{
String label = null;
String aspect = (String)this.currentActionProperties.get(PROP_ASPECT);
// find the label used by looking through the SelectItem list
for (SelectItem item : this.getAspects())
{
if (item.getValue().equals(aspect))
{
label = item.getLabel();
break;
}
}
summary = MessageFormat.format(Application.getMessage(context, "action_remove_features"),
new Object[] {label});
}
else if (CopyActionExecuter.NAME.equals(this.action))
{
NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(this.nodeService, space);
summary = MessageFormat.format(Application.getMessage(context, "action_copy"),
new Object[] {spaceName});
}
else if (MoveActionExecuter.NAME.equals(this.action))
{
NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(this.nodeService, space);
summary = MessageFormat.format(Application.getMessage(context, "action_move"),
new Object[] {spaceName});
}
else if (SimpleWorkflowActionExecuter.NAME.equals(this.action))
{
String approveStepName = (String)this.currentActionProperties.get(PROP_APPROVE_STEP_NAME);
String approveAction = (String)this.currentActionProperties.get(PROP_APPROVE_ACTION);
NodeRef approveFolder = (NodeRef)this.currentActionProperties.get(PROP_APPROVE_FOLDER);
String approveFolderName = Repository.getNameForNode(this.nodeService, approveFolder);
String approveMsg = MessageFormat.format(Application.getMessage(context, "action_simple_workflow"),
new Object[] {Application.getMessage(context, approveAction),
approveFolderName, approveStepName});
String rejectMsg = null;
String rejectStep = (String)this.currentActionProperties.get(PROP_REJECT_STEP_PRESENT);
if (rejectStep != null && "yes".equals(rejectStep))
{
String rejectStepName = (String)this.currentActionProperties.get(PROP_REJECT_STEP_NAME);
String rejectAction = (String)this.currentActionProperties.get(PROP_REJECT_ACTION);
NodeRef rejectFolder = (NodeRef)this.currentActionProperties.get(PROP_REJECT_FOLDER);
String rejectFolderName = Repository.getNameForNode(this.nodeService, rejectFolder);
rejectMsg = MessageFormat.format(Application.getMessage(context, "action_simple_workflow"),
new Object[] {Application.getMessage(context, rejectAction),
rejectFolderName, rejectStepName});
}
StringBuilder builder = new StringBuilder(approveMsg);
if (rejectMsg != null)
{
builder.append(" ");
builder.append(rejectMsg);
}
summary = builder.toString();
}
else if (LinkCategoryActionExecuter.NAME.equals(this.action))
{
NodeRef cat = (NodeRef)this.currentActionProperties.get(PROP_CATEGORY);
String name = Repository.getNameForNode(this.nodeService, cat);
summary = MessageFormat.format(Application.getMessage(context, "action_link_category"),
new Object[] {name});
}
else if (CheckOutActionExecuter.NAME.equals(this.action))
{
NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(this.nodeService, space);
summary = MessageFormat.format(Application.getMessage(context, "action_check_out"),
new Object[] {spaceName});
}
else if (CheckInActionExecuter.NAME.equals(this.action))
{
String comment = (String)this.currentActionProperties.get(PROP_CHECKIN_DESC);
Boolean minorChange = (Boolean)this.currentActionProperties.get(PROP_CHECKIN_MINOR);
String change = null;
if (minorChange != null && minorChange.booleanValue())
{
change = Application.getMessage(context, "minor_change");
}
else
{
change = Application.getMessage(context, "major_change");
}
summary = MessageFormat.format(Application.getMessage(context, "action_check_in"),
new Object[] {change, comment});
}
else if (TransformActionExecuter.NAME.equals(this.action))
{
String label = null;
NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
String name = Repository.getNameForNode(this.nodeService, space);
String transformer = (String)this.currentActionProperties.get(PROP_TRANSFORMER);
// find the label used by looking through the SelectItem list
for (SelectItem item : this.getTransformers())
{
if (item.getValue().equals(transformer))
{
label = item.getLabel();
break;
}
}
summary = MessageFormat.format(Application.getMessage(context, "action_transform"),
new Object[] {name, label});
}
else if (ImageTransformActionExecuter.NAME.equals(this.action))
{
String label = null;
NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
String name = Repository.getNameForNode(this.nodeService, space);
String transformer = (String)this.currentActionProperties.get(PROP_IMAGE_TRANSFORMER);
String option = (String)this.currentActionProperties.get(PROP_TRANSFORM_OPTIONS);
// find the label used by looking through the SelectItem list
for (SelectItem item : this.getImageTransformers())
{
if (item.getValue().equals(transformer))
{
label = item.getLabel();
break;
}
}
summary = MessageFormat.format(Application.getMessage(context, "action_transform_image"),
new Object[] {name, label, option});
}
else if (MailActionExecuter.NAME.equals(this.action))
{
String addresses = (String)this.currentActionProperties.get(PROP_TO);
if (addresses == null || addresses.length() == 0)
{
if (this.emailRecipients.size() != 0)
{
StringBuilder builder = new StringBuilder();
for (int i=0; i<this.emailRecipients.size(); i++)
{
RecipientWrapper wrapper = this.emailRecipients.get(i);
if (i != 0)
{
builder.append(", ");
}
builder.append(wrapper.getName());
}
addresses = builder.toString();
}
}
summary = MessageFormat.format(Application.getMessage(context, "action_mail"),
new Object[] {addresses});
}
else if (ImporterActionExecuter.NAME.equals(this.action))
{
NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(this.nodeService, space);
summary = MessageFormat.format(Application.getMessage(context, "action_import"),
new Object[] {spaceName});
}
else if (SpecialiseTypeActionExecuter.NAME.equals(this.action))
{
String label = null;
String objectType = (String)this.currentActionProperties.get(PROP_OBJECT_TYPE);
for (SelectItem item : getObjectTypes())
{
if (item.getValue().equals(objectType) == true)
{
label = item.getLabel();
break;
}
}
summary = MessageFormat.format(Application.getMessage(context, "action_specialise_type"),
new Object[] {label});
}
else if (ScriptActionExecutor.NAME.equals(this.action))
{
String id = (String)this.currentActionProperties.get(PROP_SCRIPT);
NodeRef scriptRef = new NodeRef(Repository.getStoreRef(), id);
String scriptName = Repository.getNameForNode(this.nodeService, scriptRef);
summary = MessageFormat.format(Application.getMessage(context, "action_script"),
new Object[] {scriptName});
}
else
{
// as the default case (i.e. for actions with no parameters) use the title
ActionDefinition actionDef = this.actionService.getActionDefinition(this.action);
summary = actionDef.getTitle();
}
return summary;
}
/** /**
* Navigates to the given page, used to go back and forth between the * Navigates to the given page, used to go back and forth between the
* wizard and the actions settings pages * wizard and the actions settings pages
@@ -1330,16 +789,55 @@ public abstract class BaseActionWizard extends BaseWizardBean
} }
/** /**
* Calculates the viewId for the given action id * Initialises the action handlers from the current configuration.
*
* @param actionId The id of the action to generate the view id for
* @return The view id
*/ */
protected String calculateActionViewId(String actionId) protected void initialiseActionHandlers()
{ {
return ACTION_PAGES_LOCATION + actionId + ".jsp"; if (this.actionHandlers == null)
} {
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null)
{
ConfigElement actionHandlerCfg = wizardCfg.getConfigElement("action-handlers");
if (actionHandlerCfg != null)
{
this.actionHandlers = new HashMap<String, IHandler>(20);
// instantiate each handler and store in the map
for (ConfigElement child : actionHandlerCfg.getChildren())
{
String actionName = child.getAttribute("name");
String handlerClass = child.getAttribute("class");
if (actionName != null && actionName.length() > 0 &&
handlerClass != null && handlerClass.length() > 0)
{
try
{
Class klass = Class.forName(handlerClass);
IHandler handler = (IHandler)klass.newInstance();
this.actionHandlers.put(actionName, handler);
}
catch (Exception e)
{
throw new AlfrescoRuntimeException("Failed to setup action handler for '" +
actionName + "'", e);
}
}
}
}
else
{
logger.warn("Could not find 'action-handlers' configuration element");
}
}
else
{
logger.warn("Could not find 'Action Wizards' configuration section");
}
}
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Inner classes // Inner classes

View File

@@ -0,0 +1,70 @@
package org.alfresco.web.bean.actions;
import java.io.Serializable;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Interface definition for a handler, classes that are responsible
* for marshalling data between the repository and the action based
* wizards.
*
* @author gavinc
*/
public interface IHandler
{
/**
* Adds any properties to the given map that need default values
* before the UI is displayed to the user.
*
* @param props The current properties map
*/
public void setupUIDefaults(Map<String, Serializable> props);
/**
* By default, a JSP with the same name as the handler will
* be loaded from a default location. If the handler has stored
* it's UI somewhere else the view id can be returned from this method.
*
* @return The path to the JSP for the handler
*/
public String getJSPPath();
/**
* Called at the end of the wizard. The properties relevant to
* this handler have to be placed in the repository properties
* map in the correct form for sending to the node service.
*
* @param props The current properties map
* @param repoProps The repository properties map to prepare
*/
public void prepareForSave(Map<String, Serializable> props,
Map<String, Serializable> repoProps);
/**
* Called at the start of the edit wizard. The repository properties
* map holds the current state of this rule. Any properties relevant
* to this handler should be retrieved and setup in the current
* properties map.
*
* @param props The current properties map
* @param repoParams The properties currently in the repository
*/
public void prepareForEdit(Map<String, Serializable> props,
Map<String, Serializable> repoProps);
/**
* Generates a summary string for this handler. The current state of
* the wizard is passed as well as the current properties map.
*
* @param context Faces context
* @param wizard The current wizard
* @param props The properties map
* @return The summary string
*/
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> props);
}

View File

@@ -2,6 +2,7 @@ package org.alfresco.web.bean.actions;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@@ -37,8 +38,14 @@ public class RunActionWizard extends BaseActionWizard
// to setup the currentActionProperties and action variables // to setup the currentActionProperties and action variables
String actionName = (String)actionParams.get(PROP_ACTION_NAME); String actionName = (String)actionParams.get(PROP_ACTION_NAME);
this.action = actionName; this.action = actionName;
this.currentActionProperties = actionParams;
Map<String, Serializable> repoActionParams = buildActionParams(); // get the action handler to prepare for the save
Map<String, Serializable> repoActionParams = new HashMap<String, Serializable>();
IHandler handler = this.actionHandlers.get(this.action);
if (handler != null)
{
handler.prepareForSave(actionParams, repoActionParams);
}
// add the action to the rule // add the action to the rule
Action action = this.actionService.createAction(actionName); Action action = this.actionService.createAction(actionName);

View File

@@ -0,0 +1,64 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
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.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "add-features" action.
*
* @author gavinc
*/
public class AddFeaturesHandler extends BaseActionHandler
{
protected static final String PROP_ASPECT = "aspect";
public String getJSPPath()
{
return getJSPPath(AddFeaturesActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoParams)
{
QName aspect = Repository.resolveToQName((String)actionProps.get(PROP_ASPECT));
repoParams.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect);
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoParams)
{
QName aspect = (QName)repoParams.get(AddFeaturesActionExecuter.PARAM_ASPECT_NAME);
actionProps.put(PROP_ASPECT, aspect.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
String aspect = (String)actionProps.get(PROP_ASPECT);
// find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getAspects())
{
if (item.getValue().equals(aspect))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_add_features"),
new Object[] {label});
}
}

View File

@@ -0,0 +1,34 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.web.bean.actions.IHandler;
/**
* Base class for all action handler implementations.
*
* @author gavinc
*/
public abstract class BaseActionHandler implements IHandler
{
protected static final String ACTION_PAGES_LOCATION = "/jsp/actions/";
protected static final String PROP_DESTINATION = "destinationLocation";
public void setupUIDefaults(Map<String, Serializable> actionProps)
{
// do nothing by default, only those action handlers that need
// to setup defaults need override this method
}
/**
* Given the action name, generates the default path for the JSP
*
* @param actionName The name of the action
* @return The path to the JSP used for the action
*/
protected String getJSPPath(String actionName)
{
return ACTION_PAGES_LOCATION + actionName + ".jsp";
}
}

View File

@@ -0,0 +1,72 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.CheckInActionExecuter;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "check-in" action.
*
* @author gavinc
*/
public class CheckInHandler extends BaseActionHandler
{
protected static final String PROP_CHECKIN_DESC = "checkinDescription";
protected static final String PROP_CHECKIN_MINOR = "checkinMinorChange";
@Override
public void setupUIDefaults(Map<String, Serializable> actionProps)
{
actionProps.put(PROP_CHECKIN_MINOR, new Boolean(true));
}
public String getJSPPath()
{
return getJSPPath(CheckInActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
repoProps.put(CheckInActionExecuter.PARAM_DESCRIPTION,
actionProps.get(PROP_CHECKIN_DESC));
repoProps.put(CheckInActionExecuter.PARAM_MINOR_CHANGE,
actionProps.get(PROP_CHECKIN_MINOR));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String checkDesc = (String)repoProps.get(CheckInActionExecuter.PARAM_DESCRIPTION);
actionProps.put(PROP_CHECKIN_DESC, checkDesc);
Boolean minorChange = (Boolean)repoProps.get(CheckInActionExecuter.PARAM_MINOR_CHANGE);
actionProps.put(PROP_CHECKIN_MINOR, minorChange);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String comment = (String)actionProps.get(PROP_CHECKIN_DESC);
Boolean minorChange = (Boolean)actionProps.get(PROP_CHECKIN_MINOR);
String change = null;
if (minorChange != null && minorChange.booleanValue())
{
change = Application.getMessage(context, "minor_change");
}
else
{
change = Application.getMessage(context, "major_change");
}
return MessageFormat.format(Application.getMessage(context, "action_check_in"),
new Object[] {change, comment});
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.CheckOutActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "check-out" action.
*
* @author gavinc
*/
public class CheckOutHandler extends BaseActionHandler
{
public String getJSPPath()
{
return getJSPPath(CheckOutActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// specify the location the checked out working copy should go
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(CheckOutActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the
// check out is performed
repoProps.put(CheckOutActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(CheckOutActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "checkout"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef destNodeRef = (NodeRef)repoProps.get(CheckOutActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
return MessageFormat.format(Application.getMessage(context, "action_check_out"),
new Object[] {spaceName});
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.CopyActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "copy" action.
*
* @author gavinc
*/
public class CopyHandler extends BaseActionHandler
{
public String getJSPPath()
{
return getJSPPath(CopyActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(CopyActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the copy
// is performed
repoProps.put(CopyActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(CopyActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef destNodeRef = (NodeRef)repoProps.get(CopyActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
return MessageFormat.format(Application.getMessage(context, "action_copy"),
new Object[] {spaceName});
}
}

View File

@@ -0,0 +1,58 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.ImporterActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "import" action.
*
* @author gavinc
*/
public class ImportHandler extends BaseActionHandler
{
protected static final String IMPORT_ENCODING = "UTF-8";
public String getJSPPath()
{
return getJSPPath(ImporterActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the encoding
repoProps.put(ImporterActionExecuter.PARAM_ENCODING, IMPORT_ENCODING);
// add the destination for the import
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(ImporterActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef destNodeRef = (NodeRef)repoProps.get(
ImporterActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
return MessageFormat.format(Application.getMessage(context, "action_import"),
new Object[] {spaceName});
}
}

View File

@@ -0,0 +1,60 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.LinkCategoryActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "link-category" action.
*
* @author gavinc
*/
public class LinkCategoryHandler extends BaseActionHandler
{
protected static final String PROP_CATEGORY = "category";
public String getJSPPath()
{
return getJSPPath(LinkCategoryActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the classifiable aspect
repoProps.put(LinkCategoryActionExecuter.PARAM_CATEGORY_ASPECT,
ContentModel.ASPECT_GEN_CLASSIFIABLE);
// put the selected category in the action params
NodeRef catNodeRef = (NodeRef)actionProps.get(PROP_CATEGORY);
repoProps.put(LinkCategoryActionExecuter.PARAM_CATEGORY_VALUE,
catNodeRef);
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef catNodeRef = (NodeRef)repoProps.get(LinkCategoryActionExecuter.PARAM_CATEGORY_VALUE);
actionProps.put(PROP_CATEGORY, catNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef cat = (NodeRef)actionProps.get(PROP_CATEGORY);
String name = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), cat);
return MessageFormat.format(Application.getMessage(context, "action_link_category"),
new Object[] {name});
}
}

View File

@@ -0,0 +1,144 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.MailActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.actions.BaseActionWizard;
import org.alfresco.web.bean.actions.BaseActionWizard.RecipientWrapper;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "mail" action.
*
* @author gavinc
*/
public class MailHandler extends BaseActionHandler
{
public static final String PROP_TO = "to";
public static final String PROP_FROM = "from";
public static final String PROP_MESSAGE = "message";
public static final String PROP_SUBJECT = "subject";
public static final String PROP_TEMPLATE = "template";
public String getJSPPath()
{
return getJSPPath(MailActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// get hold of the current wizard so we can extract some data from it
BaseActionWizard wizard = (BaseActionWizard)Application.
getWizardManager().getBean();
// add the person(s) it's going to as a list of authorities
List<String> recipients = new ArrayList<String>(wizard.getEmailRecipients().size());
for (int i=0; i < wizard.getEmailRecipients().size(); i++)
{
RecipientWrapper wrapper = wizard.getEmailRecipients().get(i);
recipients.add(wrapper.getAuthority());
}
repoProps.put(MailActionExecuter.PARAM_TO_MANY, (Serializable)recipients);
// add the actual email text to send
repoProps.put(MailActionExecuter.PARAM_TEXT, actionProps.get(PROP_MESSAGE));
// add the subject for the email
repoProps.put(MailActionExecuter.PARAM_SUBJECT, actionProps.get(PROP_SUBJECT));
// add the from address
String from = Application.getClientConfig(FacesContext.getCurrentInstance()).getFromEmailAddress();
repoProps.put(MailActionExecuter.PARAM_FROM, from);
// add the template if one was selected by the user
if (wizard.getUsingTemplate() != null)
{
repoProps.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(),
wizard.getUsingTemplate()));
}
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// get hold of the current wizard so we can extract some data from it
BaseActionWizard wizard = (BaseActionWizard)Application.
getWizardManager().getBean();
String subject = (String)repoProps.get(MailActionExecuter.PARAM_SUBJECT);
actionProps.put(PROP_SUBJECT, subject);
String message = (String)repoProps.get(MailActionExecuter.PARAM_TEXT);
actionProps.put(PROP_MESSAGE, message);
// handle single email or multiple authority recipients
String to = (String)repoProps.get(MailActionExecuter.PARAM_TO);
if (to != null)
{
actionProps.put(PROP_TO, to);
}
else
{
List<String> recipients = (List<String>)repoProps.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)
{
wizard.getEmailRecipients().add(
new RecipientWrapper(wizard.displayLabelForAuthority(authority),
authority));
}
}
}
NodeRef templateRef = (NodeRef)repoProps.get(MailActionExecuter.PARAM_TEMPLATE);
if (templateRef != null)
{
actionProps.put(PROP_TEMPLATE, templateRef.getId());
wizard.setUsingTemplate(templateRef.getId());
}
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
BaseActionWizard actionWizard = (BaseActionWizard)wizard;
String addresses = (String)actionProps.get(PROP_TO);
if (addresses == null || addresses.length() == 0)
{
if (actionWizard.getEmailRecipients().size() != 0)
{
StringBuilder builder = new StringBuilder();
for (int i=0; i < actionWizard.getEmailRecipients().size(); i++)
{
RecipientWrapper wrapper = actionWizard.getEmailRecipients().get(i);
if (i != 0)
{
builder.append(", ");
}
builder.append(wrapper.getName());
}
addresses = builder.toString();
}
}
return MessageFormat.format(Application.getMessage(context, "action_mail"),
new Object[] {addresses});
}
}

View File

@@ -0,0 +1,62 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.MoveActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "move" action.
*
* @author gavinc
*/
public class MoveHandler extends BaseActionHandler
{
public String getJSPPath()
{
return getJSPPath(MoveActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(MoveActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the move
// is performed
repoProps.put(MoveActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(MoveActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "move"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef destNodeRef = (NodeRef)repoProps.get(MoveActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String spaceName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
return MessageFormat.format(Application.getMessage(context, "action_move"),
new Object[] {spaceName});
}
}

View File

@@ -0,0 +1,65 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.executer.RemoveFeaturesActionExecuter;
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.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "remove-features" action.
*
* @author gavinc
*/
public class RemoveFeaturesHandler extends BaseActionHandler
{
protected static final String PROP_ASPECT = "aspect";
public String getJSPPath()
{
return getJSPPath(RemoveFeaturesActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
QName aspect = Repository.resolveToQName((String)actionProps.get(PROP_ASPECT));
repoProps.put(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect);
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
QName aspect = (QName)repoProps.get(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME);
actionProps.put(PROP_ASPECT, aspect.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
String aspect = (String)actionProps.get(PROP_ASPECT);
// find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getAspects())
{
if (item.getValue().equals(aspect))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_remove_features"),
new Object[] {label});
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.ScriptActionExecutor;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "script" action.
*
* @author gavinc
*/
public class ScriptHandler extends BaseActionHandler
{
protected static final String PROP_SCRIPT = "script";
public String getJSPPath()
{
return getJSPPath(ScriptActionExecutor.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the selected script noderef to the action properties
String id = (String)actionProps.get(PROP_SCRIPT);
NodeRef scriptRef = new NodeRef(Repository.getStoreRef(), id);
repoProps.put(ScriptActionExecutor.PARAM_SCRIPTREF, scriptRef);
NavigationBean navBean = (NavigationBean)FacesHelper.getManagedBean(
FacesContext.getCurrentInstance(), "NavigationBean");
repoProps.put(ScriptActionExecutor.PARAM_SPACEREF,
navBean.getCurrentNode().getNodeRef());
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef scriptRef = (NodeRef)repoProps.get(ScriptActionExecutor.PARAM_SCRIPTREF);
actionProps.put(PROP_SCRIPT, scriptRef.getId());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String id = (String)actionProps.get(PROP_SCRIPT);
NodeRef scriptRef = new NodeRef(Repository.getStoreRef(), id);
String scriptName = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), scriptRef);
return MessageFormat.format(Application.getMessage(context, "action_script"),
new Object[] {scriptName});
}
}

View File

@@ -0,0 +1,181 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.SimpleWorkflowActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "simple-workflow" action.
*
* @author gavinc
*/
public class SimpleWorkflowHandler extends BaseActionHandler
{
public static final String PROP_APPROVE_STEP_NAME = "approveStepName";
public static final String PROP_APPROVE_ACTION = "approveAction";
public static final String PROP_APPROVE_FOLDER = "approveFolder";
public static final String PROP_REJECT_STEP_PRESENT = "rejectStepPresent";
public static final String PROP_REJECT_STEP_NAME = "rejectStepName";
public static final String PROP_REJECT_ACTION = "rejectAction";
public static final String PROP_REJECT_FOLDER = "rejectFolder";
@Override
public void setupUIDefaults(Map<String, Serializable> actionProps)
{
actionProps.put(PROP_APPROVE_ACTION, "move");
actionProps.put(PROP_REJECT_STEP_PRESENT, "yes");
actionProps.put(PROP_REJECT_ACTION, "move");
}
public String getJSPPath()
{
return getJSPPath(SimpleWorkflowActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the approve step name
repoProps.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_STEP,
(String)actionProps.get(PROP_APPROVE_STEP_NAME));
// add whether the approve step will copy or move the content
boolean approveMove = true;
String approveAction = (String)actionProps.get(PROP_APPROVE_ACTION);
if (approveAction != null && approveAction.equals("copy"))
{
approveMove = false;
}
repoProps.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_MOVE, Boolean.valueOf(approveMove));
// add the destination folder of the content
NodeRef approveDestNodeRef = null;
Object approveDestNode = actionProps.get(PROP_APPROVE_FOLDER);
if (approveDestNode instanceof NodeRef)
{
approveDestNodeRef = (NodeRef)approveDestNode;
}
else if (approveDestNode instanceof String)
{
approveDestNodeRef = new NodeRef((String)approveDestNode);
}
repoProps.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_FOLDER, approveDestNodeRef);
// determine whether we have a reject step or not
boolean requireReject = true;
String rejectStepPresent = (String)actionProps.get(PROP_REJECT_STEP_PRESENT);
if (rejectStepPresent != null && rejectStepPresent.equals("no"))
{
requireReject = false;
}
if (requireReject)
{
// add the reject step name
repoProps.put(SimpleWorkflowActionExecuter.PARAM_REJECT_STEP,
(String)actionProps.get(PROP_REJECT_STEP_NAME));
// add whether the reject step will copy or move the content
boolean rejectMove = true;
String rejectAction = (String)actionProps.get(PROP_REJECT_ACTION);
if (rejectAction != null && rejectAction.equals("copy"))
{
rejectMove = false;
}
repoProps.put(SimpleWorkflowActionExecuter.PARAM_REJECT_MOVE, Boolean.valueOf(rejectMove));
// add the destination folder of the content
NodeRef rejectDestNodeRef = null;
Object rejectDestNode = actionProps.get(PROP_REJECT_FOLDER);
if (rejectDestNode instanceof NodeRef)
{
rejectDestNodeRef = (NodeRef)rejectDestNode;
}
else if (rejectDestNode instanceof String)
{
rejectDestNodeRef = new NodeRef((String)rejectDestNode);
}
repoProps.put(SimpleWorkflowActionExecuter.PARAM_REJECT_FOLDER, rejectDestNodeRef);
}
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String approveStep = (String)repoProps.get(SimpleWorkflowActionExecuter.PARAM_APPROVE_STEP);
Boolean approveMove = (Boolean)repoProps.get(SimpleWorkflowActionExecuter.PARAM_APPROVE_MOVE);
NodeRef approveFolderNode = (NodeRef)repoProps.get(
SimpleWorkflowActionExecuter.PARAM_APPROVE_FOLDER);
String rejectStep = (String)repoProps.get(SimpleWorkflowActionExecuter.PARAM_REJECT_STEP);
Boolean rejectMove = (Boolean)repoProps.get(SimpleWorkflowActionExecuter.PARAM_REJECT_MOVE);
NodeRef rejectFolderNode = (NodeRef)repoProps.get(
SimpleWorkflowActionExecuter.PARAM_REJECT_FOLDER);
actionProps.put(PROP_APPROVE_STEP_NAME, approveStep);
actionProps.put(PROP_APPROVE_ACTION, approveMove ? "move" : "copy");
actionProps.put(PROP_APPROVE_FOLDER, approveFolderNode);
if (rejectStep == null && rejectMove == null && rejectFolderNode == null)
{
actionProps.put(PROP_REJECT_STEP_PRESENT, "no");
actionProps.put(PROP_REJECT_ACTION, "move");
}
else
{
actionProps.put(PROP_REJECT_STEP_PRESENT, "yes");
actionProps.put(PROP_REJECT_STEP_NAME, rejectStep);
actionProps.put(PROP_REJECT_ACTION, rejectMove ? "move" : "copy");
actionProps.put(PROP_REJECT_FOLDER, rejectFolderNode);
}
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
String approveStepName = (String)actionProps.get(PROP_APPROVE_STEP_NAME);
String approveAction = (String)actionProps.get(PROP_APPROVE_ACTION);
NodeRef approveFolder = (NodeRef)actionProps.get(PROP_APPROVE_FOLDER);
String approveFolderName = Repository.getNameForNode(nodeService, approveFolder);
String approveMsg = MessageFormat.format(
Application.getMessage(context, "action_simple_workflow"),
new Object[] {Application.getMessage(context, approveAction),
approveFolderName, approveStepName});
String rejectMsg = null;
String rejectStep = (String)actionProps.get(PROP_REJECT_STEP_PRESENT);
if (rejectStep != null && "yes".equals(rejectStep))
{
String rejectStepName = (String)actionProps.get(PROP_REJECT_STEP_NAME);
String rejectAction = (String)actionProps.get(PROP_REJECT_ACTION);
NodeRef rejectFolder = (NodeRef)actionProps.get(PROP_REJECT_FOLDER);
String rejectFolderName = Repository.getNameForNode(nodeService, rejectFolder);
rejectMsg = MessageFormat.format(
Application.getMessage(context, "action_simple_workflow"),
new Object[] {Application.getMessage(context, rejectAction),
rejectFolderName, rejectStepName});
}
StringBuilder builder = new StringBuilder(approveMsg);
if (rejectMsg != null)
{
builder.append(" ");
builder.append(rejectMsg);
}
return builder.toString();
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.executer.SpecialiseTypeActionExecuter;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.actions.BaseActionWizard;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "specialise-type" action.
*
* @author gavinc
*/
public class SpecialiseTypeHandler extends BaseActionHandler
{
public static final String PROP_OBJECT_TYPE = "objecttype";
public String getJSPPath()
{
return getJSPPath(SpecialiseTypeActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String objectType = (String)actionProps.get(PROP_OBJECT_TYPE);
repoProps.put(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME,
QName.createQName(objectType));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
QName specialiseType = (QName)repoProps.get(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME);
actionProps.put(PROP_OBJECT_TYPE, specialiseType.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
String objectType = (String)actionProps.get(PROP_OBJECT_TYPE);
for (SelectItem item : ((BaseActionWizard)wizard).getObjectTypes())
{
if (item.getValue().equals(objectType) == true)
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_specialise_type"),
new Object[] {label});
}
}

View File

@@ -0,0 +1,85 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.TransformActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
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.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "transform" action.
*
* @author gavinc
*/
public class TransformHandler extends BaseActionHandler
{
protected static final String PROP_TRANSFORMER = "transformer";
public String getJSPPath()
{
return getJSPPath(TransformActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the transformer to use
repoProps.put(TransformActionExecuter.PARAM_MIME_TYPE,
actionProps.get(PROP_TRANSFORMER));
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(TransformActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the copy
// is performed
repoProps.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(TransformActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String transformer = (String)repoProps.get(TransformActionExecuter.PARAM_MIME_TYPE);
actionProps.put(PROP_TRANSFORMER, transformer);
NodeRef destNodeRef = (NodeRef)repoProps.get(TransformActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String name = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
String transformer = (String)actionProps.get(PROP_TRANSFORMER);
// find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getTransformers())
{
if (item.getValue().equals(transformer))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_transform"),
new Object[] {name, label});
}
}

View File

@@ -0,0 +1,95 @@
package org.alfresco.web.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.ImageTransformActionExecuter;
import org.alfresco.repo.action.executer.TransformActionExecuter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
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.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Action handler for the "transform-image" action.
*
* @author gavinc
*/
public class TransformImageHandler extends BaseActionHandler
{
protected static final String PROP_IMAGE_TRANSFORMER = "imageTransformer";
protected static final String PROP_TRANSFORM_OPTIONS = "transformOptions";
public String getJSPPath()
{
return getJSPPath(ImageTransformActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// add the transformer to use
repoProps.put(ImageTransformActionExecuter.PARAM_MIME_TYPE,
actionProps.get(PROP_IMAGE_TRANSFORMER));
// add the options
repoProps.put(ImageTransformActionExecuter.PARAM_CONVERT_COMMAND,
actionProps.get(PROP_TRANSFORM_OPTIONS));
// add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
repoProps.put(ImageTransformActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
// add the type and name of the association to create when the copy
// is performed
repoProps.put(TransformActionExecuter.PARAM_ASSOC_TYPE_QNAME,
ContentModel.ASSOC_CONTAINS);
repoProps.put(TransformActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
String transformer = (String)repoProps.get(TransformActionExecuter.PARAM_MIME_TYPE);
actionProps.put(PROP_IMAGE_TRANSFORMER, transformer);
String options = (String)repoProps.get(ImageTransformActionExecuter.PARAM_CONVERT_COMMAND);
actionProps.put(PROP_TRANSFORM_OPTIONS, options != null ? options : "");
NodeRef destNodeRef = (NodeRef)repoProps.get(ImageTransformActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
String label = null;
NodeRef space = (NodeRef)actionProps.get(PROP_DESTINATION);
String name = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), space);
String transformer = (String)actionProps.get(PROP_IMAGE_TRANSFORMER);
String option = (String)actionProps.get(PROP_TRANSFORM_OPTIONS);
// find the label used by looking through the SelectItem list
for (SelectItem item : ((BaseActionWizard)wizard).getImageTransformers())
{
if (item.getValue().equals(transformer))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, "action_transform_image"),
new Object[] {name, label, option});
}
}

View File

@@ -1,7 +1,6 @@
package org.alfresco.web.bean.rules; package org.alfresco.web.bean.rules;
import java.io.Serializable; import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -16,25 +15,21 @@ import javax.faces.model.SelectItem;
import org.alfresco.config.Config; import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigService; import org.alfresco.config.ConfigService;
import org.alfresco.model.ContentModel; 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.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition; import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionConditionDefinition; import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.dictionary.TypeDefinition; 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.Rule;
import org.alfresco.service.cmr.rule.RuleService; import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.rule.RuleType; import org.alfresco.service.cmr.rule.RuleType;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.actions.BaseActionWizard; import org.alfresco.web.bean.actions.BaseActionWizard;
import org.alfresco.web.bean.actions.IHandler;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.rules.handlers.BaseConditionHandler;
import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.IDataContainer;
import org.alfresco.web.data.QuickSort; import org.alfresco.web.data.QuickSort;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
@@ -48,9 +43,8 @@ import org.apache.commons.logging.LogFactory;
*/ */
public class CreateRuleWizard extends BaseActionWizard public class CreateRuleWizard extends BaseActionWizard
{ {
public static final String PROP_CONDITION_NAME = "conditionName"; protected static final String PROP_CONDITION_NAME = "conditionName";
public static final String PROP_CONDITION_SUMMARY = "conditionSummary"; protected static final String PROP_CONDITION_SUMMARY = "conditionSummary";
public static final String PROP_CONDITION_NOT = "notcondition";
protected RuleService ruleService; protected RuleService ruleService;
protected RulesBean rulesBean; protected RulesBean rulesBean;
@@ -60,6 +54,7 @@ public class CreateRuleWizard extends BaseActionWizard
private List<SelectItem> types; private List<SelectItem> types;
private List<SelectItem> conditions; private List<SelectItem> conditions;
protected Map<String, IHandler> conditionHandlers;
protected Map<String, Serializable> currentConditionProperties; protected Map<String, Serializable> currentConditionProperties;
protected List<Map<String, Serializable>> allConditionsProperties; protected List<Map<String, Serializable>> allConditionsProperties;
@@ -73,8 +68,6 @@ public class CreateRuleWizard extends BaseActionWizard
protected boolean applyToSubSpaces; protected boolean applyToSubSpaces;
protected boolean editingCondition; protected boolean editingCondition;
protected static final String CONDITION_PAGES_LOCATION = "/jsp/rules/";
private static final Log logger = LogFactory.getLog(CreateRuleWizard.class); private static final Log logger = LogFactory.getLog(CreateRuleWizard.class);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
@@ -94,6 +87,8 @@ public class CreateRuleWizard extends BaseActionWizard
this.conditions = null; this.conditions = null;
this.allConditionsProperties = new ArrayList<Map<String, Serializable>>(); this.allConditionsProperties = new ArrayList<Map<String, Serializable>>();
initialiseConditionHandlers();
} }
@Override @Override
@@ -488,29 +483,31 @@ public class CreateRuleWizard extends BaseActionWizard
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
this.returnViewId = context.getViewRoot().getViewId(); this.returnViewId = context.getViewRoot().getViewId();
String viewId = calculateConditionViewId(this.condition); String viewId = null;
HashMap<String, Serializable> condProps = new HashMap<String, Serializable>(3); HashMap<String, Serializable> condProps = new HashMap<String, Serializable>(3);
condProps.put(PROP_CONDITION_NAME, this.condition); condProps.put(PROP_CONDITION_NAME, this.condition);
this.currentConditionProperties = condProps; this.currentConditionProperties = condProps;
// determine whether the condition being added has any parameters // get the handler for the condition, if there isn't one we presume it
ActionConditionDefinition conditionDef = this.actionService. // is a no-parameter condition
getActionConditionDefinition(this.condition); IHandler handler = this.conditionHandlers.get(this.condition);
if (conditionDef.hasParameterDefinitions()) if (handler != null)
{ {
// setup any defaults for the UI and override the viewId if necessary // setup any UI defaults the condition may have and get the location of
String overridenViewId = setupUIDefaultsForCondition(condProps); // the JSP used to collect the parameters
if (overridenViewId != null) handler.setupUIDefaults(condProps);
{ viewId = handler.getJSPPath();
viewId = overridenViewId;
}
} }
else else
{ {
// just add the condition to the list and use the title as the summary // just add the action to the list and use the title as the summary
ActionConditionDefinition conditionDef = this.actionService.
getActionConditionDefinition(this.condition);
condProps.put(PROP_CONDITION_SUMMARY, conditionDef.getTitle()); condProps.put(PROP_CONDITION_SUMMARY, conditionDef.getTitle());
condProps.put(PROP_CONDITION_NOT, Boolean.FALSE); condProps.put(BaseConditionHandler.PROP_CONDITION_NOT, Boolean.FALSE);
// add the no params marker so we can disable the edit action
condProps.put(NO_PARAMS_MARKER, "no-params");
this.allConditionsProperties.add(condProps); this.allConditionsProperties.add(condProps);
// come back to the same page we're on now as there are no params to collect // come back to the same page we're on now as there are no params to collect
@@ -543,8 +540,9 @@ public class CreateRuleWizard extends BaseActionWizard
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
this.returnViewId = context.getViewRoot().getViewId(); this.returnViewId = context.getViewRoot().getViewId();
// refresh the wizard // go to the condition page (as there is an edit option visible,
goToPage(context, calculateConditionViewId(this.condition)); // there must be a handler for the condition so we don't check)
goToPage(context, this.conditionHandlers.get(this.condition).getJSPPath());
} }
/** /**
@@ -553,7 +551,11 @@ public class CreateRuleWizard extends BaseActionWizard
public void addCondition() public void addCondition()
{ {
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
String summary = buildConditionSummary();
// this is called from the actions page so there must be a handler
// present so there's no need to check for null
String summary = this.conditionHandlers.get(this.condition).generateSummary(
context, this, this.currentConditionProperties);
if (summary != null) if (summary != null)
{ {
@@ -654,8 +656,14 @@ public class CreateRuleWizard extends BaseActionWizard
{ {
String conditionName = (String)condParams.get(PROP_CONDITION_NAME); String conditionName = (String)condParams.get(PROP_CONDITION_NAME);
this.condition = conditionName; this.condition = conditionName;
this.currentConditionProperties = condParams;
Map<String, Serializable> repoCondParams = buildConditionParams(); // get the condition handler to prepare for the save
Map<String, Serializable> repoCondParams = new HashMap<String, Serializable>();
IHandler handler = this.conditionHandlers.get(this.condition);
if (handler != null)
{
handler.prepareForSave(condParams, repoCondParams);
}
// add the condition to the rule // add the condition to the rule
ActionCondition condition = this.actionService. ActionCondition condition = this.actionService.
@@ -663,7 +671,7 @@ public class CreateRuleWizard extends BaseActionWizard
condition.setParameterValues(repoCondParams); condition.setParameterValues(repoCondParams);
// specify whether the condition result should be inverted // specify whether the condition result should be inverted
Boolean not = (Boolean)condParams.get(PROP_CONDITION_NOT); Boolean not = (Boolean)condParams.get(BaseConditionHandler.PROP_CONDITION_NOT);
condition.setInvertCondition(((Boolean)not).booleanValue()); condition.setInvertCondition(((Boolean)not).booleanValue());
rule.addActionCondition(condition); rule.addActionCondition(condition);
@@ -676,8 +684,14 @@ public class CreateRuleWizard extends BaseActionWizard
// to setup the currentActionProperties and action variables // to setup the currentActionProperties and action variables
String actionName = (String)actionParams.get(PROP_ACTION_NAME); String actionName = (String)actionParams.get(PROP_ACTION_NAME);
this.action = actionName; this.action = actionName;
this.currentActionProperties = actionParams;
Map<String, Serializable> repoActionParams = buildActionParams(); // get the action handler to prepare for the save
Map<String, Serializable> repoActionParams = new HashMap<String, Serializable>();
IHandler handler = this.actionHandlers.get(this.action);
if (handler != null)
{
handler.prepareForSave(actionParams, repoActionParams);
}
// add the action to the rule // add the action to the rule
Action action = this.actionService.createAction(actionName); Action action = this.actionService.createAction(actionName);
@@ -689,170 +703,53 @@ public class CreateRuleWizard extends BaseActionWizard
} }
/** /**
* Sets up any default state required by the UI for collecting the * Initialises the condition handlers from the current configuration.
* condition settings. The view id to use for the condition UI can also
* be overridden by returing the path to the relevant JSP.
*
* @props The map of properties being used for the current condition
* @return An optional overridden JSP to use for condition settings collection
*/ */
protected String setupUIDefaultsForCondition(HashMap<String, Serializable> props) protected void initialiseConditionHandlers()
{ {
// NOTE: none of the built in conditions have any defaults to setup if (this.conditionHandlers == null)
{
ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
Config wizardCfg = svc.getConfig("Action Wizards");
if (wizardCfg != null)
{
ConfigElement conditionHandlerCfg = wizardCfg.getConfigElement("condition-handlers");
if (conditionHandlerCfg != null)
{
this.conditionHandlers = new HashMap<String, IHandler>(20);
return null; // instantiate each handler and store in the map
for (ConfigElement child : conditionHandlerCfg.getChildren())
{
String conditionName = child.getAttribute("name");
String handlerClass = child.getAttribute("class");
if (conditionName != null && conditionName.length() > 0 &&
handlerClass != null && handlerClass.length() > 0)
{
try
{
Class klass = Class.forName(handlerClass);
IHandler handler = (IHandler)klass.newInstance();
this.conditionHandlers.put(conditionName, handler);
} }
catch (Exception e)
/**
* Builds the Map of properties for the given condition in the format the repo is expecting
*
* @return The Map the repo is expecting
*/
protected Map<String, Serializable> buildConditionParams()
{ {
Map<String, Serializable> repoParams = new HashMap<String, Serializable>(); throw new AlfrescoRuntimeException("Failed to setup condition handler for '" +
conditionName + "'", e);
if (ComparePropertyValueEvaluator.NAME.equals(this.condition))
{
// add the text to compare
String text = (String)this.currentConditionProperties.get(PROP_CONTAINS_TEXT);
repoParams.put(ComparePropertyValueEvaluator.PARAM_VALUE, text);
}
else if (InCategoryEvaluator.NAME.equals(this.condition))
{
// put the selected category in the condition params
NodeRef nodeRef = (NodeRef)this.currentConditionProperties.get(PROP_CATEGORY);
repoParams.put(InCategoryEvaluator.PARAM_CATEGORY_VALUE, nodeRef);
// add the classifiable aspect
repoParams.put(InCategoryEvaluator.PARAM_CATEGORY_ASPECT, ContentModel.ASPECT_GEN_CLASSIFIABLE);
}
else if (IsSubTypeEvaluator.NAME.equals(this.condition))
{
// add the model type
QName type = QName.createQName((String)this.currentConditionProperties.get(PROP_MODEL_TYPE));
repoParams.put(IsSubTypeEvaluator.PARAM_TYPE, type);
}
else if (HasAspectEvaluator.NAME.equals(this.condition))
{
// add the aspect
QName aspect = QName.createQName((String)this.currentConditionProperties.get(PROP_ASPECT));
repoParams.put(HasAspectEvaluator.PARAM_ASPECT, aspect);
}
else if (CompareMimeTypeEvaluator.NAME.equals(this.condition))
{
// add the mimetype
String mimeType = (String)this.currentConditionProperties.get(PROP_MIMETYPE);
repoParams.put(CompareMimeTypeEvaluator.PARAM_VALUE, mimeType);
}
return repoParams;
}
/**
* Returns a summary string for the current condition
*
* @return The summary or null if a summary could not be built
*/
protected String buildConditionSummary()
{
String summary = null;
FacesContext context = FacesContext.getCurrentInstance();
Boolean not = (Boolean)this.currentConditionProperties.get(PROP_CONDITION_NOT);
if (ComparePropertyValueEvaluator.NAME.equals(this.condition))
{
String msgId = not.booleanValue() ?
"condition_compare_property_value_not" : "condition_compare_property_value";
String text = (String)this.currentConditionProperties.get(PROP_CONTAINS_TEXT);
summary = MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {text});
}
else if (InCategoryEvaluator.NAME.equals(this.condition))
{
String msgId = not.booleanValue() ? "condition_in_category_not" : "condition_in_category";
String name = Repository.getNameForNode(this.nodeService,
(NodeRef)this.currentConditionProperties.get(PROP_CATEGORY));
summary = MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {name});
}
else if (IsSubTypeEvaluator.NAME.equals(this.condition))
{
String msgId = not.booleanValue() ? "condition_is_subtype_not" : "condition_is_subtype";
String label = null;
String typeName = (String)this.currentConditionProperties.get(PROP_MODEL_TYPE);
for (SelectItem item : this.getModelTypes())
{
if (item.getValue().equals(typeName))
{
label = item.getLabel();
break;
} }
} }
summary = MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {label});
} }
else if (HasAspectEvaluator.NAME.equals(this.condition))
{
String msgId = not.booleanValue() ? "condition_has_aspect_not" : "condition_has_aspect";
String label = null;
String aspectName = (String)this.currentConditionProperties.get(PROP_ASPECT);
for (SelectItem item : this.getAspects())
{
if (item.getValue().equals(aspectName))
{
label = item.getLabel();
break;
}
}
summary = MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {label});
}
else if (CompareMimeTypeEvaluator.NAME.equals(this.condition))
{
String msgId = not.booleanValue() ? "condition_compare_mime_type_not" : "condition_compare_mime_type";
String label = null;
String mimetype = (String)this.currentConditionProperties.get(PROP_MIMETYPE);
for (SelectItem item : this.getMimeTypes())
{
if (item.getValue().equals(mimetype))
{
label = item.getLabel();
break;
}
}
summary = MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {label});
} }
else else
{ {
// as the default case (i.e. for conditions with no parameters) use the title logger.warn("Could not find 'condition-handlers' configuration element");
ActionConditionDefinition conditionDef = this.actionService.
getActionConditionDefinition(this.condition);
summary = conditionDef.getTitle();
} }
return summary;
} }
else
/**
* 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"; logger.warn("Could not find 'Action Wizards' configuration section");
}
}
} }
} }

View File

@@ -8,31 +8,14 @@ import java.util.Map;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import org.alfresco.error.AlfrescoRuntimeException; 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.ScriptActionExecutor;
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.Action;
import org.alfresco.service.cmr.action.ActionCondition; import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.rule.Rule; import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.namespace.QName; import org.alfresco.web.bean.actions.IHandler;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.rules.handlers.BaseConditionHandler;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -69,19 +52,38 @@ public class EditRuleWizard extends CreateRuleWizard
this.applyToSubSpaces = rule.isAppliedToChildren(); this.applyToSubSpaces = rule.isAppliedToChildren();
this.runInBackground = rule.getExecuteAsychronously(); this.runInBackground = rule.getExecuteAsychronously();
FacesContext context = FacesContext.getCurrentInstance();
// populate the conditions list with maps of properties representing each condition // populate the conditions list with maps of properties representing each condition
List<ActionCondition> conditions = rule.getActionConditions(); List<ActionCondition> conditions = rule.getActionConditions();
for (ActionCondition condition : conditions) for (ActionCondition condition : conditions)
{ {
this.currentConditionProperties = new HashMap<String, Serializable>(3); this.currentConditionProperties = new HashMap<String, Serializable>(3);
this.condition = condition.getActionConditionDefinitionName(); this.condition = condition.getActionConditionDefinitionName();
populateCondition(condition.getParameterValues());
// add the name, summary and not condition flag
this.currentConditionProperties.put(PROP_CONDITION_NAME, this.condition); this.currentConditionProperties.put(PROP_CONDITION_NAME, this.condition);
this.currentConditionProperties.put(PROP_CONDITION_NOT, this.currentConditionProperties.put(BaseConditionHandler.PROP_CONDITION_NOT,
Boolean.valueOf(condition.getInvertCondition())); Boolean.valueOf(condition.getInvertCondition()));
this.currentConditionProperties.put(PROP_CONDITION_SUMMARY, buildConditionSummary());
IHandler handler = this.conditionHandlers.get(this.condition);
if (handler != null)
{
// use the handler to populate the properties and summary
handler.prepareForEdit(this.currentConditionProperties,
condition.getParameterValues());
this.currentConditionProperties.put(PROP_CONDITION_SUMMARY,
handler.generateSummary(context, this, this.currentConditionProperties));
}
else
{
// there's no handler, so we presume it is a no-paramter
// condition, use the condition title as the summary
ActionConditionDefinition conditionDef = this.actionService.
getActionConditionDefinition(this.condition);
this.currentConditionProperties.put(PROP_CONDITION_SUMMARY,
conditionDef.getTitle());
// add the no params marker so we can disable the edit action
this.currentConditionProperties.put(NO_PARAMS_MARKER, "no-params");
}
// add the populated currentConditionProperties to the list // add the populated currentConditionProperties to the list
this.allConditionsProperties.add(this.currentConditionProperties); this.allConditionsProperties.add(this.currentConditionProperties);
@@ -93,11 +95,25 @@ public class EditRuleWizard extends CreateRuleWizard
{ {
this.currentActionProperties = new HashMap<String, Serializable>(3); this.currentActionProperties = new HashMap<String, Serializable>(3);
this.action = action.getActionDefinitionName(); this.action = action.getActionDefinitionName();
populateAction(action.getParameterValues());
// also add the name and summary
this.currentActionProperties.put(PROP_ACTION_NAME, this.action); this.currentActionProperties.put(PROP_ACTION_NAME, this.action);
this.currentActionProperties.put(PROP_ACTION_SUMMARY, buildActionSummary());
IHandler handler = this.actionHandlers.get(this.action);
if (handler != null)
{
// use the handler to populate the properties and summary
handler.prepareForEdit(this.currentActionProperties, action.getParameterValues());
this.currentActionProperties.put(PROP_ACTION_SUMMARY,
handler.generateSummary(context, this, this.currentActionProperties));
}
else
{
// there's no handler, so we presume it is a no-paramter
// action, use the action title as the summary
ActionDefinition actionDef = this.actionService.getActionDefinition(this.action);
this.currentActionProperties.put(PROP_ACTION_SUMMARY, actionDef.getTitle());
// add the no params marker so we can disable the edit action
this.currentActionProperties.put(NO_PARAMS_MARKER, "no-params");
}
// add the populated currentActionProperties to the list // add the populated currentActionProperties to the list
this.allActionsProperties.add(this.currentActionProperties); this.allActionsProperties.add(this.currentActionProperties);
@@ -152,182 +168,4 @@ public class EditRuleWizard extends CreateRuleWizard
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Helper methods // Helper methods
/**
* Populates a Map of properties the wizard is expecting for the given condition
*
* @param condition The condition to build the map for
*/
protected void populateCondition(Map<String, Serializable> conditionProps)
{
if (ComparePropertyValueEvaluator.NAME.equals(this.condition))
{
String propValue = (String)conditionProps.get(ComparePropertyValueEvaluator.PARAM_VALUE);
this.currentConditionProperties.put(PROP_CONTAINS_TEXT, propValue);
}
else if (InCategoryEvaluator.NAME.equals(this.condition))
{
NodeRef catNodeRef = (NodeRef)conditionProps.get(InCategoryEvaluator.PARAM_CATEGORY_VALUE);
this.currentConditionProperties.put(PROP_CATEGORY, catNodeRef);
}
else if (IsSubTypeEvaluator.NAME.equals(this.condition))
{
QName type = (QName)conditionProps.get(IsSubTypeEvaluator.PARAM_TYPE);
this.currentConditionProperties.put(PROP_MODEL_TYPE, type.toString());
}
else if (HasAspectEvaluator.NAME.equals(this.condition))
{
QName aspect = (QName)conditionProps.get(HasAspectEvaluator.PARAM_ASPECT);
this.currentConditionProperties.put(PROP_ASPECT, aspect.toString());
}
else if (CompareMimeTypeEvaluator.NAME.equals(this.condition))
{
String mimeType = (String)conditionProps.get(CompareMimeTypeEvaluator.PARAM_VALUE);
this.currentConditionProperties.put(PROP_MIMETYPE, mimeType);
}
}
/**
* 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 (AddFeaturesActionExecuter.NAME.equals(this.action))
{
QName aspect = (QName)actionProps.get(AddFeaturesActionExecuter.PARAM_ASPECT_NAME);
this.currentActionProperties.put(PROP_ASPECT, aspect.toString());
}
else if (RemoveFeaturesActionExecuter.NAME.equals(this.action))
{
QName aspect = (QName)actionProps.get(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME);
this.currentActionProperties.put(PROP_ASPECT, aspect.toString());
}
else if (CopyActionExecuter.NAME.equals(this.action))
{
NodeRef destNodeRef = (NodeRef)actionProps.get(CopyActionExecuter.PARAM_DESTINATION_FOLDER);
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
}
else if (MoveActionExecuter.NAME.equals(this.action))
{
NodeRef destNodeRef = (NodeRef)actionProps.get(MoveActionExecuter.PARAM_DESTINATION_FOLDER);
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
}
else if (SimpleWorkflowActionExecuter.NAME.equals(this.action))
{
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 (LinkCategoryActionExecuter.NAME.equals(this.action))
{
NodeRef catNodeRef = (NodeRef)actionProps.get(LinkCategoryActionExecuter.PARAM_CATEGORY_VALUE);
this.currentActionProperties.put(PROP_CATEGORY, catNodeRef);
}
else if (CheckOutActionExecuter.NAME.equals(this.action))
{
NodeRef destNodeRef = (NodeRef)actionProps.get(CheckOutActionExecuter.PARAM_DESTINATION_FOLDER);
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
}
else if (CheckInActionExecuter.NAME.equals(this.action))
{
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 (TransformActionExecuter.NAME.equals(this.action))
{
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 (ImageTransformActionExecuter.NAME.equals(this.action))
{
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 (MailActionExecuter.NAME.equals(this.action))
{
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 (ImporterActionExecuter.NAME.equals(this.action))
{
NodeRef destNodeRef = (NodeRef)actionProps.get(ImporterActionExecuter.PARAM_DESTINATION_FOLDER);
this.currentActionProperties.put(PROP_DESTINATION, destNodeRef);
}
else if (SpecialiseTypeActionExecuter.NAME.equals(this.action))
{
QName specialiseType = (QName)actionProps.get(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME);
this.currentActionProperties.put(PROP_OBJECT_TYPE, specialiseType.toString());
}
else if (ScriptActionExecutor.NAME.equals(this.action))
{
NodeRef scriptRef = (NodeRef)actionProps.get(ScriptActionExecutor.PARAM_SCRIPTREF);
this.currentActionProperties.put(PROP_SCRIPT, scriptRef.getId());
}
}
} }

View File

@@ -0,0 +1,34 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.web.bean.actions.IHandler;
/**
* Base class for all condition handler implementations.
*
* @author gavinc
*/
public abstract class BaseConditionHandler implements IHandler
{
protected static final String CONDITION_PAGES_LOCATION = "/jsp/rules/";
public static final String PROP_CONDITION_NOT = "notcondition";
public void setupUIDefaults(Map<String, Serializable> conditionProps)
{
// do nothing by default, only those condition handlers that need
// to setup defaults need override this method
}
/**
* Given the condition name, generates the default path for the JSP
*
* @param conditionName The name of the condition
* @return The path to the JSP used for the condition
*/
protected String getJSPPath(String conditionName)
{
return CONDITION_PAGES_LOCATION + conditionName + ".jsp";
}
}

View File

@@ -0,0 +1,63 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.evaluator.CompareMimeTypeEvaluator;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.rules.CreateRuleWizard;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler for the "compare-mime-type" condition
*
* @author gavinc
*/
public class CompareMimeTypeHandler extends BaseConditionHandler
{
protected static final String PROP_MIMETYPE = "mimetype";
public String getJSPPath()
{
return getJSPPath(CompareMimeTypeEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
String mimeType = (String)conditionProps.get(PROP_MIMETYPE);
repoProps.put(CompareMimeTypeEvaluator.PARAM_VALUE, mimeType);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
String mimeType = (String)repoProps.get(CompareMimeTypeEvaluator.PARAM_VALUE);
conditionProps.put(PROP_MIMETYPE, mimeType);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ? "condition_compare_mime_type_not" : "condition_compare_mime_type";
String label = null;
String mimetype = (String)conditionProps.get(PROP_MIMETYPE);
for (SelectItem item : ((CreateRuleWizard)wizard).getMimeTypes())
{
if (item.getValue().equals(mimetype))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {label});
}
}

View File

@@ -0,0 +1,64 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.evaluator.HasAspectEvaluator;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.rules.CreateRuleWizard;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler for the "has-aspect" condition.
*
* @author gavinc
*/
public class HasAspectHandler extends BaseConditionHandler
{
protected static final String PROP_ASPECT = "aspect";
public String getJSPPath()
{
return getJSPPath(HasAspectEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
QName aspect = QName.createQName((String)conditionProps.get(PROP_ASPECT));
repoProps.put(HasAspectEvaluator.PARAM_ASPECT, aspect);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
QName aspect = (QName)repoProps.get(HasAspectEvaluator.PARAM_ASPECT);
conditionProps.put(PROP_ASPECT, aspect.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ? "condition_has_aspect_not" : "condition_has_aspect";
String label = null;
String aspectName = (String)conditionProps.get(PROP_ASPECT);
for (SelectItem item : ((CreateRuleWizard)wizard).getAspects())
{
if (item.getValue().equals(aspectName))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {label});
}
}

View File

@@ -0,0 +1,61 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.evaluator.InCategoryEvaluator;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler for the "in-category" condition.
*
* @author gavinc
*/
public class InCategoryHandler extends BaseConditionHandler
{
protected static final String PROP_CATEGORY = "category";
public String getJSPPath()
{
return getJSPPath(InCategoryEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
// put the selected category in the condition params
NodeRef nodeRef = (NodeRef)conditionProps.get(PROP_CATEGORY);
repoProps.put(InCategoryEvaluator.PARAM_CATEGORY_VALUE, nodeRef);
// add the classifiable aspect
repoProps.put(InCategoryEvaluator.PARAM_CATEGORY_ASPECT,
ContentModel.ASPECT_GEN_CLASSIFIABLE);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
NodeRef catNodeRef = (NodeRef)repoProps.get(InCategoryEvaluator.PARAM_CATEGORY_VALUE);
conditionProps.put(PROP_CATEGORY, catNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ? "condition_in_category_not" : "condition_in_category";
String name = Repository.getNameForNode(Repository.getServiceRegistry(context).
getNodeService(), (NodeRef)conditionProps.get(PROP_CATEGORY));
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {name});
}
}

View File

@@ -0,0 +1,64 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.repo.action.evaluator.IsSubTypeEvaluator;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.rules.CreateRuleWizard;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler to the "is-subtype" condition.
*
* @author gavinc
*/
public class IsSubTypeHandler extends BaseConditionHandler
{
protected static final String PROP_MODEL_TYPE = "modeltype";
public String getJSPPath()
{
return getJSPPath(IsSubTypeEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
QName type = QName.createQName((String)conditionProps.get(PROP_MODEL_TYPE));
repoProps.put(IsSubTypeEvaluator.PARAM_TYPE, type);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
QName type = (QName)repoProps.get(IsSubTypeEvaluator.PARAM_TYPE);
conditionProps.put(PROP_MODEL_TYPE, type.toString());
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ? "condition_is_subtype_not" : "condition_is_subtype";
String label = null;
String typeName = (String)conditionProps.get(PROP_MODEL_TYPE);
for (SelectItem item : ((CreateRuleWizard)wizard).getModelTypes())
{
if (item.getValue().equals(typeName))
{
label = item.getLabel();
break;
}
}
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {label});
}
}

View File

@@ -0,0 +1,53 @@
package org.alfresco.web.bean.rules.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.wizard.IWizardBean;
/**
* Condition handler for the "compare-property-value" condition.
*
* @author gavinc
*/
public class PropertyValueHandler extends BaseConditionHandler
{
public static final String PROP_CONTAINS_TEXT = "containstext";
public String getJSPPath()
{
return getJSPPath(ComparePropertyValueEvaluator.NAME);
}
public void prepareForSave(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
String text = (String)conditionProps.get(PROP_CONTAINS_TEXT);
repoProps.put(ComparePropertyValueEvaluator.PARAM_VALUE, text);
}
public void prepareForEdit(Map<String, Serializable> conditionProps,
Map<String, Serializable> repoProps)
{
String propValue = (String)repoProps.get(ComparePropertyValueEvaluator.PARAM_VALUE);
conditionProps.put(PROP_CONTAINS_TEXT, propValue);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> conditionProps)
{
Boolean not = (Boolean)conditionProps.get(PROP_CONDITION_NOT);
String msgId = not.booleanValue() ?
"condition_compare_property_value_not" : "condition_compare_property_value";
String text = (String)conditionProps.get(PROP_CONTAINS_TEXT);
return MessageFormat.format(Application.getMessage(context, msgId),
new Object[] {text});
}
}

View File

@@ -111,14 +111,14 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="#{msg.summary}" /> <h:outputText value="#{msg.summary}" />
</f:facet> </f:facet>
<h:outputText value="#{row.actionSummary}"/> <h:outputText value="#{row.actionSummary}" />
<h:outputText value="&nbsp;&nbsp;" escape="false"/> <h:outputText value="&nbsp;&nbsp;" escape="false"/>
</h:column> </h:column>
<h:column> <h:column>
<a:actionLink action="#{WizardManager.bean.removeAction}" image="/images/icons/delete.gif" <a:actionLink action="#{WizardManager.bean.removeAction}" image="/images/icons/delete.gif"
value="#{msg.remove}" showLink="false" style="padding-left:6px;padding-right:2px" /> value="#{msg.remove}" showLink="false" style="padding-left:6px;padding-right:2px" />
<a:actionLink action="#{WizardManager.bean.editAction}" image="/images/icons/edit_icon.gif" <a:actionLink action="#{WizardManager.bean.editAction}" image="/images/icons/edit_icon.gif"
value="#{msg.change}" showLink="false" /> value="#{msg.change}" showLink="false" rendered='#{row.noParamsMarker == null}' />
</h:column> </h:column>
</h:dataTable> </h:dataTable>
<a:panel id="no-items" rendered="#{WizardManager.bean.allActionsDataModel.rowCount == 0}"> <a:panel id="no-items" rendered="#{WizardManager.bean.allActionsDataModel.rowCount == 0}">

View File

@@ -111,14 +111,13 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="#{msg.summary}" /> <h:outputText value="#{msg.summary}" />
</f:facet> </f:facet>
<h:outputText value="#{row.conditionSummary}"/> <h:outputText value="#{row.conditionSummary}" />
</h:column> </h:column>
<h:column> <h:column>
<a:actionLink action="#{WizardManager.bean.removeCondition}" image="/images/icons/delete.gif" <a:actionLink action="#{WizardManager.bean.removeCondition}" image="/images/icons/delete.gif"
value="#{msg.remove}" showLink="false" style="padding-left:6px;padding-right:2px" /> value="#{msg.remove}" showLink="false" style="padding-left:6px;padding-right:2px" />
<a:actionLink action="#{WizardManager.bean.editCondition}" image="/images/icons/edit_icon.gif" <a:actionLink action="#{WizardManager.bean.editCondition}" image="/images/icons/edit_icon.gif"
value="#{msg.change}" showLink="false" value="#{msg.change}" showLink="false" rendered='#{row.noParamsMarker == null}' />
rendered='#{row.conditionName != "no-condition"}'/>
</h:column> </h:column>
</h:dataTable> </h:dataTable>
<a:panel id="no-items" rendered="#{WizardManager.bean.allConditionsDataModel.rowCount == 0}"> <a:panel id="no-items" rendered="#{WizardManager.bean.allConditionsDataModel.rowCount == 0}">