/** * Factory method that creates a new decision state, a state where a flow routing decision is made. This method is * an atomic operation that returns a fully initialized state. It encapsulates the selection of the decision state * implementation as well as the state assembly. * @param id the identifier to assign to the state, must be unique to its owning flow (required) * @param flow the flow that will own (contain) this state (required) * @param entryActions any state entry actions; may be null * @param transitions any transitions (paths) out of this state * @param exceptionHandlers any exception handlers; may be null * @param exitActions any state exit actions; may be null * @param attributes attributes to assign to the State, which may also be used to affect state construction; may be * null * @return the fully initialized decision state instance */ public State createDecisionState(String id, Flow flow, Action[] entryActions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap<?> attributes) { DecisionState decisionState = new DecisionState(flow, id); configureCommonProperties(decisionState, entryActions, transitions, exceptionHandlers, exitActions, attributes); return decisionState; }
/** * Specialization of State's <code>doEnter</code> template method that executes behavior specific to this state type * in polymorphic fashion. * <p> * Simply looks up the first transition that matches the state of the context and executes it. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @throws FlowExecutionException if an exception occurs in this state */ protected void doEnter(RequestControlContext context) throws FlowExecutionException { getRequiredTransition(context).execute(this, context); } }
public void testCannotDecide() { Flow flow = new Flow("flow"); DecisionState state = new DecisionState(flow, "decisionState"); state.getTransitionSet().add(new Transition(new MockTransitionCriteria("foo"), to("invalid"))); state.getTransitionSet().add(new Transition(new MockTransitionCriteria("bar"), to("invalid"))); MockRequestControlContext context = new MockRequestControlContext(flow); context.setCurrentEvent(new Event(this, "bogus")); try { state.enter(context); fail("Expected no matching"); } catch (NoMatchingTransitionException e) { } }
@Override public DecisionState createDecisionState(final Flow flow, final String id, final String testExpression, final String thenStateId, final String elseStateId) { if (containsFlowState(flow, id)) { LOGGER.trace("Flow [{}] already contains a definition for state id [{}]", flow.getId(), id); return getTransitionableState(flow, id, DecisionState.class); } val decisionState = new DecisionState(flow, id); val expression = createExpression(testExpression, Boolean.class); val thenTransition = createTransition(expression, thenStateId); decisionState.getTransitionSet().add(thenTransition); val elseTransition = createTransition("*", elseStateId); decisionState.getTransitionSet().add(elseTransition); return decisionState; }
/** * Add on entry action to service check state. * * @param flow the flow */ protected void addOnEntryActionToServiceCheckState(final Flow flow) { final DecisionState state = (DecisionState) flow.getState(STATE_DEFINITION_ID_SERVICE_CHECK); final EvaluateAction action = createEvaluateAction("removeHostnameServiceInContextAction"); state.getEntryActionList().add(action); LOGGER.debug("Set on-entry action for decision state {}", state.getId()); } /**
/** * Create service unauthorized check decision state. * * @param flow the flow */ protected void createServiceUnauthorizedCheckDecisionState(final Flow flow) { val decision = createDecisionState(flow, CasWebflowConstants.STATE_ID_SERVICE_UNAUTHZ_CHECK, "flowScope.unauthorizedRedirectUrl != null", CasWebflowConstants.STATE_ID_VIEW_REDIR_UNAUTHZ_URL, CasWebflowConstants.STATE_ID_VIEW_SERVICE_ERROR); decision.getEntryActionList().add(createEvaluateAction("setServiceUnauthorizedRedirectUrlAction")); }
public void testElseDecision() { Flow flow = new Flow("flow"); DecisionState state = new DecisionState(flow, "decisionState"); state.getTransitionSet().add(new Transition(new MockTransitionCriteria("foo"), to("invalid"))); state.getTransitionSet().add(new Transition(to("target"))); new EndState(flow, "target"); MockRequestControlContext context = new MockRequestControlContext(flow); context.setCurrentEvent(new Event(this, "bogus")); state.enter(context); assertFalse(context.getFlowExecutionContext().isActive()); }
/** * Create decision state decision state. * * @param flow the flow * @param id the id * @param testExpression the test expression * @param thenStateId the then state id * @param elseStateId the else state id * @return the decision state */ protected DecisionState createDecisionState(final Flow flow, final String id, final String testExpression, final String thenStateId, final String elseStateId) { final DecisionState decisionState = new DecisionState(flow, id); final Expression expression = createExpression(flow, testExpression, Boolean.class); final Transition thenTransition = createTransition(expression, thenStateId); decisionState.getTransitionSet().add(thenTransition); final Transition elseTransition = createTransition("*", elseStateId); decisionState.getTransitionSet().add(elseTransition); return decisionState; }
realSubmit .getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS).getTargetStateId()) .getEntryActionList().add(createEvaluateAction("flowScope.pswdChangePostLogin=true"));
public void testIfDecision() { Flow flow = new Flow("flow"); DecisionState state = new DecisionState(flow, "decisionState"); state.getTransitionSet().add(new Transition(new MockTransitionCriteria("foo"), to("target"))); new EndState(flow, "target"); MockRequestControlContext context = new MockRequestControlContext(flow); context.setCurrentEvent(new Event(this, "foo")); state.enter(context); assertFalse(context.getFlowExecutionContext().isActive()); }
/** * Factory method that creates a new decision state, a state where a flow routing decision is made. This method is * an atomic operation that returns a fully initialized state. It encapsulates the selection of the decision state * implementation as well as the state assembly. * @param id the identifier to assign to the state, must be unique to its owning flow (required) * @param flow the flow that will own (contain) this state (required) * @param entryActions any state entry actions; may be null * @param transitions any transitions (paths) out of this state * @param exceptionHandlers any exception handlers; may be null * @param exitActions any state exit actions; may be null * @param attributes attributes to assign to the State, which may also be used to affect state construction; may be * null * @return the fully initialized decision state instance * @throws FlowArtifactLookupException an exception occured creating the state */ public State createDecisionState(String id, Flow flow, Action[] entryActions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) throws FlowArtifactLookupException { DecisionState decisionState = new DecisionState(flow, id); configureCommonProperties(decisionState, entryActions, transitions, exceptionHandlers, exitActions, attributes); return decisionState; }
/** * Specialization of State's <code>doEnter</code> template method that executes behavior specific to this state type * in polymorphic fashion. * <p> * Simply looks up the first transition that matches the state of the context and executes it. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @throws FlowExecutionException if an exception occurs in this state */ protected void doEnter(RequestControlContext context) throws FlowExecutionException { getRequiredTransition(context).execute(this, context); } }
/** * Factory method that creates a new decision state, a state where a flow routing decision is made. This method is * an atomic operation that returns a fully initialized state. It encapsulates the selection of the decision state * implementation as well as the state assembly. * @param id the identifier to assign to the state, must be unique to its owning flow (required) * @param flow the flow that will own (contain) this state (required) * @param entryActions any state entry actions; may be null * @param transitions any transitions (paths) out of this state * @param exceptionHandlers any exception handlers; may be null * @param exitActions any state exit actions; may be null * @param attributes attributes to assign to the State, which may also be used to affect state construction; may be * null * @return the fully initialized decision state instance */ public State createDecisionState(String id, Flow flow, Action[] entryActions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap<?> attributes) { DecisionState decisionState = new DecisionState(flow, id); configureCommonProperties(decisionState, entryActions, transitions, exceptionHandlers, exitActions, attributes); return decisionState; }
/** * Specialization of State's <code>doEnter</code> template method that executes behavior specific to this state * type in polymorphic fashion. * <p> * Simply looks up the first transition that matches the state of the context and executes it. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @throws FlowExecutionException if an exception occurs in this state */ protected void doEnter(RequestControlContext context) throws FlowExecutionException { getRequiredTransition(context).execute(this, context); } }
/** * Factory method that creates a new decision state, a state where a flow routing decision is made. This method is * an atomic operation that returns a fully initialized state. It encapsulates the selection of the decision state * implementation as well as the state assembly. * @param id the identifier to assign to the state, must be unique to its owning flow (required) * @param flow the flow that will own (contain) this state (required) * @param entryActions any state entry actions; may be null * @param transitions any transitions (paths) out of this state * @param exceptionHandlers any exception handlers; may be null * @param exitActions any state exit actions; may be null * @param attributes attributes to assign to the State, which may also be used to affect state construction; may be * null * @return the fully initialized decision state instance */ public State createDecisionState(String id, Flow flow, Action[] entryActions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { DecisionState decisionState = new DecisionState(flow, id); configureCommonProperties(decisionState, entryActions, transitions, exceptionHandlers, exitActions, attributes); return decisionState; }
/** * Specialization of State's <code>doEnter</code> template method that executes behaviour specific to this state * type in polymorphic fashion. * <p> * Simply looks up the first transition that matches the state of the context and executes it. * @param context the control context for the currently executing flow, used by this state to manipulate the flow * execution * @return a view selection containing model and view information needed to render the results of the state * execution * @throws FlowExecutionException if an exception occurs in this state */ protected ViewSelection doEnter(RequestControlContext context) throws FlowExecutionException { return getRequiredTransition(context).execute(this, context); } }