KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > bean > wizard > NewRuleWizard


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.web.bean.wizard;
18
19 import java.io.Serializable JavaDoc;
20 import java.text.MessageFormat JavaDoc;
21 import java.util.ArrayList JavaDoc;
22 import java.util.HashMap JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.Map JavaDoc;
25 import java.util.ResourceBundle JavaDoc;
26
27 import javax.faces.context.FacesContext;
28 import javax.faces.event.ActionEvent;
29 import javax.faces.model.DataModel;
30 import javax.faces.model.ListDataModel;
31 import javax.faces.model.SelectItem;
32 import javax.transaction.UserTransaction JavaDoc;
33
34 import org.alfresco.config.Config;
35 import org.alfresco.config.ConfigElement;
36 import org.alfresco.config.ConfigService;
37 import org.alfresco.error.AlfrescoRuntimeException;
38 import org.alfresco.model.ContentModel;
39 import org.alfresco.repo.action.evaluator.CompareMimeTypeEvaluator;
40 import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
41 import org.alfresco.repo.action.evaluator.HasAspectEvaluator;
42 import org.alfresco.repo.action.evaluator.InCategoryEvaluator;
43 import org.alfresco.repo.action.evaluator.IsSubTypeEvaluator;
44 import org.alfresco.repo.action.executer.CheckInActionExecuter;
45 import org.alfresco.repo.action.executer.SimpleWorkflowActionExecuter;
46 import org.alfresco.repo.action.executer.SpecialiseTypeActionExecuter;
47 import org.alfresco.service.cmr.action.Action;
48 import org.alfresco.service.cmr.action.ActionCondition;
49 import org.alfresco.service.cmr.action.ActionConditionDefinition;
50 import org.alfresco.service.cmr.dictionary.TypeDefinition;
51 import org.alfresco.service.cmr.repository.MimetypeService;
52 import org.alfresco.service.cmr.repository.NodeRef;
53 import org.alfresco.service.cmr.rule.Rule;
54 import org.alfresco.service.cmr.rule.RuleService;
55 import org.alfresco.service.cmr.rule.RuleType;
56 import org.alfresco.service.namespace.QName;
57 import org.alfresco.web.app.Application;
58 import org.alfresco.web.bean.RulesBean;
59 import org.alfresco.web.bean.repository.Node;
60 import org.alfresco.web.bean.repository.Repository;
61 import org.alfresco.web.data.IDataContainer;
62 import org.alfresco.web.data.QuickSort;
63 import org.alfresco.web.ui.common.Utils;
64 import org.apache.commons.logging.Log;
65 import org.apache.commons.logging.LogFactory;
66
67 /**
68  * Handler class used by the New Space Wizard
69  *
70  * @author gavinc
71  */

72 public class NewRuleWizard extends BaseActionWizard
73 {
74    // parameter names for actions
75
public static final String JavaDoc PROP_ACTION_NAME = "actionName";
76    public static final String JavaDoc PROP_ACTION_SUMMARY = "actionSummary";
77    
78    // parameter names for conditions
79
public static final String JavaDoc PROP_CONDITION_NAME = "conditionName";
80    public static final String JavaDoc PROP_CONDITION_SUMMARY = "conditionSummary";
81    public static final String JavaDoc PROP_CONDITION_NOT = "notcondition";
82    public static final String JavaDoc PROP_PROPERTY = "property";
83    public static final String JavaDoc PROP_CONTAINS_TEXT = "containstext";
84    public static final String JavaDoc PROP_MODEL_TYPE = "modeltype";
85    public static final String JavaDoc PROP_MIMETYPE = "mimetype";
86    public static final String JavaDoc PROP_MODEL_ASPECT = "modelaspect";
87    public static final String JavaDoc PROP_TYPE_OR_ASPECT = "typeoraspect";
88    
89    private static Log logger = LogFactory.getLog(NewRuleWizard.class);
90    
91    private static final String JavaDoc ERROR = "error_rule";
92    
93    // TODO: retrieve these from the config service
94
private static final String JavaDoc WIZARD_TITLE_ID = "new_rule_title";
95    private static final String JavaDoc WIZARD_TITLE_EDIT_ID = "new_rule_title_edit";
96    private static final String JavaDoc WIZARD_DESC_ID = "new_rule_desc";
97    private static final String JavaDoc WIZARD_DESC_EDIT_ID = "new_rule_desc_edit";
98    private static final String JavaDoc STEP1_TITLE_ID = "new_rule_step1_title";
99    private static final String JavaDoc STEP2_TITLE_ID = "new_rule_step2_title";
100    private static final String JavaDoc STEP3_TITLE_ID = "new_rule_step3_title";
101    private static final String JavaDoc FINISH_INSTRUCTION_ID = "new_rule_finish_instruction";
102    private static final String JavaDoc FINISH_INSTRUCTION_EDIT_ID = "new_rule_finish_instruction_edit";
103    
104    // new rule wizard specific properties
105
private String JavaDoc title;
106    private String JavaDoc description;
107    private String JavaDoc type;
108    private String JavaDoc condition;
109    private boolean runInBackground;
110    private boolean applyToSubSpaces;
111    private boolean editingAction;
112    private boolean editingCondition;
113
114    protected RuleService ruleService;
115    protected RulesBean rulesBean;
116    
117    private List JavaDoc<SelectItem> modelTypes;
118    private List JavaDoc<SelectItem> mimeTypes;
119    private List JavaDoc<SelectItem> types;
120    private List JavaDoc<SelectItem> conditions;
121    private List JavaDoc<SelectItem> typesAndAspects;
122    private Map JavaDoc<String JavaDoc, String JavaDoc> conditionDescriptions;
123    private Map JavaDoc<String JavaDoc, Serializable JavaDoc> currentConditionProperties;
124    
125    private List JavaDoc<Map JavaDoc<String JavaDoc, Serializable JavaDoc>> allActionsProperties;
126    private List JavaDoc<Map JavaDoc<String JavaDoc, Serializable JavaDoc>> allConditionsProperties;
127    
128    private DataModel allActionsDataModel;
129    private DataModel allConditionsDataModel;
130    
131    private boolean isFinished = false;
132    
133    /**
134     * Deals with the finish button being pressed
135     *
136     * @return outcome
137     */

138    public synchronized String JavaDoc finish()
139    {
140       String JavaDoc outcome = FINISH_OUTCOME;
141       
142       if (isFinished == false)
143       {
144           isFinished = true;
145           
146           UserTransaction JavaDoc tx = null;
147        
148           try
149           {
150              tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
151              tx.begin();
152              
153              // get hold of the space the rule will apply to and make sure
154
// it is actionable
155
Node currentSpace = browseBean.getActionSpace();
156              
157              Rule rule = null;
158              
159              if (this.editMode)
160              {
161                 // update the existing rule in the repository
162
rule = this.rulesBean.getCurrentRule();
163                             
164                 // remove all the conditions and actions from the current rule
165
rule.removeAllActionConditions();
166                 rule.removeAllActions();
167              }
168              else
169              {
170                 rule = this.ruleService.createRule(this.getType());
171              }
172     
173              // setup the rule and add it to the space
174
rule.setTitle(this.title);
175              rule.setDescription(this.description);
176              rule.applyToChildren(this.applyToSubSpaces);
177              rule.setExecuteAsynchronously(this.runInBackground);
178              
179              // add all the conditions to the rule
180
for (Map JavaDoc<String JavaDoc, Serializable JavaDoc> condParams : this.allConditionsProperties)
181              {
182                 Map JavaDoc<String JavaDoc, Serializable JavaDoc> repoCondParams = buildConditionParams(condParams);
183                 
184                 // add the condition to the rule
185
ActionCondition condition = this.actionService.createActionCondition(
186                       (String JavaDoc)condParams.get(PROP_CONDITION_NAME));
187                 condition.setParameterValues(repoCondParams);
188                 
189                 // specify whether the condition result should be inverted
190
Boolean JavaDoc not = (Boolean JavaDoc)condParams.get(PROP_CONDITION_NOT);
191                 condition.setInvertCondition(((Boolean JavaDoc)not).booleanValue());
192                 
193                 rule.addActionCondition(condition);
194              }
195              
196              // add all the actions to the rule
197
for (Map JavaDoc<String JavaDoc, Serializable JavaDoc> actionParams : this.allActionsProperties)
198              {
199                 // use the base class version of buildActionParams(), but for this we need
200
// to setup the currentActionProperties and action variables
201
String JavaDoc actionName = (String JavaDoc)actionParams.get(PROP_ACTION_NAME);
202                 this.action = actionName;
203                 this.currentActionProperties = actionParams;
204                 Map JavaDoc<String JavaDoc, Serializable JavaDoc> repoActionParams = buildActionParams();
205                 
206                 // add the action to the rule
207
Action action = this.actionService.createAction(actionName);
208                 action.setParameterValues(repoActionParams);
209                 rule.addAction(action);
210              }
211              
212              // Save the rule
213
this.ruleService.saveRule(currentSpace.getNodeRef(), rule);
214              
215              if (logger.isDebugEnabled())
216              {
217                 logger.debug(this.editMode ? "Updated" : "Added" + " rule '" + this.title + "'");
218              }
219              
220              // commit the transaction
221
tx.commit();
222           }
223           catch (Throwable JavaDoc e)
224           {
225              // rollback the transaction
226
try { if (tx != null) {tx.rollback();} } catch (Exception JavaDoc ex) {}
227              Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
228                    FacesContext.getCurrentInstance(), ERROR), e.getMessage()), e);
229              outcome = null;
230              
231              isFinished = false;
232           }
233       }
234       
235       return outcome;
236    }
237
238    /**
239     * Returns the properties for all the conditions as a JSF DataModel
240     *
241     * @return JSF DataModel representing the condition properties
242     */

