1 5 package com.opensymphony.workflow.util; 6 7 import com.opensymphony.module.propertyset.PropertySet; 8 9 import com.opensymphony.workflow.*; 10 import com.opensymphony.workflow.spi.Step; 11 import com.opensymphony.workflow.spi.WorkflowEntry; 12 import com.opensymphony.workflow.spi.WorkflowStore; 13 14 import java.util.Iterator ; 15 import java.util.List ; 16 import java.util.Map ; 17 18 19 27 public class AllowOwnerOfStepCondition implements Condition { 28 30 public boolean passesCondition(Map transientVars, Map args, PropertySet ps) throws WorkflowException { 31 String stepIdString = (String ) args.get("stepId"); 32 WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry"); 33 WorkflowContext context = (WorkflowContext) transientVars.get("context"); 34 35 if (stepIdString == null) { 36 throw new WorkflowException("This condition expects a stepId!"); 37 } 38 39 int stepId = 0; 40 41 if (stepIdString != null) { 42 try { 43 stepId = Integer.parseInt(stepIdString); 44 } catch (Exception ex) { 45 throw new WorkflowException("This condition expects a stepId > 0!"); 46 } 47 } 48 49 WorkflowStore store = (WorkflowStore) transientVars.get("store"); 50 List historySteps = store.findHistorySteps(entry.getId()); 51 52 for (Iterator iterator = historySteps.iterator(); iterator.hasNext();) { 53 Step step = (Step) iterator.next(); 54 55 if (stepId == (step.getStepId())) { 56 if (((step.getOwner() != null) && (context.getCaller() != null)) && context.getCaller().equals(step.getOwner())) { 58 return true; 59 } 60 } 61 } 62 63 return false; 64 } 65 } 66 | Popular Tags |