Radeity commented on code in PR #12454:
URL: 
https://github.com/apache/dolphinscheduler/pull/12454#discussion_r1027002733


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -214,6 +214,28 @@ private String getFullName(String currentDir, String name) 
{
                 : String.format(FORMAT_S_S, currentDir, name);
     }
 
+    private List<String> getFullNames(String currentDir, Object[] 
filesNameSet, Map<String, MultipartFile> fileMap) {

Review Comment:
   Suggest to use `String[] filesNameSet`, type is certain.



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java:
##########
@@ -24,6 +24,10 @@
 
 public final class Constants {
 
+    public static final String FILE_NAME_RESTRICTED_CONTENT= 
"file.name.restricted.content";

Review Comment:
   Please add these properties in `common.properties` and docs.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -318,6 +340,128 @@ public Result<Object> createResource(User loginUser,
         return result;
     }
 
+    /**
+     * create batch resource
+     *
+     * @param loginUser  login user
+     * @param files      files
+     * @param type       type
+     * @param pid        parent id
+     * @param currentDir current directory
+     * @return create result code
+     */
+    @Override
+    @Transactional
+    public Result<Object> createBatchResources(User loginUser,
+                                               ResourceType type,
+                                               List<MultipartFile> files,
+                                               int pid,
+                                               String currentDir) {
+        Result<Object> result = new Result<>();
+        String funcPermissionKey = type.equals(ResourceType.FILE) ? 
ApiFuncIdentificationConstant.FILE_UPLOAD
+                : ApiFuncIdentificationConstant.UDF_UPLOAD;
+        boolean canOperatorPermissions =
+                canOperatorPermissions(loginUser, null, 
AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
+        if (!canOperatorPermissions) {
+            putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
+            return result;
+        }
+        result = checkResourceUploadStartupState();
+        if (!result.getCode().equals(Status.SUCCESS.getCode())) {
+            return result;
+        }
+        result = verifyPid(loginUser, pid);
+        if (!result.getCode().equals(Status.SUCCESS.getCode())) {
+            return result;
+        }
+
+        // make sure login user has tenant
+        String tenantCode = getTenantCode(loginUser.getId(), result);
+        if (StringUtils.isEmpty(tenantCode)) {
+            return result;
+        }
+
+        result = verifyFiles(type, files);
+        if (!result.getCode().equals(Status.SUCCESS.getCode())) {
+            return result;
+        }
+        Map<String, MultipartFile> fileMap = 
files.stream().collect(Collectors.toMap(key -> key.getOriginalFilename(), value 
-> value, (isOld, isNew) -> isOld));
+
+        Object[] filesNameSet = fileMap.keySet().toArray();

Review Comment:
   Please change to `String[] filesNameSet = fileMap.keySet().toArray(new 
String[0]);`



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -655,6 +799,91 @@ private Result<Object> verifyFile(String name, 
ResourceType type, MultipartFile
         return result;
     }
 
+    private Result<Object> verifyFiles(ResourceType type, List<MultipartFile> 
files) {

Review Comment:
   Can we unify `verifyFiles` and `verifyFile`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to