243    public DataModel getAllConditionsDataModel()
244    {
245       if (this.allConditionsDataModel == null)
246       {
247          this.allConditionsDataModel = new ListDataModel();
248       }
249       
250       this.allConditionsDataModel.setWrappedData(this.allConditionsProperties);
251       
252       return this.allConditionsDataModel;
253    }
254    
255    /**
256     * Displays the settings page for the current condition being added (if required)
257     *
258     * @return The outcome
259     */

260    public String JavaDoc promptForConditionValues()
261    {
262       String JavaDoc outcome = null;
263
264       // set the flag to show we are creating a new condition
265
this.editingCondition = false;
266       
267       if ("no-condition".equals(this.condition))
268       {
269          HashMap JavaDoc<String JavaDoc, Serializable JavaDoc> condProps = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>(3);
270          condProps.put(PROP_CONDITION_NAME, this.condition);
271          condProps.put(PROP_CONDITION_SUMMARY, Application.getMessage(
272                FacesContext.getCurrentInstance(), "condition_no_condition"));
273          condProps.put(PROP_CONDITION_NOT, Boolean.FALSE);
274          this.allConditionsProperties.add(condProps);
275          
276          // NOTE: we don't set an outcome to stay on the same page as there are
277
// no settings related to 'no-condition'
278

279          if (logger.isDebugEnabled())
280             logger.debug("Add 'no-condition' condition to list");
281       }
282       else if (this.condition != null)
283       {
284          HashMap JavaDoc<String JavaDoc, Serializable JavaDoc> condProps = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>(3);
285          condProps.put(PROP_CONDITION_NAME, this.condition);
286          this.currentConditionProperties = condProps;
287          outcome = this.condition;
288          
289          if (logger.isDebugEnabled())
290             logger.debug("Added '" + this.condition + "' condition to list");
291       }
292       
293       // reset the selected condition drop down
294
this.condition = null;
295       
296       return outcome;
297    }
298    
299    /**
300     * Sets up the context for editing existing condition values
301     *
302     * @return The outcome
303     */

304    public String JavaDoc editCondition()
305    {
306       // use the built in JSF support for retrieving the object for the
307
// row that was clicked by the user
308
Map JavaDoc conditionToEdit = (Map JavaDoc)this.allConditionsDataModel.getRowData();
309       this.condition = (String JavaDoc)conditionToEdit.get(PROP_CONDITION_NAME);
310       this.currentConditionProperties = conditionToEdit;
311       
312       // set the flag to show we are editing a condition
313
this.editingCondition = true;
314       
315       return this.condition;
316    }
317    
318    /**
319     * Adds the condition just setup by the user to the list of conditions for the rule
320     *
321     * @return The outcome
322     */

323    public String JavaDoc addCondition()
324    {
325       String JavaDoc summary = buildConditionSummary(this.currentConditionProperties);
326       
327       if (summary != null)
328       {
329          this.currentConditionProperties.put(PROP_CONDITION_SUMMARY, summary);
330       }
331       
332       if (this.editingCondition)
333       {
334          this.condition = null;
335       }
336       else
337       {
338          this.allConditionsProperties.add(this.currentConditionProperties);
339       }
340       
341       // re-display the conditions step
342
return "condition";
343    }
344    
345    /**
346     * Removes the requested condition from the list
347     *
348     * @return The outcome
349     */

