REQ-3540: 日志
This commit is contained in:
parent
bec64f1e75
commit
3ce080606f
@ -68,8 +68,8 @@ public class IndexNodeDao extends ServiceImpl<IndexNodeMapper, IndexNode> {
|
||||
.one();
|
||||
}
|
||||
|
||||
public List<IndexNode> findValidChildrenNameRightLike(IndexNodeParentScope parentNode, IndexNode node) {
|
||||
return parentOrScopeRootQuery(parentNode) //
|
||||
public List<IndexNode> findValidChildrenNameRightLike(IndexNode node) {
|
||||
return parentOrScopeRootQuery(node) //
|
||||
.likeRight(IndexNode::getName, node.getName()) //
|
||||
.eq(IndexNode::getNodeType, node.getNodeType()) //
|
||||
.eq(IndexNode::getState, IndexNodeState.VALID) //
|
||||
|
||||
@ -226,7 +226,8 @@ public class IndexNode extends BaseEntity<IndexNode> implements NodeValue, Index
|
||||
|
||||
@Override
|
||||
public String parentCode() {
|
||||
// as a parent
|
||||
return code;
|
||||
// my parent scope
|
||||
return parentCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -16,8 +16,6 @@ import cn.axzo.maokai.api.util.Ref;
|
||||
import cn.axzo.maokai.api.vo.response.tree.RootNode;
|
||||
import cn.axzo.maokai.api.vo.response.tree.TreeBuilder;
|
||||
import cn.axzo.maokai.api.vo.response.tree.TreeUtils;
|
||||
import cn.axzo.nanopart.doc.api.domain.IndexNodeParentScope;
|
||||
import cn.axzo.nanopart.doc.api.domain.IndexNodeScope;
|
||||
import cn.axzo.nanopart.doc.api.domain.NodeCreate;
|
||||
import cn.axzo.nanopart.doc.api.domain.OssFile;
|
||||
import cn.axzo.nanopart.doc.api.enums.FileFormat;
|
||||
@ -90,21 +88,21 @@ public class IndexManager {
|
||||
return fileNode;
|
||||
}
|
||||
|
||||
public IndexNode createFile(NodeCreate node, OssFile ossFile) {
|
||||
public IndexNode createFile(NodeCreate create, OssFile ossFile) {
|
||||
Ref<Boolean> deleteOssFile = Ref.create(false);
|
||||
try {
|
||||
return transaction.execute(unused -> {
|
||||
indexSupport.lockParentAndReleaseOnCommit(node);
|
||||
indexSupport.lockParentAndReleaseOnCommit(create);
|
||||
try {
|
||||
// check with lock
|
||||
indexSupport.ensureChildNameNotUsed(node, IndexNodeType.FILE);
|
||||
indexSupport.ensureChildNameNotUsed(create, IndexNodeType.FILE);
|
||||
}
|
||||
catch (NameUsedException e) {
|
||||
deleteOssFile.set(true);
|
||||
throw e;
|
||||
}
|
||||
String operatorId = node.operatorId() == null ? "" : node.operatorId() + "";
|
||||
IndexNode fileNode = indexSupport.createNode(node, IndexNodeType.FILE);
|
||||
String operatorId = create.operatorId() == null ? "" : create.operatorId() + "";
|
||||
IndexNode fileNode = indexSupport.createNode(create, IndexNodeType.FILE);
|
||||
fileNode.getOrCreateFileAttributes().setOssFileKey(ossFile.getOssFileKey());
|
||||
fileNode.getOrCreateFileAttributes().setFileFormat(ossFile.getFormat());
|
||||
fileNode.getOrCreateFileAttributes().setFileExtension(ossFile.getExtension());
|
||||
@ -208,19 +206,8 @@ public class IndexManager {
|
||||
connectRoot.walkDown(new ConnectNodeVisitor(destParent));
|
||||
indexNodeDao.connectNodes(TreeUtils.collectValues(connectRoot));
|
||||
IndexNode rootNode = connectRoot.getChildren().get(0).<IndexNode> asValueNode().getValue();
|
||||
IndexNodeParentScope nameScope = new IndexNodeParentScope() {
|
||||
@Override
|
||||
public IndexNodeScope nodeScope() {
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parentCode() {
|
||||
return destParent == null ? "" : destParent.getCode();
|
||||
}
|
||||
};
|
||||
// resolve the name issue
|
||||
indexSupport.incrNameIfDuplicate(nameScope, rootNode);
|
||||
indexSupport.incrNameIfDuplicate(rootNode);
|
||||
// get the coped root with full props
|
||||
return indexNodeDao.findOrNull(rootNode.getCode());
|
||||
}
|
||||
|
||||
@ -96,9 +96,9 @@ class IndexSupport {
|
||||
"节点深度超过限制{}, 无法再创建新节点", docProps.getIndexNodeMaxDepth());
|
||||
}
|
||||
|
||||
void incrNameIfDuplicate(IndexNodeParentScope parentScope, IndexNode rename) {
|
||||
lockParentAndReleaseOnCommit(parentScope);
|
||||
List<IndexNode> nameLikeNodes = indexNodeDao.findValidChildrenNameRightLike(parentScope, rename);
|
||||
void incrNameIfDuplicate(IndexNode rename) {
|
||||
lockParentAndReleaseOnCommit(rename);
|
||||
List<IndexNode> nameLikeNodes = indexNodeDao.findValidChildrenNameRightLike(rename);
|
||||
if (nameLikeNodes.size() == 1 && IndexNode.idEquals(rename, nameLikeNodes.get(0)))
|
||||
return;
|
||||
Pattern pattern = Pattern.compile(Pattern.quote(rename.getName()) + "\\(副本(\\d+)\\)");
|
||||
@ -121,8 +121,8 @@ class IndexSupport {
|
||||
ensureChildNameNotUsed(create, nodeType, create.name());
|
||||
}
|
||||
|
||||
void ensureChildNameNotUsed(IndexNodeParentScope parentNode, IndexNodeType nodeType, String childName) {
|
||||
IndexNode child = indexNodeDao.findValidChildByName(parentNode, nodeType, childName);
|
||||
void ensureChildNameNotUsed(IndexNodeParentScope parentScope, IndexNodeType nodeType, String childName) {
|
||||
IndexNode child = indexNodeDao.findValidChildByName(parentScope, nodeType, childName);
|
||||
if (child != null)
|
||||
throw new NameUsedException("名称已被使用");
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import cn.axzo.nanopart.doc.api.wps.response.WpsRenameResponse;
|
||||
import cn.axzo.nanopart.doc.api.wps.response.WpsUsersResponse;
|
||||
import cn.axzo.nanopart.doc.dao.IndexNodeDao;
|
||||
import cn.axzo.nanopart.doc.entity.IndexNode;
|
||||
import cn.axzo.nanopart.doc.file.index.domain.NameUsedException;
|
||||
import cn.axzo.nanopart.doc.rpc.DocOssGateway;
|
||||
import cn.axzo.nanopart.doc.rpc.DocUserProfileGateway;
|
||||
import cn.axzo.oss.http.model.ApiSignUrlDownloadRequest;
|
||||
@ -140,6 +141,12 @@ public class WpsBaseManager {
|
||||
|| StringUtils.isBlank(node.getAttributes().getFileAttributes().getOssFileKey())) {
|
||||
return WpsRenameResponse.builder().updateFlag(false).build();
|
||||
}
|
||||
//TODO: 文件名重复
|
||||
//try {
|
||||
// 调用IndexManager.rename();
|
||||
//} catch (NameUsedException e) {
|
||||
// // 处理文件已被使用的情况
|
||||
//}
|
||||
indexNodeDao.rename(request.getDocCode(), request.getName());
|
||||
UpdateFileInfoResponse response = this.docOssGateway.updateFileInfo(UpdateFileInfoRequest.builder().fileKey(node.getAttributes().getFileAttributes().getOssFileKey()).build());
|
||||
return WpsRenameResponse.builder().updateFlag(response.isUpdateFlag()).build();
|
||||
|
||||
@ -90,6 +90,7 @@ public class WpsEditManager {
|
||||
public WpsEditUploadCompleteResponse uploadComplete(WpsEditUploadCompleteRequest request) {
|
||||
IndexNode node = indexNodeDao.findOrNull(request.getDocCode());
|
||||
|
||||
//TODO: 调用FileBroadcaster#fireFileSizeChanged 通知文件大小变更
|
||||
return WpsEditUploadCompleteResponse.builder()
|
||||
.docCode(request.getDocCode())
|
||||
.name(node.getName())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user