REQ-3540: 添加校验

This commit is contained in:
yanglin 2025-03-19 19:14:58 +08:00
parent c3cc138991
commit dafa096929
3 changed files with 4 additions and 8 deletions

View File

@ -142,10 +142,6 @@ public class IndexNode extends BaseEntity<IndexNode> implements NodeValue, Index
return Path.wrap(path);
}
public static boolean idEquals(IndexNode n1, IndexNode n2) {
return Objects.equals(n1.getId(), n2.getId());
}
public static void setScope(IndexNode indexNode, IndexNodeScope scope) {
indexNode.setContext(scope.context());
indexNode.setScope(scope.scope());
@ -153,12 +149,12 @@ public class IndexNode extends BaseEntity<IndexNode> implements NodeValue, Index
}
public boolean isParentOf(IndexNode node) {
if (isSameNode(node))
if (isSameNodeWith(node))
return false;
return node.path.startsWith(path);
}
public boolean isSameNode(IndexNode node) {
public boolean isSameNodeWith(IndexNode node) {
return id.equals(node.id);
}

View File

@ -193,7 +193,7 @@ public class IndexManager {
private static void checkBeforeMoveOrCopy(IndexNode srcNode, IndexNode destParentNode, String op) {
BizAssertions.assertFalse(srcNode.isDirectory() && destParentNode.isFile(), "不能{}文件夹到文件下", op);
BizAssertions.assertFalse(srcNode.isSameNode(destParentNode), "不能{}到同一节点下", op);
BizAssertions.assertFalse(srcNode.isSameNodeWith(destParentNode), "不能{}到同一节点下", op);
BizAssertions.assertFalse(srcNode.isParentOf(destParentNode), "不能{}到子节点下", op);
}

View File

@ -99,7 +99,7 @@ class IndexSupport {
void incrNameIfDuplicate(IndexNode rename) {
lockParentAndReleaseOnCommit(rename);
List<IndexNode> nameLikeNodes = indexNodeDao.findValidChildrenNameRightLike(rename);
if (nameLikeNodes.size() == 1 && IndexNode.idEquals(rename, nameLikeNodes.get(0)))
if (nameLikeNodes.size() == 1 && rename.isSameNodeWith(nameLikeNodes.get(0)))
return;
Pattern pattern = Pattern.compile(Pattern.quote(rename.getName()) + "\\(副本(\\d+)\\)");
int maxSeq = 0;