SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925395808


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesV2Controller.java:
##########
@@ -0,0 +1,802 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_FILE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZE_RESOURCE_TREE;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DOWNLOAD_RESOURCE_FILE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.EDIT_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_DATASOURCE_BY_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_PAGING;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_UDF_FUNCTION_LIST_PAGING_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.RESOURCE_FILE_IS_EMPTY;
+import static org.apache.dolphinscheduler.api.enums.Status.RESOURCE_NOT_EXIST;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_UDF_FUNCTION_NAME_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_UDF_FUNCTION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.resources.CreateDirectoryRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateResourceRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateUdfRequest;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
+import 
org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ResourcesService;
+import org.apache.dolphinscheduler.api.service.UdfFuncService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ProgramType;
+import org.apache.dolphinscheduler.common.enums.UdfType;
+import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.dao.entity.Resource;
+import org.apache.dolphinscheduler.dao.entity.UdfFunc;
+import org.apache.dolphinscheduler.dao.entity.User;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import springfox.documentation.annotations.ApiIgnore;
+
+
+
+/**
+ * resources controller
+ */
+@Api(tags = "RESOURCES_TAG")
+@RestController
+@RequestMapping("/v2/resources")
+public class ResourcesV2Controller extends BaseController {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ResourcesV2Controller.class);
+
+    @Autowired
+    private ResourcesService resourceService;
+    @Autowired
+    private UdfFuncService udfFuncService;
+
+    /**
+     * create resource director
+     *
+     * @param loginUser        login user
+     * @param directoryRequest create directory request
+     * @return create result code
+     */
+    @ApiOperation(value = "createDirectory",
+        notes = "CREATE_RESOURCE_NOTES",
+        consumes = "application/json",
+        httpMethod = "POST")

Review Comment:
   Please remove unnessnary usage.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java:
