/** * Configure common properties for a state. */ private void configureCommonProperties(State state, Action[] entryActions, FlowExecutionExceptionHandler[] exceptionHandlers, AttributeMap<?> attributes) { state.getEntryActionList().addAll(entryActions); state.getExceptionHandlerSet().addAll(exceptionHandlers); state.getAttributes().putAll(attributes); } }
/** * Handle an exception that occurred in this state during the context of the current flow execution request. * @param exception the exception that occurred * @param context the flow execution control context */ public boolean handleException(FlowExecutionException exception, RequestControlContext context) { return getExceptionHandlerSet().handleException(exception, context); }
/** * Add a state exception handler to this set. * @param exceptionHandler the exception handler to add * @return true if this set's contents changed as a result of the add operation */ public boolean add(FlowExecutionExceptionHandler exceptionHandler) { if (contains(exceptionHandler)) { return false; } return exceptionHandlers.add(exceptionHandler); }
public void testHandleException() { FlowExecutionExceptionHandlerSet handlerSet = new FlowExecutionExceptionHandlerSet(); handlerSet.add(new TestStateExceptionHandler(NullPointerException.class, "null")); handlerSet.add(new TestStateExceptionHandler(FlowExecutionException.class, "execution 1")); handlerSet.add(new TestStateExceptionHandler(FlowExecutionException.class, "execution 2")); assertEquals(3, handlerSet.size()); FlowExecutionException e = new FlowExecutionException("flowId", "stateId", "Test"); assertTrue(handlerSet.handleException(e, context)); assertFalse(context.getFlowScope().contains("null")); assertTrue(context.getFlowScope().contains("execution 1")); assertFalse(context.getFlowScope().contains("execution 2")); }
/** * 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 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()); }
/** * 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); } }
/** * 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); }
/** * 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); }
/** * Add a state exception handler to this set. * @param exceptionHandler the exception handler to add * @return true if this set's contents changed as a result of the add operation */ public boolean add(FlowExecutionExceptionHandler exceptionHandler) { if (contains(exceptionHandler)) { return false; } return exceptionHandlers.add(exceptionHandler); }
public void buildExceptionHandlers() throws FlowBuilderException { getFlow().getExceptionHandlerSet().addAll(parseExceptionHandlers(getDocumentElement())); }
/** * Clone action state. * * @param source the source * @param target the target */ public void cloneActionState(final ActionState source, final ActionState target) { source.getActionList().forEach(a -> target.getActionList().add(a)); source.getExitActionList().forEach(a -> target.getExitActionList().add(a)); source.getAttributes().asMap().forEach((k, v) -> target.getAttributes().put(k, v)); source.getTransitionSet().forEach(t -> target.getTransitionSet().addAll(t)); val field = ReflectionUtils.findField(target.getExceptionHandlerSet().getClass(), "exceptionHandlers"); ReflectionUtils.makeAccessible(field); val list = (List<FlowExecutionExceptionHandler>) ReflectionUtils.getField(field, target.getExceptionHandlerSet()); list.forEach(h -> source.getExceptionHandlerSet().add(h)); target.setDescription(source.getDescription()); target.setCaption(source.getCaption()); }
/** * Handle an exception that occurred in this state during the context of the current flow execution request. * @param exception the exception that occurred * @param context the flow execution control context */ public boolean handleException(FlowExecutionException exception, RequestControlContext context) { return getExceptionHandlerSet().handleException(exception, context); }
/** * Add a state exception handler to this set. * @param exceptionHandler the exception handler to add * @return true if this set's contents changed as a result of the add operation */ public boolean add(FlowExecutionExceptionHandler exceptionHandler) { if (contains(exceptionHandler)) { return false; } return exceptionHandlers.add(exceptionHandler); }
/** * Configure common properties for a state. */ private void configureCommonProperties(State state, Action[] entryActions, FlowExecutionExceptionHandler[] exceptionHandlers, AttributeMap attributes) { state.getEntryActionList().addAll(entryActions); state.getExceptionHandlerSet().addAll(exceptionHandlers); state.getAttributes().putAll(attributes); } }
public void buildExceptionHandlers() throws FlowBuilderException { getFlow().getExceptionHandlerSet().add( new TransitionExecutingFlowExecutionExceptionHandler().add(Exception.class, "showError")); }
/** * Handle an exception that occurred in this state during the context of the current flow execution request. * @param exception the exception that occurred * @param context the flow execution control context */ public boolean handleException(FlowExecutionException exception, RequestControlContext context) { return getExceptionHandlerSet().handleException(exception, context); }
/** * Add a state exception handler to this set. * @param exceptionHandler the exception handler to add * @return true if this set's contents changed as a result of the add operation */ public boolean add(FlowExecutionExceptionHandler exceptionHandler) { if (contains(exceptionHandler)) { return false; } return exceptionHandlers.add(exceptionHandler); }
/** * Configure common properties for a state. */ private void configureCommonProperties(State state, Action[] entryActions, FlowExecutionExceptionHandler[] exceptionHandlers, AttributeMap<?> attributes) { state.getEntryActionList().addAll(entryActions); state.getExceptionHandlerSet().addAll(exceptionHandlers); state.getAttributes().putAll(attributes); } }