REQ-3540: 校验深度
This commit is contained in:
parent
0330080d23
commit
e901ce392b
@ -193,6 +193,8 @@ public class IndexManager {
|
|||||||
public Future<IndexNode> asyncMove(String srcCode, @Nullable String destParentCode) {
|
public Future<IndexNode> asyncMove(String srcCode, @Nullable String destParentCode) {
|
||||||
IndexNode srcNode = getOrThrow(srcCode);
|
IndexNode srcNode = getOrThrow(srcCode);
|
||||||
IndexNode destParentNode = determineDestParentNode(srcNode, destParentCode, "移动");
|
IndexNode destParentNode = determineDestParentNode(srcNode, destParentCode, "移动");
|
||||||
|
if (destParentNode != null)
|
||||||
|
indexSupport.validateDepthWhenAddChild(destParentNode);
|
||||||
return async(() -> transaction.execute(unused -> {
|
return async(() -> transaction.execute(unused -> {
|
||||||
docLogDao.log("indexNode:asyncMove", srcCode, "srcCode", srcCode, "destParentCode", destParentCode);
|
docLogDao.log("indexNode:asyncMove", srcCode, "srcCode", srcCode, "destParentCode", destParentCode);
|
||||||
if (docProps.isLockSubtreeWhenMove())
|
if (docProps.isLockSubtreeWhenMove())
|
||||||
|
|||||||
@ -93,12 +93,16 @@ public class IndexSupport {
|
|||||||
"创建子节点时父子scope不匹配: {}", child.nodeScope().scope());
|
"创建子节点时父子scope不匹配: {}", child.nodeScope().scope());
|
||||||
BizAssertions.assertEquals(parent.getScopeCode(), child.nodeScope().scopeCode(), //
|
BizAssertions.assertEquals(parent.getScopeCode(), child.nodeScope().scopeCode(), //
|
||||||
"创建子节点时父子scopeCode不匹配: {}", child.parentCode());
|
"创建子节点时父子scopeCode不匹配: {}", child.parentCode());
|
||||||
BizAssertions.assertTrue(
|
validateDepthWhenAddChild(parent);
|
||||||
indexNodeDao.validChildrenCount(parent.getCode()) < docProps.getIndexNodeMaxChildrenSize(),
|
|
||||||
"创建失败, 子节点数量不能超过 {}", docProps.getIndexNodeMaxChildrenSize());
|
|
||||||
if (!parent.isRoot() && limitChildrenCount(child))
|
if (!parent.isRoot() && limitChildrenCount(child))
|
||||||
BizAssertions.assertTrue(parent.path().depth() < docProps.getIndexNodeMaxDepth(), //
|
BizAssertions.assertTrue(
|
||||||
"节点深度超过限制{}, 无法再创建新节点", docProps.getIndexNodeMaxDepth());
|
indexNodeDao.validChildrenCount(parent.getCode()) < docProps.getIndexNodeMaxChildrenSize(),
|
||||||
|
"创建失败, 子节点数量不能超过 {}", docProps.getIndexNodeMaxChildrenSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateDepthWhenAddChild(IndexNode parent) {
|
||||||
|
BizAssertions.assertTrue(parent.path().depth() < docProps.getIndexNodeMaxDepth(), //
|
||||||
|
"节点深度超过限制{}, 无法再创建新节点", docProps.getIndexNodeMaxDepth());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IndexNode> collectValidSubtreeAsValueRoot(IndexNode srcNode) {
|
List<IndexNode> collectValidSubtreeAsValueRoot(IndexNode srcNode) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user