350    public String JavaDoc removeCondition()
351    {
352       // use the built in JSF support for retrieving the object for the
353
// row that was clicked by the user
354
Map JavaDoc conditionToRemove = (Map JavaDoc)this.allConditionsDataModel.getRowData();
355       this.allConditionsProperties.remove(conditionToRemove);
356       
357       // reset the action drop down
358
this.condition = null;
359       
360       // return no outcome to refresh page
361
return null;
362    }
363    
364    /**
365     * Cancels the addition of the condition
366     *
367     * @return The outcome
368     */

369    public String JavaDoc cancelAddCondition()
370    {
371       if (this.editingCondition)
372       {
373          this.condition = null;
374       }
375       else
376       {
377          this.currentConditionProperties.clear();
378       }
379       
380       
381       return "condition";
382    }
383
384    /**
385     * Returns the properties for all the actions as a JSF DataModel
386     *
387     * @return JSF DataModel representing the action properties
388     */

389    public DataModel getAllActionsDataModel()
390    {
391       if (this.allActionsDataModel == null)
392       {
393          this.allActionsDataModel = new ListDataModel();
394       }
395       
396       this.allActionsDataModel.setWrappedData(this.allActionsProperties);
397       
398       return this.allActionsDataModel;
399    }
400    
401    /**
402     * Displays the settings page for the current action being added
403     *
404     * @return The outcome
405     */

406    public String JavaDoc promptForActionValues()
407    {
408       // set the flag to show we are creating a new action
409
this.editingAction = false;
410       
411       HashMap JavaDoc<String JavaDoc, Serializable JavaDoc> actionProps = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>(3);
412       actionProps.put(PROP_ACTION_NAME, this.action);
413       this.currentActionProperties = actionProps;
414       
415       String JavaDoc outcome = this.action;
416       
417       if (SimpleWorkflowActionExecuter.NAME.equals(this.action))
418       {
419          this.currentActionProperties.put("approveAction", "move");
420          this.currentActionProperties.put("rejectStepPresent", "yes");
421          this.currentActionProperties.put("rejectAction", "move");
422          
423          if (logger.isDebugEnabled())
424             logger.debug("Added '" + SimpleWorkflowActionExecuter.NAME +
425                   "' action to list");
426       }
427       else if (CheckInActionExecuter.NAME.equals(this.action))
428       {
429          this.currentActionProperties.put(PROP_CHECKIN_MINOR, new Boolean JavaDoc(true));
430          
431          if (logger.isDebugEnabled())
432             logger.debug("Added '" + CheckInActionExecuter.NAME +
433                   "' action to list");
434       }
435       else if ("extract-metadata".equals(this.action))
436       {
437          // This one (currently) has no parameters, so just add it...
438
actionProps.put(PROP_ACTION_SUMMARY, buildActionSummary(actionProps));
439          this.allActionsProperties.add(actionProps);
440          
441          outcome = null;
442          
443          if (logger.isDebugEnabled())
444             logger.debug("Added 'extract-metadata' action to list");
445       }
446       else
447       {
448          if (logger.isDebugEnabled())
449             logger.debug("Added '" + this.action + "' action to list");
450       }
451       
452       // reset the selected action drop down
453
this.action = null;
454       
455       return outcome;
456    }
457    
458    /**
459     * Sets up the context for editing existing action values
460     *
461     * @return The outcome
462     */

463    public String JavaDoc editAction()
464    {
465       // use the built in JSF support for retrieving the object for the
466
// row that was clicked by the user
467
Map JavaDoc actionToEdit = (Map JavaDoc)this.allActionsDataModel.getRowData();
468       this.action = (String JavaDoc)actionToEdit.get(PROP_ACTION_NAME);
469       this.currentActionProperties = actionToEdit;
470       
471       // set the flag to show we are editing an action
472
this.editingAction = true;
473       
474       return this.action;
475    }
476    
477    /**
478     * Adds the action just setup by the user to the list of actions for the rule
479     *
480     * @return The outcome
481     */

482    public String JavaDoc addAction()
483    {
484       String JavaDoc summary = buildActionSummary(this.currentActionProperties);
485       
486       if (summary != null)
487       {
488          this.currentActionProperties.put(PROP_ACTION_SUMMARY, summary);
489       }
490       
491       if (this.editingAction)
492       {
493          this.action = null;
494       }
495       else
496       {
497          this.allActionsProperties.add(this.currentActionProperties);
498       }
499       
500       // re-display the actions step
501
return "action";
502    }
503    
504    /**
505     * Removes the requested action from the list
506     *
507     * @return The outcome
508     */

509    public String JavaDoc removeAction()
510    {
511       // use the built in JSF support for retrieving the object for the
512
// row that was clicked by the user
513
Map JavaDoc actionToRemove = (Map JavaDoc)this.allActionsDataModel.getRowData();
514       this.allActionsProperties.remove(actionToRemove);
515       
516       // reset the action drop down
517
this.action = null;
518       
519       // return no outcome to refresh page
520
return null;
521    }
522    
523    /**
524     * Cancels the addition of the action
525     *
526     * @return The outcome
527     */

528    public String JavaDoc cancelAddAction()
529    {
530       if (this.editingAction)
531       {
532          this.condition = null;
533       }
534       else
535       {
536          this.currentActionProperties.clear();
537       }
538       
539       return "action";
540    }
541    
542    /**
543     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardDescription()
544     */

545    public String JavaDoc getWizardDescription()
546    {
547       if (this.editMode)
548       {
549          return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_EDIT_ID);
550       }
551       else
552       {
553          return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_DESC_ID);
554       }
555    }
556
557    /**
558     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getWizardTitle()
559     */

560    public String JavaDoc getWizardTitle()
561    {
562       if (this.editMode)
563       {
564          return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_EDIT_ID);
565       }
566       else
567       {
568          return Application.getMessage(FacesContext.getCurrentInstance(), WIZARD_TITLE_ID);
569       }
570    }
571    
572    /**
573     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepDescription()
574     */

