/** * Get a transition in this state for given flow execution request context. Throws and exception when there is no * corresponding transition. * @throws NoMatchingTransitionException when a matching transition cannot be found */ public Transition getRequiredTransition(RequestContext context) throws NoMatchingTransitionException { Transition transition = getTransitionSet().getTransition(context); if (transition == null) { throw new NoMatchingTransitionException(getFlow().getId(), getId(), context.getCurrentEvent(), "No transition found on occurence of event '" + context.getCurrentEvent() + "' in state '" + getId() + "' of flow '" + getFlow().getId() + "' -- valid transitional criteria are " + StylerUtils.style(getTransitionSet().getTransitionCriterias()) + " -- likely programmer error, check the set of TransitionCriteria for this state"); } return transition; }
TransitionDefinition getMatchingTransition(String eventId) { FlowSessionImpl session = getActiveSessionInternal(); if (session == null) { return null; } TransitionableState currentState = (TransitionableState) session.getState(); TransitionDefinition transition = currentState.getTransition(eventId); if (transition == null) { transition = session.getFlow().getGlobalTransition(eventId); } return transition; }
/** * Configure common properties for a transitionable state. */ private void configureCommonProperties(TransitionableState state, Action[] entryActions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap<?> attributes) { configureCommonProperties(state, entryActions, exceptionHandlers, attributes); state.getTransitionSet().addAll(transitions); state.getExitActionList().addAll(exitActions); }
/** * Add transition to action state. * * @param state the action state * @param criteriaOutcome the criteria outcome * @param targetState the target state * @param removeExisting the remove existing * @return the transition */ public Transition createTransitionForState(final TransitionableState state, final String criteriaOutcome, final String targetState, final boolean removeExisting) { try { if (removeExisting) { val success = (Transition) state.getTransition(criteriaOutcome); if (success != null) { state.getTransitionSet().remove(success); } } val transition = createTransition(criteriaOutcome, targetState); state.getTransitionSet().add(transition); LOGGER.trace("Added transition [{}] to the state [{}]", transition.getId(), state.getId()); return transition; } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } return null; }
public TransitionDefinition[] getTransitions() { return getTransitionSet().toArray(); }
/** * Sets start state. * * @param flow the flow * @param state the state */ protected void setStartState(final Flow flow, final TransitionableState state) { setStartState(flow, state.getId()); }
/** * Add transition to action state. * * @param state the action state * @param criteriaOutcome the criteria outcome * @param targetState the target state */ protected void createTransitionForState(final TransitionableState state, final String criteriaOutcome, final String targetState) { try { final Transition transition = createTransition(criteriaOutcome, targetState); state.getTransitionSet().add(transition); logger.debug("Added transition {} to the state {}", transition.getId(), state.getId()); } catch (final Exception e) { logger.error(e.getMessage(), e); } }
val targetSuccessId = actionState.getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS).getTargetStateId(); val targetWarningsId = actionState.getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS_WITH_WARNINGS).getTargetStateId(); val targetDenied = actionState.getTransition(CasWebflowConstants.TRANSITION_ID_DENY).getTargetStateId(); val targetUnavailable = actionState.getTransition(CasWebflowConstants.TRANSITION_ID_UNAVAILABLE).getTargetStateId(); transitionSet.add(createTransition(CasWebflowConstants.TRANSITION_ID_CANCEL, CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM)); LOGGER.trace("Creating transition [{}] for state [{}]", subflowId, actionState.getId()); createTransitionForState(actionState, subflowId, subflowId);
public void testTransitionExecutorHandlesExceptionExactMatch() { TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); handler.add(TestException.class, "state"); FlowExecutionException e = new FlowExecutionException(state.getOwner().getId(), state.getId(), "Oops", new TestException()); assertTrue("Doesn't handle state exception", handler.canHandle(e)); e = new FlowExecutionException(state.getOwner().getId(), state.getId(), "Oops", new Exception()); assertFalse("Shouldn't handle exception", handler.canHandle(e)); }
protected void appendToString(ToStringCreator creator) { creator.append("actionList", actionList); super.appendToString(creator); }
public void exit(RequestControlContext context) { super.exit(context); updateHistory(context); destroyVariables(context); context.setCurrentView(null); }
val stDef = TransitionableState.class.cast(state); acts = StreamSupport.stream(stDef.getExitActionList().spliterator(), false) .map(Object::toString) .collect(Collectors.toList()); acts = Arrays.stream(stDef.getTransitions()) .map(tr -> tr.getId() + " -> " + tr.getTargetStateId()) .collect(Collectors.toList());
realSubmit.getEntryActionList().add( createEvaluateAction(String.join(DO_CHANGE_PASSWORD_PARAMETER, "flowScope.", " = requestParameters.", " != null"))); CasWebflowConstants.VIEW_ID_MUST_CHANGE_PASSWORD, realSubmit .getTransition(CasWebflowConstants.TRANSITION_ID_SUCCESS).getTargetStateId()) .getEntryActionList().add(createEvaluateAction("flowScope.pswdChangePostLogin=true")); "flowScope.pswdChangePostLogin == true", getTransitionableState(flow, CasWebflowConstants.VIEW_ID_SHOW_AUTHN_WARNING_MSGS) .getTransition(CasWebflowConstants.TRANSITION_ID_PROCEED).getTargetStateId(), autoLogin ? CasWebflowConstants.STATE_ID_REAL_SUBMIT : CasWebflowConstants.STATE_ID_REDIRECT_TO_LOGIN);
/** * Inform this state definition that an event was signaled in it. The signaled event is the last event available in * given request context ({@link RequestContext#getCurrentEvent()}). * @param context the flow execution control context * @throws NoMatchingTransitionException when a matching transition cannot be found */ public boolean handleEvent(RequestControlContext context) throws NoMatchingTransitionException { return context.execute(getRequiredTransition(context)); }
/** * Called on completion of the subflow to handle the subflow result event as determined by the end state reached by * the subflow. */ public boolean handleEvent(RequestControlContext context) { if (subflowAttributeMapper != null) { AttributeMap<Object> subflowOutput = context.getCurrentEvent().getAttributes(); if (logger.isDebugEnabled()) { logger.debug("Mapping subflow output " + subflowOutput); } subflowAttributeMapper.mapSubflowOutput(subflowOutput, context); } return super.handleEvent(context); }
((TransitionableState) sourceState).exit(context); if (sourceState != null && sourceState instanceof TransitionableState) { selectedView = ((TransitionableState) sourceState).reenter(context); } else { throw new IllegalStateException("Execution of '" + this + "' was blocked by '" + getExecutionCriteria()
public TransitionDefinition[] getTransitions() { return getTransitionSet().toArray(); }
@Override public void setStartState(final Flow flow, final TransitionableState state) { setStartState(flow, state.getId()); }
public void testTransitionExecutorHandlesExceptionSuperclassMatch() { TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); handler.add(Exception.class, "state"); FlowExecutionException e = new FlowExecutionException(state.getOwner().getId(), state.getId(), "Oops", new TestException()); assertTrue("Doesn't handle state exception", handler.canHandle(e)); e = new FlowExecutionException(state.getOwner().getId(), state.getId(), "Oops", new RuntimeException()); assertTrue("Doesn't handle state exception", handler.canHandle(e)); }
protected void appendToString(ToStringCreator creator) { creator.append("subflow", subflow).append("subflowAttributeMapper", subflowAttributeMapper); super.appendToString(creator); }