/** * Handle an exception that occurred during an execution of this flow. * @param exception the exception that occurred * @param context the flow execution control context */ public boolean handleException(FlowExecutionException exception, RequestControlContext context) throws FlowExecutionException { return getExceptionHandlerSet().handleException(exception, context); }
/** * Creates and adds all exception handlers to the flow built by this builder. * @throws FlowBuilderException an exception occurred building this flow */ public void buildExceptionHandlers() throws FlowBuilderException { getFlow().getExceptionHandlerSet().addAll( parseExceptionHandlers(flowModel.getExceptionHandlers(), flowModel.getGlobalTransitions())); }
/** * Handle an exception that occurred during an execution of this flow. * @param exception the exception that occurred * @param context the flow execution control context */ public boolean handleException(FlowExecutionException exception, RequestControlContext context) throws FlowExecutionException { return getExceptionHandlerSet().handleException(exception, context); }
/** * Handle an exception that occurred during an execution of this flow. * @param exception the exception that occurred * @param context the flow execution control context */ public boolean handleException(FlowExecutionException exception, RequestControlContext context) throws FlowExecutionException { return getExceptionHandlerSet().handleException(exception, context); }
/** * Handle an exception that occured during an execution of this flow. * @param exception the exception that occured * @param context the flow execution control context * @return the selected error view, or <code>null</code> if no handler matched or returned a non-null view * selection */ public ViewSelection handleException(FlowExecutionException exception, RequestControlContext context) throws FlowExecutionException { return getExceptionHandlerSet().handleException(exception, context); }
/** * Add global transition if exception is thrown. * * @param flow the flow * @param targetStateId the target state id * @param clazz the exception class */ protected void addGlobalTransitionIfExceptionIsThrown(final Flow flow, final String targetStateId, final Class<? extends Throwable> clazz) { try { final TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); final TargetStateResolver targetStateResolver = (TargetStateResolver) fromStringTo(TargetStateResolver.class) .execute(targetStateId); handler.add(clazz, targetStateResolver); LOGGER.debug("Added transition {} to execute on the occurrence of {}", targetStateId, clazz.getName()); flow.getExceptionHandlerSet().add(handler); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } }
/** * Add global transition if exception is thrown. * * @param flow the flow * @param targetStateId the target state id * @param clazz the exception class */ protected void createGlobalTransition(final Flow flow, final String targetStateId, final Class<? extends Throwable> clazz) { try { final TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); final TargetStateResolver targetStateResolver = (TargetStateResolver) fromStringTo(TargetStateResolver.class) .execute(targetStateId); handler.add(clazz, targetStateResolver); logger.debug("Added transition {} to execute on the occurrence of {}", targetStateId, clazz.getName()); flow.getExceptionHandlerSet().add(handler); } catch (final Exception e) { logger.error(e.getMessage(), e); } }
public void buildExceptionHandlers() throws FlowBuilderException { getFlow().getExceptionHandlerSet().addAll(parseExceptionHandlers(getDocumentElement())); }
/** * Creates and adds all exception handlers to the flow built by this builder. * @throws FlowBuilderException an exception occurred building this flow */ public void buildExceptionHandlers() throws FlowBuilderException { getFlow().getExceptionHandlerSet().addAll( parseExceptionHandlers(flowModel.getExceptionHandlers(), flowModel.getGlobalTransitions())); }
/** * Creates and adds all exception handlers to the flow built by this builder. * @throws FlowBuilderException an exception occurred building this flow */ public void buildExceptionHandlers() throws FlowBuilderException { getFlow().getExceptionHandlerSet().addAll( parseExceptionHandlers(flowModel.getExceptionHandlers(), flowModel.getGlobalTransitions())); }
/** * Create default global exception handlers. * * @param flow the flow */ protected void createDefaultGlobalExceptionHandlers(final Flow flow) { val h = new TransitionExecutingFlowExecutionExceptionHandler(); h.add(UnauthorizedSsoServiceException.class, CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM); h.add(NoSuchFlowExecutionException.class, CasWebflowConstants.STATE_ID_VIEW_SERVICE_ERROR); h.add(UnauthorizedServiceException.class, CasWebflowConstants.STATE_ID_SERVICE_UNAUTHZ_CHECK); h.add(UnauthorizedServiceForPrincipalException.class, CasWebflowConstants.STATE_ID_SERVICE_UNAUTHZ_CHECK); h.add(PrincipalException.class, CasWebflowConstants.STATE_ID_SERVICE_UNAUTHZ_CHECK); flow.getExceptionHandlerSet().add(h); }
public void buildExceptionHandlers() throws FlowBuilderException { getFlow().getExceptionHandlerSet().add( new TransitionExecutingFlowExecutionExceptionHandler().add(Exception.class, "showError")); }
private void buildInlineFlow(Element flowElement, Flow inlineFlow) { parseAndAddFlowVariables(flowElement, inlineFlow); inlineFlow.setInputMapper(parseInputMapper(flowElement)); parseAndAddStartActions(flowElement, inlineFlow); parseAndAddInlineFlowDefinitions(flowElement, inlineFlow); parseAndAddStateDefinitions(flowElement, inlineFlow); parseAndAddGlobalTransitions(flowElement, inlineFlow); parseAndAddEndActions(flowElement, inlineFlow); inlineFlow.setOutputMapper(parseOutputMapper(flowElement)); inlineFlow.getExceptionHandlerSet().addAll(parseExceptionHandlers(flowElement)); destroyLocalServiceRegistry(); }
public void testStateExceptionHandlingTransitionNoSuchState() { TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); handler.add(TestException.class, "end"); flow.getExceptionHandlerSet().add(handler); FlowExecution execution = new FlowExecutionImplFactory().createFlowExecution(flow); try { execution.start(null, new MockExternalContext()); fail("Should have failed no such state"); } catch (IllegalArgumentException e) { } }
public void testExceptionHandledByNestedExceptionHandler() { Flow flow = new Flow("flow"); ExceptionThrowingExceptionHandler exceptionHandler = new ExceptionThrowingExceptionHandler(true); flow.getExceptionHandlerSet().add(exceptionHandler); new State(flow, "state") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { throw new FlowExecutionException("flow", "state", "Oops"); } }; FlowExecutionImpl execution = new FlowExecutionImpl(flow); MockExternalContext context = new MockExternalContext(); assertFalse(execution.hasStarted()); execution.start(null, context); assertEquals(2, exceptionHandler.getHandleCount()); }
public void testStartExceptionThrownByStateHandledByFlowExceptionHandler() { Flow flow = new Flow("flow"); StubFlowExecutionExceptionHandler exceptionHandler = new StubFlowExecutionExceptionHandler(); flow.getExceptionHandlerSet().add(exceptionHandler); final FlowExecutionException e = new FlowExecutionException("flow", "state", "Oops"); new State(flow, "state") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { throw e; } }; FlowExecutionImpl execution = new FlowExecutionImpl(flow); MockExternalContext context = new MockExternalContext(); assertFalse(execution.hasStarted()); execution.start(null, context); assertTrue(exceptionHandler.getHandled()); }
public void testFlowStateExceptionHandlingTransition() { new EndState(flow, "end"); TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); handler.add(TestException.class, "end"); flow.getExceptionHandlerSet().add(handler); FlowExecutionListener listener = new FlowExecutionListener() { @SuppressWarnings("unused") public void sessionEnding(RequestContext context, FlowSession session, MutableAttributeMap<?> output) { assertTrue(context.getFlashScope().contains("flowExecutionException")); assertTrue(context.getFlashScope().contains("rootCauseException")); assertTrue(context.getFlashScope().get("rootCauseException") instanceof TestException); } }; FlowExecutionImplFactory factory = new FlowExecutionImplFactory(); factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener)); FlowExecution execution = factory.createFlowExecution(flow); execution.start(null, new MockExternalContext()); assertTrue("Should have ended", !execution.isActive()); }
public void testHandleException() { flow.getExceptionHandlerSet().add( new TransitionExecutingFlowExecutionExceptionHandler().add(TestException.class, "myState2")); MockRequestControlContext context = new MockRequestControlContext(flow); context.setCurrentState(flow.getStateInstance("myState1")); FlowExecutionException e = new FlowExecutionException(flow.getId(), flow.getStartState().getId(), "Oops!", new TestException()); flow.handleException(e, context); assertFalse(context.getFlowExecutionContext().isActive()); }
public void testStartExceptionThrownByStateHandledByStateExceptionHandler() { Flow flow = new Flow("flow"); flow.getExceptionHandlerSet().add(new StubFlowExecutionExceptionHandler()); final FlowExecutionException e = new FlowExecutionException("flow", "state", "Oops"); State s = new State(flow, "state") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { throw e; } }; StubFlowExecutionExceptionHandler exceptionHandler = new StubFlowExecutionExceptionHandler(); s.getExceptionHandlerSet().add(exceptionHandler); FlowExecutionImpl execution = new FlowExecutionImpl(flow); MockExternalContext context = new MockExternalContext(); assertFalse(execution.hasStarted()); execution.start(null, context); assertTrue(exceptionHandler.getHandled()); }
public void testExceptionHandlers() { FlowModel model = new FlowModel(); model.setStates(asList(new EndStateModel("state"))); model.setExceptionHandlers(asList(new ExceptionHandlerModel("exceptionHandler"))); FlowExecutionExceptionHandler handler = new FlowExecutionExceptionHandler() { public boolean canHandle(FlowExecutionException exception) { return true; } public void handle(FlowExecutionException exception, RequestControlContext context) { } }; FlowModelFlowBuilder builder = new FlowModelFlowBuilder(new StaticFlowModelHolder(model)); MockFlowBuilderContext context = new MockFlowBuilderContext("foo"); context.registerBean("exceptionHandler", handler); FlowAssembler assembler = new FlowAssembler(builder, context); Flow flow = assembler.assembleFlow(); assertEquals(1, flow.getExceptionHandlerSet().size()); }