575    public String JavaDoc getStepDescription()
576    {
577       String JavaDoc stepDesc = null;
578       
579       switch (this.currentStep)
580       {
581          case 4:
582          {
583             stepDesc = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_DESCRIPTION_ID);
584             break;
585          }
586          default:
587          {
588             stepDesc = "";
589          }
590       }
591       
592       return stepDesc;
593    }
594
595    /**
596     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepTitle()
597     */

598    public String JavaDoc getStepTitle()
599    {
600       String JavaDoc stepTitle = null;
601       
602       switch (this.currentStep)
603       {
604          case 1:
605          {
606             stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP1_TITLE_ID);
607             break;
608          }
609          case 2:
610          {
611             stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP2_TITLE_ID);
612             break;
613          }
614          case 3:
615          {
616             stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), STEP3_TITLE_ID);
617             break;
618          }
619          case 4:
620          {
621             stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), SUMMARY_TITLE_ID);
622             break;
623          }
624          default:
625          {
626             stepTitle = "";
627          }
628       }
629       
630       return stepTitle;
631    }
632    
633    /**
634     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#getStepInstructions()
635     */

636    public String JavaDoc getStepInstructions()
637    {
638       String JavaDoc stepInstruction = null;
639       
640       switch (this.currentStep)
641       {
642          case 4:
643          {
644             if (this.editMode)
645             {
646                stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), FINISH_INSTRUCTION_EDIT_ID);
647             }
648             else
649             {
650                stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), FINISH_INSTRUCTION_ID);
651             }
652             break;
653          }
654          default:
655          {
656             stepInstruction = Application.getMessage(FacesContext.getCurrentInstance(), DEFAULT_INSTRUCTION_ID);
657          }
658       }
659       
660       return stepInstruction;
661    }
662    
663    /**
664     * Initialises the wizard
665     */

666    public void init()
667    {
668       super.init();
669       
670       this.title = null;
671       this.description = null;
672       this.type = "inbound";
673       this.condition = null;
674       this.action = null;
675       this.applyToSubSpaces = false;
676       this.runInBackground = false;
677       this.conditions = null;
678       this.conditionDescriptions = null;
679       
680       this.allConditionsProperties = new ArrayList JavaDoc<Map JavaDoc<String JavaDoc, Serializable JavaDoc>>();
681       this.allActionsProperties = new ArrayList JavaDoc<Map JavaDoc<String JavaDoc, Serializable JavaDoc>>();
682       
683       this.isFinished = false;
684    }
685    
686    /**
687     * Sets the context of the rule up before performing the
688     * standard wizard editing steps
689     *
690     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#startWizardForEdit(javax.faces.event.ActionEvent)
691     */

692    public void startWizardForEdit(ActionEvent event)
693    {
694       // setup context for rule to be edited
695
this.rulesBean.setupRuleAction(event);
696       
697       // perform the usual edit processing
698
super.startWizardForEdit(event);
699    }
700
701    /**
702     * Populates the values of the backing bean ready for editing the rule
703     *
704     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#populate()
705     */

706    public void populate()
707    {
708       // get hold of the current rule details
709
Rule rule = this.rulesBean.getCurrentRule();
710       
711       if (rule == null)
712       {
713          throw new AlfrescoRuntimeException("Failed to locate the current rule");
714       }
715       
716       // populate the bean with current values
717
this.type = rule.getRuleTypeName();
718       this.title = rule.getTitle();
719       this.description = rule.getDescription();
720       this.applyToSubSpaces = rule.isAppliedToChildren();
721       this.runInBackground = rule.getExecuteAsychronously();
722       
723       // populate the conditions list with maps of properties representing each condition
724
List JavaDoc<ActionCondition> conditions = rule.getActionConditions();
725       for (ActionCondition condition : conditions)
726       {
727          Map JavaDoc<String JavaDoc, Serializable JavaDoc> params = populateCondition(condition);
728          this.allConditionsProperties.add(params);
729       }
730       
731       List JavaDoc<Action> actions = rule.getActions();
732       for (Action action : actions)
733       {
734          // use the base class version of populateActionFromProperties(),
735
// but for this we need to setup the currentActionProperties and
736
// action variables
737
this.currentActionProperties = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>(3);
738          this.action = action.getActionDefinitionName();
739          populateActionFromProperties(action.getParameterValues());
740          
741          // also add the name and summary
742
this.currentActionProperties.put(PROP_ACTION_NAME, this.action);
743          // generate the summary
744
this.currentActionProperties.put(PROP_ACTION_SUMMARY,
745                buildActionSummary(this.currentActionProperties));
746          
747          // add the populated currentActionProperties to the list
748
this.allActionsProperties.add(this.currentActionProperties);
749       }
750       
751       // reset the current action
752
this.action = null;
753    }
754
755    /**
756     * @return Returns the summary data for the wizard.
757     */

758    public String JavaDoc getSummary()
759    {
760       // create the summary using all the conditions
761
StringBuilder JavaDoc conditionsSummary = new StringBuilder JavaDoc();
762       for (Map JavaDoc<String JavaDoc, Serializable JavaDoc> props : this.allConditionsProperties)
763       {
764          conditionsSummary.append(props.get(PROP_CONDITION_SUMMARY));
765          conditionsSummary.append("<br/>");
766       }
767       
768       // create the summary using all the actions
769
StringBuilder JavaDoc actionsSummary = new StringBuilder JavaDoc();
770       for (Map JavaDoc<String JavaDoc, Serializable JavaDoc> props : this.allActionsProperties)
771       {
772          actionsSummary.append(props.get(PROP_ACTION_SUMMARY));
773          actionsSummary.append("<br/>");
774       }
775       
776       ResourceBundle JavaDoc bundle = Application.getBundle(FacesContext.getCurrentInstance());
777       
778       String JavaDoc backgroundYesNo = this.runInBackground ? bundle.getString("yes") : bundle.getString("no");
779       String JavaDoc subSpacesYesNo = this.applyToSubSpaces ? bundle.getString("yes") : bundle.getString("no");
780       
781       return buildSummary(
782             new String JavaDoc[] {bundle.getString("rule_type"), bundle.getString("name"), bundle.getString("description"),
783                           bundle.getString("apply_to_sub_spaces"), bundle.getString("run_in_background"),
784                           bundle.getString("conditions"), bundle.getString("actions")},
785             new String JavaDoc[] {this.type, this.title, this.description, subSpacesYesNo, backgroundYesNo,
786                           conditionsSummary.toString(), actionsSummary.toString()});
787    }
788    
789    /**
790     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#back()
791     */

