mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
!195 enhancement #I7LGZR 优化未填写 chainId 的错误提示
Merge pull request !195 from 与或非/issues/I7LGZR
This commit is contained in:
@@ -140,6 +140,8 @@ public class ParserHelper {
|
||||
// 校验加载的 chainName 是否有重复的
|
||||
// TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
||||
String chainName = Optional.ofNullable(e.attributeValue(ID)).orElse(e.attributeValue(NAME));
|
||||
// 检查 chainName
|
||||
checkChainId(chainName, e.getText());
|
||||
if (!chainNameSet.add(chainName)) {
|
||||
throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName));
|
||||
}
|
||||
@@ -202,9 +204,11 @@ public class ParserHelper {
|
||||
JsonNode innerJsonObject = iterator.next();
|
||||
// 校验加载的 chainName 是否有重复的
|
||||
// TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
||||
String chainName = Optional.ofNullable(innerJsonObject.get(ID))
|
||||
.orElse(innerJsonObject.get(NAME))
|
||||
.textValue();
|
||||
JsonNode chainNameJsonNode = Optional.ofNullable(innerJsonObject.get(ID))
|
||||
.orElse(innerJsonObject.get(NAME));
|
||||
String chainName = Optional.ofNullable(chainNameJsonNode).map(JsonNode::textValue).orElse(null);
|
||||
// 检查 chainName
|
||||
checkChainId(chainName, innerJsonObject.toPrettyString());
|
||||
if (!chainNameSet.add(chainName)) {
|
||||
throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName));
|
||||
}
|
||||
@@ -250,6 +254,17 @@ public class ParserHelper {
|
||||
chainELBuilder.setEL(el).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查 chainId
|
||||
* @param chainId chainId
|
||||
* @param elData elData
|
||||
*/
|
||||
private static void checkChainId(String chainId, String elData) {
|
||||
if (StrUtil.isBlank(chainId)) {
|
||||
throw new ParseException("missing chain id in expression \r\n" + elData);
|
||||
}
|
||||
}
|
||||
|
||||
private static class RegexUtil {
|
||||
|
||||
// java 注释的正则表达式
|
||||
|
||||
Reference in New Issue
Block a user