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
11,007
[Bug] [Master] Recovery failed and stuck after successful enforcement of failed tasks in sub workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Recovery failed and stuck after successful enforcement of failed tasks in sub workflow ### What you expected to happen Sub workflow succeeded ### How to reproduce 1. AA workflow have three tasks A, B and C. A and B run successfully, while C fails 2. AA is a sub workflow of BB 3. Run BB. 4. Forced successfully C task 5. Execute on BB recovery Failed ### Anything else _No response_ ### Version 2.0.5 ### Are you willing to submit 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/11007
https://github.com/apache/dolphinscheduler/pull/11088
bfff3a7c5d58429dd14cb81f91931687b236a069
e5cca0e79bfe16d07e931bcc68c279643ad45fab
2022-07-16T09:21:52Z
java
2022-07-30T15:28:31Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
*/ @Override public boolean robTaskGroupResouce(TaskGroupQueue taskGroupQueue) { TaskGroup taskGroup = taskGroupMapper.selectById(taskGroupQueue.getGroupId()); int affectedCount = taskGroupMapper.updateTaskGroupResource(taskGroup.getId(), taskGroupQueue.getId(), TaskGroupQueueStatus.WAIT_QUEUE.getCode()); if (affectedCount > 0) { taskGroupQueue.setStatus(TaskGroupQueueStatus.ACQUIRE_SUCCESS); this.taskGroupQueueMapper.updateById(taskGroupQueue); this.taskGroupQueueMapper.updateInQueue(Flag.NO.getCode(), taskGroupQueue.getId()); return true; } return false; } @Override public boolean acquireTaskGroupAgain(TaskGroupQueue taskGroupQueue) { return robTaskGroupResouce(taskGroupQueue); } @Override public void releaseAllTaskGroup(int processInstanceId) { List<TaskInstance> taskInstances = this.taskInstanceMapper.loadAllInfosNoRelease(processInstanceId, TaskGroupQueueStatus.ACQUIRE_SUCCESS.getCode()); for (TaskInstance info : taskInstances) { releaseTaskGroup(info); } } /** * release the TGQ resource when the corresponding task is finished. * * @return the result code and msg */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,007
[Bug] [Master] Recovery failed and stuck after successful enforcement of failed tasks in sub workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Recovery failed and stuck after successful enforcement of failed tasks in sub workflow ### What you expected to happen Sub workflow succeeded ### How to reproduce 1. AA workflow have three tasks A, B and C. A and B run successfully, while C fails 2. AA is a sub workflow of BB 3. Run BB. 4. Forced successfully C task 5. Execute on BB recovery Failed ### Anything else _No response_ ### Version 2.0.5 ### Are you willing to submit 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/11007
https://github.com/apache/dolphinscheduler/pull/11088
bfff3a7c5d58429dd14cb81f91931687b236a069
e5cca0e79bfe16d07e931bcc68c279643ad45fab
2022-07-16T09:21:52Z
java
2022-07-30T15:28:31Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
@Override public TaskInstance releaseTaskGroup(TaskInstance taskInstance) { TaskGroup taskGroup = taskGroupMapper.selectById(taskInstance.getTaskGroupId()); if (taskGroup == null) { return null; } TaskGroupQueue thisTaskGroupQueue = this.taskGroupQueueMapper.queryByTaskId(taskInstance.getId()); if (thisTaskGroupQueue.getStatus() == TaskGroupQueueStatus.RELEASE) { return null; } try { while (thisTaskGroupQueue.getForceStart() == Flag.NO.getCode() && taskGroupMapper.releaseTaskGroupResource(taskGroup.getId(), taskGroup.getUseSize() , thisTaskGroupQueue.getId(), TaskGroupQueueStatus.ACQUIRE_SUCCESS.getCode()) != 1) { thisTaskGroupQueue = this.taskGroupQueueMapper.queryByTaskId(taskInstance.getId()); if (thisTaskGroupQueue.getStatus() == TaskGroupQueueStatus.RELEASE) { return null; } taskGroup = taskGroupMapper.selectById(taskInstance.getTaskGroupId()); } } catch (Exception e) { logger.error("release the task group error", e); } logger.info("updateTask:{}", taskInstance.getName()); changeTaskGroupQueueStatus(taskInstance.getId(), TaskGroupQueueStatus.RELEASE); TaskGroupQueue taskGroupQueue = this.taskGroupQueueMapper.queryTheHighestPriorityTasks(taskGroup.getId(), TaskGroupQueueStatus.WAIT_QUEUE.getCode(), Flag.NO.getCode(), Flag.NO.getCode()); if (taskGroupQueue == null) { return null; } while (this.taskGroupQueueMapper.updateInQueueCAS(Flag.NO.getCode(), Flag.YES.getCode(), taskGroupQueue.getId()) != 1) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,007
[Bug] [Master] Recovery failed and stuck after successful enforcement of failed tasks in sub workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Recovery failed and stuck after successful enforcement of failed tasks in sub workflow ### What you expected to happen Sub workflow succeeded ### How to reproduce 1. AA workflow have three tasks A, B and C. A and B run successfully, while C fails 2. AA is a sub workflow of BB 3. Run BB. 4. Forced successfully C task 5. Execute on BB recovery Failed ### Anything else _No response_ ### Version 2.0.5 ### Are you willing to submit 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/11007
https://github.com/apache/dolphinscheduler/pull/11088
bfff3a7c5d58429dd14cb81f91931687b236a069
e5cca0e79bfe16d07e931bcc68c279643ad45fab
2022-07-16T09:21:52Z
java
2022-07-30T15:28:31Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
taskGroupQueue = this.taskGroupQueueMapper.queryTheHighestPriorityTasks(taskGroup.getId(), TaskGroupQueueStatus.WAIT_QUEUE.getCode(), Flag.NO.getCode(), Flag.NO.getCode()); if (taskGroupQueue == null) { return null; } } return this.taskInstanceMapper.selectById(taskGroupQueue.getTaskId()); } /** * release the TGQ resource when the corresponding task is finished. * * @param taskId task id * @return the result code and msg */ @Override public void changeTaskGroupQueueStatus(int taskId, TaskGroupQueueStatus status) { TaskGroupQueue taskGroupQueue = taskGroupQueueMapper.queryByTaskId(taskId); taskGroupQueue.setStatus(status); taskGroupQueue.setUpdateTime(new Date(System.currentTimeMillis())); taskGroupQueueMapper.updateById(taskGroupQueue); } /** * insert into task group queue * * @param taskId task id * @param taskName task name * @param groupId group id * @param processId process id * @param priority priority * @return result and msg code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,007
[Bug] [Master] Recovery failed and stuck after successful enforcement of failed tasks in sub workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Recovery failed and stuck after successful enforcement of failed tasks in sub workflow ### What you expected to happen Sub workflow succeeded ### How to reproduce 1. AA workflow have three tasks A, B and C. A and B run successfully, while C fails 2. AA is a sub workflow of BB 3. Run BB. 4. Forced successfully C task 5. Execute on BB recovery Failed ### Anything else _No response_ ### Version 2.0.5 ### Are you willing to submit 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/11007
https://github.com/apache/dolphinscheduler/pull/11088
bfff3a7c5d58429dd14cb81f91931687b236a069
e5cca0e79bfe16d07e931bcc68c279643ad45fab
2022-07-16T09:21:52Z
java
2022-07-30T15:28:31Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
*/ @Override public TaskGroupQueue insertIntoTaskGroupQueue(Integer taskId, String taskName, Integer groupId, Integer processId, Integer priority, TaskGroupQueueStatus status) { TaskGroupQueue taskGroupQueue = new TaskGroupQueue(taskId, taskName, groupId, processId, priority, status); taskGroupQueue.setCreateTime(new Date()); taskGroupQueue.setUpdateTime(new Date()); taskGroupQueueMapper.insert(taskGroupQueue); return taskGroupQueue; } @Override public int updateTaskGroupQueueStatus(Integer taskId, int status) { return taskGroupQueueMapper.updateStatusByTaskId(taskId, status); } @Override public int updateTaskGroupQueue(TaskGroupQueue taskGroupQueue) { return taskGroupQueueMapper.updateById(taskGroupQueue); } @Override public TaskGroupQueue loadTaskGroupQueue(int taskId) { return this.taskGroupQueueMapper.queryByTaskId(taskId); } @Override public void sendStartTask2Master(ProcessInstance processInstance, int taskId, org.apache.dolphinscheduler.remote.command.CommandType taskType) { TaskEventChangeCommand taskEventChangeCommand = new TaskEventChangeCommand( processInstance.getId(), taskId ); Host host = new Host(processInstance.getHost());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
11,007
[Bug] [Master] Recovery failed and stuck after successful enforcement of failed tasks in sub workflow
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened Recovery failed and stuck after successful enforcement of failed tasks in sub workflow ### What you expected to happen Sub workflow succeeded ### How to reproduce 1. AA workflow have three tasks A, B and C. A and B run successfully, while C fails 2. AA is a sub workflow of BB 3. Run BB. 4. Forced successfully C task 5. Execute on BB recovery Failed ### Anything else _No response_ ### Version 2.0.5 ### Are you willing to submit 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/11007
https://github.com/apache/dolphinscheduler/pull/11088
bfff3a7c5d58429dd14cb81f91931687b236a069
e5cca0e79bfe16d07e931bcc68c279643ad45fab
2022-07-16T09:21:52Z
java
2022-07-30T15:28:31Z
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
stateEventCallbackService.sendResult(host, taskEventChangeCommand.convert2Command(taskType)); } @Override public ProcessInstance loadNextProcess4Serial(long code, int state, int id) { return this.processInstanceMapper.loadNextProcess4Serial(code, state, id); } protected void deleteCommandWithCheck(int commandId) { int delete = this.commandMapper.deleteById(commandId); if (delete != 1) { throw new ServiceException("delete command fail, id:" + commandId); } } /** * find k8s config yaml by clusterName * * @param clusterName clusterName * @return datasource */ @Override public String findConfigYamlByName(String clusterName) { if (Strings.isNullOrEmpty(clusterName)) { return null; } QueryWrapper<K8s> nodeWrapper = new QueryWrapper<>(); nodeWrapper.eq("k8s_name", clusterName); K8s k8s = k8sMapper.selectOne(nodeWrapper); return k8s.getK8sConfig(); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.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 org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.DataSourceService;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.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.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService; import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.enums.DbType; import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; import org.apache.dolphinscheduler.spi.utils.StringUtils; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
import java.util.List; import java.util.Map; import java.util.Set; import java.util.Optional; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.stereo.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.node.ObjectNode; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.*; /** * data source service impl */ @Service public class DataSourceServiceImpl extends BaseServiceImpl implements DataSourceService { private static final Logger logger = LoggerFactory.getLogger(DataSourceServiceImpl.class); @Autowired private DataSourceMapper dataSourceMapper; @Autowired private DataSourceUserMapper datasourceUserMapper; @Autowired private ResourcePermissionCheckService resourcePermissionCheckService; private static final String TABLE = "TABLE"; private static final String VIEW = "VIEW"; private static final String[] TABLE_TYPES = new String[]{TABLE, VIEW};
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
private static final String TABLE_NAME = "TABLE_NAME"; private static final String COLUMN_NAME = "COLUMN_NAME"; /** * create data source * * @param loginUser login user * @param datasourceParam datasource parameters * @return create result code */ @Override @Transactional public Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) { DataSourceUtils.checkDatasourceParam(datasourceParam); Result<Object> result = new Result<>(); if (!canOperatorPermissions(loginUser,null, AuthorizationType.DATASOURCE, DATASOURCE_CREATE_DATASOURCE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (checkName(datasourceParam.getName())) { putMsg(result, Status.DATASOURCE_EXIST); return result; } ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(datasourceParam); Result<Object> isConnection = checkConnection(datasourceParam.getType(), connectionParam); if (Status.SUCCESS.getCode() != isConnection.getCode()) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
DataSource dataSource = new DataSource(); Date now = new Date(); dataSource.setName(datasourceParam.getName().trim()); dataSource.setNote(datasourceParam.getNote()); dataSource.setUserId(loginUser.getId()); dataSource.setUserName(loginUser.getUserName()); dataSource.setType(datasourceParam.getType()); dataSource.setConnectionParams(JSONUtils.toJsonString(connectionParam)); dataSource.setCreateTime(now); dataSource.setUpdateTime(now); try { dataSourceMapper.insert(dataSource); putMsg(result, Status.SUCCESS); permissionPostHandle(AuthorizationType.DATASOURCE, loginUser.getId(), Collections.singletonList(dataSource.getId()), logger); } catch (DuplicateKeyException ex) { logger.error("Create datasource error.", ex); putMsg(result, Status.DATASOURCE_EXIST); } return result; } /** * updateProcessInstance datasource * * @param loginUser login user * @param id data source id * @return update result code */ @Override public Result<Object> updateDataSource(int id, User loginUser, BaseDataSourceParamDTO dataSourceParam) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
DataSourceUtils.checkDatasourceParam(dataSourceParam); Result<Object> result = new Result<>(); DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!canOperatorPermissions(loginUser,new Object[]{dataSource.getId()}, AuthorizationType.DATASOURCE, DATASOURCE_UPDATE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (!dataSource.getName().trim().equals(dataSource.getName()) && checkName(dataSource.getName())) { putMsg(result, Status.DATASOURCE_EXIST); return result; } BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams(dataSourceParam); String password = connectionParam.getPassword(); if (StringUtils.isBlank(password)) { String oldConnectionParams = dataSource.getConnectionParams(); ObjectNode oldParams = JSONUtils.parseObject(oldConnectionParams); connectionParam.setPassword(oldParams.path(Constants.PASSWORD).asText()); } Result<Object> isConnection = checkConnection(dataSource.getType(), connectionParam); if (isConnection.isFailed()) { return isConnection; } Date now = new Date();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
dataSource.setName(dataSourceParam.getName().trim()); dataSource.setNote(dataSourceParam.getNote()); dataSource.setUserName(loginUser.getUserName()); dataSource.setType(dataSource.getType()); dataSource.setConnectionParams(JSONUtils.toJsonString(connectionParam)); dataSource.setUpdateTime(now); try { dataSourceMapper.updateById(dataSource); putMsg(result, Status.SUCCESS); } catch (DuplicateKeyException ex) { logger.error("Update datasource error.", ex); putMsg(result, Status.DATASOURCE_EXIST); } return result; } private boolean checkName(String name) { List<DataSource> queryDataSource = dataSourceMapper.queryDataSourceByName(name.trim()); return queryDataSource != null && !queryDataSource.isEmpty(); } /** * updateProcessInstance datasource * * @param id datasource id * @return data source detail */ @Override public Map<String, Object> queryDataSource(int id) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } // BaseDataSourceParamDTO baseDataSourceParamDTO = DataSourceUtils.buildDatasourceParamDTO( dataSource.getType(), dataSource.getConnectionParams()); baseDataSourceParamDTO.setId(dataSource.getId()); baseDataSourceParamDTO.setName(dataSource.getName()); baseDataSourceParamDTO.setNote(dataSource.getNote()); result.put(Constants.DATA_LIST, baseDataSourceParamDTO); putMsg(result, Status.SUCCESS); return result; } /** * query datasource list by keyword * * @param loginUser login user * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return data source list page */ @Override public Result queryDataSourceListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); IPage<DataSource> dataSourceList = null; Page<DataSource> dataSourcePage = new Page<>(pageNo, pageSize); PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize); if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { dataSourceList = dataSourceMapper.selectPaging(dataSourcePage, UserType.ADMIN_USER.equals(loginUser.getUserType()) ? 0 : loginUser.getId(), searchVal);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} else { Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), logger); if (ids.isEmpty()) { result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } dataSourceList = dataSourceMapper.selectPagingByIds(dataSourcePage, new ArrayList<>(ids), searchVal); } List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>(); handlePasswd(dataSources); pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L)); pageInfo.setTotalList(dataSources); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /** * handle datasource connection password for safety */ private void handlePasswd(List<DataSource> dataSourceList) { for (DataSource dataSource : dataSourceList) { String connectionParams = dataSource.getConnectionParams(); ObjectNode object = JSONUtils.parseObject(connectionParams); object.put(Constants.PASSWORD, getHiddenPassword()); dataSource.setConnectionParams(object.toString()); } } /** * get hidden password (resolve the security hotspot)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
* * @return hidden password */ private String getHiddenPassword() { return Constants.XXXXXX; } /** * query data resource list * * @param loginUser login user * @param data source * @return data source list page */ @Override public Map<String, Object> queryDataSourceList(User loginUser, Integer ) { Map<String, Object> result = new HashMap<>(); List<DataSource> datasourceList = null; if (loginUser.getUserType().equals(UserType.ADMIN_USER)) { datasourceList = dataSourceMapper.queryDataSourceByType(0, ); } else { Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), logger); if (ids.isEmpty()) { result.put(Constants.DATA_LIST, Collections.emptyList()); putMsg(result, Status.SUCCESS); return result; } datasourceList = dataSourceMapper.selectBatchIds(ids).stream().filter(dataSource -> dataSource.getType().getCode() == ).collect(Collectors.toList()); } result.put(Constants.DATA_LIST, datasourceList); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
return result; } /** * verify datasource exists * * @param name datasource name * @return true if data datasource not exists, otherwise return false */ @Override public Result<Object> verifyDataSourceName(String name) { Result<Object> result = new Result<>(); List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(name); if (dataSourceList != null && !dataSourceList.isEmpty()) { putMsg(result, Status.DATASOURCE_EXIST); } else { putMsg(result, Status.SUCCESS); } return result; } /** * check connection * * @param data source * @param connectionParam connectionParam * @return true if connect successfully, otherwise false * @return true if connect successfully, otherwise false */ @Override public Result<Object> checkConnection(DbType , ConnectionParam connectionParam) { Result<Object> result = new Result<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
try (Connection connection = DataSourceClientProvider.getInstance().getConnection(, connectionParam)) { if (connection == null) { putMsg(result, Status.CONNECTION_TEST_FAILURE); return result; } putMsg(result, Status.SUCCESS); return result; } catch (Exception e) { String message = Optional.of(e).map(Throwable::getCause) .map(Throwable::getMessage) .orElse(e.getMessage()); logger.error("datasource test connection error, dbType:{}, connectionParam:{}, message:{}.", , connectionParam, message); return new Result<>(Status.CONNECTION_TEST_FAILURE.getCode(), message); } } /** * test connection * * @param id datasource id * @return connect result code */ @Override public Result<Object> connectionTest(int id) { DataSource dataSource = dataSourceMapper.selectById(id); if (dataSource == null) { Result<Object> result = new Result<>(); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } return checkConnection(dataSource.getType(), DataSourceUtils.buildConnectionParams(dataSource.getType(), dataSource.getConnectionParams()));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} /** * delete datasource * * @param loginUser login user * @param datasourceId data source id * @return delete result code */ @Override @Transactional public Result<Object> delete(User loginUser, int datasourceId) { Result<Object> result = new Result<>(); try { // DataSource dataSource = dataSourceMapper.selectById(datasourceId); if (dataSource == null) { logger.error("resource id {} not exist", datasourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!canOperatorPermissions(loginUser, new Object[]{dataSource.getId()},AuthorizationType.DATASOURCE,DATASOURCE_DELETE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } dataSourceMapper.deleteById(datasourceId); datasourceUserMapper.deleteByDatasourceId(datasourceId); putMsg(result, Status.SUCCESS); } catch (Exception e) { logger.error("delete datasource error", e); throw new RuntimeException("delete datasource error");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} return result; } /** * unauthorized datasource * * @param loginUser login user * @param userId user id * @return unauthed data source result code */ @Override public Map<String, Object> unauthDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); List<DataSource> datasourceList; if (canOperatorPermissions(loginUser,null,AuthorizationType.DATASOURCE,null)) { // datasourceList = dataSourceMapper.queryDatasourceExceptUserId(userId); } else { // datasourceList = dataSourceMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId())); } List<DataSource> resultList = new ArrayList<>(); Set<DataSource> datasourceSet; if (datasourceList != null && !datasourceList.isEmpty()) { datasourceSet = new HashSet<>(datasourceList); List<DataSource> authedDataSourceList = dataSourceMapper.queryAuthedDatasource(userId); Set<DataSource> authedDataSourceSet; if (authedDataSourceList != null && !authedDataSourceList.isEmpty()) { authedDataSourceSet = new HashSet<>(authedDataSourceList); datasourceSet.removeAll(authedDataSourceSet);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
} resultList = new ArrayList<>(datasourceSet); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * authorized datasource * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authedDatasource(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); List<DataSource> authedDatasourceList = dataSourceMapper.queryAuthedDatasource(userId); result.put(Constants.DATA_LIST, authedDatasourceList); putMsg(result, Status.SUCCESS); return result; } @Override public Map<String, Object> getTables(Integer datasourceId) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(datasourceId); List<String> tableList = null; BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( dataSource.getType(),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
dataSource.getConnectionParams()); if (null == connectionParam) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; } Connection connection = DataSourceUtils.getConnection(dataSource.getType(), connectionParam); ResultSet tables = null; try { if (null == connection) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; } DatabaseMetaData metaData = connection.getMetaData(); String schema = null; try { schema = metaData.getConnection().getSchema(); } catch (SQLException e) { logger.error("cant not get the schema : {}", e.getMessage(), e); } tables = metaData.getTables( connectionParam.getDatabase(), getDbSchemaPattern(dataSource.getType(),schema,connectionParam), "%", TABLE_TYPES); if (null == tables) { putMsg(result, Status.GET_DATASOURCE_TABLES_ERROR); return result; } tableList = new ArrayList<>(); while (tables.next()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
String name = tables.getString(TABLE_NAME); tableList.add(name); } } catch (Exception e) { logger.error(e.toString(), e); putMsg(result, Status.GET_DATASOURCE_TABLES_ERROR); return result; } finally { closeResult(tables); releaseConnection(connection); } List<ParamsOptions> options = getParamsOptions(tableList); result.put(Constants.DATA_LIST, options); putMsg(result, Status.SUCCESS); return result; } @Override public Map<String, Object> getTableColumns(Integer datasourceId,String tableName) { Map<String, Object> result = new HashMap<>(); DataSource dataSource = dataSourceMapper.selectById(datasourceId); BaseConnectionParam connectionParam = (BaseConnectionParam) DataSourceUtils.buildConnectionParams( dataSource.getType(), dataSource.getConnectionParams()); if (null == connectionParam) { putMsg(result, Status.DATASOURCE_CONNECT_FAILED); return result; } Connection connection = DataSourceUtils.getConnection(dataSource.getType(), connectionParam);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
List<String> columnList = new ArrayList<>(); ResultSet rs = null; try { String database = connectionParam.getDatabase(); if (null == connection) { return result; } DatabaseMetaData metaData = connection.getMetaData(); if (dataSource.getType() == DbType.ORACLE) { database = null; } rs = metaData.getColumns(database, null, tableName, "%"); if (rs == null) { return result; } while (rs.next()) { columnList.add(rs.getString(COLUMN_NAME)); } } catch (Exception e) { logger.error(e.toString(), e); } finally { closeResult(rs); releaseConnection(connection); } List<ParamsOptions> options = getParamsOptions(columnList); result.put(Constants.DATA_LIST, options); putMsg(result, Status.SUCCESS); return result; } private List<ParamsOptions> getParamsOptions(List<String> columnList) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
List<ParamsOptions> options = null; if (CollectionUtils.isNotEmpty(columnList)) { options = new ArrayList<>(); for (String column : columnList) { ParamsOptions childrenOption = new ParamsOptions(column, column, false); options.add(childrenOption); } } return options; } private String getDbSchemaPattern(DbType dbType,String schema,BaseConnectionParam connectionParam) { if (dbType == null) { return null; } String schemaPattern = null; switch (dbType) { case HIVE: schemaPattern = connectionParam.getDatabase(); break; case ORACLE: schemaPattern = connectionParam.getUser(); if (null != schemaPattern) { schemaPattern = schemaPattern.toUpperCase(); } break; case SQLSERVER: schemaPattern = "dbo"; break; case CLICKHOUSE:
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
case PRESTO: if (!StringUtils.isEmpty(schema)) { schemaPattern = schema; } break; default: break; } return schemaPattern; } private static void releaseConnection(Connection connection) { if (null != connection) { try { connection.close(); } catch (Exception e) { logger.error("Connection release error", e); } } } private static void closeResult(ResultSet rs) { if (rs != null) { try { rs.close(); } catch (Exception e) { logger.error("ResultSet close error", e); } } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.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 static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.PROJECT; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.PROJECT_CREATE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.PROJECT_DELETE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.PROJECT_UPDATE; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService; import org.apache.dolphinscheduler.api.service.ProjectService; 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.utils.CodeGenerateUtils;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; 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.ProjectUserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.commons.lang3.StringUtils; import java.text.MessageFormat; import java.util.ArrayList; 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.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * project service impl **/ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
public class ProjectServiceImpl extends BaseServiceImpl implements ProjectService{ private static final Logger logger = LoggerFactory.getLogger(ProjectServiceImpl.class); @Autowired private ProjectMapper projectMapper; @Autowired private ProjectUserMapper projectUserMapper; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private UserMapper userMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
@Autowired private ResourcePermissionCheckService resourcePermissionCheckService; /** * create project * * @param loginUser login user * @param name project name * @param desc description * @return returns an error if it exists */ @Override @Transactional public Result createProject(User loginUser, String name, String desc) { Result result = new Result(); checkDesc(result, desc); if (result.getCode() != Status.SUCCESS.getCode()) { return result; } if (!canOperatorPermissions(loginUser, null,AuthorizationType.PROJECTS, PROJECT_CREATE)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } Project project = projectMapper.queryByName(name); if (project != null) { putMsg(result, Status.PROJECT_ALREADY_EXISTS, name); return result; } Date now = new Date(); try { project = Project
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
.newBuilder() .name(name) .code(CodeGenerateUtils.getInstance().genCode()) .description(desc) .userId(loginUser.getId()) .userName(loginUser.getUserName()) .createTime(now) .updateTime(now) .build(); } catch (CodeGenerateException e) { putMsg(result, Status.CREATE_PROJECT_ERROR); return result; } if (projectMapper.insert(project) > 0) { result.setData(project); putMsg(result, Status.SUCCESS); permissionPostHandle(AuthorizationType.PROJECTS, loginUser.getId(), Collections.singletonList(project.getId()), logger); } else { putMsg(result, Status.CREATE_PROJECT_ERROR); } logger.info("create project complete and id is :{}", project.getId()); return result; } /** * check project description * * @param result * @param desc desc */ public static void checkDesc(Result result, String desc) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
if (!StringUtils.isEmpty(desc) && desc.length() > 200) { result.setCode(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode()); result.setMsg(MessageFormat.format(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getMsg(), "desc length")); } else { result.setCode(Status.SUCCESS.getCode()); } } /** * query project details by code * * @param projectCode project code * @return project detail information */ @Override public Result queryByCode(User loginUser, long projectCode) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode); boolean hasProjectAndPerm = hasProjectAndPerm(loginUser, project, result, PROJECT); if (!hasProjectAndPerm) { return result; } if (project != null) { result.setData(project); putMsg(result, Status.SUCCESS); } return result; } @Override public Map<String, Object> queryByName(User loginUser, String projectName) { Map<String, Object> result = new HashMap<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
Project project = projectMapper.queryByName(projectName); boolean hasProjectAndPerm = hasProjectAndPerm(loginUser, project, result,PROJECT); if (!hasProjectAndPerm) { return result; } if (project != null) { result.put(Constants.DATA_LIST, project); putMsg(result, Status.SUCCESS); } return result; } /** * check project and authorization * * @param loginUser login user * @param project project * @param projectCode project code * @return true if the login user have permission to see the project */ @Override public Map<String, Object> checkProjectAndAuth(User loginUser, Project project, long projectCode, String permission) { Map<String, Object> result = new HashMap<>(); if (project == null) { putMsg(result, Status.PROJECT_NOT_EXIST); } else if (!canOperatorPermissions(loginUser, new Object[] {project.getId()}, AuthorizationType.PROJECTS, permission)) { putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), projectCode); } else { putMsg(result, Status.SUCCESS); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
return result; } @Override public boolean hasProjectAndPerm(User loginUser, Project project, Map<String, Object> result, String permission) { boolean checkResult = false; if (project == null) { putMsg(result, Status.PROJECT_NOT_FOUND, ""); } else if (!canOperatorPermissions(loginUser, new Object[] {project.getId()}, AuthorizationType.PROJECTS, permission)) { putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getCode()); } else { checkResult = true; } return checkResult; } @Override public boolean hasProjectAndPerm(User loginUser, Project project, Result result, String permission) { boolean checkResult = false; if (project == null) { putMsg(result, Status.PROJECT_NOT_FOUND, ""); } else if (!canOperatorPermissions(loginUser, new Object[] {project.getId()}, AuthorizationType.PROJECTS, permission)) { putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getName()); } else { checkResult = true; } return checkResult; } /** * admin can view all projects * * @param loginUser login user
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
* @param searchVal search value * @param pageSize page size * @param pageNo page number * @return project list which the login user have permission to see */ @Override public Result queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal) { Result result = new Result(); PageInfo<Project> pageInfo = new PageInfo<>(pageNo, pageSize); Page<Project> page = new Page<>(pageNo, pageSize); Set<Integer> projectIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger); if (projectIds.isEmpty()) { result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } IPage<Project> projectIPage = projectMapper.queryProjectListPaging(page, new ArrayList<>(projectIds), searchVal); List<Project> projectList = projectIPage.getRecords(); if (loginUser.getUserType() != UserType.ADMIN_USER) { for (Project project : projectList) { project.setPerm(Constants.DEFAULT_ADMIN_PERMISSION); } } pageInfo.setTotal((int) projectIPage.getTotal()); pageInfo.setTotalList(projectList); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
* delete project by code * * @param loginUser login user * @param projectCode project code * @return delete result code */ @Override public Result deleteProject(User loginUser, Long projectCode) { Result result = new Result(); Project project = projectMapper.queryByCode(projectCode); checkProjectAndAuth(result, loginUser, project, project == null ? 0L : project.getCode(), PROJECT_DELETE); if (result.getCode() != Status.SUCCESS.getCode()) { return result; } List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryAllDefinitionList(project.getCode()); if (!processDefinitionList.isEmpty()) { putMsg(result, Status.DELETE_PROJECT_ERROR_DEFINES_NOT_NULL); return result; } int delete = projectMapper.deleteById(project.getId()); if (delete > 0) { result.setData(Boolean.TRUE); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.DELETE_PROJECT_ERROR); } return result; } /** * get check result
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
* * @param loginUser login user * @param project project * @return check result */ private Map<String, Object> getCheckResult(User loginUser, Project project,String perm) { Map<String, Object> checkResult = checkProjectAndAuth(loginUser, project, project == null ? 0L : project.getCode(),perm); Status status = (Status) checkResult.get(Constants.STATUS); if (status != Status.SUCCESS) { return checkResult; } return null; } /** * updateProcessInstance project * * @param loginUser login user * @param projectCode project code * @param projectName project name * @param desc description * @param userName project owner * @return update result code */ @Override public Result update(User loginUser, Long projectCode, String projectName, String desc, String userName) { Result result = new Result(); checkDesc(result, desc); if (result.getCode() != Status.SUCCESS.getCode()) { return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
Project project = projectMapper.queryByCode(projectCode); boolean hasProjectAndPerm = hasProjectAndPerm(loginUser, project, result, PROJECT_UPDATE); if (!hasProjectAndPerm) { return result; } Project tempProject = projectMapper.queryByName(projectName); if (tempProject != null && tempProject.getCode() != project.getCode()) { putMsg(result, Status.PROJECT_ALREADY_EXISTS, projectName); return result; } User user = userMapper.queryByUserNameAccurately(userName); if (user == null) { putMsg(result, Status.USER_NOT_EXIST, userName); return result; } project.setName(projectName); project.setDescription(desc); project.setUpdateTime(new Date()); project.setUserId(user.getId()); int update = projectMapper.updateById(project); if (update > 0) { result.setData(project); putMsg(result, Status.SUCCESS); } else { putMsg(result, Status.UPDATE_PROJECT_ERROR); } return result; } /** * query unauthorized project
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
* * @param loginUser login user * @param userId user id * @return the projects which user have not permission to see */ @Override public Result queryUnauthorizedProject(User loginUser, Integer userId) { Result result = new Result(); Set<Integer> projectIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger); if (projectIds.isEmpty()) { result.setData(Collections.emptyList()); putMsg(result, Status.SUCCESS); return result; } List<Project> projectList = projectMapper.listAuthorizedProjects(loginUser.getUserType().equals(UserType.ADMIN_USER) ? 0 : loginUser.getId(), new ArrayList<>(projectIds)); List<Project> resultList = new ArrayList<>(); Set<Project> projectSet; if (projectList != null && !projectList.isEmpty()) { projectSet = new HashSet<>(projectList); List<Project> authedProjectList = projectMapper.queryAuthedProjectListByUserId(userId); resultList = getUnauthorizedProjects(projectSet, authedProjectList); } result.setData(resultList); putMsg(result, Status.SUCCESS); return result; } /** * get unauthorized project * * @param projectSet project set
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
* @param authedProjectList authed project list * @return project list that authorization */ private List<Project> getUnauthorizedProjects(Set<Project> projectSet, List<Project> authedProjectList) { List<Project> resultList; Set<Project> authedProjectSet; if (authedProjectList != null && !authedProjectList.isEmpty()) { authedProjectSet = new HashSet<>(authedProjectList); projectSet.removeAll(authedProjectSet); } resultList = new ArrayList<>(projectSet); return resultList; } /** * query authorized project * * @param loginUser login user * @param userId user id * @return projects which the user have permission to see, Except for items created by this user */ @Override public Result queryAuthorizedProject(User loginUser, Integer userId) { Result result = new Result(); List<Project> projects = projectMapper.queryAuthedProjectListByUserId(userId); result.setData(projects); putMsg(result, Status.SUCCESS); return result; } /** * query authorized user
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
* * @param loginUser login user * @param projectCode project code * @return users who have permission for the specified project */ @Override public Result queryAuthorizedUser(User loginUser, Long projectCode) { Result result = new Result(); Project project = this.projectMapper.queryByCode(projectCode); boolean hasProjectAndPerm = this.hasProjectAndPerm(loginUser, project, result, PROJECT); if (!hasProjectAndPerm) { return result; } List<User> users = this.userMapper.queryAuthedUserListByProjectId(project.getId()); result.setData(users); this.putMsg(result, Status.SUCCESS); return result; } /** * query authorized project * * @param loginUser login user * @return projects which the user have permission to see, Except for items created by this user */ @Override public Map<String, Object> queryProjectCreatedByUser(User loginUser) { Map<String, Object> result = new HashMap<>(); List<Project> projects = projectMapper.queryProjectCreatedByUser(loginUser.getId());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
result.put(Constants.DATA_LIST, projects); putMsg(result, Status.SUCCESS); return result; } /** * query authorized and user create project list by user * * @param loginUser login user * @return project list */ @Override public Result queryProjectCreatedAndAuthorizedByUser(User loginUser) { Result result = new Result(); Set<Integer> projectIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger); if (projectIds.isEmpty()) { result.setData(Collections.emptyList()); putMsg(result, Status.SUCCESS); return result; } List<Project> projects = projectMapper.selectBatchIds(projectIds); result.setData(projects); putMsg(result, Status.SUCCESS); return result; } /** * check whether have read permission * * @param user user * @param project project * @return true if the user have permission to see the project, otherwise return false
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
*/ private boolean checkReadPermission(User user, Project project) { int permissionId = queryPermission(user, project); return (permissionId & Constants.READ_PERMISSION) != 0; } /** * query permission id * * @param user user * @param project project * @return permission */ private int queryPermission(User user, Project project) { if (user.getUserType() == UserType.ADMIN_USER) { return Constants.READ_PERMISSION; } if (project.getUserId() == user.getId()) { return Constants.ALL_PERMISSIONS; } ProjectUser projectUser = projectUserMapper.queryProjectRelation(project.getId(), user.getId()); if (projectUser == null) { return 0; } return projectUser.getPerm(); } /** * query all project list * @param user * @return project list */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
@Override public Result queryAllProjectList(User user) { Result result = new Result(); List<Project> projects = projectMapper.queryAllProject(user.getUserType() == UserType.ADMIN_USER ? 0 : user.getId()); result.setData(projects); putMsg(result, Status.SUCCESS); return result; } /** * check project and authorization * * @param result result * @param loginUser login user * @param project project * @param projectCode project code * @return true if the login user have permission to see the project */ @Override public void checkProjectAndAuth(Result result, User loginUser, Project project, long projectCode, String permission) { if (project == null) { putMsg(result, Status.PROJECT_NOT_EXIST); } else if (!canOperatorPermissions(loginUser, new Object[] {project.getId()}, AuthorizationType.PROJECTS, permission)) { putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), projectCode); } else { putMsg(result, Status.SUCCESS); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import org.apache.commons.collections.CollectionUtils; 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;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; 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;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import static org.apache.dolphinscheduler.common.Constants.EMPTY_STRING; import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR; 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; import static org.apache.dolphinscheduler.common.Constants.PERIOD; /** * 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* * @param loginUser login user * @param name alias * @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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } String fullName = getFullName(currentDir, name); 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) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("resource already exists, can't recreate ", e); throw new ServiceException("resource already exists, can't recreate"); } 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,
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String currentDir) { Result<Object> result = new Result<>(); String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPLOAD : ApiFuncIdentificationConstant.UDF_UPLOAD; boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey); if (!canOperatorPermissions){ putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); return result; } result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } result = verifyPid(loginUser, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } if (fullName.length() > Constants.RESOURCE_FULL_NAME_MAX_LENGTH) { 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()));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} return result; } /** * 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); } } } } } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* check resource is exists * * @param fullName fullName * @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<>();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE; boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(type), funcPermissionKey); if (!canOperatorPermissions){ 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();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
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); 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()) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String originSuffix = Files.getFileExtension(originFullName); String suffix = Files.getFileExtension(fullName); boolean suffixIsChanged = false; 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
resource.setFullName(fullName); resource.setDescription(desc); resource.setUpdateTime(now); 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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (file != null) { if (!upload(loginUser, fullName, file, type)) { 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; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
private Result<Object> verifyFile(String name, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); 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; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) { logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg()); 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (directory == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } } 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();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String directoryName = storageOperate.getFileName(type, tenantCode, fullName); String resourceRootPath = storageOperate.getDir(type, tenantCode); try { 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)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return false; } 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 */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
@Override public Map<String, Object> queryResourceList(User loginUser, ResourceType type) { Map<String, Object> result = new HashMap<>(); 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:
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
case SCALA: break; case PYTHON: 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return resultCheck; } String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DELETE : ApiFuncIdentificationConstant.UDF_DELETE; 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
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()); 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);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
storageOperate.delete(tenantCode, storageFilename, true); putMsg(result, Status.SUCCESS); return result; } /** * 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();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
try { String filename = storageOperate.getFileName(type, tenantCode, fullName); if (storageOperate.exists(tenantCode, filename)) { 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; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Resource resource; if (StringUtils.isNotBlank(fullName)) { List<Resource> resourceList = resourcesMapper.queryResource(fullName, type.ordinal()); 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; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * get resource by id * @param id resource id * @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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ @Override public Result<Object> readResource(User loginUser, int resourceId, int skipLineNum, int limit) { 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; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String tenantCode = getTenantCode(resource.getUserId(), result); if (StringUtils.isEmpty(tenantCode)) { return result; } 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param fileName file name * @param fileSuffix file suffix * @param desc description * @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(","));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support create", nameSuffix); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); 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());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} return result; } /** * create or update resource. * If the folder is not already created, it will be * * @param loginUser user who create or update resource * @param fileFullName The full name of resource.Includes path and suffix. * @param desc description of resource * @param content content of resource * @return create result code */ @Override @Transactional public Result<Object> onlineCreateOrUpdateResourceWithDir(User loginUser, String fileFullName, String desc, String content) { if (checkResourceExists(fileFullName, ResourceType.FILE.ordinal())) { Resource resource = resourcesMapper.queryResource(fileFullName, ResourceType.FILE.ordinal()).get(0); Result<Object> result = this.updateResourceContent(loginUser, resource.getId(), content); if (result.getCode() == Status.SUCCESS.getCode()) { resource.setDescription(desc); 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); } return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} else { String resourceSuffix = fileFullName.substring(fileFullName.indexOf(PERIOD) + 1); String fileNameWithSuffix = fileFullName.substring(fileFullName.lastIndexOf(FOLDER_SEPARATOR) + 1); String resourceDir = fileFullName.replace(fileNameWithSuffix, EMPTY_STRING); String resourceName = fileNameWithSuffix.replace(PERIOD + resourceSuffix, EMPTY_STRING); String[] dirNames = resourceDir.split(FOLDER_SEPARATOR); int pid = -1; StringBuilder currDirPath = new StringBuilder(); for (String dirName : dirNames) { if (StringUtils.isNotEmpty(dirName)) { pid = queryOrCreateDirId(loginUser, pid, currDirPath.toString(), dirName); currDirPath.append(FOLDER_SEPARATOR).append(dirName); } } return this.onlineCreateResource( loginUser, ResourceType.FILE, resourceName, resourceSuffix, desc, content, pid, currDirPath.toString()); } } @Override @Transactional public Integer createOrUpdateResource(String userName, String fullName, String description, String resourceContent) { User user = userMapper.queryByUserNameAccurately(userName); int suffixLabelIndex = fullName.indexOf(PERIOD); if (suffixLabelIndex == -1) { String msg = String.format("The suffix of file can not be empty : %s", fullName); logger.error(msg); throw new IllegalArgumentException(msg); } if (!fullName.startsWith(FOLDER_SEPARATOR)) { fullName = FOLDER_SEPARATOR + fullName;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} Result<Object> createResult = onlineCreateOrUpdateResourceWithDir( user, fullName, description, resourceContent); if (createResult.getCode() == Status.SUCCESS.getCode()) { Map<String, Object> resultMap = (Map<String, Object>) createResult.getData(); return (int) resultMap.get("id"); } String msg = String.format("Can not create or update resource : %s", fullName); logger.error(msg); throw new IllegalArgumentException(msg); } private int queryOrCreateDirId(User user, int pid, String currentDir, String dirName) { String dirFullName = currentDir + FOLDER_SEPARATOR + dirName; if (checkResourceExists(dirFullName, ResourceType.FILE.ordinal())) { List<Resource> resourceList = resourcesMapper.queryResource(dirFullName, ResourceType.FILE.ordinal()); return resourceList.get(0).getId(); } else { Result<Object> createDirResult = this.createDirectory( user, dirName, EMPTY_STRING, ResourceType.FILE, pid, currentDir); if (createDirResult.getCode() == Status.SUCCESS.getCode()) { Map<String, Object> resultMap = (Map<String, Object>) createDirResult.getData(); return (int) resultMap.get("id"); } else { String msg = String.format("Can not create dir %s", dirFullName); logger.error(msg); throw new IllegalArgumentException(msg); } } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
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,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.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.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.UsersService; import org.apache.dolphinscheduler.api.utils.CheckUtils; 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.Flag; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.storage.StorageOperate; import org.apache.dolphinscheduler.common.utils.EncryptionUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.DatasourceUser; import org.apache.dolphinscheduler.dao.entity.K8sNamespaceUser; import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.ProjectUser; 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.UDFUser; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.K8sNamespaceUserMapper; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
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.UDFUserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TimeZone; import java.util.Arrays; import java.util.Objects; import java.util.stream.Collectors; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.USER_MANAGER; /** * users service impl */ @Service
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
public class UsersServiceImpl extends BaseServiceImpl implements UsersService { private static final Logger logger = LoggerFactory.getLogger(UsersServiceImpl.class); @Autowired private AccessTokenMapper accessTokenMapper; @Autowired private UserMapper userMapper; @Autowired private TenantMapper tenantMapper; @Autowired private ProjectUserMapper projectUserMapper; @Autowired private ResourceUserMapper resourceUserMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
private ResourceMapper resourceMapper; @Autowired private DataSourceUserMapper datasourceUserMapper; @Autowired private UDFUserMapper udfUserMapper; @Autowired private AlertGroupMapper alertGroupMapper; @Autowired private ProcessDefinitionMapper processDefinitionMapper; @Autowired private ProjectMapper projectMapper; @Autowired(required = false) private StorageOperate storageOperate; @Autowired private K8sNamespaceUserMapper k8sNamespaceUserMapper; @Autowired private ResourcePermissionCheckService resourcePermissionCheckService; /** * create user, only system admin have permission * * @param loginUser login user * @param userName user name * @param userPassword user password * @param email email * @param tenantId tenant id * @param phone phone * @param queue queue * @return create result code * @throws Exception exception */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
10,760
[Feature][dolphinscheduler-api] Some variables are redundant
### 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 Subclasses that inherit BaseServiceImpl and have the resourcePermissionCheckService attribute should remove this attribute in the subclass. Because this attribute already exists in the BaseServiceImpl class (eg:DataSourceServiceImpl ,ProjectServiceImpl) ### Use case remove the resourcePermissionCheckService attribute ### Related issues _No response_ ### 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/10760
https://github.com/apache/dolphinscheduler/pull/11213
163df5f1a3acccea6f6cd68e2921a892b6dc8935
cb001b581aa7649f6bde5b15cbc022ba8b989874
2022-07-04T05:53:40Z
java
2022-08-01T01:24:02Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
@Override @Transactional public Map<String, Object> createUser(User loginUser, String userName, String userPassword, String email, int tenantId, String phone, String queue, int state) throws Exception { Map<String, Object> result = new HashMap<>(); String msg = this.checkUserParams(userName, userPassword, email, phone); if(resourcePermissionCheckService.functionDisabled()){ putMsg(result, Status.FUNCTION_DISABLED, msg); return result; } if (!isAdmin(loginUser)) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (!StringUtils.isEmpty(msg)) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg); return result; } if (!checkTenantExists(tenantId)) { putMsg(result, Status.TENANT_NOT_EXIST); return result; } User user = createUser(userName, userPassword, email, tenantId, phone, queue, state);