status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
} else if (project.getUserId() != user.getId()) { ProjectUser projectUser = projectUserMapper.queryProjectRelation(project.getId(), user.getId()); if (projectUser == null) { grantProjectToUser(project, user); } } } public Tenant createTenant(String tenantCode, String desc, String queueName) { return tenantService.createTenantIfNotExists(tenantCode, desc, queueName, queueName); } public void createUser(String userName, String userPassword, String email, String phone, String tenantCode, String queue, int state) { User user = usersService.queryUser(userName); if (Objects.isNull(user)) { Map<String, Object> tenantResult = tenantService.queryByTenantCode(tenantCode); Tenant tenant = (Tenant) tenantResult.get(Constants.DATA_LIST); usersService.createUser(userName, userPassword, email, tenant.getId(), phone, queue, state); } } /** * Get datasource by given datasource name. It return map contain datasource id, type, name. * Useful in Python API create sql task which need datasource information. * * @param datasourceName user who create or update schedule */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
public Map<String, Object> getDatasourceInfo(String datasourceName) { Map<String, Object> result = new HashMap<>(); List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(datasourceName); if (dataSourceList == null || dataSourceList.isEmpty()) { String msg = String.format("Can not find any datasource by name %s", datasourceName); logger.error(msg); throw new IllegalArgumentException(msg); } else if (dataSourceList.size() > 1) { String msg = String.format("Get more than one datasource by name %s", datasourceName); logger.error(msg); throw new IllegalArgumentException(msg); } else { DataSource dataSource = dataSourceList.get(0); result.put("id", dataSource.getId()); result.put("type", dataSource.getType().name()); result.put("name", dataSource.getName()); } return result; } /** * Get processDefinition by given processDefinitionName name. It return map contain processDefinition id, name, code. * Useful in Python API create subProcess task which need processDefinition information. * * @param userName user who create or update schedule * @param projectName project name which process definition belongs to * @param processDefinitionName process definition name */ public Map<String, Object> getProcessDefinitionInfo(String userName, String projectName, String processDefinitionName) { Map<String, Object> result = new HashMap<>(); User user = usersService.queryUser(userName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
Project project = (Project) projectService.queryByName(user, projectName).get(Constants.DATA_LIST); long projectCode = project.getCode(); ProcessDefinition processDefinition = getProcessDefinition(user, projectCode, processDefinitionName); if (processDefinition != null) { processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinition.getCode(), ReleaseState.ONLINE); result.put("id", processDefinition.getId()); result.put("name", processDefinition.getName()); result.put("code", processDefinition.getCode()); } else { String msg = String.format("Can not find valid process definition by name %s", processDefinitionName); logger.error(msg); throw new IllegalArgumentException(msg); } return result; } /** * Get project, process definition, task code. * Useful in Python API create dependent task which need processDefinition information. * * @param projectName project name which process definition belongs to * @param processDefinitionName process definition name * @param taskName task name */ public Map<String, Object> getDependentInfo(String projectName, String processDefinitionName, String taskName) { Map<String, Object> result = new HashMap<>(); Project project = projectMapper.queryByName(projectName); if (project == null) { String msg = String.format("Can not find valid project by name %s", projectName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
logger.error(msg); throw new IllegalArgumentException(msg); } long projectCode = project.getCode(); result.put("projectCode", projectCode); ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(projectCode, processDefinitionName); if (processDefinition == null) { String msg = String.format("Can not find valid process definition by name %s", processDefinitionName); logger.error(msg); throw new IllegalArgumentException(msg); } result.put("processDefinitionCode", processDefinition.getCode()); if (taskName != null) { TaskDefinition taskDefinition = taskDefinitionMapper.queryByName(projectCode, processDefinition.getCode(), taskName); result.put("taskDefinitionCode", taskDefinition.getCode()); } return result; } /** * Get resource by given program type and full name. It return map contain resource id, name. * Useful in Python API create flink or spark task which need processDefinition information. * * @param programType program type one of SCALA, JAVA and PYTHON * @param fullName full name of the resource */ public Map<String, Object> getResourcesFileInfo(String programType, String fullName) { Map<String, Object> result = new HashMap<>(); Result<Object> resources = resourceService.queryResourceByProgramType(dummyAdminUser, ResourceType.FILE, ProgramType.valueOf(programType)); List<ResourceComponent> resourcesComponent = (List<ResourceComponent>) resources.getData(); List<ResourceComponent> namedResources = resourcesComponent.stream().filter(s -> fullName.equals(s.getFullName())).collect(Collectors.toList());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
if (CollectionUtils.isEmpty(namedResources)) { String msg = String.format("Can not find valid resource by program type %s and name %s", programType, fullName); logger.error(msg); throw new IllegalArgumentException(msg); } result.put("id", namedResources.get(0).getId()); result.put("name", namedResources.get(0).getName()); return result; } /** * Get resource by given resource type and full name. It return map contain resource id, name. * Useful in Python API create task which need processDefinition information. * * @param userName user who query resource * @param fullName full name of the resource */ public Map<String, Object> queryResourcesFileInfo(String userName, String fullName) { Map<String, Object> result = new HashMap<>(); User user = usersService.queryUser(userName); Result<Object> resourceResponse = resourceService.queryResource(user, fullName, null, ResourceType.FILE); if (resourceResponse.getCode() != Status.SUCCESS.getCode()) { String msg = String.format("Can not find valid resource by name %s", fullName); logger.error(msg); throw new IllegalArgumentException(msg); } Resource resource = (Resource) resourceResponse.getData(); result.put("id", resource.getId()); result.put("name", resource.getFullName()); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
@PostConstruct public void init() { if (pythonGatewayConfiguration.getEnabled()) { this.start(); } } private void start() { GatewayServer server; try { InetAddress gatewayHost = InetAddress.getByName(pythonGatewayConfiguration.getGatewayServerAddress()); InetAddress pythonHost = InetAddress.getByName(pythonGatewayConfiguration.getPythonAddress()); server = new GatewayServer( this, pythonGatewayConfiguration.getGatewayServerPort(), pythonGatewayConfiguration.getPythonPort(), gatewayHost, pythonHost, pythonGatewayConfiguration.getConnectTimeout(), pythonGatewayConfiguration.getReadTimeout(), null ); GatewayServer.turnLoggingOn(); logger.info("PythonGatewayService started on: " + gatewayHost.toString()); server.start(); } catch (UnknownHostException e) { logger.error("exception occurred while constructing PythonGatewayService().", e); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
/* * 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.service; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.enums.ProgramType; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.spi.enums.ResourceType; import java.io.IOException; import java.util.Map; import org.springframework.web.multipart.MultipartFile; /** * resources service */ public interface ResourcesService {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
/** * create directory * * @param loginUser login user * @param name alias * @param description description * @param type type * @param pid parent id * @param currentDir current directory
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
* @return create directory result */ Result<Object> createDirectory(User loginUser, String name, String description, ResourceType type, int pid, String currentDir); /** * create resource * * @param loginUser login user * @param name alias * @param desc description * @param file file * @param type type * @param pid parent id * @param currentDir current directory * @return create result code */ Result<Object> createResource(User loginUser, String name, String desc, ResourceType type, MultipartFile file, int pid, String currentDir); /** * update resource * @param loginUser login user
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
* @param resourceId resource id * @param name name * @param desc description * @param type resource type * @param file resource file * @return update result code */ Result<Object> updateResource(User loginUser, int resourceId, String name, String desc, ResourceType type, MultipartFile file); /** * query resources list paging * * @param loginUser login user * @param type resource type * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return resource list page */ Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize); /** * query resource list * * @param loginUser login user * @param type resource type * @return resource list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
*/ Map<String, Object> queryResourceList(User loginUser, ResourceType type); /** * query resource list by program type * * @param loginUser login user * @param type resource type * @return resource list */ Result<Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType); /** * delete resource * * @param loginUser login user * @param resourceId resource id * @return delete result code * @throws IOException exception */ Result<Object> delete(User loginUser, int resourceId) throws IOException; /** * verify resource by name and type * @param loginUser login user * @param fullName resource full name * @param type resource type * @return true if the resource name not exists, otherwise return false */ Result<Object> verifyResourceName(String fullName, ResourceType type,User loginUser); /** * verify resource by full name or pid and type * @param fullName resource full name
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
* @param id resource id * @param type resource type * @return true if the resource full name or pid not exists, otherwise return false */ Result<Object> queryResource(User loginUser,String fullName,Integer id,ResourceType type); /** * view resource file online * * @param resourceId resource id * @param skipLineNum skip line number * @param limit limit * @return resource content */ Result<Object> readResource(User loginUser,int resourceId, int skipLineNum, int limit); /** * create resource file online * * @param loginUser login user * @param type resource type * @param fileName file name * @param fileSuffix file suffix * @param desc description * @param content content * @return create result code */ Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content,int pid,String currentDirectory); /** * updateProcessInstance resource * * @param resourceId resource id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
* @param content content * @return update result cod */ Result<Object> updateResourceContent(User loginUser,int resourceId, String content); /** * download file * * @param resourceId resource id * @return resource content * @throws IOException exception */ org.springframework.core.io.Resource downloadResource(User loginUser, int resourceId) throws IOException; /** * list all file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ Map<String, Object> authorizeResourceTree(User loginUser, Integer userId); /** * unauthorized file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ Map<String, Object> unauthorizedFile(User loginUser, Integer userId); /** * unauthorized udf function
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
* * @param loginUser login user * @param userId user id * @return unauthorized result code */ Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId); /** * authorized udf function * * @param loginUser login user * @param userId user id * @return authorized result code */ Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId); /** * authorized file * * @param loginUser login user * @param userId user id * @return authorized result */ Map<String, Object> authorizedFile(User loginUser, Integer userId); /** * get resource by id * @param resourceId resource id * @return resource */ Result<Object> queryResourceById(User loginUser, Integer resourceId); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/* * 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.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.SerializationFeature; import com.google.common.base.Joiner; import com.google.common.io.Files; import org.apache.commons.beanutils.BeanMap; import org.apache.commons.collections.CollectionUtils;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import org.apache.commons.lang3.StringUtils; import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter; import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor; import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.ResourcesService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.RegexUtils; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.ProgramType; import org.apache.dolphinscheduler.common.enums.ResUploadType; import org.apache.dolphinscheduler.common.storage.StorageOperate; import org.apache.dolphinscheduler.common.utils.FileUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.ResourcesUser; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.rmi.ServerException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.UUID; import java.util.regex.Matcher; import java.util.stream.Collectors; import static org.apache.dolphinscheduler.common.Constants.ALIAS; import static org.apache.dolphinscheduler.common.Constants.CONTENT; import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import static org.apache.dolphinscheduler.common.Constants.FORMAT_SS; import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S; import static org.apache.dolphinscheduler.common.Constants.JAR; /** * resources service impl */ @Service public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesService { private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceImpl.class); @Autowired private ResourceMapper resourcesMapper; @Autowired private UdfFuncMapper udfFunctionMapper; @Autowired private TenantMapper tenantMapper; @Autowired private UserMapper userMapper; @Autowired private ResourceUserMapper resourceUserMapper; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired(required = false) private StorageOperate storageOperate; @Autowired private ResourcePermissionCheckService resourcePermissionCheckService; /** * create directory * * @param loginUser login user * @param name alias
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param description description * @param type type * @param pid parent id * @param currentDir current directory * @return create directory result */ @Override @Transactional public Result<Object> createDirectory(User loginUser, String name, String description, ResourceType type, 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); if (!canOperatorPermissions){ putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (FileUtils.directoryTraversal(name)) { putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } String fullName = getFullName(currentDir, name);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
result = verifyResource(loginUser, type, fullName, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (checkResourceExists(fullName, type.ordinal())) { logger.error("resource directory {} has exist, can't recreate", fullName); putMsg(result, Status.RESOURCE_EXIST); return result; } Date now = new Date(); Resource resource = new Resource(pid, name, fullName, true, description, name, loginUser.getId(), type, 0, now, now); try { resourcesMapper.insert(resource); putMsg(result, Status.SUCCESS); permissionPostHandle(resource.getType(), loginUser, resource.getId()); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) { if (!"class".equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); } catch (DuplicateKeyException e) { logger.error("resource directory {} has exist, can't recreate", fullName); putMsg(result, Status.RESOURCE_EXIST); return result; } catch (Exception e) { logger.error("resource already exists, can't recreate ", e); throw new ServiceException("resource already exists, can't recreate"); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
createDirectory(loginUser, fullName, type, result); return result; } private String getFullName(String currentDir, String name) { return currentDir.equals(FOLDER_SEPARATOR) ? String.format(FORMAT_SS, currentDir, name) : String.format(FORMAT_S_S, currentDir, name); } /** * create resource * * @param loginUser login user * @param name alias * @param desc description * @param file file * @param type type * @param pid parent id * @param currentDir current directory * @return create result code */ @Override @Transactional public Result<Object> createResource(User loginUser, String name, String desc, ResourceType type, MultipartFile file, int pid, String currentDir) { Result<Object> result = new Result<>(); String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPLOAD : ApiFuncIdentificationConstant.UDF_UPLOAD;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey); if (!canOperatorPermissions){ putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } result = verifyPid(loginUser, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String tenantCode = getTenantCode(loginUser.getId(), result); if (StringUtils.isEmpty(tenantCode)) { return result; } result = verifyFile(name, type, file); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String fullName = getFullName(currentDir, name); if (checkResourceExists(fullName, type.ordinal())) { logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name)); putMsg(result, Status.RESOURCE_EXIST); return result; } if (fullName.length() > Constants.RESOURCE_FULL_NAME_MAX_LENGTH) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("resource {}'s full name {}' is longer than the max length {}", RegexUtils.escapeNRT(name), fullName, Constants.RESOURCE_FULL_NAME_MAX_LENGTH); putMsg(result, Status.RESOURCE_FULL_NAME_TOO_LONG_ERROR); return result; } Date now = new Date(); Resource resource = new Resource(pid, name, fullName, false, desc, file.getOriginalFilename(), loginUser.getId(), type, file.getSize(), now, now); try { resourcesMapper.insert(resource); updateParentResourceSize(resource, resource.getSize()); putMsg(result, Status.SUCCESS); permissionPostHandle(resource.getType(), loginUser, resource.getId()); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) { if (!"class".equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); } catch (Exception e) { logger.error("resource already exists, can't recreate ", e); throw new ServiceException("resource already exists, can't recreate"); } if (!upload(loginUser, fullName, file, type)) { logger.error("upload resource: {} file: {} failed.", RegexUtils.escapeNRT(name), RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR); throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * update the folder's size of the resource * * @param resource the current resource * @param size size */ private void updateParentResourceSize(Resource resource, long size) { if (resource.getSize() > 0) { String[] splits = resource.getFullName().split("/"); for (int i = 1; i < splits.length; i++) { String parentFullName = Joiner.on("/").join(Arrays.copyOfRange(splits, 0, i)); if (StringUtils.isNotBlank(parentFullName)) { List<Resource> resources = resourcesMapper.queryResource(parentFullName, resource.getType().ordinal()); if (CollectionUtils.isNotEmpty(resources)) { Resource parentResource = resources.get(0); if (parentResource.getSize() + size >= 0) { parentResource.setSize(parentResource.getSize() + size); } else { parentResource.setSize(0L); } resourcesMapper.updateById(parentResource); } } } } } /** * check resource is exists * * @param fullName fullName
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param type type * @return true if resource exists */ private boolean checkResourceExists(String fullName, int type) { Boolean existResource = resourcesMapper.existResource(fullName, type); return Boolean.TRUE.equals(existResource); } /** * update resource * * @param loginUser login user * @param resourceId resource id * @param name name * @param desc description * @param type resource type * @param file resource file * @return update result code */ @Override @Transactional public Result<Object> updateResource(User loginUser, int resourceId, String name, String desc, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(type), funcPermissionKey); if (!canOperatorPermissions){
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!PropertyUtils.getResUploadStartupState()){ putMsg(result, Status.STORAGE_NOT_STARTUP); return result; } if (resource.isDirectory() && storageOperate.returnStorageType().equals(ResUploadType.S3) && !resource.getFileName().equals(name)) { putMsg(result, Status.S3_CANNOT_RENAME); return result; } if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) { putMsg(result, Status.SUCCESS); return result; } String originFullName = resource.getFullName(); String originResourceName = resource.getAlias(); String fullName = String.format(FORMAT_SS, originFullName.substring(0, originFullName.lastIndexOf(FOLDER_SEPARATOR) + 1), name); if (!originResourceName.equals(name) && checkResourceExists(fullName, type.ordinal())) { logger.error("resource {} already exists, can't recreate", name);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.RESOURCE_EXIST); return result; } result = verifyFile(name, type, file); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String tenantCode = getTenantCode(resource.getUserId(), result); if (StringUtils.isEmpty(tenantCode)) { return result; } String originFileName = storageOperate.getFileName(resource.getType(), tenantCode, originFullName); try { if (!storageOperate.exists(tenantCode, originFileName)) { logger.error("{} not exist", originFileName); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } } catch (IOException e) { logger.error(e.getMessage(), e); throw new ServiceException(Status.HDFS_OPERATION_ERROR); } if (!resource.isDirectory()) { String originSuffix = Files.getFileExtension(originFullName); String suffix = Files.getFileExtension(fullName); boolean suffixIsChanged = false;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (StringUtils.isBlank(suffix) && StringUtils.isNotBlank(originSuffix)) { suffixIsChanged = true; } if (StringUtils.isNotBlank(suffix) && !suffix.equals(originSuffix)) { suffixIsChanged = true; } if (suffixIsChanged) { Map<String, Object> columnMap = new HashMap<>(); columnMap.put("resources_id", resourceId); List<ResourcesUser> resourcesUsers = resourceUserMapper.selectByMap(columnMap); if (CollectionUtils.isNotEmpty(resourcesUsers)) { List<Integer> userIds = resourcesUsers.stream().map(ResourcesUser::getUserId).collect(Collectors.toList()); List<User> users = userMapper.selectBatchIds(userIds); String userNames = users.stream().map(User::getUserName).collect(Collectors.toList()).toString(); logger.error("resource is authorized to user {},suffix not allowed to be modified", userNames); putMsg(result, Status.RESOURCE_IS_AUTHORIZED, userNames); return result; } } } Date now = new Date(); long originFileSize = resource.getSize(); resource.setAlias(name); resource.setFileName(name); resource.setFullName(fullName); resource.setDescription(desc); resource.setUpdateTime(now);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (file != null) { resource.setSize(file.getSize()); } try { resourcesMapper.updateById(resource); if (resource.isDirectory()) { List<Integer> childrenResource = listAllChildren(resource, false); if (CollectionUtils.isNotEmpty(childrenResource)) { String matcherFullName = Matcher.quoteReplacement(fullName); List<Resource> childResourceList; Integer[] childResIdArray = childrenResource.toArray(new Integer[childrenResource.size()]); List<Resource> resourceList = resourcesMapper.listResourceByIds(childResIdArray); childResourceList = resourceList.stream().map(t -> { t.setFullName(t.getFullName().replaceFirst(originFullName, matcherFullName)); t.setUpdateTime(now); return t; }).collect(Collectors.toList()); resourcesMapper.batchUpdateResource(childResourceList); if (ResourceType.UDF.equals(resource.getType())) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(childResIdArray); if (CollectionUtils.isNotEmpty(udfFuncs)) { udfFuncs = udfFuncs.stream().map(t -> { t.setResourceName(t.getResourceName().replaceFirst(originFullName, matcherFullName)); t.setUpdateTime(now); return t; }).collect(Collectors.toList()); udfFunctionMapper.batchUpdateUdfFunc(udfFuncs); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} else if (ResourceType.UDF.equals(resource.getType())) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(new Integer[]{resourceId}); if (CollectionUtils.isNotEmpty(udfFuncs)) { udfFuncs = udfFuncs.stream().map(t -> { t.setResourceName(fullName); t.setUpdateTime(now); return t; }).collect(Collectors.toList()); udfFunctionMapper.batchUpdateUdfFunc(udfFuncs); } } putMsg(result, Status.SUCCESS); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) { if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); } catch (Exception e) { logger.error(Status.UPDATE_RESOURCE_ERROR.getMsg(), e); throw new ServiceException(Status.UPDATE_RESOURCE_ERROR); } if (originResourceName.equals(name) && file == null) { return result; } if (file != null) { if (!upload(loginUser, fullName, file, type)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("upload resource: {} file: {} failed.", name, RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } if (!fullName.equals(originFullName)) { try { storageOperate.delete(tenantCode, originFileName, false); } catch (IOException e) { logger.error(e.getMessage(), e); throw new ServiceException(String.format("delete resource: %s failed.", originFullName)); } } updateParentResourceSize(resource, resource.getSize() - originFileSize); return result; } String destHdfsFileName = storageOperate.getFileName(resource.getType(), tenantCode, fullName); try { logger.info("start copy {} -> {}", originFileName, destHdfsFileName); storageOperate.copy(originFileName, destHdfsFileName, true, true); } catch (Exception e) { logger.error(MessageFormat.format(" copy {0} -> {1} fail", originFileName, destHdfsFileName), e); putMsg(result, Status.HDFS_COPY_FAIL); throw new ServiceException(Status.HDFS_COPY_FAIL); } return result; } private Result<Object> verifyFile(String name, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (FileUtils.directoryTraversal(name)) { logger.error("file alias name {} verify failed", name); putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } if (file != null && FileUtils.directoryTraversal(Objects.requireNonNull(file.getOriginalFilename()))) { logger.error("file original name {} verify failed", file.getOriginalFilename()); putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } if (file != null) { if (file.isEmpty()) { logger.error("file is empty: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_FILE_IS_EMPTY); return result; } String fileSuffix = Files.getFileExtension(file.getOriginalFilename()); String nameSuffix = Files.getFileExtension(name); if (!fileSuffix.equalsIgnoreCase(nameSuffix)) { logger.error("rename file suffix and original suffix must be consistent: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE); return result; } if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) { logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR); return result; } if (file.getSize() > Constants.MAX_FILE_SIZE) { logger.error("file size is too large: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT); return result; } } return result; } /** * query resources list paging * * @param loginUser login user * @param type resource type * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return resource list page */ @Override public Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) { Result<Object> result = new Result<>(); Page<Resource> page = new Page<>(pageNo, pageSize); if (directoryId != -1) { Resource directory = resourcesMapper.selectById(directoryId); if (directory == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} } PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize); Set<Integer> resourcesIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); if (resourcesIds.isEmpty()) { result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, directoryId, type.ordinal(), searchVal, new ArrayList<>(resourcesIds)); pageInfo.setTotal((int) resourceIPage.getTotal()); pageInfo.setTotalList(resourceIPage.getRecords()); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * create directory * xxx The steps to verify resources are cumbersome and can be optimized * * @param loginUser login user * @param fullName full name * @param type resource type * @param result Result */ private void createDirectory(User loginUser, String fullName, ResourceType type, Result<Object> result) { String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String directoryName = storageOperate.getFileName(type, tenantCode, fullName); String resourceRootPath = storageOperate.getDir(type, tenantCode); try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!storageOperate.exists(tenantCode, resourceRootPath)) { storageOperate.createTenantDirIfNotExists(tenantCode); } if (!storageOperate.mkdir(tenantCode, directoryName)) { logger.error("create resource directory {} failed", directoryName); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } catch (Exception e) { logger.error("create resource directory {} failed", directoryName); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } /** * upload file to hdfs * * @param loginUser login user * @param fullName full name * @param file file */ private boolean upload(User loginUser, String fullName, MultipartFile file, ResourceType type) { String fileSuffix = Files.getFileExtension(file.getOriginalFilename()); String nameSuffix = Files.getFileExtension(fullName); if (!fileSuffix.equalsIgnoreCase(nameSuffix)) { return false; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); String fileName = storageOperate.getFileName(type, tenantCode, fullName); String resourcePath = storageOperate.getDir(type, tenantCode); try { if (!storageOperate.exists(tenantCode, resourcePath)) { storageOperate.createTenantDirIfNotExists(tenantCode); } org.apache.dolphinscheduler.api.utils.FileUtils.copyInputStreamToFile(file, localFilename); storageOperate.upload(tenantCode, localFilename, fileName, true, true); } catch (Exception e) { FileUtils.deleteFile(localFilename); logger.error(e.getMessage(), e); return false; } return true; } /** * query resource list * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Map<String, Object> queryResourceList(User loginUser, ResourceType type) { Map<String, Object> result = new HashMap<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type); Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * query resource list by program type * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Result<Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) { Result<Object> result = new Result<>(); Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); if (resourceIds.isEmpty()){ result.setData(Collections.emptyList()); putMsg(result, Status.SUCCESS); return result; } List<Resource> allResourceList = resourcesMapper.selectBatchIds(resourceIds); String suffix = ".jar"; if (programType != null) { switch (programType) { case JAVA: case SCALA: break; case PYTHON:
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
suffix = ".py"; break; default: } } List<Resource> resources = new ResourceFilter(suffix, new ArrayList<>(allResourceList)).filter(); Visitor resourceTreeVisitor = new ResourceTreeVisitor(resources); result.setData(resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * delete resource * * @param loginUser login user * @param resourceId resource id * @return delete result code * @throws IOException exception */ @Override @Transactional public Result<Object> delete(User loginUser, int resourceId) throws IOException { Result<Object> resultCheck = new Result<>(); Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(resultCheck, Status.RESOURCE_NOT_EXIST); return resultCheck; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DELETE : ApiFuncIdentificationConstant.UDF_DELETE;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey); if (!canOperatorPermissions){ putMsg(resultCheck, Status.NO_CURRENT_OPERATING_PERMISSION); return resultCheck; } Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (!canOperator(loginUser, resource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } String tenantCode = getTenantCode(resource.getUserId(), result); if (StringUtils.isEmpty(tenantCode)) { return result; } List<Map<String, Object>> list = processDefinitionMapper.listResources(); Map<Integer, Set<Long>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list); Set<Integer> resourceIdSet = resourceProcessMap.keySet(); List<Integer> allChildren = listAllChildren(resource, true); Integer[] needDeleteResourceIdArray = allChildren.toArray(new Integer[allChildren.size()]); if (resource.getType() == (ResourceType.UDF)) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(needDeleteResourceIdArray); if (CollectionUtils.isNotEmpty(udfFuncs)) { logger.error("can't be deleted,because it is bound by UDF functions:{}", udfFuncs); putMsg(result, Status.UDF_RESOURCE_IS_BOUND, udfFuncs.get(0).getFuncName());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } } if (resourceIdSet.contains(resource.getPid())) { logger.error("can't be deleted,because it is used of process definition"); putMsg(result, Status.RESOURCE_IS_USED); return result; } resourceIdSet.retainAll(allChildren); if (CollectionUtils.isNotEmpty(resourceIdSet)) { logger.error("can't be deleted,because it is used of process definition"); for (Integer resId : resourceIdSet) { logger.error("resource id:{} is used of process definition {}",resId,resourceProcessMap.get(resId)); } putMsg(result, Status.RESOURCE_IS_USED); return result; } String storageFilename = storageOperate.getFileName(resource.getType(), tenantCode, resource.getFullName()); resourcesMapper.selectBatchIds(Arrays.asList(needDeleteResourceIdArray)).forEach(item -> { updateParentResourceSize(item, item.getSize() * -1); }); resourcesMapper.deleteIds(needDeleteResourceIdArray); resourceUserMapper.deleteResourceUserArray(0, needDeleteResourceIdArray); storageOperate.delete(tenantCode, storageFilename, true); putMsg(result, Status.SUCCESS); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} /** * verify resource by name and type * * @param loginUser login user * @param fullName resource full name * @param type resource type * @return true if the resource name not exists, otherwise return false */ @Override public Result<Object> verifyResourceName(String fullName, ResourceType type, User loginUser) { Result<Object> result = new Result<>(); String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_RENAME : ApiFuncIdentificationConstant.UDF_FILE_VIEW; boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey); if (!canOperatorPermissions){ putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } putMsg(result, Status.SUCCESS); if (checkResourceExists(fullName, type.ordinal())) { logger.error("resource type:{} name:{} has exist, can't create again.", type, RegexUtils.escapeNRT(fullName)); putMsg(result, Status.RESOURCE_EXIST); } else { Tenant tenant = tenantMapper.queryById(loginUser.getTenantId()); if (tenant != null) { String tenantCode = tenant.getTenantCode(); try { String filename = storageOperate.getFileName(type, tenantCode, fullName); if (storageOperate.exists(tenantCode, filename)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
putMsg(result, Status.RESOURCE_FILE_EXIST, filename); } } catch (Exception e) { logger.error("verify resource failed and the reason is {}", e.getMessage()); putMsg(result, Status.STORE_OPERATE_CREATE_ERROR); } } else { putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); } } return result; } /** * verify resource by full name or pid and type * * @param fullName resource full name * @param id resource id * @param type resource type * @return true if the resource full name or pid not exists, otherwise return false */ @Override public Result<Object> queryResource(User loginUser, String fullName, Integer id, ResourceType type) { Result<Object> result = new Result<>(); if (StringUtils.isBlank(fullName) && id == null) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR); return result; } Resource resource; if (StringUtils.isNotBlank(fullName)) { List<Resource> resourceList = resourcesMapper.queryResource(fullName, type.ordinal());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (CollectionUtils.isEmpty(resourceList)) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } resource = resourceList.get(0); } else { resource = resourcesMapper.selectById(id); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } resource = resourcesMapper.selectById(resource.getPid()); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } } String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resource.getId()}, checkResourceType(type), funcPermissionKey); if (!canOperatorPermissions){ putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } putMsg(result, Status.SUCCESS); result.setData(resource); return result; } /** * get resource by id * @param id resource id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @return resource */ @Override public Result<Object> queryResourceById(User loginUser, Integer id) { Result<Object> result = new Result<>(); Resource resource = resourcesMapper.selectById(id); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{id}, checkResourceType(resource.getType()), funcPermissionKey); if (!canOperatorPermissions){ putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } putMsg(result, Status.SUCCESS); result.setData(resource); return result; } /** * view resource file online * * @param resourceId resource id * @param skipLineNum skip line number * @param limit limit * @return resource content */ @Override public Result<Object> readResource(User loginUser, int resourceId, int skipLineNum, int limit) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey); if (!canOperatorPermissions){ putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String nameSuffix = Files.getFileExtension(resource.getAlias()); String resourceViewSuffixes = FileUtils.getResourceViewSuffixes(); if (StringUtils.isNotEmpty(resourceViewSuffixes)) { List<String> strList = Arrays.asList(resourceViewSuffixes.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support view, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(), result); if (StringUtils.isEmpty(tenantCode)) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} String resourceFileName = storageOperate.getResourceFileName(tenantCode, resource.getFullName()); logger.info("resource path is {}", resourceFileName); try { if (storageOperate.exists(tenantCode, resourceFileName)) { List<String> content = storageOperate.vimFile(tenantCode, resourceFileName, skipLineNum, limit); putMsg(result, Status.SUCCESS); Map<String, Object> map = new HashMap<>(); map.put(ALIAS, resource.getAlias()); map.put(CONTENT, String.join("\n", content)); result.setData(map); } else { logger.error("read file {} not exist in storage", resourceFileName); putMsg(result, Status.RESOURCE_FILE_NOT_EXIST, resourceFileName); } } catch (Exception e) { logger.error("Resource {} read failed", resourceFileName, e); putMsg(result, Status.HDFS_OPERATION_ERROR); } return result; } /** * create resource file online * * @param loginUser login user * @param type resource type * @param fileName file name * @param fileSuffix file suffix * @param desc description
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param content content * @param pid pid * @param currentDir current directory * @return create result code */ @Override @Transactional public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content, int pid, String currentDir) { Result<Object> result = new Result<>(); boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE); if (!canOperatorPermissions){ putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (FileUtils.directoryTraversal(fileName)) { putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED); return result; } String nameSuffix = fileSuffix.trim(); String resourceViewSuffixes = FileUtils.getResourceViewSuffixes(); if (StringUtils.isNotEmpty(resourceViewSuffixes)) { List<String> strList = Arrays.asList(resourceViewSuffixes.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support create", nameSuffix); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } } String name = fileName.trim() + "." + nameSuffix; String fullName = getFullName(currentDir, name); result = verifyResource(loginUser, type, fullName, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Date now = new Date(); Resource resource = new Resource(pid, name, fullName, false, desc, name, loginUser.getId(), type, content.getBytes().length, now, now); resourcesMapper.insert(resource); updateParentResourceSize(resource, resource.getSize()); putMsg(result, Status.SUCCESS); permissionPostHandle(resource.getType(), loginUser, resource.getId()); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) { if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); result = uploadContentToStorage(loginUser, fullName, tenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg()); } return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
private void permissionPostHandle(ResourceType resourceType, User loginUser, Integer resourceId) { AuthorizationType authorizationType = resourceType.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID : AuthorizationType.UDF_FILE; permissionPostHandle(authorizationType, loginUser.getId(), Collections.singletonList(resourceId), logger); } private Result<Object> checkResourceUploadStartupState() { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState()); putMsg(result, Status.STORAGE_NOT_STARTUP); return result; } return result; } private Result<Object> verifyResource(User loginUser, ResourceType type, String fullName, int pid) { Result<Object> result = verifyResourceName(fullName, type, loginUser); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } return verifyPid(loginUser, pid); } private Result<Object> verifyPid(User loginUser, int pid) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (pid != -1) { Resource parentResource = resourcesMapper.selectById(pid); if (parentResource == null) { putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} if (!canOperator(loginUser, parentResource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } } return result; } /** * updateProcessInstance resource * * @param resourceId resource id * @param content content * @return update result cod */ @Override @Transactional public Result<Object> updateResourceContent(User loginUser, int resourceId, String content) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("read file not exist, resource id {}", resourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!canOperatorPermissions){ putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } String nameSuffix = Files.getFileExtension(resource.getAlias()); String resourceViewSuffixes = FileUtils.getResourceViewSuffixes(); if (StringUtils.isNotEmpty(resourceViewSuffixes)) { List<String> strList = Arrays.asList(resourceViewSuffixes.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support updateProcessInstance, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(), result); if (StringUtils.isEmpty(tenantCode)) { return result; } long originFileSize = resource.getSize(); resource.setSize(content.getBytes().length); resource.setUpdateTime(new Date()); resourcesMapper.updateById(resource); result = uploadContentToStorage(loginUser, resource.getFullName(), tenantCode, content); updateParentResourceSize(resource, resource.getSize() - originFileSize); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg()); } return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * @param resourceName resource name * @param tenantCode tenant code * @param content content * @return result */ private Result<Object> uploadContentToStorage(User loginUser,String resourceName, String tenantCode, String content) { Result<Object> result = new Result<>(); String localFilename = ""; String storageFileName = ""; try { localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); if (!FileUtils.writeContent2File(content, localFilename)) { logger.error("file {} fail, content is {}", localFilename, RegexUtils.escapeNRT(content)); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } storageFileName = storageOperate.getResourceFileName(tenantCode, resourceName); String resourcePath = storageOperate.getResDir(tenantCode); logger.info("resource path is {}, resource dir is {}", storageFileName, resourcePath); if (!storageOperate.exists(tenantCode, resourcePath)) { storageOperate.createTenantDirIfNotExists(tenantCode); } if (storageOperate.exists(tenantCode, storageFileName)) { storageOperate.delete(tenantCode, storageFileName, false); } storageOperate.upload(tenantCode, localFilename, storageFileName, true, true);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} catch (Exception e) { logger.error(e.getMessage(), e); result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); result.setMsg(String.format("copy %s to hdfs %s fail", localFilename, storageFileName)); return result; } putMsg(result, Status.SUCCESS); return result; } /** * download file * * @param resourceId resource id * @return resource content * @throws IOException exception */ @Override public org.springframework.core.io.Resource downloadResource(User loginUser, int resourceId) throws IOException { if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState()); throw new ServiceException("hdfs not startup"); } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("download file not exist, resource id {}", resourceId); return null; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DOWNLOAD : ApiFuncIdentificationConstant.UDF_DOWNLOAD; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!canOperatorPermissions){ logger.error("{}: {}", Status.NO_CURRENT_OPERATING_PERMISSION.getMsg(), PropertyUtils.getResUploadStartupState()); throw new ServiceException(Status.NO_CURRENT_OPERATING_PERMISSION.getMsg()); } if (resource.isDirectory()) { logger.error("resource id {} is directory,can't download it", resourceId); throw new ServiceException("can't download directory"); } int userId = resource.getUserId(); User user = userMapper.selectById(userId); if (user == null) { logger.error("user id {} not exists", userId); throw new ServiceException(String.format("resource owner id %d not exist", userId)); } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant id {} not exists", user.getTenantId()); throw new ServiceException(String.format("The tenant id %d of resource owner not exist", user.getTenantId())); } String tenantCode = tenant.getTenantCode(); String fileName = storageOperate.getFileName(resource.getType(), tenantCode, resource.getFullName()); String localFileName = FileUtils.getDownloadFilename(resource.getAlias()); logger.info("resource path is {}, download local filename is {}", fileName, localFileName); try { storageOperate.download(tenantCode, fileName, localFileName, false, true); return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName); } catch (IOException e) { logger.error("download resource error, the path is {}, and local filename is {}, the error message is {}", fileName, localFileName, e.getMessage()); throw new ServerException("download the resource file failed ,it may be related to your storage"); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} /** * list all file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (!resourcePermissionCheckService.functionDisabled()){ putMsg(result, Status.FUNCTION_DISABLED); return result; } List<Resource> resourceList; if (isAdmin(loginUser)) { resourceList = resourcesMapper.queryResourceExceptUserId(userId); } else { resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1); } List<ResourceComponent> list; if (CollectionUtils.isNotEmpty(resourceList)) { Visitor visitor = new ResourceTreeVisitor(resourceList); list = visitor.visit().getChildren(); } else { list = new ArrayList<>(0); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
result.put(Constants.DATA_LIST, list); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); List<Resource> resourceList; if (isAdmin(loginUser)) { resourceList = resourcesMapper.queryResourceExceptUserId(userId); } else { resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1); } List<Resource> list; if (resourceList != null && !resourceList.isEmpty()) { Set<Resource> resourceSet = new HashSet<>(resourceList); List<Resource> authedResourceList = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); getAuthorizedResourceList(resourceSet, authedResourceList); list = new ArrayList<>(resourceSet); } else { list = new ArrayList<>(0);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} Visitor visitor = new ResourceTreeVisitor(list); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized udf function * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (!resourcePermissionCheckService.functionDisabled()){ putMsg(result, Status.FUNCTION_DISABLED); return result; } List<UdfFunc> udfFuncList; if (isAdmin(loginUser)) { udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId); } else { udfFuncList = udfFunctionMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId())); } List<UdfFunc> resultList = new ArrayList<>(); Set<UdfFunc> udfFuncSet;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (CollectionUtils.isNotEmpty(udfFuncList)) { udfFuncSet = new HashSet<>(udfFuncList); List<UdfFunc> authedUDFFuncList = udfFunctionMapper.queryAuthedUdfFunc(userId); getAuthorizedResourceList(udfFuncSet, authedUDFFuncList); resultList = new ArrayList<>(udfFuncSet); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * authorized udf function * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (!resourcePermissionCheckService.functionDisabled()){ putMsg(result, Status.FUNCTION_DISABLED); return result; } List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId); result.put(Constants.DATA_LIST, udfFuncs); putMsg(result, Status.SUCCESS); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* authorized file * * @param loginUser login user * @param userId user id * @return authorized result */ @Override public Map<String, Object> authorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (!resourcePermissionCheckService.functionDisabled()){ putMsg(result, Status.FUNCTION_DISABLED); return result; } List<Resource> authedResources = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); Visitor visitor = new ResourceTreeVisitor(authedResources); String visit = JSONUtils.toJsonString(visitor.visit(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(visit); String jsonTreeStr = JSONUtils.toJsonString(visitor.visit().getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(jsonTreeStr); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * get authorized resource list * * @param resourceSet resource set * @param authedResourceList authorized resource list */ private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Set<?> authedResourceSet; if (CollectionUtils.isNotEmpty(authedResourceList)) { authedResourceSet = new HashSet<>(authedResourceList); resourceSet.removeAll(authedResourceSet); } } /** * get tenantCode by UserId * * @param userId user id * @param result return result * @return tenant code */ private String getTenantCode(int userId, Result<Object> result) { User user = userMapper.selectById(userId); if (user == null) { logger.error("user {} not exists", userId); putMsg(result, Status.USER_NOT_EXIST, userId); return null; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); return null; } return tenant.getTenantCode(); } /** * list all children id
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* * @param resource resource * @param containSelf whether add self to children list * @return all children id */ List<Integer> listAllChildren(Resource resource, boolean containSelf) { List<Integer> childList = new ArrayList<>(); if (resource.getId() != -1 && containSelf) { childList.add(resource.getId()); } if (resource.isDirectory()) { listAllChildren(resource.getId(), childList); } return childList; } /** * list all children id * * @param resourceId resource id * @param childList child list */ void listAllChildren(int resourceId, List<Integer> childList) { List<Integer> children = resourcesMapper.listChildren(resourceId); for (int childId : children) { childList.add(childId); listAllChildren(childId, childList); } } /** * query authored resource list (own and authorized)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* * @param loginUser login user * @param type ResourceType * @return all authored resource list */ private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) { Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); if (resourceIds.isEmpty()){ return Collections.emptyList(); } List<Resource> resources = resourcesMapper.selectBatchIds(resourceIds); resources = resources.stream().filter(rs -> rs.getType() == type).collect(Collectors.toList()); return resources; } /** * query resource list by userId and perm * * @param userId userId * @param perm perm * @return resource list */ private List<Resource> queryResourceList(Integer userId, int perm) { List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, perm); return CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourcesMapper.queryResourceListById(resIds); } private AuthorizationType checkResourceType(ResourceType type) { return type.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID : AuthorizationType.UDF_FILE; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
/* * 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.python; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.ResourcesService; import org.apache.dolphinscheduler.api.service.UsersService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import java.util.Date; import java.util.Map; /** * python gate test */ @RunWith(MockitoJUnitRunner.class) public class PythonGatewayTest { @InjectMocks private PythonGateway pythonGateway; @Mock private ProjectMapper projectMapper; @Mock
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
private ProcessDefinitionMapper processDefinitionMapper; @Mock private TaskDefinitionMapper taskDefinitionMapper; @Mock private ResourcesService resourcesService; @Mock private UsersService usersService; @Test public void testGetCodeAndVersion() throws CodeGenerateUtils.CodeGenerateException { Project project = getTestProject(); Mockito.when(projectMapper.queryByName(project.getName())).thenReturn(project); ProcessDefinition processDefinition = getTestProcessDefinition(); Mockito.when(processDefinitionMapper.queryByDefineName(project.getCode(), processDefinition.getName())).thenReturn(processDefinition); TaskDefinition taskDefinition = getTestTaskDefinition(); Mockito.when(taskDefinitionMapper.queryByName(project.getCode(), processDefinition.getCode(), taskDefinition.getName())).thenReturn(taskDefinition); Map<String, Long> result = pythonGateway.getCodeAndVersion(project.getName(), processDefinition.getName(), taskDefinition.getName()); Assert.assertEquals(result.get("code").longValue(), taskDefinition.getCode()); } @Test public void testGetDependentInfo() { Project project = getTestProject(); Mockito.when(projectMapper.queryByName(project.getName())).thenReturn(project); ProcessDefinition processDefinition = getTestProcessDefinition(); Mockito.when(processDefinitionMapper.queryByDefineName(project.getCode(), processDefinition.getName())).thenReturn(processDefinition); TaskDefinition taskDefinition = getTestTaskDefinition(); Mockito.when(taskDefinitionMapper.queryByName(project.getCode(), processDefinition.getCode(), taskDefinition.getName())).thenReturn(taskDefinition); Map<String, Object> result = pythonGateway.getDependentInfo(project.getName(), processDefinition.getName(), taskDefinition.getName()); Assert.assertEquals((long) result.get("taskDefinitionCode"), taskDefinition.getCode()); } @Test
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
public void testQueryResourcesFileInfo() { User user = getTestUser(); Mockito.when(usersService.queryUser(user.getUserName())).thenReturn(user); Result<Object> mockResult = new Result<>(); mockResult.setCode(Status.SUCCESS.getCode()); Resource resource = getTestResource(); mockResult.setData(resource); Mockito.when(resourcesService.queryResource(user, resource.getFullName(), null, ResourceType.FILE)).thenReturn(mockResult); Map<String, Object> result = pythonGateway.queryResourcesFileInfo(user.getUserName(), resource.getFullName()); Assert.assertEquals((int) result.get("id"), resource.getId()); } private Resource getTestResource() { Resource resource = new Resource(); resource.setId(1); resource.setType(ResourceType.FILE); resource.setFullName("/dev/test.py"); return resource; } private User getTestUser() { User user = new User(); user.setId(1); user.setUserName("ut-user"); return user; } private Project getTestProject() { Project project = new Project(); project.setName("ut-project"); project.setUserId(111); project.setCode(1L); project.setCreateTime(new Date());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/python/PythonGatewayTest.java
project.setUpdateTime(new Date()); return project; } private ProcessDefinition getTestProcessDefinition() { ProcessDefinition processDefinition = new ProcessDefinition(); processDefinition.setCode(1L); processDefinition.setName("ut-process-definition"); processDefinition.setProjectCode(1L); processDefinition.setUserId(111); processDefinition.setUpdateTime(new Date()); processDefinition.setCreateTime(new Date()); return processDefinition; } private TaskDefinition getTestTaskDefinition() { TaskDefinition taskDefinition = new TaskDefinition(); taskDefinition.setCode(888888L); taskDefinition.setName("ut-task-definition"); taskDefinition.setProjectCode(1L); taskDefinition.setTaskType("SHELL"); taskDefinition.setUserId(111); taskDefinition.setResourceIds("1"); taskDefinition.setWorkerGroup("default"); taskDefinition.setEnvironmentCode(1L); taskDefinition.setVersion(1); taskDefinition.setCreateTime(new Date()); taskDefinition.setUpdateTime(new Date()); return taskDefinition; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
/* * 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.service; import static org.mockito.ArgumentMatchers.eq; import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.impl.BaseServiceImpl; import org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
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.AuthorizationType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.storage.StorageOperate; import org.apache.dolphinscheduler.common.utils.FileUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.commons.collections.CollectionUtils; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Random;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
import java.util.Set; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.mock.web.MockMultipartFile; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.io.Files; /** * resources service test */ @RunWith(PowerMockRunner.class) @PowerMockIgnore({"sun.security.*", "javax.net.*"}) @PrepareForTest({PropertyUtils.class, FileUtils.class, org.apache.dolphinscheduler.api.utils.FileUtils.class, Files.class}) public class ResourcesServiceTest { private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceTest.class); @InjectMocks private ResourcesServiceImpl resourcesService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
@Mock private ResourceMapper resourcesMapper; @Mock private TenantMapper tenantMapper; @Mock private StorageOperate storageOperate; @Mock private UserMapper userMapper; @Mock private UdfFuncMapper udfFunctionMapper; @Mock private ProcessDefinitionMapper processDefinitionMapper; @Mock private ResourceUserMapper resourceUserMapper; @Mock private ResourcePermissionCheckService resourcePermissionCheckService; private static final Logger serviceLogger = LoggerFactory.getLogger(BaseServiceImpl.class); private static final Logger resourceLogger = LoggerFactory.getLogger(ResourcesServiceImpl.class); @Before public void setUp() { PowerMockito.mockStatic(FileUtils.class); PowerMockito.mockStatic(Files.class); PowerMockito.mockStatic(org.apache.dolphinscheduler.api.utils.FileUtils.class); try { } catch (Exception e) { e.printStackTrace(); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
PowerMockito.mockStatic(PropertyUtils.class); } @Test public void testCreateResource() { PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPLOAD, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); User user = new User(); user.setId(1); user.setUserType(UserType.GENERAL_USER); MockMultipartFile mockMultipartFile = new MockMultipartFile("test.pdf", "test.pdf", "pdf", "test".getBytes()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); Mockito.when(tenantMapper.queryById(1)).thenReturn(null); Result result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg()); user.setTenantId(1); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg()); mockMultipartFile = new MockMultipartFile("test.pdf", "".getBytes()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_FILE_IS_EMPTY.getMsg(), result.getMsg()); mockMultipartFile = new MockMultipartFile("test.pdf", "test.pdf", "pdf", "test".getBytes()); PowerMockito.when(Files.getFileExtension("test.pdf")).thenReturn("pdf"); PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar"); result = resourcesService.createResource(user, "ResourcesServiceTest.jar", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_SUFFIX_FORBID_CHANGE.getMsg(), result.getMsg()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.UDF_UPLOAD, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true); mockMultipartFile = new MockMultipartFile("ResourcesServiceTest.pdf", "ResourcesServiceTest.pdf", "pdf", "test".getBytes()); PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.pdf")).thenReturn("pdf"); result = resourcesService.createResource(user, "ResourcesServiceTest.pdf", "ResourcesServiceTest", ResourceType.UDF, mockMultipartFile, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg(), result.getMsg()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPLOAD, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true); String tooLongFileName = getRandomStringWithLength(Constants.RESOURCE_FULL_NAME_MAX_LENGTH) + ".pdf"; mockMultipartFile = new MockMultipartFile(tooLongFileName, tooLongFileName, "pdf", "test".getBytes()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); PowerMockito.when(Files.getFileExtension(tooLongFileName)).thenReturn("pdf"); result = resourcesService.createResource(user, tooLongFileName, tooLongFileName, ResourceType.FILE, mockMultipartFile, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_FULL_NAME_TOO_LONG_ERROR.getMsg(), result.getMsg()); } @Test public void testCreateDirecotry() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); User user = new User(); user.setId(1); user.setUserType(UserType.GENERAL_USER); Result result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg()); user.setId(1); user.setTenantId(1); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(resourcesMapper.selectById(Mockito.anyInt())).thenReturn(null); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_RENAME, serviceLogger)).thenReturn(true); result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, 1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.PARENT_RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(resourcesMapper.existResource("/directoryTest", 0)).thenReturn(true); result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
@Test public void testUpdateResource() { PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); User user = new User(); user.setId(1); user.setUserType(UserType.GENERAL_USER); Result result = resourcesService.updateResource(user, 1, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString()); Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{0}, 1, serviceLogger)).thenReturn(true); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); result = resourcesService.updateResource(user, 0, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); user.setId(2); user.setUserType(UserType.GENERAL_USER); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 2, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 2, serviceLogger)).thenReturn(false); result = resourcesService.updateResource(user, 1, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString()); Assert.assertEquals(Status.NO_CURRENT_OPERATING_PERMISSION.getMsg(), result.getMsg()); user.setId(1);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); PowerMockito.when(storageOperate.getFileName(Mockito.any(), Mockito.any(), Mockito.anyString())).thenReturn("test1"); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF_FILE, 1, ApiFuncIdentificationConstant.UDF_UPDATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF_FILE, new Object[]{1}, 1, serviceLogger)).thenReturn(true); try { Mockito.when(storageOperate.exists(Mockito.any(), Mockito.any())).thenReturn(false); } catch (IOException e) { logger.error(e.getMessage(), e); } result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); user.setId(1); Mockito.when(userMapper.queryDetailsById(1)).thenReturn(getUser()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); try { Mockito.when(storageOperate.exists(Mockito.any(), Mockito.any())).thenReturn(true); } catch (IOException e) { logger.error(e.getMessage(), e); } PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true); result = resourcesService.updateResource(user, 1, "ResourcesServiceTest.jar", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); Mockito.when(resourcesMapper.existResource("/ResourcesServiceTest1.jar", 0)).thenReturn(true); result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.UDF_UPDATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true); Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(null); result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null); logger.info(result.toString()); Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode()); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); Mockito.when(tenantMapper.queryById(Mockito.anyInt())).thenReturn(null); result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null); logger.info(result.toString()); Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); PowerMockito.when(storageOperate.getResourceFileName(Mockito.any(), Mockito.any())).thenReturn("test"); try { } catch (Exception e) { logger.error(e.getMessage(), e); } result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest1.jar", ResourceType.UDF, null); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testQueryResourceListPaging() { User loginUser = new User(); loginUser.setId(1);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
loginUser.setUserType(UserType.ADMIN_USER); IPage<Resource> resourcePage = new Page<>(1, 10); resourcePage.setTotal(1); resourcePage.setRecords(getResourceList()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 0, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.RESOURCE_FILE_ID, 1, resourceLogger)).thenReturn(getSetIds()); Mockito.when(resourcesMapper.queryResourcePaging(Mockito.any(Page.class), eq(-1), eq(0), eq("test"), Mockito.any())).thenReturn(resourcePage); Result result = resourcesService.queryResourceListPaging(loginUser, -1, ResourceType.FILE, "test", 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode()); PageInfo pageInfo = (PageInfo) result.getData(); Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList())); } @Test public void testQueryResourceList() { User loginUser = new User(); loginUser.setId(0); loginUser.setUserType(UserType.ADMIN_USER); PowerMockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.RESOURCE_FILE_ID, 0, resourceLogger)).thenReturn(getSetIds()); Mockito.when(resourcesMapper.selectBatchIds(Mockito.anySet())).thenReturn(getResourceList()); Map<String, Object> result = resourcesService.queryResourceList(loginUser, ResourceType.FILE); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<Resource> resourceList = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resourceList)); PowerMockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.UDF_FILE, 0, resourceLogger)).thenReturn(getSetIds()); Mockito.when(resourcesMapper.selectBatchIds(Mockito.anySet())).thenReturn(Arrays.asList(getResource(11, ResourceType.UDF), getResource(10, ResourceType.UDF), getResource(9, ResourceType.UDF), getResource(8, ResourceType.UDF)));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
loginUser.setUserType(UserType.GENERAL_USER); result = resourcesService.queryResourceList(loginUser, ResourceType.UDF); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); resourceList = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(resourceList.size() == 4); } @Test public void testDelete() { User loginUser = new User(); loginUser.setId(0); loginUser.setUserType(UserType.GENERAL_USER); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 0, ApiFuncIdentificationConstant.FILE_DELETE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 0, serviceLogger)).thenReturn(true); try { Result result = resourcesService.delete(loginUser, 1); logger.info(result.toString()); Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 0, ApiFuncIdentificationConstant.FILE_DELETE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{2}, 0, serviceLogger)).thenReturn(true); result = resourcesService.delete(loginUser, 2); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
result = resourcesService.delete(loginUser, 2); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); loginUser.setUserType(UserType.ADMIN_USER); loginUser.setTenantId(2); Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(loginUser); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 0, ApiFuncIdentificationConstant.FILE_DELETE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 0, serviceLogger)).thenReturn(true); result = resourcesService.delete(loginUser, 1); logger.info(result.toString()); Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg()); loginUser.setTenantId(1); Mockito.when(storageOperate.delete(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(true); Mockito.when(processDefinitionMapper.listResources()).thenReturn(getResources()); Mockito.when(resourcesMapper.deleteIds(Mockito.any())).thenReturn(1); Mockito.when(resourceUserMapper.deleteResourceUserArray(Mockito.anyInt(), Mockito.any())).thenReturn(1); result = resourcesService.delete(loginUser, 1); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } catch (Exception e) { logger.error("delete error", e); Assert.assertTrue(false); } } @Test public void testVerifyResourceName() { PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_RENAME, serviceLogger)).thenReturn(true);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true); User user = new User(); user.setId(1); user.setUserType(UserType.GENERAL_USER); Mockito.when(resourcesMapper.existResource("/ResourcesServiceTest.jar", 0)).thenReturn(true); Result result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); String unExistFullName = "/test.jar"; try { Mockito.when(storageOperate.exists(Mockito.anyString(), eq(unExistFullName))).thenReturn(false); } catch (IOException e) { logger.error("hadoop error", e); } result = resourcesService.verifyResourceName("/test.jar", ResourceType.FILE, user); logger.info(result.toString()); Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg()); user.setTenantId(1); try { Mockito.when(storageOperate.exists(Mockito.any(), eq("test"))).thenReturn(true); } catch (IOException e) { logger.error("hadoop error", e); } PowerMockito.when(storageOperate.getResourceFileName("123", "test1")).thenReturn("test"); result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user); logger.info(result.toString()); Assert.assertTrue(Status.RESOURCE_EXIST.getCode() == result.getCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
result = resourcesService.verifyResourceName("test2", ResourceType.FILE, user); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testReadResource() { PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); Result result = resourcesService.readResource(getUser(), 1, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg()); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{2}, 1, serviceLogger)).thenReturn(true); result = resourcesService.readResource(getUser(), 2, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true); PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class"); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); result = resourcesService.readResource(getUser(), 1, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar"); PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar"); result = resourcesService.readResource(getUser(), 1, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.USER_NOT_EXIST.getCode(), (int) result.getCode()); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); result = resourcesService.readResource(getUser(), 1, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); try { Mockito.when(storageOperate.exists(Mockito.any(), Mockito.anyString())).thenReturn(false); } catch (IOException e) { logger.error("hadoop error", e); } result = resourcesService.readResource(getUser(), 1, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_FILE_NOT_EXIST.getCode(), (int) result.getCode()); try { Mockito.when(storageOperate.exists(Mockito.any(), Mockito.any())).thenReturn(true); Mockito.when(storageOperate.vimFile(Mockito.any(), Mockito.any(), eq(1), eq(10))).thenReturn(getContent()); } catch (IOException e) { logger.error("storage error", e); } result = resourcesService.readResource(getUser(), 1, 1, 10); logger.info(result.toString());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testOnlineCreateResource() { PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); PowerMockito.when(storageOperate.getResourceFileName(Mockito.anyString(), eq("hdfsdDir"))).thenReturn("hdfsDir"); PowerMockito.when(storageOperate.getUdfDir("udfDir")).thenReturn("udfDir"); User user = getUser(); user.setId(1); Result result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class"); result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg()); try { PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar"); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/"); } catch (RuntimeException ex) { logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), ex.getMessage()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_RENAME, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true); Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test"); PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true); result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testUpdateResourceContent() { PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true); Result result = resourcesService.updateResourceContent(getUser(), 1, "content"); logger.info(result.toString()); Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{2}, 1, serviceLogger)).thenReturn(true); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); result = resourcesService.updateResourceContent(getUser(), 2, "content"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true); PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class"); result = resourcesService.updateResourceContent(getUser(), 1, "content"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg()); PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar"); PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar"); result = resourcesService.updateResourceContent(getUser(), 1, "content"); logger.info(result.toString()); Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode()); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); result = resourcesService.updateResourceContent(getUser(), 1, "content"); logger.info(result.toString()); Assert.assertTrue(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getCode() == result.getCode()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test"); PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true); result = resourcesService.updateResourceContent(getUser(), 1, "content"); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testDownloadResource() { PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_DOWNLOAD, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
org.springframework.core.io.Resource resourceMock = Mockito.mock(org.springframework.core.io.Resource.class); try { org.springframework.core.io.Resource resource = resourcesService.downloadResource(getUser(), 1); Assert.assertNull(resource); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); PowerMockito.when(org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(Mockito.any())).thenReturn(resourceMock); resource = resourcesService.downloadResource(getUser(), 1); Assert.assertNotNull(resource); } catch (Exception e) { logger.error("DownloadResource error", e); Assert.assertTrue(false); } } @Test public void testAuthorizeResourceTree() { User user = getUser(); user.setId(1); user.setUserType(UserType.ADMIN_USER); int userId = 3; List<Integer> resIds = new ArrayList<>(); resIds.add(1); Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true); Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList()); Map<String, Object> result = resourcesService.authorizeResourceTree(user, userId); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
user.setId(2); user.setUserType(UserType.GENERAL_USER); Mockito.when(resourcesMapper.queryResourceListAuthored(user.getId(), -1)).thenReturn(getResourceList()); result = resourcesService.authorizeResourceTree(user, userId); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); resources = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); } @Test public void testUnauthorizedFile() { User user = getUser(); user.setId(1); user.setUserType(UserType.ADMIN_USER); int userId = 3; List<Integer> resIds = new ArrayList<>(); resIds.add(1); Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true); Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList()); Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds); Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getSingleResourceList()); Map<String, Object> result = resourcesService.unauthorizedFile(user, userId); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); user.setId(2);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
user.setUserType(UserType.GENERAL_USER); Mockito.when(resourcesMapper.queryResourceListAuthored(user.getId(), -1)).thenReturn(getResourceList()); result = resourcesService.unauthorizedFile(user, userId); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); resources = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); } @Test public void testUnauthorizedUDFFunction() { User user = getUser(); user.setId(1); user.setUserType(UserType.ADMIN_USER); int userId = 3; Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true); Mockito.when(udfFunctionMapper.queryUdfFuncExceptUserId(userId)).thenReturn(getUdfFuncList()); Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getSingleUdfFuncList()); Map<String, Object> result = resourcesService.unauthorizedUDFFunction(user, userId); logger.info(result.toString()); List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs)); user.setId(2); user.setUserType(UserType.GENERAL_USER); Mockito.when(udfFunctionMapper.selectByMap(Collections.singletonMap("user_id", user.getId()))).thenReturn(getUdfFuncList()); result = resourcesService.unauthorizedUDFFunction(user, userId); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs)); } @Test public void testAuthorizedUDFFunction() { User user = getUser(); user.setId(1); user.setUserType(UserType.ADMIN_USER); int userId = 3; Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true); Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList()); Map<String, Object> result = resourcesService.authorizedUDFFunction(user, userId); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs)); user.setUserType(UserType.GENERAL_USER); user.setId(2); Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList()); result = resourcesService.authorizedUDFFunction(user, userId); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs)); } @Test public void testAuthorizedFile() { User user = getUser(); user.setId(1);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
user.setUserType(UserType.ADMIN_USER); int userId = 3; List<Integer> resIds = new ArrayList<>(); resIds.add(1); Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true); Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds); Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList()); Map<String, Object> result = resourcesService.authorizedFile(user, userId); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); user.setId(2); user.setUserType(UserType.GENERAL_USER); Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds); Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList()); result = resourcesService.authorizedFile(user, userId); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); resources = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); } @Test public void testCatFile() { PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); try { Mockito.when(storageOperate.exists(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Mockito.when(storageOperate.vimFile(Mockito.anyString(), Mockito.anyString(), eq(1), eq(10))).thenReturn(getContent()); List<String> list = storageOperate.vimFile(Mockito.any(), Mockito.anyString(), eq(1), eq(10)); Assert.assertNotNull(list); } catch (IOException e) { logger.error("hadoop error", e); } } private List<Resource> getResourceList() { List<Resource> resources = new ArrayList<>(); resources.add(getResource(1)); resources.add(getResource(2)); resources.add(getResource(3)); return resources; } private Set<Integer> getSetIds() { Set<Integer> resources = new HashSet<>(); resources.add(1); return resources; } private List<Resource> getSingleResourceList() { return Collections.singletonList(getResource(1)); } private Tenant getTenant() { Tenant tenant = new Tenant(); tenant.setTenantCode("123"); return tenant; } private Resource getResource() { Resource resource = new Resource(); resource.setPid(-1);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
resource.setUserId(1); resource.setDescription("ResourcesServiceTest.jar"); resource.setAlias("ResourcesServiceTest.jar"); resource.setFullName("/ResourcesServiceTest.jar"); resource.setType(ResourceType.FILE); return resource; } private Resource getResource(int resourceId) { Resource resource = new Resource(); resource.setId(resourceId); resource.setPid(-1); resource.setUserId(1); resource.setDescription("ResourcesServiceTest.jar"); resource.setAlias("ResourcesServiceTest.jar"); resource.setFullName("/ResourcesServiceTest.jar"); resource.setType(ResourceType.FILE); return resource; } private Resource getResource(int resourceId,ResourceType type) { Resource resource = new Resource(); resource.setId(resourceId); resource.setPid(-1); resource.setUserId(1); resource.setDescription("ResourcesServiceTest.jar"); resource.setAlias("ResourcesServiceTest.jar"); resource.setFullName("/ResourcesServiceTest.jar"); resource.setType(type); return resource; } private Resource getUdfResource() {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Resource resource = new Resource(); resource.setUserId(1); resource.setDescription("udfTest"); resource.setAlias("udfTest.jar"); resource.setFullName("/udfTest.jar"); resource.setType(ResourceType.UDF); return resource; } private UdfFunc getUdfFunc() { UdfFunc udfFunc = new UdfFunc(); udfFunc.setId(1); return udfFunc; } private UdfFunc getUdfFunc(int udfId) { UdfFunc udfFunc = new UdfFunc(); udfFunc.setId(udfId); return udfFunc; } private List<UdfFunc> getUdfFuncList() { List<UdfFunc> udfFuncs = new ArrayList<>(); udfFuncs.add(getUdfFunc(1)); udfFuncs.add(getUdfFunc(2)); udfFuncs.add(getUdfFunc(3)); return udfFuncs; } private List<UdfFunc> getSingleUdfFuncList() { return Collections.singletonList(getUdfFunc(3)); } private User getUser() { User user = new User();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
user.setId(1); user.setUserType(UserType.GENERAL_USER); user.setTenantId(1); user.setTenantCode("tenantCode"); return user; } private List<String> getContent() { List<String> contentList = new ArrayList<>(); contentList.add("test"); return contentList; } private List<Map<String, Object>> getResources() { List<Map<String, Object>> resources = new ArrayList<>(); Map<String, Object> resource = new HashMap<>(); resource.put("id", 1); resource.put("resource_ids", "1"); resources.add(resource); return resources; } private static String getRandomStringWithLength(int length) { Random r = new Random(); StringBuilder sb = new StringBuilder(); while (sb.length() < length) { char c = (char) (r.nextInt(26) + 'a'); sb.append(c); } return sb.toString(); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
/* * 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.common; import org.apache.dolphinscheduler.plugin.task.api.enums.ExecutionStatus; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; import java.time.Duration; import java.util.regex.Pattern; /** * Constants */ public final class Constants {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
private Constants() { throw new UnsupportedOperationException("Construct Constants"); } /** * common properties path */ public static final String COMMON_PROPERTIES_PATH = "/common.properties"; /** * registry properties */ public static final String REGISTRY_DOLPHINSCHEDULER_MASTERS = "/nodes/master"; public static final String REGISTRY_DOLPHINSCHEDULER_WORKERS = "/nodes/worker"; public static final String REGISTRY_DOLPHINSCHEDULER_DEAD_SERVERS = "/dead-servers"; public static final String REGISTRY_DOLPHINSCHEDULER_NODE = "/nodes"; public static final String REGISTRY_DOLPHINSCHEDULER_LOCK_MASTERS = "/lock/masters"; public static final String REGISTRY_DOLPHINSCHEDULER_LOCK_FAILOVER_MASTERS = "/lock/failover/masters"; public static final String REGISTRY_DOLPHINSCHEDULER_LOCK_FAILOVER_WORKERS = "/lock/failover/workers"; public static final String REGISTRY_DOLPHINSCHEDULER_LOCK_FAILOVER_STARTUP_MASTERS = "/lock/failover/startup-masters"; public static final String FORMAT_SS = "%s%s"; public static final String FORMAT_S_S = "%s/%s"; public static final String FOLDER_SEPARATOR = "/"; public static final String RESOURCE_TYPE_FILE = "resources";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
public static final String RESOURCE_TYPE_UDF = "udfs"; public static final String STORAGE_S3 = "S3"; public static final String STORAGE_HDFS = "HDFS"; public static final String EMPTY_STRING = ""; /** * resource.hdfs.fs.defaultFS */ public static final String FS_DEFAULT_FS = "resource.hdfs.fs.defaultFS"; /** * hadoop configuration */ public static final String HADOOP_RM_STATE_ACTIVE = "ACTIVE"; public static final String HADOOP_RESOURCE_MANAGER_HTTPADDRESS_PORT = "resource.manager.httpaddress.port"; /** * yarn.resourcemanager.ha.rm.ids */ public static final String YARN_RESOURCEMANAGER_HA_RM_IDS = "yarn.resourcemanager.ha.rm.ids"; /** * yarn.application.status.address */ public static final String YARN_APPLICATION_STATUS_ADDRESS = "yarn.application.status.address"; /** * yarn.job.history.status.address */ public static final String YARN_JOB_HISTORY_STATUS_ADDRESS = "yarn.job.history.status.address"; /** * hdfs configuration * resource.hdfs.root.user */ public static final String HDFS_ROOT_USER = "resource.hdfs.root.user";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
/** * hdfs/s3 configuration * resource.storage.upload.base.path */ public static final String RESOURCE_UPLOAD_PATH = "resource.storage.upload.base.path"; /** * data basedir path */ public static final String DATA_BASEDIR_PATH = "data.basedir.path"; /** * dolphinscheduler.env.path */ public static final String DOLPHINSCHEDULER_ENV_PATH = "dolphinscheduler.env.path"; /** * environment properties default path */ public static final String ENV_PATH = "dolphinscheduler_env.sh"; /** * resource.view.suffixs */ public static final String RESOURCE_VIEW_SUFFIXES = "resource.view.suffixs"; public static final String RESOURCE_VIEW_SUFFIXES_DEFAULT_VALUE = "txt,log,sh,bat,conf,cfg,py,java,sql,xml,hql,properties,json,yml,yaml,ini,js"; /** * development.state */ public static final String DEVELOPMENT_STATE = "development.state"; /** * sudo enable */ public static final String SUDO_ENABLE = "sudo.enable";
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,822
[Improvement][Python] Python-gate supports creating or editing resources.
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Our company now deploy and manage scripts automatically through Python-gate, but resource files need to be maintained manually.We find it inconvenient.So, I think Python-gate should supports creating or editing resources. ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/10822
https://github.com/apache/dolphinscheduler/pull/10823
499e5b1307665928f2a17e878d091ac593adbfd8
59cd86157ff8d5ab25f0b200d6a30abd95a64c03
2022-07-07T02:40:19Z
java
2022-07-12T12:44:59Z
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
/** * string true */ public static final String STRING_TRUE = "true"; /** * resource storage type */ public static final String RESOURCE_STORAGE_TYPE = "resource.storage.type"; public static final String AWS_S3_BUCKET_NAME = "resource.aws.s3.bucket.name"; public static final String AWS_END_POINT = "resource.aws.s3.endpoint"; /** * comma , */ public static final String COMMA = ","; /** * COLON : */ public static final String COLON = ":"; /** * QUESTION ? */ public static final String QUESTION = "?"; /** * SPACE " " */ public static final String SPACE = " "; /** * SINGLE_SLASH / */ public static final String SINGLE_SLASH = "/";