792    public String JavaDoc back()
793    {
794       // reset the drop downs when back is clicked
795
this.action = null;
796       this.condition = null;
797       
798       return super.back();
799    }
800
801    /**
802     * @see org.alfresco.web.bean.wizard.AbstractWizardBean#next()
803     */

804    public String JavaDoc next()
805    {
806       // reset the drop downs when next is clicked
807
this.action = null;
808       this.condition = null;
809       
810       return super.next();
811    }
812
813    /**
814     * @return Returns the description.
815     */

816    public String JavaDoc getDescription()
817    {
818       return description;
819    }
820    
821    /**
822     * @param description The description to set.
823     */

824    public void setDescription(String JavaDoc description)
825    {
826       this.description = description;
827    }
828
829    /**
830     * @return Returns the title.
831     */

832    public String JavaDoc getTitle()
833    {
834       return title;
835    }
836    
837    /**
838     * @param title The title to set.
839     */

840    public void setTitle(String JavaDoc title)
841    {
842       this.title = title;
843    }
844    
845    /**
846     * @return Returns whether the rule should run in the background
847     */

848    public boolean getRunInBackground()
849    {
850       return this.runInBackground;
851    }
852
853    /**
854     * @param runInBackground Sets whether the rule should run in the background
855     */

856    public void setRunInBackground(boolean runInBackground)
857    {
858       this.runInBackground = runInBackground;
859    }
860
861    /**
862     * @return Returns whether the rule should be applied to sub spaces i.e. if it gets inherited
863     */

864    public boolean getApplyToSubSpaces()
865    {
866       return this.applyToSubSpaces;
867    }
868
869    /**
870     * @param applyToSubSpaces Sets whether the rule will get applied to sub spaces
871     */

872    public void setApplyToSubSpaces(boolean applyToSubSpaces)
873    {
874       this.applyToSubSpaces = applyToSubSpaces;
875    }
876
877    /**
878     * @return Returns the type.
879     */

880    public String JavaDoc getType()
881    {
882       return type;
883    }
884
885    /**
886     * @param type The type to set
887     */

888    public void setType(String JavaDoc type)
889    {
890       this.type = type;
891    }
892    
893    /**
894     * @return Returns the selected condition
895     */

896    public String JavaDoc getCondition()
897    {
898       return this.condition;
899    }
900
901    /**
902     * @param condition Sets the selected condition
903     */

904    public void setCondition(String JavaDoc condition)
905    {
906       this.condition = condition;
907    }
908
909    /**
910     * @param ruleService Sets the rule service to use
911     */

912    public void setRuleService(RuleService ruleService)
913    {
914       this.ruleService = ruleService;
915    }
916    
917    /**
918     * @param mimetypeService Sets the mimetype service to use
919     */

920    public void setMimetypeService(MimetypeService mimetypeService)
921    {
922       this.mimetypeService = mimetypeService;
923    }
924    
925    /**
926     * Sets the RulesBean instance to be used by the wizard in edit mode
927     *
928     * @param rulesBean The RulesBean
929     */

930    public void setRulesBean(RulesBean rulesBean)
931    {
932       this.rulesBean = rulesBean;
933    }
934
935    /**
936     * @return Returns the list of selectable actions
937     */

938    public List JavaDoc<SelectItem> getActions()
939    {
940       if (this.actions == null)
941       {
942          super.getActions();
943          
944          // add the "Select an action" entry at the beginning of the list
945
this.actions.add(0, new SelectItem("null",
946                Application.getMessage(FacesContext.getCurrentInstance(), "select_an_action")));
947       }
948       
949       return this.actions;
950    }
951    
952    /**
953     * Returns a list of the types available in the repository
954     *
955     * @return List of SelectItem objects
956     */

957    public List JavaDoc<SelectItem> getModelTypes()
958    {
959       if (this.modelTypes == null)
960       {
961          ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance());
962          Config wizardCfg = svc.getConfig("Action Wizards");
963          if (wizardCfg != null)
964          {
965             ConfigElement typesCfg = wizardCfg.getConfigElement("types");
966             if (typesCfg != null)
967             {
968                FacesContext context = FacesContext.getCurrentInstance();
969                this.modelTypes = new ArrayList JavaDoc<SelectItem>();
970                for (ConfigElement child : typesCfg.getChildren())
971                {
972                   QName idQName = Repository.resolveToQName(child.getAttribute("name"));
973
974                   // look for a client localized string
975
String JavaDoc label = null;
976                   String JavaDoc msgId = child.getAttribute("displayLabelId");
977                   if (msgId != null)
978                   {
979                      label = Application.getMessage(context, msgId);
980                   }
981                   
982                   // if there wasn't an externalized string look for one in the config
983
if (label == null)
984                   {
985                      label = child.getAttribute("displayLabel");
986                   }
987
988                   // if there wasn't a client based label try and get it from the dictionary
989
if (label == null)
990                   {
991                      TypeDefinition typeDef = this.dictionaryService.getType(idQName);
992                      if (typeDef != null)
993                      {
994                         label = typeDef.getTitle();
995                      }
996                      else
997                      {
998                         label = idQName.getLocalName();
999                      }
1000                  }
1001                  
1002                  this.modelTypes.add(new SelectItem(idQName.toString(), label));
1003               }
1004               
1005               // make sure the list is sorted by the label
1006
QuickSort sorter = new QuickSort(this.modelTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
1007               sorter.sort();
1008            }
1009            else
1010            {
1011               logger.warn("Could not find types configuration element");
1012            }
1013         }
1014         else
1015         {
1016            logger.warn("Could not find Action Wizards configuration section");
1017         }
1018      }
1019      
1020      return this.modelTypes;
1021   }
1022   
1023   /**
1024    * Returns a list of mime types in the system
1025    *
1026    * @return List of mime types
1027    */

