Source:
private void handle(String key, Payload payload, FlowParameters flowParameters, String flowChainId, Map<Object, Object> contextParams) throws TransactionExecutionException { switch (key) { case FLOW_CANCEL: cancelRunningFlows(payload.getResourceId()); break; case FLOW_FINAL: finalizeFlow(flowParameters, flowChainId, payload.getResourceId(), contextParams); break; default: String flowId = flowParameters.getFlowId(); if (flowId == null) { LOGGER.debug("flow trigger arrived: key: {}, payload: {}", key, payload); FlowConfiguration<?> flowConfig = flowConfigurationMap.get(key); if (flowConfig != null && flowConfig.getFlowTriggerCondition().isFlowTriggerable(payload.getResourceId())) { if (!isFlowAcceptable(key, payload)) { LOGGER.info("Flow operation not allowed, other flow is running. Stack ID {}, event {}", payload.getResourceId(), key); return; } flowId = UUID.randomUUID().toString(); FlowAcceptResult acceptResult; if (flowChainId != null) { acceptResult = FlowAcceptResult.runningInFlowChain(flowChainId); } else { acceptResult = FlowAcceptResult.runningInFlow(flowId); } flowParameters.setFlowId(flowId); Flow flow = flowConfig.createFlow(flowId, payload.getResourceId()); flow.initialize(contextParams); runningFlows.put(flow, flowChainId); try { transactionService.required(() -> { flowLogService.save(flowParameters, flowChainId, key, payload, null, flowConfig.getClass(), flow.getCurrentState()); if (flowChainId != null) { flowChains.removeLastTriggerEvent(flowChainId, flowParameters.getFlowTriggerUserCrn()); } return null; }); } catch (Exception e) { LOGGER.error("Can't save flow: {}", flowId); runningFlows.remove(flowId); throw e; } acceptFlow(payload, acceptResult); logFlowId(flowId); flow.sendEvent(key, flowParameters.getFlowTriggerUserCrn(), payload, flowParameters.getSpanContext()); } } else { handleFlowControlEvent(key, payload, flowParameters, flowChainId); } break; } }

Target:
private void handle(String key, Payload payload, FlowParameters flowParameters, String flowChainId, Map<Object, Object> contextParams) throws TransactionExecutionException { switch (key) { case FLOW_CANCEL: cancelRunningFlows(payload.getResourceId()); break; case FLOW_FINAL: finalizeFlow(flowParameters, flowChainId, payload.getResourceId(), contextParams); break; default: String flowId = flowParameters.getFlowId(); if (flowId == null) { LOGGER.debug("flow trigger arrived: key: {}, payload: {}", key, payload); FlowConfiguration<?> flowConfig = flowConfigurationMap.get(key); if (flowConfig != null && flowConfig.getFlowTriggerCondition().isFlowTriggerable(payload.getResourceId())) { if (!isFlowAcceptable(key, payload)) { LOGGER.info("Flow operation not allowed, other flow is running. Stack ID {}, event {}", payload.getResourceId(), key); return; } flowId = UUID.randomUUID().toString(); FlowAcceptResult acceptResult; if (flowChainId != null) { acceptResult = FlowAcceptResult.runningInFlowChain(flowChainId); } else { acceptResult = FlowAcceptResult.runningInFlow(flowId); } flowParameters.setFlowId(flowId); Flow flow = flowConfig.createFlow(flowId, payload.getResourceId()); flow.initialize(contextParams); runningFlows.put(flow, flowChainId); try { transactionService.required(() -> { flowLogService.save(flowParameters, flowChainId, key, payload, null, flowConfig.getClass(), flow.getCurrentState()); if (flowChainId != null) { flowChains.removeLastTriggerEvent(flowChainId, flowParameters.getFlowTriggerUserCrn()); } }); } catch (Exception e) { LOGGER.error("Can't save flow: {}", flowId); runningFlows.remove(flowId); throw e; } acceptFlow(payload, acceptResult); logFlowId(flowId); flow.sendEvent(key, flowParameters.getFlowTriggerUserCrn(), payload, flowParameters.getSpanContext()); } } else { handleFlowControlEvent(key, payload, flowParameters, flowChainId); } break; } }