按《FL最终代码审计与上线阻断清单》194 项已审计工作树形成候选,基座 = origin/main 11e0778。
- 源码/测试/资源:沿用已审计工作树内容(96 项相对远端为新增或更新),含未跟踪实现
CallbackFactStore、CallbackSourcePolicy、VariableContract、FormalApplyCommandService、
FlowActorContextGate 等;C01 续验夹具修正一并入内。
- CI:保留远端 11e0778 的门禁强化(CI_SOURCE_SHA 核对、容器回收验证、空 schema 反向门禁、
main ref 才推镜像);ci/flow-test-schema.sql 按当前实体重新生成(14→20 表,补 6 新表与
6 新列,回调日志复合唯一键 uk_flw_log_event_reg),workflow 表数断言同步 14→20。
- 依据:docs/tasks/evidence/FL-final-audit-20261027(194 项哈希/版本核对)。
50 lines
2.0 KiB
Java
50 lines
2.0 KiB
Java
package com.yunhai.flowcenter.service;
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.yunhai.flowcenter.engine.FlowDefModel;
|
|
import com.yunhai.platform.apistd.BizException;
|
|
import com.yunhai.platform.utils.exception.ErrorCode;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
/** 发起前按冻结的定义契约校验;历史无声明版本保留原有的引用变量存在性规则。 */
|
|
@Slf4j
|
|
@Component
|
|
@RequiredArgsConstructor
|
|
public class ApplyVariableValidator {
|
|
|
|
private final ObjectMapper objectMapper;
|
|
|
|
/** def 的全部 EXPRESSION 出边引用的业务变量键(去重保序) */
|
|
public Set<String> referencedBusinessKeys(FlowDefModel model) {
|
|
return com.yunhai.flowcenter.engine.VariableContract.referencedKeys(model);
|
|
}
|
|
|
|
public void requireVariablesPresent(FlowDefModel model, String formDataJson) {
|
|
com.yunhai.flowcenter.engine.VariableContract.validateInput(model, parse(formDataJson, model.variables != null));
|
|
}
|
|
|
|
/** 与 ConditionRouteService.parseVariables 同源:formData 顶层即变量;非对象 JSON=空(后续逐键报缺失) */
|
|
private Map<String, Object> parse(String formDataJson, boolean strict) {
|
|
if (formDataJson == null || formDataJson.trim().isEmpty()) {
|
|
return new java.util.HashMap<>();
|
|
}
|
|
try {
|
|
Map<String, Object> values = objectMapper.readValue(formDataJson, new TypeReference<Map<String, Object>>() { });
|
|
if (values == null) {
|
|
if (strict) throw new IllegalArgumentException("null object");
|
|
return new java.util.HashMap<>();
|
|
}
|
|
return values;
|
|
} catch (Exception e) {
|
|
if (strict) throw new BizException(ErrorCode.PARAM_ERROR, "formData 必须为 JSON 对象");
|
|
return new java.util.HashMap<>();
|
|
}
|
|
}
|
|
}
|