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 | 8,110 | [Bug] [Worker/Master] Data duplication caused by worker faking death | ### 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
1. Because of cpu load is too high, worker lost connection with Zookeeper.
2. Master failover the worker and restart the tasks, but cannot kill the tasks.
3. Then the same task would be run twice and result data would be duplicate.
### What you expected to happen
1. Worker should check resource before submitting task to execution thread.
2. Can worker actively reduce CPU load through killing task ?
### How to reproduce
1. CPU load is too high:

2. worker lost connection with zk:

### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [ ] 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/8110 | https://github.com/apache/dolphinscheduler/pull/8490 | 512f8cb5dde7fb42398e7caa50c0c6665b6ec45f | f2b9796bc20ef40e1737ea3afe9a00503b44ae3d | 2022-01-18T16:27:25Z | java | 2022-02-23T10:22:42Z | dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.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.server.worker;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.IStoppable;
import org.apache.dolphinscheduler.common.enums.NodeType;
import org.apache.dolphinscheduler.common.thread.Stopper;
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
import org.apache.dolphinscheduler.server.log.LoggerRequestProcessor;
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
import org.apache.dolphinscheduler.server.worker.plugin.TaskPluginManager;
import org.apache.dolphinscheduler.server.worker.processor.DBTaskAckProcessor;
import org.apache.dolphinscheduler.server.worker.processor.DBTaskResponseProcessor; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,110 | [Bug] [Worker/Master] Data duplication caused by worker faking death | ### 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
1. Because of cpu load is too high, worker lost connection with Zookeeper.
2. Master failover the worker and restart the tasks, but cannot kill the tasks.
3. Then the same task would be run twice and result data would be duplicate.
### What you expected to happen
1. Worker should check resource before submitting task to execution thread.
2. Can worker actively reduce CPU load through killing task ?
### How to reproduce
1. CPU load is too high:

2. worker lost connection with zk:

### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [ ] 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/8110 | https://github.com/apache/dolphinscheduler/pull/8490 | 512f8cb5dde7fb42398e7caa50c0c6665b6ec45f | f2b9796bc20ef40e1737ea3afe9a00503b44ae3d | 2022-01-18T16:27:25Z | java | 2022-02-23T10:22:42Z | dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java | import org.apache.dolphinscheduler.server.worker.processor.HostUpdateProcessor;
import org.apache.dolphinscheduler.server.worker.processor.TaskExecuteProcessor;
import org.apache.dolphinscheduler.server.worker.processor.TaskKillProcessor;
import org.apache.dolphinscheduler.server.worker.registry.WorkerRegistryClient;
import org.apache.dolphinscheduler.server.worker.runner.RetryReportTaskStatusThread;
import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread;
import org.apache.dolphinscheduler.service.alert.AlertClientService;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
import java.util.Set;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableTransactionManagement
@ComponentScan("org.apache.dolphinscheduler")
public class WorkerServer implements IStoppable {
/**
* logger
*/
private static final Logger logger = LoggerFactory.getLogger(WorkerServer.class);
/**
* netty remote server
*/
private NettyRemotingServer nettyRemotingServer;
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,110 | [Bug] [Worker/Master] Data duplication caused by worker faking death | ### 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
1. Because of cpu load is too high, worker lost connection with Zookeeper.
2. Master failover the worker and restart the tasks, but cannot kill the tasks.
3. Then the same task would be run twice and result data would be duplicate.
### What you expected to happen
1. Worker should check resource before submitting task to execution thread.
2. Can worker actively reduce CPU load through killing task ?
### How to reproduce
1. CPU load is too high:

2. worker lost connection with zk:

### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [ ] 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/8110 | https://github.com/apache/dolphinscheduler/pull/8490 | 512f8cb5dde7fb42398e7caa50c0c6665b6ec45f | f2b9796bc20ef40e1737ea3afe9a00503b44ae3d | 2022-01-18T16:27:25Z | java | 2022-02-23T10:22:42Z | dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java | * worker config
*/
@Autowired
private WorkerConfig workerConfig;
/**
* spring application context
* only use it for initialization
*/
@Autowired
private SpringApplicationContext springApplicationContext;
/**
* alert model netty remote server
*/
@Autowired
private AlertClientService alertClientService;
@Autowired
private RetryReportTaskStatusThread retryReportTaskStatusThread;
@Autowired
private WorkerManagerThread workerManagerThread;
/**
* worker registry
*/
@Autowired
private WorkerRegistryClient workerRegistryClient;
@Autowired
private TaskPluginManager taskPluginManager;
@Autowired
private TaskExecuteProcessor taskExecuteProcessor;
@Autowired
private TaskKillProcessor taskKillProcessor; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,110 | [Bug] [Worker/Master] Data duplication caused by worker faking death | ### 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
1. Because of cpu load is too high, worker lost connection with Zookeeper.
2. Master failover the worker and restart the tasks, but cannot kill the tasks.
3. Then the same task would be run twice and result data would be duplicate.
### What you expected to happen
1. Worker should check resource before submitting task to execution thread.
2. Can worker actively reduce CPU load through killing task ?
### How to reproduce
1. CPU load is too high:

2. worker lost connection with zk:

### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [ ] 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/8110 | https://github.com/apache/dolphinscheduler/pull/8490 | 512f8cb5dde7fb42398e7caa50c0c6665b6ec45f | f2b9796bc20ef40e1737ea3afe9a00503b44ae3d | 2022-01-18T16:27:25Z | java | 2022-02-23T10:22:42Z | dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java | @Autowired
private DBTaskAckProcessor dbTaskAckProcessor;
@Autowired
private DBTaskResponseProcessor dbTaskResponseProcessor;
@Autowired
private HostUpdateProcessor hostUpdateProcessor;
@Autowired
private LoggerRequestProcessor loggerRequestProcessor;
/**
* worker server startup, not use web service
*
* @param args arguments
*/
public static void main(String[] args) {
Thread.currentThread().setName(Constants.THREAD_NAME_WORKER_SERVER);
SpringApplication.run(WorkerServer.class);
}
/**
* worker server run
*/
@PostConstruct
public void run() {
NettyServerConfig serverConfig = new NettyServerConfig();
serverConfig.setListenPort(workerConfig.getListenPort());
this.nettyRemotingServer = new NettyRemotingServer(serverConfig);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_EXECUTE_REQUEST, taskExecuteProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.TASK_KILL_REQUEST, taskKillProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.DB_TASK_ACK, dbTaskAckProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.DB_TASK_RESPONSE, dbTaskResponseProcessor); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,110 | [Bug] [Worker/Master] Data duplication caused by worker faking death | ### 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
1. Because of cpu load is too high, worker lost connection with Zookeeper.
2. Master failover the worker and restart the tasks, but cannot kill the tasks.
3. Then the same task would be run twice and result data would be duplicate.
### What you expected to happen
1. Worker should check resource before submitting task to execution thread.
2. Can worker actively reduce CPU load through killing task ?
### How to reproduce
1. CPU load is too high:

2. worker lost connection with zk:

### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [ ] 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/8110 | https://github.com/apache/dolphinscheduler/pull/8490 | 512f8cb5dde7fb42398e7caa50c0c6665b6ec45f | f2b9796bc20ef40e1737ea3afe9a00503b44ae3d | 2022-01-18T16:27:25Z | java | 2022-02-23T10:22:42Z | dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java | this.nettyRemotingServer.registerProcessor(CommandType.PROCESS_HOST_UPDATE_REQUEST, hostUpdateProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.GET_LOG_BYTES_REQUEST, loggerRequestProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.ROLL_VIEW_LOG_REQUEST, loggerRequestProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.VIEW_WHOLE_LOG_REQUEST, loggerRequestProcessor);
this.nettyRemotingServer.registerProcessor(CommandType.REMOVE_TAK_LOG_REQUEST, loggerRequestProcessor);
this.nettyRemotingServer.start();
try {
this.workerRegistryClient.registry();
this.workerRegistryClient.setRegistryStoppable(this);
Set<String> workerZkPaths = this.workerRegistryClient.getWorkerZkPaths();
this.workerRegistryClient.handleDeadServer(workerZkPaths, NodeType.WORKER, Constants.DELETE_OP);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RuntimeException(e);
}
this.workerManagerThread.start();
this.retryReportTaskStatusThread.start();
/*
* registry hooks, which are called before the process exits
*/
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (Stopper.isRunning()) {
close("shutdownHook");
}
}));
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,110 | [Bug] [Worker/Master] Data duplication caused by worker faking death | ### 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
1. Because of cpu load is too high, worker lost connection with Zookeeper.
2. Master failover the worker and restart the tasks, but cannot kill the tasks.
3. Then the same task would be run twice and result data would be duplicate.
### What you expected to happen
1. Worker should check resource before submitting task to execution thread.
2. Can worker actively reduce CPU load through killing task ?
### How to reproduce
1. CPU load is too high:

2. worker lost connection with zk:

