[Improvement] File deletion logic optimization (#11519)
* [Improvement] File deletion logic optimization
This commit is contained in:
parent
11d74fd7e8
commit
006d8e21a6
|
|
@ -239,6 +239,7 @@ public enum Status {
|
|||
PARENT_RESOURCE_NOT_EXIST(20015, "parent resource not exist", "父资源文件不存在"),
|
||||
RESOURCE_NOT_EXIST_OR_NO_PERMISSION(20016, "resource not exist or no permission,please view the task node and remove error resource", "请检查任务节点并移除无权限或者已删除的资源"),
|
||||
RESOURCE_IS_AUTHORIZED(20017, "resource is authorized to user {0},suffix not allowed to be modified", "资源文件已授权其他用户[{0}],后缀不允许修改"),
|
||||
RESOURCE_HAS_FOLDER(20018, "There are files or folders in the current directory:{0}", "当前目录下有文件或文件夹[{0}]"),
|
||||
|
||||
USER_NO_OPERATION_PERM(30001, "user has no operation privilege", "当前用户没有操作权限"),
|
||||
USER_NO_OPERATION_PROJECT_PERM(30002, "user {0} is not has project {1} permission", "当前用户[{0}]没有[{1}]项目的操作权限"),
|
||||
|
|
|
|||
|
|
@ -828,8 +828,16 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
Set<Integer> resourceIdSet = resourceProcessMap.keySet();
|
||||
// get all children of the resource
|
||||
List<Integer> allChildren = listAllChildren(resource, true);
|
||||
|
||||
Integer[] needDeleteResourceIdArray = allChildren.toArray(new Integer[allChildren.size()]);
|
||||
|
||||
|
||||
if (needDeleteResourceIdArray.length >= 2){
|
||||
logger.error("can't be deleted,because There are files or folders in the current directory:{}", resource);
|
||||
putMsg(result, Status.RESOURCE_HAS_FOLDER, resource.getFileName());
|
||||
return result;
|
||||
}
|
||||
|
||||
//if resource type is UDF,need check whether it is bound by UDF function
|
||||
if (resource.getType() == (ResourceType.UDF)) {
|
||||
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(needDeleteResourceIdArray);
|
||||
|
|
@ -840,6 +848,8 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (resourceIdSet.contains(resource.getPid())) {
|
||||
logger.error("can't be deleted,because it is used of process definition");
|
||||
putMsg(result, Status.RESOURCE_IS_USED);
|
||||
|
|
|
|||
Loading…
Reference in New Issue