01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.workflow.util;
06:
07: import com.opensymphony.module.propertyset.PropertySet;
08:
09: import com.opensymphony.workflow.FunctionProvider;
10: import com.opensymphony.workflow.WorkflowException;
11: import com.opensymphony.workflow.spi.Step;
12:
13: import java.util.Collection;
14: import java.util.Map;
15:
16: /**
17: * @author hani Date: Feb 17, 2005 Time: 3:56:57 PM
18: */
19: public class VerifyCurrentSteps implements FunctionProvider {
20: //~ Methods ////////////////////////////////////////////////////////////////
21:
22: public void execute(Map transientVars, Map args, PropertySet ps)
23: throws WorkflowException {
24: Collection currentSteps = (Collection) transientVars
25: .get("currentSteps");
26:
27: if (currentSteps.size() != 1) {
28: throw new WorkflowException(
29: "Expected 1 step to be in currentSteps, instead found "
30: + currentSteps.size());
31: }
32:
33: int expectedId = Integer.parseInt((String) args.get("step.id"));
34: Step step = (Step) currentSteps.iterator().next();
35:
36: if (step.getStepId() != expectedId) {
37: throw new WorkflowException("Expected step id "
38: + expectedId + " in prefunction, instead found id "
39: + step.getStepId());
40: }
41: }
42: }
|