### Anything else
_No response_
### Version
dev
### Are you willing to submit PR?
- [ ] 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/8110 | https://github.com/apache/dolphinscheduler/pull/8490 | 512f8cb5dde7fb42398e7caa50c0c6665b6ec45f | f2b9796bc20ef40e1737ea3afe9a00503b44ae3d | 2022-01-18T16:27:25Z | java | 2022-02-23T10:22:42Z | dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/WorkerServer.java | public void close(String cause) {
try {
if (Stopper.isStopped()) {
return;
}
logger.info("worker server is stopping ..., cause : {}", cause);
Stopper.stop();
try {
Thread.sleep(3000L);
} catch (Exception e) {
logger.warn("thread sleep exception", e);
}
this.nettyRemotingServer.close();
this.workerRegistryClient.unRegistry();
this.alertClientService.close();
this.springApplicationContext.close();
} catch (Exception e) {
logger.error("worker server stop exception ", e);
}
}
@Override
public void stop(String cause) {
close(cause);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.TaskDefinitionService;
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.ConditionType;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.TaskType;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation;
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
import org.apache.dolphinscheduler.dao.entity.TaskMainInfo;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
import org.apache.dolphinscheduler.service.permission.PermissionCheck; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
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;
import com.google.common.collect.Lists;
/**
* task definition service impl
*/
@Service
public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDefinitionService {
private static final Logger logger = LoggerFactory.getLogger(TaskDefinitionServiceImpl.class);
private static final String RELEASESTATE = "releaseState";
@Autowired
private ProjectMapper projectMapper;
@Autowired |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | private ProjectService projectService;
@Autowired
private TaskDefinitionMapper taskDefinitionMapper;
@Autowired
private TaskDefinitionLogMapper taskDefinitionLogMapper;
@Autowired
private ProcessTaskRelationMapper processTaskRelationMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
@Autowired
private ProcessService processService;
/**
* create task definition
*
* @param loginUser login user
* @param projectCode project code
* @param taskDefinitionJson task definition json
*/
@Transactional(rollbackFor = RuntimeException.class)
@Override
public Map<String, Object> createTaskDefinition(User loginUser,
long projectCode,
String taskDefinitionJson) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
List<TaskDefinitionLog> taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | if (taskDefinitionLogs.isEmpty()) {
logger.error("taskDefinitionJson invalid: {}", taskDefinitionJson);
putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJson);
return result;
}
for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) {
if (!CheckUtils.checkTaskDefinitionParameters(taskDefinitionLog)) {
logger.error("task definition {} parameter invalid", taskDefinitionLog.getName());
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionLog.getName());
return result;
}
}
int saveTaskResult = processService.saveTaskDefine(loginUser, projectCode, taskDefinitionLogs, Boolean.TRUE);
if (saveTaskResult == Constants.DEFINITION_FAILURE) {
putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR);
throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR);
}
Map<String, Object> resData = new HashMap<>();
resData.put("total", taskDefinitionLogs.size());
resData.put("code", StringUtils.join(taskDefinitionLogs.stream().map(TaskDefinition::getCode).collect(Collectors.toList()), ","));
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, resData);
return result;
}
/**
* create single task definition that binds the workflow
*
* @param loginUser login user
* @param projectCode project code
* @param processDefinitionCode process definition code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | * @param taskDefinitionJsonObj task definition json object
* @param upstreamCodes upstream task codes, sep comma
* @return create result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Override
public Map<String, Object> createTaskBindsWorkFlow(User loginUser,
long projectCode,
long processDefinitionCode,
String taskDefinitionJsonObj,
String upstreamCodes) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode);
if (processDefinition == null || projectCode != processDefinition.getProjectCode()) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionCode);
return result;
}
if (processDefinition.getReleaseState() == ReleaseState.ONLINE) {
putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE, processDefinitionCode);
return result;
}
TaskDefinitionLog taskDefinition = JSONUtils.parseObject(taskDefinitionJsonObj, TaskDefinitionLog.class);
if (taskDefinition == null) {
logger.error("taskDefinitionJsonObj is not valid json");
putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJsonObj); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | return result;
}
if (!CheckUtils.checkTaskDefinitionParameters(taskDefinition)) {
logger.error("task definition {} parameter invalid", taskDefinition.getName());
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinition.getName());
return result;
}
long taskCode = taskDefinition.getCode();
if (taskCode == 0) {
try {
taskCode = CodeGenerateUtils.getInstance().genCode();
taskDefinition.setCode(taskCode);
} catch (CodeGenerateException e) {
logger.error("Task code get error, ", e);
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, taskDefinitionJsonObj);
return result;
}
}
if (StringUtils.isNotBlank(upstreamCodes)) {
Set<Long> upstreamTaskCodes = Arrays.stream(upstreamCodes.split(Constants.COMMA)).map(Long::parseLong).collect(Collectors.toSet());
List<TaskDefinition> upstreamTaskDefinitionList = taskDefinitionMapper.queryByCodeList(upstreamTaskCodes);
Set<Long> queryUpStreamTaskCodes = upstreamTaskDefinitionList.stream().map(TaskDefinition::getCode).collect(Collectors.toSet());
Set<Long> diffCode = upstreamTaskCodes.stream().filter(code -> !queryUpStreamTaskCodes.contains(code)).collect(Collectors.toSet());
if (!diffCode.isEmpty()) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, StringUtils.join(diffCode, Constants.COMMA));
return result;
}
List<ProcessTaskRelationLog> processTaskRelationLogList = Lists.newArrayList();
for (TaskDefinition upstreamTask : upstreamTaskDefinitionList) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog();
processTaskRelationLog.setPreTaskCode(upstreamTask.getCode());
processTaskRelationLog.setPreTaskVersion(upstreamTask.getVersion());
processTaskRelationLog.setPostTaskCode(taskCode);
processTaskRelationLog.setPostTaskVersion(Constants.VERSION_FIRST);
processTaskRelationLog.setConditionType(ConditionType.NONE);
processTaskRelationLog.setConditionParams("{}");
processTaskRelationLogList.add(processTaskRelationLog);
}
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode);
if (!processTaskRelationList.isEmpty()) {
processTaskRelationLogList.addAll(processTaskRelationList.stream().map(ProcessTaskRelationLog::new).collect(Collectors.toList()));
}
int insertResult = processService.saveTaskRelation(loginUser, projectCode, processDefinition.getCode(), processDefinition.getVersion(),
processTaskRelationLogList, Lists.newArrayList(), Boolean.TRUE);
if (insertResult != Constants.EXIT_CODE_SUCCESS) {
putMsg(result, Status.CREATE_PROCESS_TASK_RELATION_ERROR);
throw new ServiceException(Status.CREATE_PROCESS_TASK_RELATION_ERROR);
}
}
int saveTaskResult = processService.saveTaskDefine(loginUser, projectCode, Lists.newArrayList(taskDefinition), Boolean.TRUE);
if (saveTaskResult == Constants.DEFINITION_FAILURE) {
putMsg(result, Status.CREATE_TASK_DEFINITION_ERROR);
throw new ServiceException(Status.CREATE_TASK_DEFINITION_ERROR);
}
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, taskDefinition);
return result;
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | * query task definition
*
* @param loginUser login user
* @param projectCode project code
* @param taskName task name
*/
@Override
public Map<String, Object> queryTaskDefinitionByName(User loginUser, long projectCode, String taskName) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
TaskDefinition taskDefinition = taskDefinitionMapper.queryByName(project.getCode(), taskName);
if (taskDefinition == null) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskName);
} else {
result.put(Constants.DATA_LIST, taskDefinition);
putMsg(result, Status.SUCCESS);
}
return result;
}
/**
* delete task definition
* Only offline and no downstream dependency can be deleted
*
* @param loginUser login user
* @param projectCode project code
* @param taskCode task code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | */
@Transactional(rollbackFor = RuntimeException.class)
@Override
public Map<String, Object> deleteTaskDefinitionByCode(User loginUser, long projectCode, long taskCode) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
if (taskCode == 0) {
putMsg(result, Status.DELETE_TASK_DEFINE_BY_CODE_ERROR);
return result;
}
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode);
if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode);
return result;
}
if (processService.isTaskOnline(taskCode) && taskDefinition.getFlag() == Flag.YES) {
putMsg(result, Status.TASK_DEFINE_STATE_ONLINE, taskCode);
return result;
}
List<ProcessTaskRelation> processTaskRelationList = processTaskRelationMapper.queryDownstreamByTaskCode(taskCode);
if (!processTaskRelationList.isEmpty()) {
Set<Long> postTaskCodes = processTaskRelationList
.stream()
.map(ProcessTaskRelation::getPostTaskCode)
.collect(Collectors.toSet());
putMsg(result, Status.TASK_HAS_DOWNSTREAM, StringUtils.join(postTaskCodes, ",")); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | return result;
}
int delete = taskDefinitionMapper.deleteByCode(taskCode);
if (delete > 0) {
List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryUpstreamByCode(projectCode, taskCode);
if (!taskRelationList.isEmpty()) {
long processDefinitionCode = taskRelationList.get(0).getProcessDefinitionCode();
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode);
List<ProcessTaskRelation> relationList = processTaskRelations.stream().filter(r -> r.getPostTaskCode() != taskCode).collect(Collectors.toList());
updateDag(loginUser, result, processDefinitionCode, relationList, Lists.newArrayList());
} else {
putMsg(result, Status.SUCCESS);
}
} else {
putMsg(result, Status.DELETE_TASK_DEFINE_BY_CODE_ERROR);
throw new ServiceException(Status.DELETE_TASK_DEFINE_BY_CODE_ERROR);
}
return result;
}
private void updateDag(User loginUser, Map<String, Object> result, long processDefinitionCode, List<ProcessTaskRelation> processTaskRelationList,
List<TaskDefinitionLog> taskDefinitionLogs) {
ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode);
if (processDefinition == null) {
throw new ServiceException(Status.PROCESS_DEFINE_NOT_EXIST);
}
int insertVersion = processService.saveProcessDefine(loginUser, processDefinition, Boolean.TRUE, Boolean.TRUE);
if (insertVersion <= 0) {
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR);
}
List<ProcessTaskRelationLog> relationLogs = processTaskRelationList.stream().map(ProcessTaskRelationLog::new).collect(Collectors.toList()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | int insertResult = processService.saveTaskRelation(loginUser, processDefinition.getProjectCode(), processDefinition.getCode(),
insertVersion, relationLogs, taskDefinitionLogs, Boolean.TRUE);
if (insertResult == Constants.EXIT_CODE_SUCCESS) {
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, processDefinition);
} else {
putMsg(result, Status.UPDATE_PROCESS_DEFINITION_ERROR);
throw new ServiceException(Status.UPDATE_PROCESS_DEFINITION_ERROR);
}
}
/**
* update task definition
*
* @param loginUser login user
* @param projectCode project code
* @param taskCode task code
* @param taskDefinitionJsonObj task definition json object
*/
@Transactional(rollbackFor = RuntimeException.class)
@Override
public Map<String, Object> updateTaskDefinition(User loginUser, long projectCode, long taskCode, String taskDefinitionJsonObj) {
Map<String, Object> result = new HashMap<>();
TaskDefinitionLog taskDefinitionToUpdate = updateTask(loginUser, projectCode, taskCode, taskDefinitionJsonObj, result);
if (taskDefinitionToUpdate == null) {
return result;
}
List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryUpstreamByCode(projectCode, taskCode);
if (!taskRelationList.isEmpty()) {
long processDefinitionCode = taskRelationList.get(0).getProcessDefinitionCode();
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | updateDag(loginUser, result, processDefinitionCode, processTaskRelations, Lists.newArrayList(taskDefinitionToUpdate));
}
result.put(Constants.DATA_LIST, taskCode);
putMsg(result, Status.SUCCESS);
return result;
}
private TaskDefinitionLog updateTask(User loginUser, long projectCode, long taskCode, String taskDefinitionJsonObj, Map<String, Object> result) {
Project project = projectMapper.queryByCode(projectCode);
result.putAll(projectService.checkProjectAndAuth(loginUser, project, projectCode));
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return null;
}
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode);
if (taskDefinition == null) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode);
return null;
}
if (processService.isTaskOnline(taskCode) && taskDefinition.getFlag() == Flag.YES) {
putMsg(result, Status.NOT_SUPPORT_UPDATE_TASK_DEFINITION);
return null;
}
TaskDefinitionLog taskDefinitionToUpdate = JSONUtils.parseObject(taskDefinitionJsonObj, TaskDefinitionLog.class);
if (taskDefinition.equals(taskDefinitionToUpdate)) {
return null;
}
if (taskDefinitionToUpdate == null) {
logger.error("taskDefinitionJson is not valid json");
putMsg(result, Status.DATA_IS_NOT_VALID, taskDefinitionJsonObj);
return null; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | }
if (!CheckUtils.checkTaskDefinitionParameters(taskDefinitionToUpdate)) {
logger.error("task definition {} parameter invalid", taskDefinitionToUpdate.getName());
putMsg(result, Status.PROCESS_NODE_S_PARAMETER_INVALID, taskDefinitionToUpdate.getName());
return null;
}
Integer version = taskDefinitionLogMapper.queryMaxVersionForDefinition(taskCode);
if (version == null || version == 0) {
putMsg(result, Status.DATA_IS_NOT_VALID, taskCode);
return null;
}
Date now = new Date();
taskDefinitionToUpdate.setCode(taskCode);
taskDefinitionToUpdate.setId(taskDefinition.getId());
taskDefinitionToUpdate.setProjectCode(projectCode);
taskDefinitionToUpdate.setUserId(taskDefinition.getUserId());
taskDefinitionToUpdate.setVersion(++version);
taskDefinitionToUpdate.setTaskType(taskDefinitionToUpdate.getTaskType().toUpperCase());
taskDefinitionToUpdate.setResourceIds(processService.getResourceIds(taskDefinitionToUpdate));
taskDefinitionToUpdate.setUpdateTime(now);
int update = taskDefinitionMapper.updateById(taskDefinitionToUpdate);
taskDefinitionToUpdate.setOperator(loginUser.getId());
taskDefinitionToUpdate.setOperateTime(now);
taskDefinitionToUpdate.setCreateTime(now);
int insert = taskDefinitionLogMapper.insert(taskDefinitionToUpdate);
if ((update & insert) != 1) {
putMsg(result, Status.UPDATE_TASK_DEFINITION_ERROR);
throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR);
}
return taskDefinitionToUpdate; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | }
/**
* update task definition and upstream
*
* @param loginUser login user
* @param projectCode project code
* @param taskCode task definition code
* @param taskDefinitionJsonObj task definition json object
* @param upstreamCodes upstream task codes, sep comma
* @return update result code
*/
@Override
public Map<String, Object> updateTaskWithUpstream(User loginUser, long projectCode, long taskCode, String taskDefinitionJsonObj, String upstreamCodes) {
Map<String, Object> result = new HashMap<>();
TaskDefinitionLog taskDefinitionToUpdate = updateTask(loginUser, projectCode, taskCode, taskDefinitionJsonObj, result);
if (result.get(Constants.STATUS) != Status.SUCCESS && taskDefinitionToUpdate == null) {
return result;
}
List<ProcessTaskRelation> upstreamTaskRelations = processTaskRelationMapper.queryUpstreamByCode(projectCode, taskCode);
Set<Long> upstreamCodeSet = upstreamTaskRelations.stream().map(ProcessTaskRelation::getPreTaskCode).collect(Collectors.toSet());
Set<Long> upstreamTaskCodes = Collections.emptySet();
if (StringUtils.isNotEmpty(upstreamCodes)) {
upstreamTaskCodes = Arrays.stream(upstreamCodes.split(Constants.COMMA)).map(Long::parseLong).collect(Collectors.toSet());
}
if (CollectionUtils.isEqualCollection(upstreamCodeSet, upstreamTaskCodes) && taskDefinitionToUpdate == null) {
putMsg(result, Status.SUCCESS);
return result;
} else {
if (taskDefinitionToUpdate == null) {
taskDefinitionToUpdate = JSONUtils.parseObject(taskDefinitionJsonObj, TaskDefinitionLog.class); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | }
}
Map<Long, TaskDefinition> queryUpStreamTaskCodeMap;
if (!upstreamTaskCodes.isEmpty()) {
List<TaskDefinition> upstreamTaskDefinitionList = taskDefinitionMapper.queryByCodeList(upstreamTaskCodes);
queryUpStreamTaskCodeMap = upstreamTaskDefinitionList.stream().collect(Collectors.toMap(TaskDefinition::getCode, taskDefinition -> taskDefinition));
upstreamTaskCodes.removeAll(queryUpStreamTaskCodeMap.keySet());
if (!upstreamTaskCodes.isEmpty()) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, StringUtils.join(upstreamTaskCodes, Constants.COMMA));
return result;
}
} else {
queryUpStreamTaskCodeMap = new HashMap<>();
}
if (!upstreamTaskRelations.isEmpty()) {
ProcessTaskRelation taskRelation = upstreamTaskRelations.get(0);
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(projectCode, taskRelation.getProcessDefinitionCode());
List<ProcessTaskRelation> processTaskRelationList = Lists.newArrayList(processTaskRelations);
List<ProcessTaskRelation> relationList = Lists.newArrayList();
for (ProcessTaskRelation processTaskRelation : processTaskRelationList) {
if (processTaskRelation.getPostTaskCode() == taskCode) {
if (queryUpStreamTaskCodeMap.containsKey(processTaskRelation.getPreTaskCode()) && processTaskRelation.getPreTaskCode() != 0L) {
queryUpStreamTaskCodeMap.remove(processTaskRelation.getPreTaskCode());
} else {
processTaskRelation.setPreTaskCode(0L);
processTaskRelation.setPreTaskVersion(0);
relationList.add(processTaskRelation);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | }
processTaskRelationList.removeAll(relationList);
for (Map.Entry<Long, TaskDefinition> queryUpStreamTask : queryUpStreamTaskCodeMap.entrySet()) {
taskRelation.setPreTaskCode(queryUpStreamTask.getKey());
taskRelation.setPreTaskVersion(queryUpStreamTask.getValue().getVersion());
processTaskRelationList.add(taskRelation);
}
if (queryUpStreamTaskCodeMap.isEmpty() && !processTaskRelationList.isEmpty()) {
processTaskRelationList.add(processTaskRelationList.get(0));
}
updateDag(loginUser, result, taskRelation.getProcessDefinitionCode(), processTaskRelations, Lists.newArrayList(taskDefinitionToUpdate));
}
result.put(Constants.DATA_LIST, taskCode);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* switch task definition
*
* @param loginUser login user
* @param projectCode project code
* @param taskCode task code
* @param version the version user want to switch
*/
@Transactional(rollbackFor = RuntimeException.class)
@Override
public Map<String, Object> switchVersion(User loginUser, long projectCode, long taskCode, int version) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
if (processService.isTaskOnline(taskCode)) {
putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE);
return result;
}
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode);
if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode);
return result;
}
TaskDefinitionLog taskDefinitionUpdate = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskCode, version);
taskDefinitionUpdate.setUserId(loginUser.getId());
taskDefinitionUpdate.setUpdateTime(new Date());
taskDefinitionUpdate.setId(taskDefinition.getId());
int switchVersion = taskDefinitionMapper.updateById(taskDefinitionUpdate);
if (switchVersion > 0) {
List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryUpstreamByCode(projectCode, taskCode);
if (!taskRelationList.isEmpty()) {
long processDefinitionCode = taskRelationList.get(0).getProcessDefinitionCode();
List<ProcessTaskRelation> processTaskRelations = processTaskRelationMapper.queryByProcessCode(projectCode, processDefinitionCode);
updateDag(loginUser, result, processDefinitionCode, processTaskRelations, Lists.newArrayList(taskDefinitionUpdate));
} else {
putMsg(result, Status.SUCCESS);
}
} else {
putMsg(result, Status.SWITCH_TASK_DEFINITION_VERSION_ERROR);
}
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | }
@Override
public Result queryTaskDefinitionVersions(User loginUser,
long projectCode,
long taskCode,
int pageNo,
int pageSize) {
Result result = new Result();
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode);
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
if (resultStatus != Status.SUCCESS) {
putMsg(result, resultStatus);
return result;
}
PageInfo<TaskDefinitionLog> pageInfo = new PageInfo<>(pageNo, pageSize);
Page<TaskDefinitionLog> page = new Page<>(pageNo, pageSize);
IPage<TaskDefinitionLog> taskDefinitionVersionsPaging = taskDefinitionLogMapper.queryTaskDefinitionVersionsPaging(page, taskCode, projectCode);
List<TaskDefinitionLog> taskDefinitionLogs = taskDefinitionVersionsPaging.getRecords();
pageInfo.setTotalList(taskDefinitionLogs);
pageInfo.setTotal((int) taskDefinitionVersionsPaging.getTotal());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
@Override
public Map<String, Object> deleteByCodeAndVersion(User loginUser, long projectCode, long taskCode, int version) {
Project project = projectMapper.queryByCode(projectCode); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode);
if (taskDefinition == null) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode);
} else {
if (taskDefinition.getVersion() == version) {
putMsg(result, Status.MAIN_TABLE_USING_VERSION);
return result;
}
int delete = taskDefinitionLogMapper.deleteByCodeAndVersion(taskCode, version);
if (delete > 0) {
putMsg(result, Status.SUCCESS);
} else {
putMsg(result, Status.DELETE_TASK_DEFINITION_VERSION_ERROR);
}
}
return result;
}
@Override
public Map<String, Object> queryTaskDefinitionDetail(User loginUser, long projectCode, long taskCode) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return result;
}
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCode); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, taskCode);
} else {
result.put(Constants.DATA_LIST, taskDefinition);
putMsg(result, Status.SUCCESS);
}
return result;
}
@Override
public Result queryTaskDefinitionListPaging(User loginUser,
long projectCode,
String searchWorkflowName,
String searchTaskName,
TaskType taskType,
Integer pageNo,
Integer pageSize) {
Result result = new Result();
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectCode);
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
if (resultStatus != Status.SUCCESS) {
putMsg(result, resultStatus);
return result;
}
Page<TaskMainInfo> page = new Page<>(pageNo, pageSize);
IPage<TaskMainInfo> taskMainInfoIPage = taskDefinitionMapper.queryDefineListPaging(page, projectCode, searchWorkflowName,
searchTaskName, taskType == null ? StringUtils.EMPTY : taskType.getDesc());
List<TaskMainInfo> records = taskMainInfoIPage.getRecords();
if (!records.isEmpty()) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | Map<Long, TaskMainInfo> taskMainInfoMap = new HashMap<>();
for (TaskMainInfo info : records) {
taskMainInfoMap.compute(info.getTaskCode(), (k, v) -> {
if (v == null) {
Map<Long, String> upstreamTaskMap = new HashMap<>();
if (info.getUpstreamTaskCode() != 0) {
upstreamTaskMap.put(info.getUpstreamTaskCode(), info.getUpstreamTaskName());
info.setUpstreamTaskCode(0L);
info.setUpstreamTaskName(StringUtils.EMPTY);
}
info.setUpstreamTaskMap(upstreamTaskMap);
v = info;
}
if (info.getUpstreamTaskCode() != 0) {
v.getUpstreamTaskMap().put(info.getUpstreamTaskCode(), info.getUpstreamTaskName());
}
return v;
});
}
taskMainInfoIPage.setRecords(Lists.newArrayList(taskMainInfoMap.values()));
taskMainInfoIPage.setTotal(taskMainInfoMap.values().size());
}
PageInfo<TaskMainInfo> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotal((int) taskMainInfoIPage.getTotal());
pageInfo.setTotalList(taskMainInfoIPage.getRecords());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
@Override |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | public Map<String, Object> genTaskCodeList(Integer genNum) {
Map<String, Object> result = new HashMap<>();
if (genNum == null || genNum < 1 || genNum > 100) {
logger.error("the genNum must be great than 1 and less than 100");
putMsg(result, Status.DATA_IS_NOT_VALID, genNum);
return result;
}
List<Long> taskCodes = new ArrayList<>();
try {
for (int i = 0; i < genNum; i++) {
taskCodes.add(CodeGenerateUtils.getInstance().genCode());
}
} catch (CodeGenerateException e) {
logger.error("Task code get error, ", e);
putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS, "Error generating task definition code");
}
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, taskCodes);
return result;
}
/**
* release task definition
*
* @param loginUser login user
* @param projectCode project code
* @param code task definition code
* @param releaseState releaseState
* @return update result code
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | @Transactional(rollbackFor = RuntimeException.class)
@Override
public Map<String, Object> releaseTaskDefinition(User loginUser, long projectCode, long code, ReleaseState releaseState) {
Project project = projectMapper.queryByCode(projectCode);
Map<String, Object> result = projectService.checkProjectAndAuth(loginUser, project, projectCode);
Status resultStatus = (Status) result.get(Constants.STATUS);
if (resultStatus != Status.SUCCESS) {
return result;
}
if (null == releaseState) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE);
return result;
}
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(code);
if (taskDefinition == null || projectCode != taskDefinition.getProjectCode()) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, code);
return result;
}
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(code, taskDefinition.getVersion());
if (taskDefinitionLog == null) {
putMsg(result, Status.TASK_DEFINE_NOT_EXIST, code);
return result;
}
switch (releaseState) {
case OFFLINE:
taskDefinition.setFlag(Flag.NO);
taskDefinitionLog.setFlag(Flag.NO);
break;
case ONLINE: |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,431 | [Bug] [API] The name of the process definition doesn't display on the page of task definition. | ### 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
When I browsed the list page of task definition I found that the name of process definition didn't display. So I checked the result of the requested api and make sure that this issue is caused by the backend.

### What you expected to happen
I expect that the name of process definition can display correctly.
### How to reproduce
You can browse the list page of task definition and then you will see it.
### Anything else
_No response_
### Version
dev
### 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/8431 | https://github.com/apache/dolphinscheduler/pull/8509 | 6fb112d1daf1a07dee15dcc0ca00ed272d2e387b | c590ad43d7826a2c441801d71ee07ba284cfb042 | 2022-02-18T10:35:35Z | java | 2022-02-24T00:50:03Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java | String resourceIds = taskDefinition.getResourceIds();
if (StringUtils.isNotBlank(resourceIds)) {
Integer[] resourceIdArray = Arrays.stream(resourceIds.split(",")).map(Integer::parseInt).toArray(Integer[]::new);
PermissionCheck<Integer> permissionCheck = new PermissionCheck(AuthorizationType.RESOURCE_FILE_ID, processService, resourceIdArray, loginUser.getId(), logger);
try {
permissionCheck.checkPermission();
} catch (Exception e) {
logger.error(e.getMessage(), e);
putMsg(result, Status.RESOURCE_NOT_EXIST_OR_NO_PERMISSION);
return result;
}
}
taskDefinition.setFlag(Flag.YES);
taskDefinitionLog.setFlag(Flag.YES);
break;
default:
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, RELEASESTATE);
return result;
}
int update = taskDefinitionMapper.updateById(taskDefinition);
int updateLog = taskDefinitionLogMapper.updateById(taskDefinitionLog);
if ((update == 0 && updateLog == 1) || (update == 1 && updateLog == 0)) {
putMsg(result, Status.UPDATE_TASK_DEFINITION_ERROR);
throw new ServiceException(Status.UPDATE_TASK_DEFINITION_ERROR);
}
putMsg(result, Status.SUCCESS);
return result;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,311 | [Bug] [Worker Server] shell task error java.nio.file.NoSuchFileException | ### 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
```
[INFO] 2022-02-09 04:15:03.388 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[138] - task execute path : /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680
[ERROR] 2022-02-09 04:15:03.389 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[103] - shell task error
java.nio.file.NoSuchFileException: /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680/308426_645680_node.sh
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.createFile(Files.java:632)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.buildCommand(ShellTask.java:146)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.handle(ShellTask.java:96)
at org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread.run(TaskExecuteThread.java:193)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
### What you expected to happen
Shell task created all files successfully.
### How to reproduce
The bug appears accidentally. It is speculated that too many files are created at the same time.
### Anything else
_No response_
### Version
2.0.3
### Are you willing to submit PR?
- [ ] 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/8311 | https://github.com/apache/dolphinscheduler/pull/8526 | 3025f67d370e02ebae075a4ef68e1d7f0461b2d6 | dd1397aaed9b498357c8e6f7fb2311ed61660630 | 2022-02-09T01:58:48Z | java | 2022-02-24T09:36:54Z | dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.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.plugin.task.shell;
import static org.apache.dolphinscheduler.spi.task.TaskConstants.EXIT_CODE_FAILURE;
import static org.apache.dolphinscheduler.spi.task.TaskConstants.RWXR_XR_X;
import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
import org.apache.dolphinscheduler.plugin.task.api.TaskResponse;
import org.apache.dolphinscheduler.plugin.task.util.OSUtils;
import org.apache.dolphinscheduler.spi.task.AbstractParameters; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,311 | [Bug] [Worker Server] shell task error java.nio.file.NoSuchFileException | ### 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
```
[INFO] 2022-02-09 04:15:03.388 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[138] - task execute path : /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680
[ERROR] 2022-02-09 04:15:03.389 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[103] - shell task error
java.nio.file.NoSuchFileException: /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680/308426_645680_node.sh
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.createFile(Files.java:632)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.buildCommand(ShellTask.java:146)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.handle(ShellTask.java:96)
at org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread.run(TaskExecuteThread.java:193)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
### What you expected to happen
Shell task created all files successfully.
### How to reproduce
The bug appears accidentally. It is speculated that too many files are created at the same time.
### Anything else
_No response_
### Version
2.0.3
### Are you willing to submit PR?
- [ ] 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/8311 | https://github.com/apache/dolphinscheduler/pull/8526 | 3025f67d370e02ebae075a4ef68e1d7f0461b2d6 | dd1397aaed9b498357c8e6f7fb2311ed61660630 | 2022-02-09T01:58:48Z | java | 2022-02-24T09:36:54Z | dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java | import org.apache.dolphinscheduler.spi.task.Property;
import org.apache.dolphinscheduler.spi.task.paramparser.ParamUtils;
import org.apache.dolphinscheduler.spi.task.paramparser.ParameterUtils;
import org.apache.dolphinscheduler.spi.task.request.TaskRequest;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import org.apache.commons.collections4.MapUtils;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* shell task
*/
public class ShellTask extends AbstractTaskExecutor {
/**
* shell parameters
*/
private ShellParameters shellParameters;
/**
* shell command executor
*/
private ShellCommandExecutor shellCommandExecutor;
/**
* taskExecutionContext |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,311 | [Bug] [Worker Server] shell task error java.nio.file.NoSuchFileException | ### 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
```
[INFO] 2022-02-09 04:15:03.388 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[138] - task execute path : /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680
[ERROR] 2022-02-09 04:15:03.389 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[103] - shell task error
java.nio.file.NoSuchFileException: /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680/308426_645680_node.sh
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.createFile(Files.java:632)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.buildCommand(ShellTask.java:146)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.handle(ShellTask.java:96)
at org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread.run(TaskExecuteThread.java:193)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
### What you expected to happen
Shell task created all files successfully.
### How to reproduce
The bug appears accidentally. It is speculated that too many files are created at the same time.
### Anything else
_No response_
### Version
2.0.3
### Are you willing to submit PR?
- [ ] 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/8311 | https://github.com/apache/dolphinscheduler/pull/8526 | 3025f67d370e02ebae075a4ef68e1d7f0461b2d6 | dd1397aaed9b498357c8e6f7fb2311ed61660630 | 2022-02-09T01:58:48Z | java | 2022-02-24T09:36:54Z | dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java | */
private TaskRequest taskExecutionContext;
/**
* constructor
*
* @param taskExecutionContext taskExecutionContext
*/
public ShellTask(TaskRequest taskExecutionContext) {
super(taskExecutionContext);
this.taskExecutionContext = taskExecutionContext;
this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
taskExecutionContext,
logger);
}
@Override
public void init() {
logger.info("shell task params {}", taskExecutionContext.getTaskParams());
shellParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), ShellParameters.class);
if (!shellParameters.checkParameters()) {
throw new RuntimeException("shell task params is not valid");
}
}
@Override
public void handle() throws Exception {
try {
String command = buildCommand();
TaskResponse commandExecuteResult = shellCommandExecutor.run(command);
setExitStatusCode(commandExecuteResult.getExitStatusCode());
setAppIds(commandExecuteResult.getAppIds()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,311 | [Bug] [Worker Server] shell task error java.nio.file.NoSuchFileException | ### 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
```
[INFO] 2022-02-09 04:15:03.388 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[138] - task execute path : /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680
[ERROR] 2022-02-09 04:15:03.389 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[103] - shell task error
java.nio.file.NoSuchFileException: /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680/308426_645680_node.sh
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.createFile(Files.java:632)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.buildCommand(ShellTask.java:146)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.handle(ShellTask.java:96)
at org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread.run(TaskExecuteThread.java:193)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
### What you expected to happen
Shell task created all files successfully.
### How to reproduce
The bug appears accidentally. It is speculated that too many files are created at the same time.
### Anything else
_No response_
### Version
2.0.3
### Are you willing to submit PR?
- [ ] 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/8311 | https://github.com/apache/dolphinscheduler/pull/8526 | 3025f67d370e02ebae075a4ef68e1d7f0461b2d6 | dd1397aaed9b498357c8e6f7fb2311ed61660630 | 2022-02-09T01:58:48Z | java | 2022-02-24T09:36:54Z | dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java | setProcessId(commandExecuteResult.getProcessId());
shellParameters.dealOutParam(shellCommandExecutor.getVarPool());
} catch (Exception e) {
logger.error("shell task error", e);
setExitStatusCode(EXIT_CODE_FAILURE);
throw e;
}
}
@Override
public void cancelApplication(boolean cancelApplication) throws Exception {
shellCommandExecutor.cancelApplication();
}
/**
* create command
*
* @return file name
* @throws Exception exception
*/
private String buildCommand() throws Exception {
String fileName = String.format("%s/%s_node.%s",
taskExecutionContext.getExecutePath(),
taskExecutionContext.getTaskAppId(), OSUtils.isWindows() ? "bat" : "sh");
Path path = new File(fileName).toPath();
if (Files.exists(path)) {
return fileName;
}
String script = shellParameters.getRawScript().replaceAll("\\r\\n", "\n");
script = parseScript(script); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 8,311 | [Bug] [Worker Server] shell task error java.nio.file.NoSuchFileException | ### 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
```
[INFO] 2022-02-09 04:15:03.388 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[138] - task execute path : /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680
[ERROR] 2022-02-09 04:15:03.389 TaskLogLogger-class org.apache.dolphinscheduler.plugin.task.shell.ShellTask:[103] - shell task error
java.nio.file.NoSuchFileException: /data/dolphinscheduler/exec/process/853772144123904/853777148452864_2/308426/645680/308426_645680_node.sh
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.createFile(Files.java:632)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.buildCommand(ShellTask.java:146)
at org.apache.dolphinscheduler.plugin.task.shell.ShellTask.handle(ShellTask.java:96)
at org.apache.dolphinscheduler.server.worker.runner.TaskExecuteThread.run(TaskExecuteThread.java:193)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```
### What you expected to happen
Shell task created all files successfully.
### How to reproduce
The bug appears accidentally. It is speculated that too many files are created at the same time.
### Anything else
_No response_
### Version
2.0.3
### Are you willing to submit PR?
- [ ] 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/8311 | https://github.com/apache/dolphinscheduler/pull/8526 | 3025f67d370e02ebae075a4ef68e1d7f0461b2d6 | dd1397aaed9b498357c8e6f7fb2311ed61660630 | 2022-02-09T01:58:48Z | java | 2022-02-24T09:36:54Z | dolphinscheduler-task-plugin/dolphinscheduler-task-shell/src/main/java/org/apache/dolphinscheduler/plugin/task/shell/ShellTask.java | shellParameters.setRawScript(script);
logger.info("raw script : {}", shellParameters.getRawScript());
logger.info("task execute path : {}", taskExecutionContext.getExecutePath());
Set<PosixFilePermission> perms = PosixFilePermissions.fromString(RWXR_XR_X);
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
if (OSUtils.isWindows()) {
Files.createFile(path);
} else {
Files.createFile(path, attr);
}
Files.write(path, shellParameters.getRawScript().getBytes(), StandardOpenOption.APPEND);
return fileName;
}
@Override
public AbstractParameters getParameters() {
return shellParameters;
}
private String parseScript(String script) {
Map<String, Property> paramsMap = ParamUtils.convert(taskExecutionContext,getParameters());
if (MapUtils.isEmpty(paramsMap)) {
paramsMap = new HashMap<>();
}
if (MapUtils.isNotEmpty(taskExecutionContext.getParamsMap())) {
paramsMap.putAll(taskExecutionContext.getParamsMap());
}
return ParameterUtils.convertParameterPlaceholders(script, ParamUtils.convert(paramsMap));
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | 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 static org.apache.dolphinscheduler.common.Constants.ALIAS;
import static org.apache.dolphinscheduler.common.Constants.CONTENT;
import static org.apache.dolphinscheduler.common.Constants.JAR;
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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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.ProgramType;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.apache.dolphinscheduler.common.utils.FileUtils;
import org.apache.dolphinscheduler.common.utils.HadoopUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.ResourcesUser;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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 java.util.UUID;
import java.util.regex.Matcher;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
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.io.Files;
/**
* 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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | private UdfFuncMapper udfFunctionMapper;
@Autowired
private TenantMapper tenantMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private ResourceUserMapper resourceUserMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
/**
* create directory
*
* @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(rollbackFor = Exception.class)
public Result<Object> createDirectory(User loginUser,
String name,
String description,
ResourceType type,
int pid,
String currentDir) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | return result;
}
String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",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);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.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 | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | 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;
}
/**
* 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(rollbackFor = Exception.class)
public Result<Object> createResource(User loginUser,
String name,
String desc,
ResourceType type,
MultipartFile file,
int pid,
String currentDir) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | return result;
}
result = verifyPid(loginUser, pid);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
result = verifyFile(name, type, file);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name);
if (checkResourceExists(fullName, type.ordinal())) {
logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name));
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
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);
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | } 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.HDFS_OPERATION_ERROR);
throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
return result;
}
/**
* 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 existResource == Boolean.TRUE;
}
/**
* update resource
* @param loginUser login user
* @param resourceId resource id
* @param name name
* @param desc description
* @param type resource type |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param file resource file
* @return update result code
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> updateResource(User loginUser,
int resourceId,
String name,
String desc,
ResourceType type,
MultipartFile file) {
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;
}
if (!hasPerm(loginUser, resource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) {
putMsg(result, Status.SUCCESS);
return result;
}
String originFullName = resource.getFullName(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | String originResourceName = resource.getAlias();
String fullName = String.format("%s%s",originFullName.substring(0,originFullName.lastIndexOf("/") + 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 originHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,originFullName);
try {
if (!HadoopUtils.getInstance().exists(originHdfsFileName)) {
logger.error("{} not exist", originHdfsFileName);
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 | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | 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();
resource.setAlias(name);
resource.setFileName(name); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | 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 | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | 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<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.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 | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | 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 {
HadoopUtils.getInstance().delete(originHdfsFileName,false);
} catch (IOException e) {
logger.error(e.getMessage(),e);
throw new ServiceException(String.format("delete resource: %s failed.", originFullName));
}
}
return result;
}
String destHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,fullName);
try {
logger.info("start hdfs copy {} -> {}", originHdfsFileName, destHdfsFileName);
HadoopUtils.getInstance().copy(originHdfsFileName, destHdfsFileName, true, true);
} catch (Exception e) {
logger.error(MessageFormat.format("hdfs copy {0} -> {1} fail", originHdfsFileName, 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 | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | 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 (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 (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) {
logger.error("rename file suffix and original suffix must be consistent: {}", RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE);
return result;
}
if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) {
logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg());
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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
}
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 result = new Result();
Page<Resource> page = new Page<>(pageNo, pageSize);
int userId = loginUser.getId();
if (isAdmin(loginUser)) {
userId = 0;
}
if (directoryId != -1) {
Resource directory = resourcesMapper.selectById(directoryId);
if (directory == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
}
List<Integer> resourcesIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, 0); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, userId, directoryId, type.ordinal(), searchVal,resourcesIds);
PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotal((int)resourceIPage.getTotal());
pageInfo.setTotalList(resourceIPage.getRecords());
result.setData(pageInfo);
putMsg(result,Status.SUCCESS);
return result;
}
/**
* create directory
* @param loginUser login user
* @param fullName full name
* @param type resource type
* @param result Result
*/
private void createDirectory(User loginUser,String fullName,ResourceType type,Result<Object> result) {
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
String directoryName = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
String resourceRootPath = HadoopUtils.getHdfsDir(type,tenantCode);
try {
if (!HadoopUtils.getInstance().exists(resourceRootPath)) {
createTenantDirIfNotExists(tenantCode);
}
if (!HadoopUtils.getInstance().mkdir(directoryName)) {
logger.error("create resource directory {} of hdfs failed",directoryName);
putMsg(result,Status.HDFS_OPERATION_ERROR);
throw new ServiceException(String.format("create resource directory: %s failed.", directoryName));
}
} catch (Exception e) {
logger.error("create resource directory {} of hdfs failed",directoryName); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | putMsg(result,Status.HDFS_OPERATION_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 (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) {
return false;
}
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString());
String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
String resourcePath = HadoopUtils.getHdfsDir(type,tenantCode);
try {
if (!HadoopUtils.getInstance().exists(resourcePath)) {
createTenantDirIfNotExists(tenantCode); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
org.apache.dolphinscheduler.api.utils.FileUtils.copyInputStreamToFile(file, localFilename);
HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true);
} catch (Exception e) {
FileUtils.deleteFile(localFilename);
logger.error(e.getMessage(), e);
return false;
}
return true;
}
/**
* query resource list
*
* @param loginUser login user
* @param type resource type
* @return resource list
*/
@Override
public Map<String, Object> queryResourceList(User loginUser, ResourceType type) {
Map<String, Object> result = new HashMap<>();
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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param type resource type
* @return resource list
*/
@Override
public Map<String, Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) {
Map<String, Object> result = new HashMap<>();
List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type);
String suffix = ".jar";
if (programType != null) {
switch (programType) {
case 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.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren());
putMsg(result, Status.SUCCESS);
return result;
}
/**
* delete resource
*
* @param loginUser login user
* @param resourceId resource id |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @return delete result code
* @throws IOException exception
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> delete(User loginUser, int resourceId) throws IOException {
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;
}
if (!hasPerm(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); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | Integer[] needDeleteResourceIdArray = allChildren.toArray(new Integer[allChildren.size()]);
if (resource.getType() == (ResourceType.UDF)) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(needDeleteResourceIdArray);
if (CollectionUtils.isNotEmpty(udfFuncs)) {
logger.error("can't be deleted,because it is bound by UDF functions:{}", udfFuncs);
putMsg(result,Status.UDF_RESOURCE_IS_BOUND,udfFuncs.get(0).getFuncName());
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 hdfsFilename = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName());
resourcesMapper.deleteIds(needDeleteResourceIdArray);
resourceUserMapper.deleteResourceUserArray(0, needDeleteResourceIdArray); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | HadoopUtils.getInstance().delete(hdfsFilename, 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<>();
putMsg(result, Status.SUCCESS);
if (checkResourceExists(fullName, type.ordinal())) {
logger.error("resource type:{} name:{} has exist, can't create again.", type, RegexUtils.escapeNRT(fullName));
putMsg(result, Status.RESOURCE_EXIST);
} else {
Tenant tenant = tenantMapper.queryById(loginUser.getTenantId());
if (tenant != null) {
String tenantCode = tenant.getTenantCode();
try {
String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
if (HadoopUtils.getInstance().exists(hdfsFilename)) {
logger.error("resource type:{} name:{} has exist in hdfs {}, can't create again.", type, RegexUtils.escapeNRT(fullName), hdfsFilename);
putMsg(result, Status.RESOURCE_FILE_EXIST,hdfsFilename);
}
} catch (Exception e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | logger.error(e.getMessage(),e);
putMsg(result,Status.HDFS_OPERATION_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(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;
}
if (StringUtils.isNotBlank(fullName)) {
List<Resource> resourceList = resourcesMapper.queryResource(fullName,type.ordinal());
if (CollectionUtils.isEmpty(resourceList)) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
putMsg(result, Status.SUCCESS); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | result.setData(resourceList.get(0));
} else {
Resource resource = resourcesMapper.selectById(id);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
Resource parentResource = resourcesMapper.selectById(resource.getPid());
if (parentResource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
putMsg(result, Status.SUCCESS);
result.setData(parentResource);
}
return result;
}
/**
* view resource file online
*
* @param resourceId resource id
* @param skipLineNum skip line number
* @param limit limit
* @return resource content
*/
@Override
public Result<Object> readResource(int resourceId, int skipLineNum, int limit) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
String nameSuffix = Files.getFileExtension(resource.getAlias());
String resourceViewSuffixs = FileUtils.getResourceViewSuffixs();
if (StringUtils.isNotEmpty(resourceViewSuffixs)) {
List<String> strList = Arrays.asList(resourceViewSuffixs.split(","));
if (!strList.contains(nameSuffix)) {
logger.error("resource suffix {} not support view, resource id {}", nameSuffix, resourceId);
putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW);
return result;
}
}
String tenantCode = getTenantCode(resource.getUserId(),result);
if (StringUtils.isEmpty(tenantCode)) {
return result;
}
String hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resource.getFullName());
logger.info("resource hdfs path is {}", hdfsFileName);
try {
if (HadoopUtils.getInstance().exists(hdfsFileName)) {
List<String> content = HadoopUtils.getInstance().catFile(hdfsFileName, skipLineNum, limit);
putMsg(result, Status.SUCCESS);
Map<String, Object> map = new HashMap<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | map.put(ALIAS, resource.getAlias());
map.put(CONTENT, String.join("\n", content));
result.setData(map);
} else {
logger.error("read file {} not exist in hdfs", hdfsFileName);
putMsg(result, Status.RESOURCE_FILE_NOT_EXIST,hdfsFileName);
}
} catch (Exception e) {
logger.error("Resource {} read failed", hdfsFileName, e);
putMsg(result, Status.HDFS_OPERATION_ERROR);
}
return result;
}
/**
* create resource file online
*
* @param loginUser login user
* @param type resource type
* @param fileName file name
* @param fileSuffix file suffix
* @param desc description
* @param content content
* @param pid pid
* @param currentDir current directory
* @return create result code
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content,int pid,String currentDir) {
Result<Object> result = checkResourceUploadStartupState(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
String nameSuffix = fileSuffix.trim();
String resourceViewSuffixs = FileUtils.getResourceViewSuffixs();
if (StringUtils.isNotEmpty(resourceViewSuffixs)) {
List<String> strList = Arrays.asList(resourceViewSuffixs.split(","));
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 = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",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);
putMsg(result, Status.SUCCESS);
Map<Object, Object> dataMap = new BeanMap(resource);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) {
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
}
result.setData(resultMap);
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
result = uploadContentToHdfs(fullName, tenantCode, content);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
throw new ServiceException(result.getMsg());
}
return result;
}
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.HDFS_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<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | putMsg(result, Status.SUCCESS);
if (pid != -1) {
Resource parentResource = resourcesMapper.selectById(pid);
if (parentResource == null) {
putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST);
return result;
}
if (!hasPerm(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(rollbackFor = Exception.class)
public Result<Object> updateResourceContent(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) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | logger.error("read file not exist, resource id {}", resourceId);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
String nameSuffix = Files.getFileExtension(resource.getAlias());
String resourceViewSuffixs = FileUtils.getResourceViewSuffixs();
if (StringUtils.isNotEmpty(resourceViewSuffixs)) {
List<String> strList = Arrays.asList(resourceViewSuffixs.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;
}
resource.setSize(content.getBytes().length);
resource.setUpdateTime(new Date());
resourcesMapper.updateById(resource);
result = uploadContentToHdfs(resource.getFullName(), tenantCode, content);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
throw new ServiceException(result.getMsg());
}
return result;
}
/**
* @param resourceName resource name |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param tenantCode tenant code
* @param content content
* @return result
*/
private Result<Object> uploadContentToHdfs(String resourceName, String tenantCode, String content) {
Result<Object> result = new Result<>();
String localFilename = "";
String hdfsFileName = "";
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;
}
hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resourceName);
String resourcePath = HadoopUtils.getHdfsResDir(tenantCode);
logger.info("resource hdfs path is {}, resource dir is {}", hdfsFileName, resourcePath);
HadoopUtils hadoopUtils = HadoopUtils.getInstance();
if (!hadoopUtils.exists(resourcePath)) {
createTenantDirIfNotExists(tenantCode);
}
if (hadoopUtils.exists(hdfsFileName)) {
hadoopUtils.delete(hdfsFileName, false);
}
hadoopUtils.copyLocalToHdfs(localFilename, hdfsFileName, true, true);
} catch (Exception e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | logger.error(e.getMessage(), e);
result.setCode(Status.HDFS_OPERATION_ERROR.getCode());
result.setMsg(String.format("copy %s to hdfs %s fail", localFilename, hdfsFileName));
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(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;
}
if (resource.isDirectory()) {
logger.error("resource id {} is directory,can't download it", resourceId);
throw new ServiceException("can't download directory"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
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 hdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName());
String localFileName = FileUtils.getDownloadFilename(resource.getAlias());
logger.info("resource hdfs path is {}, download local filename is {}", hdfsFileName, localFileName);
HadoopUtils.getInstance().copyHdfsToLocal(hdfsFileName, localFileName, false, true);
return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName);
}
/**
* 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<>();
List<Resource> resourceList; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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);
}
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)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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);
}
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<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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;
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<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId);
result.put(Constants.DATA_LIST, udfFuncs);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* 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<>();
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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | */
private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) {
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();
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | /**
* list all children id
* @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 | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | 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) {
List<Resource> relationResources;
int userId = loginUser.getId();
if (isAdmin(loginUser)) {
userId = 0;
relationResources = new ArrayList<>();
} else {
relationResources = queryResourceList(userId, 0);
}
List<Resource> ownResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal());
ownResourceList.addAll(relationResources);
return ownResourceList;
}
/**
* 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);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | * (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl;
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.UserType;
import org.apache.dolphinscheduler.common.utils.FileUtils;
import org.apache.dolphinscheduler.common.utils.HadoopUtils;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.apache.commons.collections.CollectionUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.mock.web.MockMultipartFile;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.io.Files;
/**
* resources service test
*/
@RunWith(PowerMockRunner.class) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | @PowerMockIgnore({"sun.security.*", "javax.net.*"})
@PrepareForTest({HadoopUtils.class, PropertyUtils.class,
FileUtils.class, org.apache.dolphinscheduler.api.utils.FileUtils.class,
Files.class})
public class ResourcesServiceTest {
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceTest.class);
@InjectMocks
private ResourcesServiceImpl resourcesService;
@Mock
private ResourceMapper resourcesMapper;
@Mock
private TenantMapper tenantMapper;
@Mock
private HadoopUtils hadoopUtils;
@Mock
private UserMapper userMapper;
@Mock
private UdfFuncMapper udfFunctionMapper;
@Mock
private ProcessDefinitionMapper processDefinitionMapper;
@Mock
private ResourceUserMapper resourceUserMapper;
@Before
public void setUp() {
PowerMockito.mockStatic(HadoopUtils.class);
PowerMockito.mockStatic(FileUtils.class);
PowerMockito.mockStatic(Files.class);
PowerMockito.mockStatic(org.apache.dolphinscheduler.api.utils.FileUtils.class); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | try {
PowerMockito.whenNew(HadoopUtils.class).withNoArguments().thenReturn(hadoopUtils);
} catch (Exception e) {
e.printStackTrace();
}
PowerMockito.when(HadoopUtils.getInstance()).thenReturn(hadoopUtils);
PowerMockito.mockStatic(PropertyUtils.class);
}
@Test
public void testCreateResource() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
Result result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg());
MockMultipartFile mockMultipartFile = new MockMultipartFile("test.pdf", "".getBytes());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_FILE_IS_EMPTY.getMsg(), result.getMsg());
mockMultipartFile = new MockMultipartFile("test.pdf", "test.pdf", "pdf", "test".getBytes());
PowerMockito.when(Files.getFileExtension("test.pdf")).thenReturn("pdf");
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.createResource(user, "ResourcesServiceTest.jar", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_FORBID_CHANGE.getMsg(), result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | mockMultipartFile = new MockMultipartFile("ResourcesServiceTest.pdf", "ResourcesServiceTest.pdf", "pdf", "test".getBytes());
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.pdf")).thenReturn("pdf");
result = resourcesService.createResource(user, "ResourcesServiceTest.pdf", "ResourcesServiceTest", ResourceType.UDF, mockMultipartFile, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg(), result.getMsg());
}
@Test
public void testCreateDirecotry() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
Result result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg());
user.setId(1);
user.setTenantId(1);
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(Mockito.anyInt())).thenReturn(null);
result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, 1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.PARENT_RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.existResource("/directoryTest", 0)).thenReturn(true);
result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, -1, "/");
logger.info(result.toString()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg());
}
@Test
public void testUpdateResource() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
Result result = resourcesService.updateResource(user, 1, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg());
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.updateResource(user, 0, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM.getMsg(), result.getMsg());
user.setId(1);
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(HadoopUtils.getHdfsFileName(Mockito.any(), Mockito.any(), Mockito.anyString())).thenReturn("test1");
try {
Mockito.when(HadoopUtils.getInstance().exists(Mockito.any())).thenReturn(false);
} catch (IOException e) {
logger.error(e.getMessage(), e);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null);
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
user.setId(1);
Mockito.when(userMapper.queryDetailsById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Mockito.when(HadoopUtils.getInstance().exists(Mockito.any())).thenReturn(true);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest.jar", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
Mockito.when(resourcesMapper.existResource("/ResourcesServiceTest1.jar", 0)).thenReturn(true);
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg());
Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(null);
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null);
logger.info(result.toString());
Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(Mockito.anyInt())).thenReturn(null);
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null);
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(HadoopUtils.getHdfsResourceFileName(Mockito.any(), Mockito.any())).thenReturn("test");
try {
PowerMockito.when(HadoopUtils.getInstance().copy(Mockito.anyString(), Mockito.anyString(), true, true)).thenReturn(true);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest1.jar", ResourceType.UDF, null);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testQueryResourceListPaging() {
User loginUser = new User();
loginUser.setUserType(UserType.ADMIN_USER);
IPage<Resource> resourcePage = new Page<>(1, 10);
resourcePage.setTotal(1);
resourcePage.setRecords(getResourceList());
Mockito.when(resourcesMapper.queryResourcePaging(Mockito.any(Page.class),
Mockito.eq(0), Mockito.eq(-1), Mockito.eq(0), Mockito.eq("test"), Mockito.any())).thenReturn(resourcePage);
Result result = resourcesService.queryResourceListPaging(loginUser, -1, ResourceType.FILE, "test", 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode());
PageInfo pageInfo = (PageInfo) result.getData();
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
}
@Test
public void testQueryResourceList() {
User loginUser = new User(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | loginUser.setId(0);
loginUser.setUserType(UserType.ADMIN_USER);
Mockito.when(resourcesMapper.queryResourceListAuthored(0, 0)).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.queryResourceList(loginUser, ResourceType.FILE);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resourceList = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resourceList));
}
@Test
public void testDelete() {
User loginUser = new User();
loginUser.setId(0);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Result result = resourcesService.delete(loginUser, 1);
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
result = resourcesService.delete(loginUser, 2);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
result = resourcesService.delete(loginUser, 2);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | loginUser.setUserType(UserType.ADMIN_USER);
loginUser.setTenantId(2);
Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(loginUser);
result = resourcesService.delete(loginUser, 1);
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
loginUser.setTenantId(1);
Mockito.when(hadoopUtils.delete(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(true);
Mockito.when(processDefinitionMapper.listResources()).thenReturn(getResources());
Mockito.when(resourcesMapper.deleteIds(Mockito.any())).thenReturn(1);
Mockito.when(resourceUserMapper.deleteResourceUserArray(Mockito.anyInt(), Mockito.any())).thenReturn(1);
result = resourcesService.delete(loginUser, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
} catch (Exception e) {
logger.error("delete error", e);
Assert.assertTrue(false);
}
}
@Test
public void testVerifyResourceName() {
User user = new User();
user.setId(1);
Mockito.when(resourcesMapper.existResource("/ResourcesServiceTest.jar", 0)).thenReturn(true);
Result result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
String unExistFullName = "/test.jar";
try {
Mockito.when(hadoopUtils.exists(unExistFullName)).thenReturn(false);
} catch (IOException e) {
logger.error("hadoop error", e);
}
result = resourcesService.verifyResourceName("/test.jar", ResourceType.FILE, user);
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
user.setTenantId(1);
try {
Mockito.when(hadoopUtils.exists("test")).thenReturn(true);
} catch (IOException e) {
logger.error("hadoop error", e);
}
PowerMockito.when(HadoopUtils.getHdfsResourceFileName("123", "test1")).thenReturn("test");
result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user);
logger.info(result.toString());
Assert.assertTrue(Status.RESOURCE_EXIST.getCode() == result.getCode());
result = resourcesService.verifyResourceName("test2", ResourceType.FILE, user);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testReadResource() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Result result = resourcesService.readResource(1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg());
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.readResource(2, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("class");
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.readResource(1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("jar");
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.readResource(1, 1, 10);
logger.info(result.toString());
Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
result = resourcesService.readResource(1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Mockito.when(hadoopUtils.exists(Mockito.anyString())).thenReturn(false); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | } catch (IOException e) {
logger.error("hadoop error", e);
}
result = resourcesService.readResource(1, 1, 10);
logger.info(result.toString());
Assert.assertTrue(Status.RESOURCE_FILE_NOT_EXIST.getCode() == result.getCode());
try {
Mockito.when(hadoopUtils.exists(null)).thenReturn(true);
Mockito.when(hadoopUtils.catFile(null, 1, 10)).thenReturn(getContent());
} catch (IOException e) {
logger.error("hadoop error", e);
}
result = resourcesService.readResource(1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testOnlineCreateResource() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
PowerMockito.when(HadoopUtils.getHdfsResDir("hdfsdDir")).thenReturn("hdfsDir");
PowerMockito.when(HadoopUtils.getHdfsUdfDir("udfDir")).thenReturn("udfDir");
User user = getUser();
Result result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("class"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
try {
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("jar");
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
} catch (RuntimeException ex) {
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), ex.getMessage());
}
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testUpdateResourceContent() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Result result = resourcesService.updateResourceContent(1, "content");
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
result = resourcesService.updateResourceContent(2, "content"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("class");
result = resourcesService.updateResourceContent(1, "content");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("jar");
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.updateResourceContent(1, "content");
logger.info(result.toString());
Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
result = resourcesService.updateResourceContent(1, "content");
logger.info(result.toString());
Assert.assertTrue(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getCode() == result.getCode());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.updateResourceContent(1, "content");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testDownloadResource() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
org.springframework.core.io.Resource resourceMock = Mockito.mock(org.springframework.core.io.Resource.class);
try {
org.springframework.core.io.Resource resource = resourcesService.downloadResource(1);
Assert.assertNull(resource);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(Mockito.any())).thenReturn(resourceMock);
resource = resourcesService.downloadResource(1);
Assert.assertNotNull(resource);
} catch (Exception e) {
logger.error("DownloadResource error", e);
Assert.assertTrue(false);
}
}
@Test
public void testAuthorizeResourceTree() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.authorizeResourceTree(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourcesMapper.queryResourceListAuthored(user.getId(), -1)).thenReturn(getResourceList());
result = resourcesService.authorizeResourceTree(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testUnauthorizedFile() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList());
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getSingleResourceList());
Map<String, Object> result = resourcesService.unauthorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
user.setId(2); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourcesMapper.queryResourceListAuthored(user.getId(), -1)).thenReturn(getResourceList());
result = resourcesService.unauthorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testUnauthorizedUDFFunction() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
Mockito.when(udfFunctionMapper.queryUdfFuncExceptUserId(userId)).thenReturn(getUdfFuncList());
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getSingleUdfFuncList());
Map<String, Object> result = resourcesService.unauthorizedUDFFunction(user, userId);
logger.info(result.toString());
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(udfFunctionMapper.selectByMap(Collections.singletonMap("user_id", user.getId()))).thenReturn(getUdfFuncList());
result = resourcesService.unauthorizedUDFFunction(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | }
@Test
public void testAuthorizedUDFFunction() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList());
Map<String, Object> result = resourcesService.authorizedUDFFunction(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
user.setUserType(UserType.GENERAL_USER);
user.setId(2);
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList());
result = resourcesService.authorizedUDFFunction(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
}
@Test
public void testAuthorizedFile() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.authorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList());
result = resourcesService.authorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testCatFile() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
try {
Mockito.when(hadoopUtils.exists(null)).thenReturn(true);
Mockito.when(hadoopUtils.catFile(null, 1, 10)).thenReturn(getContent());
List<String> list = hadoopUtils.catFile(null, 1, 10);
Assert.assertNotNull(list); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | } catch (IOException e) {
logger.error("hadoop error", e);
}
}
private List<Resource> getResourceList() {
List<Resource> resources = new ArrayList<>();
resources.add(getResource(1));
resources.add(getResource(2));
resources.add(getResource(3));
return resources;
}
private List<Resource> getSingleResourceList() {
return Collections.singletonList(getResource(1));
}
private Tenant getTenant() {
Tenant tenant = new Tenant();
tenant.setTenantCode("123");
return tenant;
}
private Resource getResource() {
Resource resource = new Resource();
resource.setPid(-1);
resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(ResourceType.FILE);
return resource;
}
private Resource getResource(int resourceId) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,892 | [Bug] [api] When a non-admin user creates a udf function, resources other than .jar will be displayed in the UDF resource | ### 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
1. When a non-admin user has authorized other resources, when creating a udf function, the UDF resource will display non `.jar` resources

2. UDF resource displays correctly when creating user with admin user
### What you expected to happen
It is wrong to display non-.jar resources in UDF resources
### How to reproduce
step1: Authorize some resources to user a under the administrator user
step2: Log in with user a, and create or modify UDF functions, UDF resources display non `.jar` resources
### Anything else
Discovered by looking at the code
In the `org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl#queryAuthoredResourceList` code, when querying UDF resources, the `t_ds_relation_udfs_user` table is not filtered by type, but the `t_ds_relation_resources_user` table is directly queried

### Version
2.0.1
### 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/7892 | https://github.com/apache/dolphinscheduler/pull/8458 | b92f6d876d41c7e419572ac9ced3d0aad895d293 | 1ffb5d6e8d6512ee0be958069e8bbd1c105b2989 | 2022-01-08T03:49:51Z | java | 2022-02-24T10:17:25Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Resource resource = new Resource();
resource.setId(resourceId);
resource.setPid(-1);
resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(ResourceType.FILE);
return resource;
}
private Resource getUdfResource() {
Resource resource = new Resource();
resource.setUserId(1);
resource.setDescription("udfTest");
resource.setAlias("udfTest.jar");
resource.setFullName("/udfTest.jar");
resource.setType(ResourceType.UDF);
return resource;
}
private UdfFunc getUdfFunc() {
UdfFunc udfFunc = new UdfFunc();
udfFunc.setId(1);
return udfFunc;
}
private UdfFunc getUdfFunc(int udfId) {
UdfFunc udfFunc = new UdfFunc();
udfFunc.setId(udfId);
return udfFunc;
}
private List<UdfFunc> getUdfFuncList() { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.