You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/07/15 10:04:41 UTC
[GitHub] [dolphinscheduler] liguotian opened a new pull request, #10998: [10983][refactor] ResourcesController
liguotian opened a new pull request, #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998
refactor for api ResourcesController
#10983
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925655903
##########
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:
You can take a look at #10290.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1219428508
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [22 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [63.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1223497155
@SbloodyS Can you help to review code for PR ?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1233876932
@SbloodyS Excuse me ,but can you help approving
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r929864924
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
>
OK ,I fix it and repush, approve please
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1202266692
> > @SbloodyS i have modified the code ,please review
>
> I have fetch latest conflict commit and fix checkstyle ,please approval again 。 @SbloodyS
Done.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1202851686
> > > @SbloodyS i have modified the code ,please review
> >
> >
> > I have fetch latest conflict commit and fix checkstyle ,please approval again 。 @SbloodyS
>
> Done.
@SbloodyS sorry ,i made a UT error when fix PR conf conflict, now I fix ,please approval
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1204764669
>
OK , please let me know when branch api-refactor is checked ,then i will create a new PR. @ruanwenjun @SbloodyS @caishunfeng
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1188776100
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [19 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [36.9% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [1.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925416574
##########
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:
this POJO is use for api org.apache.dolphinscheduler.api.controller.ResourcesV2Controller#createDirectory
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1187005153
> > I had approved to run CI.
>
> it is confusing to me that i have checked by check-style plugin in my local , it also has no problem .Do you have any suggestions?
The current CI is incremental detection. Please check all files you have modified.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1191154342
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [26 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [43.6% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1186910977
I had approved to run CI.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1192180755
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [26 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [43.6% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1188771035
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [19 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [36.9% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [1.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925793413
##########
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:
> You can take a look at #10290.
I view AccessTokenV2Controller ,the class CreateTokenResponse extend Result ,but accessTokenService is also use Result , so can i just wrap the Response like that?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925417646
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
I think it's unnessnary since we are doing V2 refactoring.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925413031
##########
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:
ResourcesController is marked by Deprecated in this refactor issue 。 is that nessary to do more about this
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] caishunfeng commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
caishunfeng commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r928360276
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java:
##########
@@ -146,7 +151,7 @@ public Result<Object> createDirectory(@ApiIgnore @RequestAttribute(value = Const
@PostMapping()
@ApiException(CREATE_RESOURCE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
- public Result<Object> createResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+ public Result<org.apache.dolphinscheduler.dao.entity.Resource> createResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
Review Comment:
```suggestion
public Result<Resource> createResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
```
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesV2Controller.java:
##########
@@ -0,0 +1,770 @@
+/*
+ * 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.CreateResourceResponse;
+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.ResourceContentResponse;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceListResponse;
+import org.apache.dolphinscheduler.api.dto.resources.ResourcePageResponse;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UdfFuncListResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UdfFuncPageResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UdfFuncResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.dto.resources.UpdateResourceResponse;
+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 createDirectoryRequest create directory request
+ * @return create result code
+ */
+ @ApiOperation(value = "createDirectory", notes = "CREATE_RESOURCE_NOTES")
+ @PostMapping(value = "/directory", consumes = "application/json")
+ @ApiException(CREATE_RESOURCE_ERROR)
+ @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+ public CreateResourceResponse createDirectory(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+ @RequestBody CreateDirectoryRequest createDirectoryRequest) {
+ //todo verify the directory name
Review Comment:
It's better to put this todo into service.
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
> I think it's unnessnary since we are doing V2 refactoring.
+1, I think we don't need to copy result, because the old way is bad case, which should be optimized in the future.
##########
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:
```suggestion
public Result<Resource> createDirectory(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
```
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java:
##########
@@ -338,10 +343,10 @@ public Result<Object> queryResourceJarList(@ApiIgnore @RequestAttribute(value =
@ResponseStatus(HttpStatus.OK)
@ApiException(RESOURCE_NOT_EXIST)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
- public Result<Object> queryResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
- @RequestParam(value = "fullName", required = false) String fullName,
- @PathVariable(value = "id", required = false) Integer id,
- @RequestParam(value = "type") ResourceType type
+ public Result<org.apache.dolphinscheduler.dao.entity.Resource> queryResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r1000711697
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/UpdateResourceResponse.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.api.utils.Result;
+
+/**
+ * update resource response
+ */
+public class UpdateResourceResponse extends Result<Object> {
+
+ private Object data;
+
+ public UpdateResourceResponse(Result<Object> result) {
+ super();
+ this.setCode(result.getCode());
+ this.setMsg(result.getMsg());
+ this.setData(result.getData());
+ }
+
+ @Override
+ public Object getData() {
+ return data;
+ }
+
+ @Override
+ public void setData(Object data) {
+ this.data = data;
+ }
+}
Review Comment:
i see `ScheduleV2Controller ` refer service method with V2 。So do I have to do the same. or i just to return result object like `Result<Object>` | `Map<String,` Object>`
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207657967
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [35 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [60.1% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1214561833
@SbloodyS I have rebase the latest commits from dev ,please help to approval .
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1220189661
@SbloodyS I can see that there is still a check failed, but the status of the RP is "review required". Is this check important? How do I do it? Can you help me
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1245499868
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [2 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [1 Vulnerability](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [136 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [50.1% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [22.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1186162870
I‘m sorry to forget to add license text for new class, so I repush the code
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925415157
##########
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:
OK
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1187002727
> I had approved to run CI.
it is confusing to me that i have checked by check-style plugin in my local , it also has no problem .Do you have any suggestions?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r928375835
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesV2Controller.java:
##########
@@ -0,0 +1,770 @@
+/*
+ * 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.CreateResourceResponse;
+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.ResourceContentResponse;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceListResponse;
+import org.apache.dolphinscheduler.api.dto.resources.ResourcePageResponse;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UdfFuncListResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UdfFuncPageResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UdfFuncResponse;
+import org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.dto.resources.UpdateResourceResponse;
+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 createDirectoryRequest create directory request
+ * @return create result code
+ */
+ @ApiOperation(value = "createDirectory", notes = "CREATE_RESOURCE_NOTES")
+ @PostMapping(value = "/directory", consumes = "application/json")
+ @ApiException(CREATE_RESOURCE_ERROR)
+ @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
+ public CreateResourceResponse createDirectory(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+ @RequestBody CreateDirectoryRequest createDirectoryRequest) {
+ //todo verify the directory name
Review Comment:
this note allready exists in old version code,do you means I need move the note into service?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925419400
##########
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:
i think Result is a common result type ,so i use i with a pojo generic-type .do you means don't use Result ?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925415513
##########
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:
Sorry. What i mean is we should do this in V2.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925463136
##########
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:
This is my habit to add interface `Serializable` with pojo and add serialVersionUID, for POJO can be serialized Avoid unnecessary serialize-error。
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1191240871
>
Done
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1210132425
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [78 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [41.1% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [8.8% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1208184658
> @liguotian please split the service part and the v2 controller/entity part into two PR based on the above conclusions. Thanks.
OK ,I will reset this branch and pick this code which only contain DTO and ResourceV2Controller 。
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r952182459
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -28,6 +26,7 @@
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
Review Comment:
Yes , I understand 。 I've made the smallest and necessary change in ResourcesServiceImpl。 If we don’t do this, it will be weird when convert to DTO。 I'm not sure about this boundary according to comment https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207708303
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] EricGao888 commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
EricGao888 commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1275900284
> @EricGao888 Excuse me, Can this PR still be review 。
Of course.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10983] [refactor] ResourcesController [dolphinscheduler]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #10998: [Feature-10983] [refactor] ResourcesController
URL: https://github.com/apache/dolphinscheduler/pull/10998
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r929864924
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
>
OK ,I fix it and repush, approve please @SbloodyS
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1186806100
I have fix all check-style error with incremental code @SbloodyS
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r922661265
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
What is this used for?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925421545
##########
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:
which is unnessnary usage ? consumes OR http ? is that use for swagger
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925653317
##########
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")
Review Comment:
```suggestion
@PostMapping(value = "/directory", consumes = "application/json")
```
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r928374787
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ResourcesController.java:
##########
@@ -146,7 +151,7 @@ public Result<Object> createDirectory(@ApiIgnore @RequestAttribute(value = Const
@PostMapping()
@ApiException(CREATE_RESOURCE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
- public Result<Object> createResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+ public Result<org.apache.dolphinscheduler.dao.entity.Resource> createResource(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
Review Comment:
this Resource is duplicated with `org.springframework.core.io.Resource` in method downloadResource。 and this Controller is assigned with Deprecated。so haven’t do anything about this。
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925779653
##########
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:
> You can take a look at #10290.
Get
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1191161467
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [26 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [43.6% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1192204604
> > @SbloodyS e2e MysqlDataSource module error , I haven't change it ,is it because I pull the lastest commit ?
>
> Please merge the latest dev branch again. This problem was just fixed this afternoon.
@SbloodyS FileManageE2ETest UnitTest error . how to deal with this
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925653002
##########
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:
The `value` and `consumes` and `httpMethod` is unnessnary since swagger would automatically detect according to the interface type.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925851950
##########
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:
i have deleted Serializable And serialVersionUID
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r945399999
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -144,8 +141,10 @@ public Result<Object> createDirectory(User loginUser,
int pid,
String currentDir) {
Result<Object> result = new Result<>();
- String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE : ApiFuncIdentificationConstant.UDF_FOLDER_ONLINE_CREATE;
- boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
+ String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE
Review Comment:
Please put the modification of this file in other pr.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1219029495
@SbloodyS Can you help to approval 。it seems this RP will outdate
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1220180836
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [22 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [67.7% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1245446658
> @SbloodyS Excuse me ,but can you help approving
Sorry for late reply. I had approved to run CI.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1208984065
> @liguotian please split the service part and the v2 controller/entity part into two PR based on the above conclusions. Thanks.
> @liguotian please split the service part and the v2 controller/entity part into two PR based on the above conclusions. Thanks.
@SbloodyS this PR is just the v2 controller/entity with UT , please review 。
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207554168
> It‘s better to create a new branch e.g. api-refactor, and don't merge this kind of pr to dev, otherwise, we may need to solve many conflicts before 4.0 @SbloodyS @caishunfeng @liguotian
I'm not quite sure about it. But one thing to be considered is that if a new branch is created, its contribution will not be directly displayed in `https://github.com/apache/dolphinscheduler/graphs/contributors` when the contributor's code is merged into the new branch. cc @caishunfeng @zhongjiajie
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] codecov-commenter commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207655702
# [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/10998?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#10998](https://codecov.io/gh/apache/dolphinscheduler/pull/10998?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b32d016) into [dev](https://codecov.io/gh/apache/dolphinscheduler/commit/d9516e22360fca283e011040e1bef7a8b239cc06?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d9516e2) will **increase** coverage by `0.09%`.
> The diff coverage is `69.16%`.
```diff
@@ Coverage Diff @@
## dev #10998 +/- ##
============================================
+ Coverage 40.24% 40.33% +0.09%
- Complexity 4839 4872 +33
============================================
Files 973 983 +10
Lines 37302 37440 +138
Branches 4141 4129 -12
============================================
+ Hits 15012 15103 +91
- Misses 20749 20790 +41
- Partials 1541 1547 +6
```
| [Impacted Files](https://codecov.io/gh/apache/dolphinscheduler/pull/10998?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...nscheduler/api/dto/resources/ResourceResponse.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2R0by9yZXNvdXJjZXMvUmVzb3VyY2VSZXNwb25zZS5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...uler/api/dto/resources/UpdateResourceResponse.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2R0by9yZXNvdXJjZXMvVXBkYXRlUmVzb3VyY2VSZXNwb25zZS5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...hinscheduler/api/service/impl/BaseServiceImpl.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL3NlcnZpY2UvaW1wbC9CYXNlU2VydmljZUltcGwuamF2YQ==) | `89.79% <0.00%> (ø)` | |
| [...che/dolphinscheduler/api/python/PythonGateway.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL3B5dGhvbi9QeXRob25HYXRld2F5LmphdmE=) | `19.81% <50.00%> (ø)` | |
| [...cheduler/api/controller/ResourcesV2Controller.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2NvbnRyb2xsZXIvUmVzb3VyY2VzVjJDb250cm9sbGVyLmphdmE=) | `59.30% <59.30%> (ø)` | |
| [...heduler/api/service/impl/ResourcesServiceImpl.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL3NlcnZpY2UvaW1wbC9SZXNvdXJjZXNTZXJ2aWNlSW1wbC5qYXZh) | `51.12% <71.87%> (-0.17%)` | :arrow_down: |
| [...nscheduler/api/controller/ResourcesController.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2NvbnRyb2xsZXIvUmVzb3VyY2VzQ29udHJvbGxlci5qYXZh) | `53.19% <75.00%> (-2.58%)` | :arrow_down: |
| [...olphinscheduler/api/controller/BaseController.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2NvbnRyb2xsZXIvQmFzZUNvbnRyb2xsZXIuamF2YQ==) | `53.52% <100.00%> (ø)` | |
| [...uler/api/dto/resources/CreateResourceResponse.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2R0by9yZXNvdXJjZXMvQ3JlYXRlUmVzb3VyY2VSZXNwb25zZS5qYXZh) | `100.00% <100.00%> (ø)` | |
| [...ler/api/dto/resources/ResourceContentResponse.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvYXBpL2R0by9yZXNvdXJjZXMvUmVzb3VyY2VDb250ZW50UmVzcG9uc2UuamF2YQ==) | `100.00% <100.00%> (ø)` | |
| ... and [11 more](https://codecov.io/gh/apache/dolphinscheduler/pull/10998/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: Codecov can now indicate which changes are the most critical in Pull Requests. [Learn more](https://about.codecov.io/product/feature/runtime-insights/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207661050
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [35 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [60.1% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1202044252
> @SbloodyS i have modified the code ,please review
I have fetch latest conflict commit and fix checkstyle ,please approval again 。 @SbloodyS
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] caishunfeng commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
caishunfeng commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207646526
> > > It‘s better to create a new branch e.g. api-refactor, and don't merge this kind of pr to dev, otherwise, we may need to solve many conflicts before 4.0 @SbloodyS @caishunfeng @liguotian
> >
> >
> > I find this patch almost adds new files and only changes the existing file `ResourcesController`, so it can be cherry-picked without not to many conflicts, So I think we can be merge into dev branch, I think I think the one need to create a new branch to keep code it significant change not compatible with the current code/function(maybe part of DSIP or foundation), and we didn't want to release it int the next released
>
> AFAIK, the PR related to this issue #10257 will be released at 4.0 :), and most of these might be incompatible.
In my opinion, it should be merged in dev, which is always the latest branch. The question is to reduce the cherry-pick cost with less conflicts, what about spliting the pr into two parts, one is the service logic,another is the v2 controller and dto? When cherry-pick, we just cp the first one part without v2 controller logic. WDYT?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1210132738
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [78 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [41.2% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [8.8% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925850777
##########
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")
Review Comment:
Get And fix
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1192181824
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [26 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [43.6% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1187112725
>
OK, it seems that check-style plugin skip the Test package
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925425596
##########
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:
Yes.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r928376625
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
yes ,i agree with you .but i just don't kown how to do with it for now,using get/set ?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1191171774
@SbloodyS e2e MysqlDataSource module error , I haven't change it ,is it because I pull the lastest commit ?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1219029814
@SbloodyS Can you help to approval 。it seems this PR will outdate
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1220160798
> > > @SbloodyS Can you help to approval 。it seems this PR will outdate
> >
> >
> > I had approved to run CI.
>
> @SbloodyS Sorry ,I had e a mistake in code. now i had fix it .i find i can run action in my repo to check ALL UNIT Test , now i had run action in my own forked repo and they all success, please approved again . I'm sorry for the trouble
It's alright. I had rerun the CI.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1275890879
@EricGao888 Excuse me, Can this PR still be review 。
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r926335253
##########
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:
> I view AccessTokenV2Controller ,the class CreateTokenResponse extend Result ,but accessTokenService is also use Result , so can i just wrap the Response like that?
Yes. In order to be compatible with old and new apis and reduce modification costs.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1190051369
@caishunfeng will you please help to review code
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925657884
##########
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:
I'm not quite sure whether we should do this. PTAL @ruanwenjun @caishunfeng
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925427374
##########
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 i mean is `serialVersionUID`.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] ruanwenjun commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207585087
> > It‘s better to create a new branch e.g. api-refactor, and don't merge this kind of pr to dev, otherwise, we may need to solve many conflicts before 4.0 @SbloodyS @caishunfeng @liguotian
>
> I find this patch almost adds new files and only changes the existing file `ResourcesController`, so it can be cherry-picked without not to many conflicts, So I think we can be merge into dev branch, I think I think the one need to create a new branch to keep code it significant change not compatible with the current code/function(maybe part of DSIP or foundation), and we didn't want to release it int the next released
AFAIK, the PR related to this issue #10257 will be released at 4.0 :), and most of these might be incompatible.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1210158443
@SbloodyS it seem error in e2e Unit Test module,and there exists TaskTimeoutStateEventHandler whice has no edit in this RP
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r952128123
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -28,6 +26,7 @@
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
Review Comment:
Please split this part into other PR.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1245499078
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [2 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [1 Vulnerability](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [136 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [50.1% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [22.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r925472213
##########
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:
Sorry i am puzzled,if we don't use Result ,it will increase large POJO ,and some api just need a simple result such as `{"code": 0 ,"msg":""}` , and how to keep the format of response the same , do you have a success PR for reference?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r945415184
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -144,8 +141,10 @@ public Result<Object> createDirectory(User loginUser,
int pid,
String currentDir) {
Result<Object> result = new Result<>();
- String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE : ApiFuncIdentificationConstant.UDF_FOLDER_ONLINE_CREATE;
- boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
+ String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE
Review Comment:
OK , It seam the code is no different ,except a wraping ine
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1220155224
> > @SbloodyS Can you help to approval 。it seems this PR will outdate
>
> I had approved to run CI.
@SbloodyS Sorry ,I had e a mistake in code. now i had fix it .i find i can run action in my repo to check ALL UNIT Test , now
i had run action in my own forked repo and they all success, please approved again . I'm sorry for the trouble
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r922670042
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
I use this for copy msg Result from one service-method to another Result,because i think the result should declare generic type ,but we usually have different generic type ,and the msg is must delived by result ,the code below show this,
```java
Result<Resource> result = new Result<>();
........
.......
Result<Object> verifyPidResult = verifyPid(loginUser, pid);
if (!verifyPidResult.getCode().equals(Status.SUCCESS.getCode())) {
copyMsg(verifyPidResult, result);
return result;
}
```
of course i can set /get code and msg in every time
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r929753760
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
> @SbloodyS @caishunfeng so what i should do is delete copy method and use get/set ? right ?
Yes.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r929614827
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
@SbloodyS @caishunfeng so what i should do is delete copy method and use get/set ? right ?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r952154073
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -28,6 +26,7 @@
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
Review Comment:
do you means we should not to modify `ResourcesServiceImpl` ?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1257540742
@SbloodyS can you please review code ?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] EricGao888 commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
EricGao888 commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1257545523
> > @SbloodyS can you please review code ?
>
> Sorry for late reply. I can't spare time these days. Do you have time to take a look at this PR? Thanks. @EricGao888 @caishunfeng @zhongjiajie @ruanwenjun @zhuangchong
Sure, I will help with the review : )
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1257543571
> @SbloodyS can you please review code ?
Sorry for late reply. I can't spare time these days. Do you have time to take a look at this PR? Thanks. @EricGao888 @caishunfeng @zhongjiajie @ruanwenjun @zhuangchong
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1246186284
> > @SbloodyS Excuse me ,but can you help approving
>
> Sorry for late reply. I had approved to run CI.
It’s no matter。can you help CR。
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1219429499
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10998)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL) [22 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10998&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list) [63.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10998&metric=new_duplicated_lines_density&view=list)
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1220164396
> > > > @SbloodyS Can you help to approval 。it seems this PR will outdate
> > >
> > >
> > > I had approved to run CI.
> >
> >
> > @SbloodyS Sorry ,I had e a mistake in code. now i had fix it .i find i can run action in my repo to check ALL UNIT Test , now i had run action in my own forked repo and they all success, please approved again . I'm sorry for the trouble
>
> It's alright. I had rerun the CI.
Thanks!
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r955935816
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -28,6 +26,7 @@
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
Review Comment:
@SbloodyS I have split ,please approve
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] ruanwenjun commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1203999000
It‘s better to create a new branch e.g. api-refactor, and don't merge this kind of pr to dev, otherwise, we may need to solve many conflicts before 4.0 @SbloodyS @caishunfeng @liguotian
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10983] [refactor] ResourcesController [dolphinscheduler]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1811600675
This pull request has been closed because it has not had recent activity. You could reopen it if you try to continue your work, and anyone who are interested in it are encouraged to continue work on this pull request.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207565161
> It‘s better to create a new branch e.g. api-refactor, and don't merge this kind of pr to dev, otherwise, we may need to solve many conflicts before 4.0 @SbloodyS @caishunfeng @liguotian
I find this patch almost adds new files and only changes the existing file `ResourcesController`, so it can be cherry-picked without not to many conflicts, So I think we can be merge into dev branch, I think I think the one need to create a new branch to keep code it significant change not compatible with the current code/function(maybe part of DSIP or foundation), and we didn't want to release it int the next released
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207717203
@liguotian please split the service part and the v2 controller/entity part into two PR based on the above conclusions.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] ruanwenjun commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207708303
> > > > It‘s better to create a new branch e.g. api-refactor, and don't merge this kind of pr to dev, otherwise, we may need to solve many conflicts before 4.0 @SbloodyS @caishunfeng @liguotian
> > >
> > >
> > > I find this patch almost adds new files and only changes the existing file `ResourcesController`, so it can be cherry-picked without not to many conflicts, So I think we can be merge into dev branch, I think I think the one need to create a new branch to keep code it significant change not compatible with the current code/function(maybe part of DSIP or foundation), and we didn't want to release it int the next released
> >
> >
> > AFAIK, the PR related to this issue #10257 will be released at 4.0 :), and most of these might be incompatible.
>
> In my opinion, it should be merged in dev, which is always the latest branch. The question is to reduce the cherry-pick cost with less conflicts, what about spliting the pr into two parts, one is the service logic,another is the v2 controller and dto? When cherry-pick, we just cp the first one part without v2 controller logic. WDYT?
LGTM, the change about service can be released in 3.x.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1188575138
> > > I had approved to run CI.
> >
> >
> > it is confusing to me that i have checked by check-style plugin in my local , it also has no problem .Do you have any suggestions?
>
> The current CI is incremental detection. Please check all files you have modified.
I try to fix check-style error ,please help to approve it
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1185393768
I have reactor the code and supplement UnitTest。but when i mvn package in my compute ,there has some stylecheck error like `ImportOrder` in java where i haven't edit.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature-10983] [refactor] ResourcesController [dolphinscheduler]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1797071727
This pull request has been automatically marked as stale because it has not had recent activity for 120 days. It will be closed in 7 days if no further activity occurs.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r1000231298
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/resources/UpdateResourceResponse.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.api.utils.Result;
+
+/**
+ * update resource response
+ */
+public class UpdateResourceResponse extends Result<Object> {
+
+ private Object data;
+
+ public UpdateResourceResponse(Result<Object> result) {
+ super();
+ this.setCode(result.getCode());
+ this.setMsg(result.getMsg());
+ this.setData(result.getData());
+ }
+
+ @Override
+ public Object getData() {
+ return data;
+ }
+
+ @Override
+ public void setData(Object data) {
+ this.data = data;
+ }
+}
Review Comment:
about all the response, is an other Result object, maybe we can directly use result object, we already have some example, you can see `ScheduleV2Controller` as example
##########
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ResourcesV2ControllerTest.java:
##########
@@ -0,0 +1,485 @@
+/*
+ * 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.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import org.apache.dolphinscheduler.api.dto.resources.CreateResourceRequest;
+import org.apache.dolphinscheduler.api.dto.resources.CreateUdfRequest;
+import org.apache.dolphinscheduler.api.dto.resources.UpdateResourceContentRequest;
+import org.apache.dolphinscheduler.api.enums.Status;
+import org.apache.dolphinscheduler.api.service.ResourcesService;
+import org.apache.dolphinscheduler.api.service.UdfFuncService;
+import org.apache.dolphinscheduler.api.utils.Result;
+import org.apache.dolphinscheduler.common.enums.UdfType;
+import org.apache.dolphinscheduler.common.utils.JSONUtils;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
Review Comment:
please upgrade to Junit5, you can see exists tests in our codebase
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1191184679
> @SbloodyS e2e MysqlDataSource module error , I haven't change it ,is it because I pull the lastest commit ?
Please merge the latest dev branch again. This problem was just fixed this afternoon.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r928377959
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
> yes ,i agree with you .but i just don't kown how to do with it for now,using get/set ?
You can take a look at `org.apache.dolphinscheduler.api.controller.AccessTokenV2Controller`.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1198813935
@SbloodyS i have modified the code ,please review
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [10983][refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r928393148
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java:
##########
@@ -76,6 +76,14 @@ public interface BaseService {
*/
void putMsg(Result<Object> result, Status status, Object... statusParams);
+ /**
+ * copy result msg from source to target
+ *
+ * @param source source result
+ * @param target target result
+ */
+ void copyMsg(Result source, Result target);
+
Review Comment:
i see, but it's different , AccessTokenServiceImpl don't use The generic-type, and it is too simple, just use putMsg。
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r945429633
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -144,8 +141,10 @@ public Result<Object> createDirectory(User loginUser,
int pid,
String currentDir) {
Result<Object> result = new Result<>();
- String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE : ApiFuncIdentificationConstant.UDF_FOLDER_ONLINE_CREATE;
- boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
+ String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE
Review Comment:
OK ,DONE IT 。
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] liguotian commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
liguotian commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r945415184
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -144,8 +141,10 @@ public Result<Object> createDirectory(User loginUser,
int pid,
String currentDir) {
Result<Object> result = new Result<>();
- String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE : ApiFuncIdentificationConstant.UDF_FOLDER_ONLINE_CREATE;
- boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
+ String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE
Review Comment:
OK , It seam the code is no different ,except a wraping ine
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1219297426
> @SbloodyS Can you help to approval 。it seems this PR will outdate
I had approved to run CI.
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10998: [Feature-10983] [refactor] ResourcesController
Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10998:
URL: https://github.com/apache/dolphinscheduler/pull/10998#discussion_r952173112
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java:
##########
@@ -28,6 +26,7 @@
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
+import org.apache.dolphinscheduler.api.dto.resources.ResourceContent;
Review Comment:
We should split it according to the comment https://github.com/apache/dolphinscheduler/pull/10998#issuecomment-1207708303
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org