##########
@@ -119,7 +124,7 @@ public class ResourcesController extends BaseController {
     @PostMapping(value = "/directory")
     @ApiException(CREATE_RESOURCE_ERROR)
     @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
-    public Result<Object> createDirectory(@ApiIgnore @RequestAttribute(value = 
Constants.SESSION_USER) User loginUser,
+    public Result<org.apache.dolphinscheduler.dao.entity.Resource> 
createDirectory(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) 
User loginUser,

Review Comment:
   It's better to use a pojo for each api. 



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesV2Controller.java:
##########
@@ -0,0 +1,802 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_FILE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZE_RESOURCE_TREE;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DOWNLOAD_RESOURCE_FILE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.EDIT_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_DATASOURCE_BY_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_PAGING;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_UDF_FUNCTION_LIST_PAGING_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.RESOURCE_FILE_IS_EMPTY;
+import static org.apache.dolphinscheduler.api.enums.Status.RESOURCE_NOT_EXIST;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_UDF_FUNCTION_NAME_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_UDF_FUNCTION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.resources.CreateDirectoryRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateResourceRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateUdfRequest;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
+import 
org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ResourcesService;
+import org.apache.dolphinscheduler.api.service.UdfFuncService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ProgramType;
+import org.apache.dolphinscheduler.common.enums.UdfType;
+import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.dao.entity.Resource;
+import org.apache.dolphinscheduler.dao.entity.UdfFunc;
+import org.apache.dolphinscheduler.dao.entity.User;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import springfox.documentation.annotations.ApiIgnore;
+
+
+
+/**
+ * resources controller
+ */
+@Api(tags = "RESOURCES_TAG")
+@RestController
+@RequestMapping("/v2/resources")
+public class ResourcesV2Controller extends BaseController {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ResourcesV2Controller.class);
+
+    @Autowired
+    private ResourcesService resourceService;
+    @Autowired
+    private UdfFuncService udfFuncService;
+
+    /**
+     * create resource director
+     *
+     * @param loginUser        login user
+     * @param directoryRequest create directory request
+     * @return create result code
+     */
+    @ApiOperation(value = "createDirectory",
+        notes = "CREATE_RESOURCE_NOTES",
+        consumes = "application/json",
+        httpMethod = "POST")
+    @PostMapping(value = "/directory")
+    @ApiException(CREATE_RESOURCE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result<Resource> createDirectory(@ApiIgnore @RequestAttribute(value 
= Constants.SESSION_USER) User loginUser,

Review Comment:
   It's better to use a pojo instead of this.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesV2Controller.java:
##########
@@ -0,0 +1,802 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_FILE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZE_RESOURCE_TREE;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DOWNLOAD_RESOURCE_FILE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.EDIT_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_DATASOURCE_BY_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_PAGING;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_UDF_FUNCTION_LIST_PAGING_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.RESOURCE_FILE_IS_EMPTY;
+import static org.apache.dolphinscheduler.api.enums.Status.RESOURCE_NOT_EXIST;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_UDF_FUNCTION_NAME_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_UDF_FUNCTION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.resources.CreateDirectoryRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateResourceRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateUdfRequest;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
+import 
org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ResourcesService;
+import org.apache.dolphinscheduler.api.service.UdfFuncService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ProgramType;
+import org.apache.dolphinscheduler.common.enums.UdfType;
+import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.dao.entity.Resource;
+import org.apache.dolphinscheduler.dao.entity.UdfFunc;
+import org.apache.dolphinscheduler.dao.entity.User;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import springfox.documentation.annotations.ApiIgnore;
+
+
+
+/**
+ * resources controller
+ */
+@Api(tags = "RESOURCES_TAG")
+@RestController
+@RequestMapping("/v2/resources")
+public class ResourcesV2Controller extends BaseController {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ResourcesV2Controller.class);
+
+    @Autowired
+    private ResourcesService resourceService;
+    @Autowired
+    private UdfFuncService udfFuncService;
+
+    /**
+     * create resource director
+     *
+     * @param loginUser        login user
+     * @param directoryRequest create directory request
+     * @return create result code
+     */
+    @ApiOperation(value = "createDirectory",
+        notes = "CREATE_RESOURCE_NOTES",
+        consumes = "application/json",
+        httpMethod = "POST")
+    @PostMapping(value = "/directory")
+    @ApiException(CREATE_RESOURCE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result<Resource> createDirectory(@ApiIgnore @RequestAttribute(value 
= Constants.SESSION_USER) User loginUser,
+                                            @RequestBody 
CreateDirectoryRequest directoryRequest) {

Review Comment:
   ```suggestion
                                               @RequestBody 
CreateDirectoryRequest createDirectoryRequest) {
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesV2Controller.java:
##########
@@ -0,0 +1,802 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_FILE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZE_RESOURCE_TREE;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DOWNLOAD_RESOURCE_FILE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.EDIT_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_DATASOURCE_BY_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_PAGING;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_UDF_FUNCTION_LIST_PAGING_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.RESOURCE_FILE_IS_EMPTY;
+import static org.apache.dolphinscheduler.api.enums.Status.RESOURCE_NOT_EXIST;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_UDF_FUNCTION_NAME_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_UDF_FUNCTION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.resources.CreateDirectoryRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateResourceRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateUdfRequest;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
+import 
org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ResourcesService;
+import org.apache.dolphinscheduler.api.service.UdfFuncService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ProgramType;
+import org.apache.dolphinscheduler.common.enums.UdfType;
+import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.dao.entity.Resource;
+import org.apache.dolphinscheduler.dao.entity.UdfFunc;
+import org.apache.dolphinscheduler.dao.entity.User;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import springfox.documentation.annotations.ApiIgnore;
+
+
+
+/**
+ * resources controller
+ */
+@Api(tags = "RESOURCES_TAG")
+@RestController
+@RequestMapping("/v2/resources")
+public class ResourcesV2Controller extends BaseController {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ResourcesV2Controller.class);
+
+    @Autowired
+    private ResourcesService resourceService;
+    @Autowired
+    private UdfFuncService udfFuncService;
+
+    /**
+     * create resource director
+     *
+     * @param loginUser        login user
+     * @param directoryRequest create directory request
+     * @return create result code
+     */
+    @ApiOperation(value = "createDirectory",
+        notes = "CREATE_RESOURCE_NOTES",
+        consumes = "application/json",
+        httpMethod = "POST")
+    @PostMapping(value = "/directory")
+    @ApiException(CREATE_RESOURCE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result<Resource> createDirectory(@ApiIgnore @RequestAttribute(value 
= Constants.SESSION_USER) User loginUser,
+                                            @RequestBody 
CreateDirectoryRequest directoryRequest) {
+        //todo verify the directory name
+        return resourceService.createDirectory(loginUser,
+            directoryRequest.getName(),
+            directoryRequest.getDescription(),
+            directoryRequest.getType(),
+            directoryRequest.getPid(),
+            directoryRequest.getCurrentDir());
+    }
+
+    /**
+     * update resource
+     *
+     * @param loginUser   login user
+     * @param name        alias
+     * @param type        resource type
+     * @param description description
+     * @param file        resource file
+     * @param pid         pid
+     * @param currentDir  currentDir
+     * @return update result code
+     */
+    @ApiOperation(value = "createResource",
+        notes = "CREATE_RESOURCE_NOTES",
+        consumes = "application/x-www-form-urlencoded",
+        httpMethod = "POST")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = 
true, dataType = "ResourceType", example = "FILE,UDF"),
+        @ApiImplicitParam(name = "name", value = "RESOURCE_NAME", required = 
true, dataType = "String", example = "startupShell"),
+        @ApiImplicitParam(name = "description", value = "RESOURCE_DESC", 
dataType = "String", example = "startupShell is description"),
+        @ApiImplicitParam(name = "file", value = "RESOURCE_FILE", required = 
true, dataType = "MultipartFile"),
+        @ApiImplicitParam(name = "pid", value = "RESOURCE_PID", required = 
true, dataType = "Int", example = "10"),
+        @ApiImplicitParam(name = "currentDir", value = "RESOURCE_CURRENT_DIR", 
required = true, dataType = "String")
+    })
+    @PostMapping()
+    @ApiException(CREATE_RESOURCE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result<Resource> createResource(@ApiIgnore @RequestAttribute(value 
= Constants.SESSION_USER) User loginUser,
+                                           @RequestParam(value = "type") 
ResourceType type,
+                                           @RequestParam(value = "name") 
String name,
+                                           @RequestParam(value = 
"description", required = false) String description,
+                                           @RequestParam("file") MultipartFile 
file,
+                                           @RequestParam(value = "pid") int 
pid,
+                                           @RequestParam(value = "currentDir") 
String currentDir) {
+        //todo  verify the file name
+        return resourceService.createResource(loginUser, name, description, 
type, file, pid, currentDir);
+    }
+
+    /**
+     * update resource
+     *
+     * @param loginUser   login user
+     * @param name        alias
+     * @param resourceId  resource id
+     * @param type        resource type
+     * @param description description
+     * @param file        resource file
+     * @return update result code
+     */
+    @ApiOperation(value = "updateResource",
+        notes = "UPDATE_RESOURCE_NOTES",
+        consumes = "application/x-www-form-urlencoded",
+        httpMethod = "POST")

Review Comment:
   Same here.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/CreateDirectoryRequest.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.dto.resources;
+
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import java.io.Serializable;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * create directory request
+ */
+@Data
+@ApiModel(value = "CREATE_RESOURCE_NOTES")
+public class CreateDirectoryRequest implements Serializable {
+
+    private static final long serialVersionUID = 2158023425391177729L;

Review Comment:
   What is the purpose of this?



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesV2Controller.java:
##########
@@ -0,0 +1,802 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_FILE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZE_RESOURCE_TREE;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DOWNLOAD_RESOURCE_FILE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.EDIT_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_DATASOURCE_BY_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_PAGING;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_UDF_FUNCTION_LIST_PAGING_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.RESOURCE_FILE_IS_EMPTY;
+import static org.apache.dolphinscheduler.api.enums.Status.RESOURCE_NOT_EXIST;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_UDF_FUNCTION_NAME_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_UDF_FUNCTION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.resources.CreateDirectoryRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateResourceRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateUdfRequest;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
+import 
org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ResourcesService;
+import org.apache.dolphinscheduler.api.service.UdfFuncService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ProgramType;
+import org.apache.dolphinscheduler.common.enums.UdfType;
+import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.dao.entity.Resource;
+import org.apache.dolphinscheduler.dao.entity.UdfFunc;
+import org.apache.dolphinscheduler.dao.entity.User;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import springfox.documentation.annotations.ApiIgnore;
+
+
+
+/**
+ * resources controller
+ */
+@Api(tags = "RESOURCES_TAG")
+@RestController
+@RequestMapping("/v2/resources")
+public class ResourcesV2Controller extends BaseController {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ResourcesV2Controller.class);
+
+    @Autowired
+    private ResourcesService resourceService;
+    @Autowired
+    private UdfFuncService udfFuncService;
+
+    /**
+     * create resource director
+     *
+     * @param loginUser        login user
+     * @param directoryRequest create directory request
+     * @return create result code
+     */
+    @ApiOperation(value = "createDirectory",
+        notes = "CREATE_RESOURCE_NOTES",
+        consumes = "application/json",
+        httpMethod = "POST")
+    @PostMapping(value = "/directory")
+    @ApiException(CREATE_RESOURCE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result<Resource> createDirectory(@ApiIgnore @RequestAttribute(value 
= Constants.SESSION_USER) User loginUser,
+                                            @RequestBody 
CreateDirectoryRequest directoryRequest) {
+        //todo verify the directory name
+        return resourceService.createDirectory(loginUser,
+            directoryRequest.getName(),
+            directoryRequest.getDescription(),
+            directoryRequest.getType(),
+            directoryRequest.getPid(),
+            directoryRequest.getCurrentDir());
+    }
+
+    /**
+     * update resource
+     *
+     * @param loginUser   login user
+     * @param name        alias
+     * @param type        resource type
+     * @param description description
+     * @param file        resource file
+     * @param pid         pid
+     * @param currentDir  currentDir
+     * @return update result code
+     */
+    @ApiOperation(value = "createResource",
+        notes = "CREATE_RESOURCE_NOTES",
+        consumes = "application/x-www-form-urlencoded",
+        httpMethod = "POST")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = 
true, dataType = "ResourceType", example = "FILE,UDF"),
+        @ApiImplicitParam(name = "name", value = "RESOURCE_NAME", required = 
true, dataType = "String", example = "startupShell"),
+        @ApiImplicitParam(name = "description", value = "RESOURCE_DESC", 
dataType = "String", example = "startupShell is description"),
+        @ApiImplicitParam(name = "file", value = "RESOURCE_FILE", required = 
true, dataType = "MultipartFile"),
+        @ApiImplicitParam(name = "pid", value = "RESOURCE_PID", required = 
true, dataType = "Int", example = "10"),
+        @ApiImplicitParam(name = "currentDir", value = "RESOURCE_CURRENT_DIR", 
required = true, dataType = "String")
+    })
+    @PostMapping()
+    @ApiException(CREATE_RESOURCE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result<Resource> createResource(@ApiIgnore @RequestAttribute(value 
= Constants.SESSION_USER) User loginUser,
+                                           @RequestParam(value = "type") 
ResourceType type,
+                                           @RequestParam(value = "name") 
String name,
+                                           @RequestParam(value = 
"description", required = false) String description,
+                                           @RequestParam("file") MultipartFile 
file,
+                                           @RequestParam(value = "pid") int 
pid,
+                                           @RequestParam(value = "currentDir") 
String currentDir) {
+        //todo  verify the file name
+        return resourceService.createResource(loginUser, name, description, 
type, file, pid, currentDir);
+    }
+
+    /**
+     * update resource
+     *
+     * @param loginUser   login user
+     * @param name        alias
+     * @param resourceId  resource id
+     * @param type        resource type
+     * @param description description
+     * @param file        resource file
+     * @return update result code
+     */
+    @ApiOperation(value = "updateResource",
+        notes = "UPDATE_RESOURCE_NOTES",
+        consumes = "application/x-www-form-urlencoded",
+        httpMethod = "POST")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "id", value = "RESOURCE_ID", required = true, 
dataType = "Int", example = "100"),
+        @ApiImplicitParam(name = "type", value = "RESOURCE_TYPE", required = 
true, dataType = "ResourceType", example = "FILE,UDF"),
+        @ApiImplicitParam(name = "name", value = "RESOURCE_NAME", required = 
true, dataType = "String", example = "startupShell"),
+        @ApiImplicitParam(name = "description", value = "RESOURCE_DESC", 
dataType = "String", example = "startupShell is description"),
+        @ApiImplicitParam(name = "file", value = "RESOURCE_FILE", required = 
true, dataType = "MultipartFile")
+    })
+    @PutMapping(value = "/{id}")
+    @ApiException(UPDATE_RESOURCE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result<Resource> updateResource(@ApiIgnore @RequestAttribute(value 
= Constants.SESSION_USER) User loginUser,
+                                           @PathVariable(value = "id") int 
resourceId,
+                                           @RequestParam(value = "type") 
ResourceType type,
+                                           @RequestParam(value = "name") 
String name,
+                                           @RequestParam(value = 
"description", required = false) String description,
+                                           @RequestParam(value = "file", 
required = false) MultipartFile file) {
+        //todo verify the resource name
+        return resourceService.updateResource(loginUser, resourceId, name, 
description, type, file);
+    }
+
+    /**
+     * query resources list
+     *
+     * @param loginUser login user
+     * @param type      resource type
+     * @return resource list
+     */
+    @ApiOperation(value = "queryResourceList",
+        notes = "QUERY_RESOURCE_LIST_NOTES",
+        httpMethod = "GET")

Review Comment:
   Same here.



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesV2Controller.java:
##########
@@ -0,0 +1,802 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.api.controller;
+
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_FILE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.AUTHORIZE_RESOURCE_TREE;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.CREATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DELETE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.DOWNLOAD_RESOURCE_FILE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.EDIT_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_DATASOURCE_BY_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_RESOURCES_LIST_PAGING;
+import static 
org.apache.dolphinscheduler.api.enums.Status.QUERY_UDF_FUNCTION_LIST_PAGING_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.RESOURCE_FILE_IS_EMPTY;
+import static org.apache.dolphinscheduler.api.enums.Status.RESOURCE_NOT_EXIST;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_RESOURCE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.UPDATE_UDF_FUNCTION_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_RESOURCE_BY_NAME_AND_TYPE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VERIFY_UDF_FUNCTION_NAME_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_RESOURCE_FILE_ON_LINE_ERROR;
+import static 
org.apache.dolphinscheduler.api.enums.Status.VIEW_UDF_FUNCTION_ERROR;
+
+import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
+import org.apache.dolphinscheduler.api.dto.resources.CreateDirectoryRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateResourceRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateUdfRequest;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
+import 
org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.exceptions.ApiException;
+import org.apache.dolphinscheduler.api.service.ResourcesService;
+import org.apache.dolphinscheduler.api.service.UdfFuncService;
+import org.apache.dolphinscheduler.api.utils.PageInfo;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ProgramType;
+import org.apache.dolphinscheduler.common.enums.UdfType;
+import org.apache.dolphinscheduler.common.utils.ParameterUtils;
+import org.apache.dolphinscheduler.dao.entity.Resource;
+import org.apache.dolphinscheduler.dao.entity.UdfFunc;
+import org.apache.dolphinscheduler.dao.entity.User;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestAttribute;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import springfox.documentation.annotations.ApiIgnore;
+
+
+
+/**
+ * resources controller
+ */
+@Api(tags = "RESOURCES_TAG")
+@RestController
+@RequestMapping("/v2/resources")
+public class ResourcesV2Controller extends BaseController {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ResourcesV2Controller.class);
+
+    @Autowired
+    private ResourcesService resourceService;
+    @Autowired
+    private UdfFuncService udfFuncService;
+
+    /**
+     * create resource director
+     *
+     * @param loginUser        login user
+     * @param directoryRequest create directory request
+     * @return create result code
+     */
+    @ApiOperation(value = "createDirectory",
+        notes = "CREATE_RESOURCE_NOTES",
+        consumes = "application/json",
+        httpMethod = "POST")
+    @PostMapping(value = "/directory")
+    @ApiException(CREATE_RESOURCE_ERROR)
+    @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+    public Result<Resource> createDirectory(@ApiIgnore @RequestAttribute(value 
= Constants.SESSION_USER) User loginUser,
+                                            @RequestBody 
CreateDirectoryRequest directoryRequest) {
+        //todo verify the directory name
+        return resourceService.createDirectory(loginUser,
+            directoryRequest.getName(),
+            directoryRequest.getDescription(),
+            directoryRequest.getType(),
+            directoryRequest.getPid(),
+            directoryRequest.getCurrentDir());
+    }
+
+    /**
+     * update resource
+     *
+     * @param loginUser   login user
+     * @param name        alias
+     * @param type        resource type
+     * @param description description
+     * @param file        resource file
+     * @param pid         pid
+     * @param currentDir  currentDir
+     * @return update result code
+     */
+    @ApiOperation(value = "createResource",
+        notes = "CREATE_RESOURCE_NOTES",
+        consumes = "application/x-www-form-urlencoded",
+        httpMethod = "POST")

Review Comment:
   Same here.



-- 
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