1028   public List JavaDoc<SelectItem> getMimeTypes()
1029   {
1030       if (this.mimeTypes == null)
1031       {
1032           this.mimeTypes = new ArrayList JavaDoc<SelectItem>(50);
1033           
1034           Map JavaDoc<String JavaDoc, String JavaDoc> mimeTypes = mimetypeService.getDisplaysByMimetype();
1035           for (String JavaDoc mimeType : mimeTypes.keySet())
1036           {
1037              this.mimeTypes.add(new SelectItem(mimeType, mimeTypes.get(mimeType)));
1038           }
1039           
1040           // make sure the list is sorted by the values
1041
QuickSort sorter = new QuickSort(this.mimeTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
1042           sorter.sort();
1043       }
1044       
1045       return this.mimeTypes;
1046   }
1047   
1048   /**
1049    * @return Returns the list of selectable conditions
1050    */

1051   public List JavaDoc<SelectItem> getConditions()
1052   {
1053      if (this.conditions == null)
1054      {
1055         List JavaDoc<ActionConditionDefinition> ruleConditions = this.actionService.getActionConditionDefinitions();
1056         this.conditions = new ArrayList JavaDoc<SelectItem>(ruleConditions.size());
1057         for (ActionConditionDefinition ruleConditionDef : ruleConditions)
1058         {
1059            // add to SelectItem list
1060
this.conditions.add(new SelectItem(ruleConditionDef.getName(),
1061                  ruleConditionDef.getTitle()));
1062         }
1063         
1064         // make sure the list is sorted by the label
1065
QuickSort sorter = new QuickSort(this.conditions, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
1066         sorter.sort();
1067         
1068         // add the "Select a condition" entry at the beginning of the list
1069
this.conditions.add(0, new SelectItem("null",
1070               Application.getMessage(FacesContext.getCurrentInstance(), "select_a_condition")));
1071      }
1072      
1073      return this.conditions;
1074   }
1075   
1076   /**
1077    * @return Returns a map of all the condition descriptions
1078    */

1079   public Map JavaDoc<String JavaDoc, String JavaDoc> getConditionDescriptions()
1080   {
1081      if (this.conditionDescriptions == null)
1082      {
1083         List JavaDoc<ActionConditionDefinition> ruleConditions = this.actionService.getActionConditionDefinitions();
1084         this.conditionDescriptions = new HashMap JavaDoc<String JavaDoc, String JavaDoc>(ruleConditions.size());
1085         for (ActionConditionDefinition ruleConditionDef : ruleConditions)
1086         {
1087            this.conditionDescriptions.put(ruleConditionDef.getName(),
1088                  ruleConditionDef.getDescription());
1089         }
1090      }
1091      
1092      return this.conditionDescriptions;
1093   }
1094
1095   /**
1096    * @return Returns the types of rules that can be defined
1097    */

1098   public List JavaDoc<SelectItem> getTypes()
1099   {
1100      if (this.types == null)
1101      {
1102         List JavaDoc<RuleType> ruleTypes = this.ruleService.getRuleTypes();
1103         this.types = new ArrayList JavaDoc<SelectItem>(ruleTypes.size());
1104         for (RuleType ruleType : ruleTypes)
1105         {
1106            this.types.add(new SelectItem(ruleType.getName(), ruleType.getDisplayLabel()));
1107         }
1108      }
1109      
1110      return this.types;
1111   }
1112   
1113   /**
1114    * @return Gets the condition settings
1115    */

1116   public Map JavaDoc<String JavaDoc, Serializable JavaDoc> getConditionProperties()
1117   {
1118      return this.currentConditionProperties;
1119   }
1120   
1121   /**
1122    * @see org.alfresco.web.bean.wizard.AbstractWizardBean#determineOutcomeForStep(int)
1123    */

1124   protected String JavaDoc determineOutcomeForStep(int step)
1125   {
1126      String JavaDoc outcome = null;
1127      
1128      switch(step)
1129      {
1130         case 1:
1131         {
1132            outcome = "details";
1133            break;
1134         }
1135         case 2:
1136         {
1137            outcome = "condition";
1138            break;
1139         }
1140         case 3:
1141         {
1142            outcome = "action";
1143            break;
1144         }
1145         case 4:
1146         {
1147            outcome = "summary";
1148            break;
1149         }
1150         default:
1151         {
1152            outcome = CANCEL_OUTCOME;
1153         }
1154      }
1155      
1156      return outcome;
1157   }
1158   
1159   /**
1160    * Builds the Map of properties for the given condition in the format the repo is expecting
1161    *
1162    * @param params The Map of properties built from the UI
1163    * @return The Map the repo is expecting
1164    */

1165   protected Map JavaDoc<String JavaDoc, Serializable JavaDoc> buildConditionParams(Map JavaDoc<String JavaDoc, Serializable JavaDoc> params)
1166   {
1167      Map JavaDoc<String JavaDoc, Serializable JavaDoc> repoParams = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>(params.size());
1168      
1169      String JavaDoc condName = (String JavaDoc)params.get(PROP_CONDITION_NAME);
1170      if (condName.equals(ComparePropertyValueEvaluator.NAME))
1171      {
1172         repoParams.put(ComparePropertyValueEvaluator.PARAM_VALUE, params.get(PROP_CONTAINS_TEXT));
1173      }
1174      else if (condName.equals(InCategoryEvaluator.NAME))
1175      {
1176         // put the selected category in the condition params
1177
repoParams.put(InCategoryEvaluator.PARAM_CATEGORY_VALUE, params.get(PROP_CATEGORY));
1178         
1179         // add the classifiable aspect
1180
repoParams.put(InCategoryEvaluator.PARAM_CATEGORY_ASPECT, ContentModel.ASPECT_GEN_CLASSIFIABLE);
1181      }
1182      else if (condName.equals(IsSubTypeEvaluator.NAME))
1183      {
1184         // add the model type
1185
repoParams.put(IsSubTypeEvaluator.PARAM_TYPE, QName.createQName((String JavaDoc)params.get(PROP_MODEL_TYPE)));
1186      }
1187      else if (condName.equals(HasAspectEvaluator.NAME))
1188      {
1189         // add the aspect
1190
repoParams.put(HasAspectEvaluator.PARAM_ASPECT, QName.createQName((String JavaDoc)params.get(PROP_ASPECT)));
1191      }
1192      else if (condName.equals(CompareMimeTypeEvaluator.NAME))
1193      {
1194          repoParams.put(CompareMimeTypeEvaluator.PARAM_VALUE, params.get(PROP_MIMETYPE));
1195      }
1196      
1197      return repoParams;
1198   }
1199   
1200   /**
1201    * Populates a Map of properties the wizard is expecting for the given condition
1202    *
1203    * @param condition The condition to build the map for
1204    */

1205   protected Map JavaDoc<String JavaDoc, Serializable JavaDoc> populateCondition(ActionCondition condition)
1206   {
1207      // find out what the condition is called
1208
Map JavaDoc<String JavaDoc, Serializable JavaDoc> condProps = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>(3);
1209      String JavaDoc name = condition.getActionConditionDefinitionName();
1210      condProps.put(PROP_CONDITION_NAME, name);
1211      
1212      // add the appropriate properties
1213
Map JavaDoc<String JavaDoc, Serializable JavaDoc> repoCondProps = condition.getParameterValues();
1214      if (name.equals(ComparePropertyValueEvaluator.NAME))
1215      {
1216         condProps.put(PROP_CONTAINS_TEXT, (String JavaDoc)repoCondProps.get(ComparePropertyValueEvaluator.PARAM_VALUE));
1217      }
1218      else if (name.equals(InCategoryEvaluator.NAME))
1219      {
1220         NodeRef catNodeRef = (NodeRef)repoCondProps.get(InCategoryEvaluator.PARAM_CATEGORY_VALUE);
1221         condProps.put(PROP_CATEGORY, catNodeRef);
1222      }
1223      else if (name.equals(IsSubTypeEvaluator.NAME))
1224      {
1225         condProps.put(PROP_MODEL_TYPE, ((QName)repoCondProps.get(IsSubTypeEvaluator.PARAM_TYPE)).toString());
1226      }
1227      else if (name.equals(HasAspectEvaluator.NAME))
1228      {
1229         condProps.put(PROP_ASPECT, ((QName)repoCondProps.get(HasAspectEvaluator.PARAM_ASPECT)).toString());
1230      }
1231      else if (name.equals(CompareMimeTypeEvaluator.NAME))
1232      {
1233          condProps.put(PROP_MIMETYPE, repoCondProps.get(CompareMimeTypeEvaluator.PARAM_VALUE));
1234      }
1235      
1236      // specify whether the condition result should be inverted
1237
condProps.put(PROP_CONDITION_NOT, Boolean.valueOf(condition.getInvertCondition()));
1238      
1239      // generate the summary
1240
condProps.put(PROP_CONDITION_SUMMARY, buildConditionSummary(condProps));
1241         
1242      return condProps;
1243   }
1244   
1245   /**
1246    * Returns a summary string for the given condition parameters
1247    *
1248    * @return The summary or null if a summary could not be built
1249    */

1250   protected String JavaDoc buildConditionSummary(Map JavaDoc<String JavaDoc, Serializable JavaDoc> props)
1251   {
1252      String JavaDoc summaryResult = null;
1253      
1254      String JavaDoc condName = (String JavaDoc)props.get(PROP_CONDITION_NAME);
1255      if (condName != null)
1256      {
1257         StringBuilder JavaDoc summary = new StringBuilder JavaDoc();
1258         
1259         String JavaDoc msgId = "condition_" + condName.replace('-', '_');
1260         
1261         // JSF is putting the boolean into the map as a Boolean object so we
1262
// need to handle that - adding a converter doesn't seem to help!
1263
Boolean JavaDoc not = (Boolean JavaDoc)props.get(PROP_CONDITION_NOT);
1264         if (not.booleanValue())
1265         {
1266            msgId = msgId + "_not";
1267         }
1268         
1269         if (logger.isDebugEnabled())
1270            logger.debug("Looking up condition summary string: " + msgId);
1271         
1272         summary.append(Application.getMessage(FacesContext.getCurrentInstance(), msgId));
1273         summary.append(" ");
1274         
1275         // define a summary to be added for each condition
1276
if ("in-category".equals(condName))
1277         {
1278            String JavaDoc name = Repository.getNameForNode(this.nodeService, (NodeRef)props.get(PROP_CATEGORY));
1279            summary.append("'").append(name).append("'");
1280         }
1281         else if ("compare-property-value".equals(condName))
1282         {
1283            summary.append("'");
1284            summary.append(props.get(PROP_CONTAINS_TEXT));
1285            summary.append("'");
1286         }
1287         else if ("is-subtype".equals(condName))
1288         {
1289            // find the label used by looking through the SelectItem list
1290
String JavaDoc typeName = (String JavaDoc)props.get(PROP_MODEL_TYPE);
1291            for (SelectItem item : this.getModelTypes())
1292            {
1293               if (item.getValue().equals(typeName))
1294               {
1295                  summary.append("'").append(item.getLabel()).append("'");
1296                  break;
1297               }
1298            }
1299         }
1300         else if ("has-aspect".equals(condName))
1301         {
1302            // find the label used by looking through the SelectItem list
1303
String JavaDoc aspectName = (String JavaDoc)props.get(PROP_ASPECT);
1304            for (SelectItem item : this.getAspects())
1305            {
1306               if (item.getValue().equals(aspectName))
1307               {
1308                  summary.append("'").append(item.getLabel()).append("'");
1309                  break;
1310               }
1311            }
1312         }
1313         else if (CompareMimeTypeEvaluator.NAME.equals(condName))
1314         {
1315            String JavaDoc mimetype = (String JavaDoc)props.get(PROP_MIMETYPE);
1316            for (SelectItem item : this.getMimeTypes())
1317            {
1318               if (item.getValue().equals(mimetype))
1319               {
1320                  summary.append("'").append(item.getLabel()).append("'");
1321                  break;
1322               }
1323            }
1324         }
1325         
1326         summaryResult = summary.toString();
1327      }
1328      
1329      return summaryResult;
1330   }
1331   
1332   /**
1333    * Returns a summary string for the given action parameters
1334    *
1335    * @return The summary or null if a summary could not be built
1336    */

1337   protected String JavaDoc buildActionSummary(Map JavaDoc<String JavaDoc, Serializable JavaDoc> props)
1338   {
1339      String JavaDoc summaryResult = null;
1340      
1341      String JavaDoc actionName = (String JavaDoc)this.currentActionProperties.get(PROP_ACTION_NAME);
1342      if (actionName != null)
1343      {
1344         StringBuilder JavaDoc summary = new StringBuilder JavaDoc();
1345         summary.append(Application.getMessage(FacesContext.getCurrentInstance(),
1346               "action_" + actionName.replace('-', '_')));
1347         summary.append(" ");
1348         
1349         // define a summary to be added for each action
1350
if ("add-features".equals(actionName))
1351         {
1352            String JavaDoc aspect = (String JavaDoc)this.currentActionProperties.get(PROP_ASPECT);
1353            
1354            // find the label used by looking through the SelectItem list
1355
for (SelectItem item : this.getAspects())
1356            {
1357               if (item.getValue().equals(aspect))
1358               {
1359                  summary.append("'").append(item.getLabel()).append("'");
1360                  break;
1361               }
1362            }
1363         }
1364         else if ("simple-workflow".equals(actionName))
1365         {
1366            // just leave the summary as the title for now
1367
String JavaDoc approveStepName = (String JavaDoc)this.currentActionProperties.get(PROP_APPROVE_STEP_NAME);
1368            String JavaDoc approveAction = (String JavaDoc)this.currentActionProperties.get(PROP_APPROVE_ACTION);
1369            NodeRef approveFolder = (NodeRef)this.currentActionProperties.get(PROP_APPROVE_FOLDER);
1370            String JavaDoc approveFolderName = Repository.getNameForNode(this.nodeService, approveFolder);
1371            String JavaDoc approveMsg = MessageFormat.format(summary.toString(),
1372                  new Object JavaDoc[] {Application.getMessage(FacesContext.getCurrentInstance(), approveAction),
1373                                approveFolderName, approveStepName});
1374            
1375            String JavaDoc rejectStep = (String JavaDoc)this.currentActionProperties.get(PROP_REJECT_STEP_PRESENT);
1376            
1377            String JavaDoc rejectMsg = null;
1378            if (rejectStep != null && "yes".equals(rejectStep))
1379            {
1380               String JavaDoc rejectStepName = (String JavaDoc)this.currentActionProperties.get(PROP_REJECT_STEP_NAME);
1381               String JavaDoc rejectAction = (String JavaDoc)this.currentActionProperties.get(PROP_REJECT_ACTION);
1382               NodeRef rejectFolder = (NodeRef)this.currentActionProperties.get(PROP_REJECT_FOLDER);
1383               String JavaDoc rejectFolderName = Repository.getNameForNode(this.nodeService, rejectFolder);
1384               rejectMsg = MessageFormat.format(summary.toString(),
1385                  new Object JavaDoc[] {Application.getMessage(FacesContext.getCurrentInstance(), rejectAction),
1386                                rejectFolderName, rejectStepName});
1387            }
1388            
1389            summary = new StringBuilder JavaDoc(approveMsg);
1390            if (rejectMsg != null)
1391            {
1392               summary.append(" ");
1393               summary.append(rejectMsg);
1394            }
1395         }
1396         else if ("link-category".equals(actionName))
1397         {
1398            NodeRef cat = (NodeRef)this.currentActionProperties.get(PROP_CATEGORY);
1399            String JavaDoc name = Repository.getNameForNode(this.nodeService, cat);
1400            summary.append("'").append(name).append("'");
1401         }
1402         else if ("transform".equals(actionName))
1403         {
1404            NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
1405            String JavaDoc name = Repository.getNameForNode(this.nodeService, space);
1406            String JavaDoc transformer = (String JavaDoc)this.currentActionProperties.get(PROP_TRANSFORMER);
1407            
1408            // find the label used by looking through the SelectItem list
1409
for (SelectItem item : this.getTransformers())
1410            {
1411               if (item.getValue().equals(transformer))
1412               {
1413                  transformer = item.getLabel();
1414                  break;
1415               }
1416            }
1417            
1418            // recreate the summary object as it contains parameters
1419
String JavaDoc msg = MessageFormat.format(summary.toString(), new Object JavaDoc[] {name, transformer});
1420            summary = new StringBuilder JavaDoc(msg);
1421         }
1422         else if ("transform-image".equals(actionName))
1423         {
1424            NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
1425            String JavaDoc name = Repository.getNameForNode(this.nodeService, space);
1426            String JavaDoc transformer = (String JavaDoc)this.currentActionProperties.get(PROP_IMAGE_TRANSFORMER);
1427            String JavaDoc option = (String JavaDoc)this.currentActionProperties.get(PROP_TRANSFORM_OPTIONS);
1428            
1429            // find the label used by looking through the SelectItem list
1430
for (SelectItem item : this.getImageTransformers())
1431            {
1432               if (item.getValue().equals(transformer))
1433               {
1434                  transformer = item.getLabel();
1435                  break;
1436               }
1437            }
1438            
1439            // recreate the summary object as it contains parameters
1440
String JavaDoc msg = MessageFormat.format(summary.toString(), new Object JavaDoc[] {name, transformer, option});
1441            summary = new StringBuilder JavaDoc(msg);
1442         }
1443         else if ("copy".equals(actionName) || "move".equals(actionName) || "check-out".equals(actionName))
1444         {
1445            NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
1446            String JavaDoc spaceName = Repository.getNameForNode(this.nodeService, space);
1447            summary.append("'").append(spaceName).append("'");
1448         }
1449         else if ("mail".equals(actionName))
1450         {
1451            String JavaDoc address = (String JavaDoc)this.currentActionProperties.get(PROP_TO);
1452            summary.append("'").append(address).append("'");
1453         }
1454         else if ("check-in".equals(actionName))
1455         {
1456            String JavaDoc comment = (String JavaDoc)this.currentActionProperties.get(PROP_CHECKIN_DESC);
1457            Boolean JavaDoc minorChange = (Boolean JavaDoc)this.currentActionProperties.get(PROP_CHECKIN_MINOR);
1458            String JavaDoc change = null;
1459            if (minorChange != null && minorChange.booleanValue())
1460            {
1461               change = Application.getMessage(FacesContext.getCurrentInstance(), "minor_change");
1462            }
1463            else
1464            {
1465               change = Application.getMessage(FacesContext.getCurrentInstance(), "major_change");
1466            }
1467            
1468            // recreate the summary object as it contains parameters
1469
String JavaDoc msg = MessageFormat.format(summary.toString(), new Object JavaDoc[] {change, comment});
1470            summary = new StringBuilder JavaDoc(msg);
1471         }
1472         else if ("import".equals(actionName))
1473         {
1474            NodeRef space = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
1475            String JavaDoc spaceName = Repository.getNameForNode(this.nodeService, space);
1476            summary.append("'").append(spaceName).append("'");
1477         }
1478         else if (SpecialiseTypeActionExecuter.NAME.equals(actionName) == true)
1479         {
1480             String JavaDoc label = null;
1481             String JavaDoc objectType = (String JavaDoc)this.currentActionProperties.get(PROP_OBJECT_TYPE);
1482             for (SelectItem item : getObjectTypes())
1483             {
1484                if (item.getValue().equals(objectType) == true)
1485                {
1486                    label = item.getLabel();
1487                    break;
1488                }
1489             }
1490             
1491             summary.append("'").append(label).append("'");
1492         }
1493
1494         summaryResult = summary.toString();
1495      }
1496      
1497      return summaryResult;
1498   }
1499}
1500
Popular Tags