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