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
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
resource.setDescription(desc);
resource.setUpdateTime(now);
if (file != null) {
resource.setSize(file.getSize());
}
if (originResourceName.equals(name) && file == null) {
return result;
}
List<ResourcesTask> existResourcesList;
if (resource.isDirectory()) {
existResourcesList = resourceTaskMapper.selectSubfoldersFullNames(originFullName + FOLDER_SEPARATOR);
} else {
existResourcesList = resourceTaskMapper.selectByMap(
Collections.singletonMap("full_name", originFullName));
}
if (existResourcesList.size() > 0 && !fullName.equals(originFullName)) {
for (ResourcesTask existResource : existResourcesList) {
int taskId = existResource.getTaskId();
if (processService.isTaskOnline(taskDefinitionMapper.selectById(taskId).getCode())) {
logger.error("can't be updated,because it is used of process definition that's online");
logger.error("resource task relation id:{} is used of task code {}", existResource.getId(),
taskDefinitionMapper.selectById(taskId).getCode());
putMsg(result, Status.RESOURCE_IS_USED);
return result;
}
}
for (ResourcesTask existResource : existResourcesList) {
int taskId = existResource.getTaskId();
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
long taskCode = taskDefinitionMapper.selectById(taskId).getCode();
List<ProcessTaskRelation> processTaskRelation = processTaskRelationMapper.selectByMap(
Collections.singletonMap("post_task_code", taskCode));
if (processTaskRelation.size() > 0) {
long processDefinitionCode = processTaskRelation.get(0).getProcessDefinitionCode();
int processDefinitionVersion = processTaskRelation.get(0).getProcessDefinitionVersion();
List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryByProcessCode(
processTaskRelation.get(0).getProjectCode(),
processDefinitionCode);
List<TaskDefinition> taskDefinitionLogList = new ArrayList<>();
if (taskRelationList.size() > 0) {
ProcessDefinitionLog processDefinition =
processDefinitionLogMapper.queryByDefinitionCodeAndVersion(
processDefinitionCode, processDefinitionVersion);
for (ProcessTaskRelation taskRelation : taskRelationList) {
long taskCodeInProcess = taskRelation.getPostTaskCode();
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCodeInProcess);
if (taskCodeInProcess == taskCode) {
taskDefinition.setTaskParams(RemoveResourceFromResourceList(originFullName,
taskDefinition.getTaskParams(),
resource.isDirectory()));
taskDefinition.setTaskParams(AddResourceToResourceList(originFullName,
fullName,
existResource.getFullName(),
taskDefinition.getTaskParams(),
resource.isDirectory()));
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
taskDefinitionLogList.add(taskDefinition);
}
if (processDefinition != null) {
processDefinitionService.updateProcessDefinition(loginUser,
processDefinition.getProjectCode(),
processDefinition.getName(),
processDefinition.getCode(),
processDefinition.getDescription(),
processDefinition.getGlobalParams(),
processDefinition.getLocations(),
processDefinition.getTimeout(),
tenantCode,
JSONUtils.toJsonString(taskRelationList.toArray()),
JSONUtils.toJsonString(taskDefinitionLogList.toArray()),
"",
processDefinition.getExecutionType());
}
}
}
}
}
if (file != null) {
if (!upload(loginUser, fullName, file, type)) {
logger.error("Storage operation error, resourceName:{}, originFileName:{}.",
name, RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.HDFS_OPERATION_ERROR);
throw new ServiceException(
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
if (!fullName.equals(originFullName)) {
try {
storageOperate.delete(originFullName, false);
} catch (IOException e) {
logger.error("Resource delete error, resourceFullName:{}.", originFullName, e);
throw new ServiceException(String.format("delete resource: %s failed.", originFullName));
}
}
return result;
}
String destHdfsFileName = fullName;
try {
logger.info("start copy {} -> {}", originFullName, destHdfsFileName);
storageOperate.copy(originFullName, destHdfsFileName, true, true);
} catch (Exception e) {
logger.error(MessageFormat.format(" copy {0} -> {1} fail", originFullName, destHdfsFileName), e);
putMsg(result, Status.HDFS_COPY_FAIL);
throw new ServiceException(MessageFormat.format(
Status.HDFS_COPY_FAIL.getMsg(), originFullName, destHdfsFileName));
}
return result;
}
private Result<Object> verifyFile(String name, ResourceType type, MultipartFile file) {
Result<Object> result = new Result<>();
putMsg(result, Status.SUCCESS);
if (FileUtils.directoryTraversal(name)) {
logger.warn("Parameter file alias name verify failed, fileAliasName:{}.", RegexUtils.escapeNRT(name));
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
if (file != null && FileUtils.directoryTraversal(Objects.requireNonNull(file.getOriginalFilename()))) {
logger.warn("File original name verify failed, fileOriginalName:{}.",
RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
if (file != null) {
if (file.isEmpty()) {
logger.warn("Parameter file is empty, fileOriginalName:{}.",
RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.RESOURCE_FILE_IS_EMPTY);
return result;
}
String fileSuffix = Files.getFileExtension(file.getOriginalFilename());
String nameSuffix = Files.getFileExtension(name);
if (!fileSuffix.equalsIgnoreCase(nameSuffix)) {
logger.warn("Rename file suffix and original suffix must be consistent, fileOriginalName:{}.",
RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE);
return result;
}
if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) {
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
logger.warn(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.warn(
"Resource file size is larger than max file size, fileOriginalName:{}, fileSize:{}, maxFileSize:{}.",
RegexUtils.escapeNRT(file.getOriginalFilename()), file.getSize(), Constants.MAX_FILE_SIZE);
putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT);
return result;
}
}
return result;
}
/**
* query resources list paging
*
* @param loginUser login user
* @param fullName resource full name
* @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource,
* can be different from the login user in the case of logging in as admin users.
* @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, String fullName, String resTenantCode,
ResourceType type, String searchVal, Integer pageNo, Integer pageSize) {
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
Result<Object> result = new Result<>();
PageInfo<StorageEntity> pageInfo = new PageInfo<>(pageNo, pageSize);
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) {
logger.error("current user does not have permission");
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
String defaultPath = "";
List<StorageEntity> resourcesList = new ArrayList<>();
if (isAdmin(loginUser) && StringUtils.isBlank(fullName)) {
List<User> userList = userMapper.selectList(null);
Set<String> visitedTenantEntityCode = new HashSet<>();
for (User userEntity : userList) {
String tenantEntityCode = tenantMapper.queryById(userEntity.getTenantId()).getTenantCode();
if (!visitedTenantEntityCode.contains(tenantEntityCode)) {
defaultPath = storageOperate.getResDir(tenantEntityCode);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
if (type.equals(ResourceType.UDF)) {
defaultPath = storageOperate.getUdfDir(tenantEntityCode);
}
try {
resourcesList.addAll(storageOperate.listFilesStatus(defaultPath, defaultPath,
tenantEntityCode, type));
visitedTenantEntityCode.add(tenantEntityCode);
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}", defaultPath, e);
putMsg(result, Status.RESOURCE_NOT_EXIST);
throw new ServiceException(String.format(e.getMessage() +
" make sure resource path: %s exists in hdfs", defaultPath));
}
}
}
} else {
defaultPath = storageOperate.getResDir(tenantCode);
if (type.equals(ResourceType.UDF)) {
defaultPath = storageOperate.getUdfDir(tenantCode);
}
try {
if (StringUtils.isBlank(fullName)) {
resourcesList = storageOperate.listFilesStatus(defaultPath, defaultPath, tenantCode, type);
} else {
resourcesList = storageOperate.listFilesStatus(fullName, defaultPath, tenantCode, type);
}
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}", fullName, e);
putMsg(result, Status.RESOURCE_NOT_EXIST);
throw new ServiceException(String.format(e.getMessage() +
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
" make sure resource path: %s exists in hdfs", defaultPath));
}
}
String trimmedSearchVal = searchVal != null ? searchVal.trim() : "";
List<StorageEntity> filteredResourceList = resourcesList.stream()
.filter(x -> x.getFileName().matches("(.*)" + trimmedSearchVal + "(.*)")).collect(Collectors.toList());
List<StorageEntity> slicedResourcesList = filteredResourceList.stream().skip((long) (pageNo - 1) * pageSize)
.limit(pageSize).collect(Collectors.toList());
pageInfo.setTotal(resourcesList.size());
pageInfo.setTotalList(slicedResourcesList);
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* create directory
* xxx The steps to verify resources are cumbersome and can be optimized
*
* @param loginUser login user
* @param fullName full name
* @param type resource type
* @param result Result
*/
private void createDirectory(User loginUser, String fullName, ResourceType type, Result<Object> result) {
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
String resourceRootPath = storageOperate.getDir(type, tenantCode);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
try {
if (!storageOperate.exists(resourceRootPath)) {
storageOperate.createTenantDirIfNotExists(tenantCode);
}
if (!storageOperate.mkdir(tenantCode, fullName)) {
logger.error("create resource directory {} failed", fullName);
putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
}
} catch (Exception e) {
logger.error("create resource directory {} failed", fullName);
putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
throw new ServiceException(String.format("create resource directory: %s failed.", fullName));
}
}
/**
* upload file to hdfs
*
* @param loginUser login user
* @param fullName full name
* @param file file
*/
private boolean upload(User loginUser, String fullName, MultipartFile file, ResourceType type) {
String fileSuffix = Files.getFileExtension(file.getOriginalFilename());
String nameSuffix = Files.getFileExtension(fullName);
if (!fileSuffix.equalsIgnoreCase(nameSuffix)) {
return false;
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString());
String resourcePath = storageOperate.getDir(type, tenantCode);
try {
if (!storageOperate.exists(resourcePath)) {
storageOperate.createTenantDirIfNotExists(tenantCode);
}
org.apache.dolphinscheduler.api.utils.FileUtils.copyInputStreamToFile(file, localFilename);
storageOperate.upload(tenantCode, localFilename, fullName, 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
* @param fullName resource full name
* @return resource list
*/
@Override
public Map<String, Object> queryResourceList(User loginUser, ResourceType type, String fullName) {
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
Map<String, Object> result = new HashMap<>();
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
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;
}
String tenantCode = tenant.getTenantCode();
String defaultPath = "";
List<StorageEntity> resourcesList = new ArrayList<>();
if (StringUtils.isBlank(fullName)) {
if (isAdmin(loginUser)) {
List<User> userList = userMapper.selectList(null);
Set<String> visitedTenantEntityCode = new HashSet<>();
for (User userEntity : userList) {
Tenant tt = tenantMapper.queryById(userEntity.getTenantId());
String tenantEntityCode = tenantMapper.queryById(userEntity.getTenantId()).getTenantCode();
if (!visitedTenantEntityCode.contains(tenantEntityCode)) {
defaultPath = storageOperate.getResDir(tenantEntityCode);
if (type.equals(ResourceType.UDF)) {
defaultPath = storageOperate.getUdfDir(tenantEntityCode);
}
resourcesList.addAll(storageOperate.listFilesStatusRecursively(defaultPath, defaultPath,
tenantEntityCode, type));
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
visitedTenantEntityCode.add(tenantEntityCode);
}
}
} else {
defaultPath = storageOperate.getResDir(tenantCode);
if (type.equals(ResourceType.UDF)) {
defaultPath = storageOperate.getUdfDir(tenantCode);
}
resourcesList = storageOperate.listFilesStatusRecursively(defaultPath, defaultPath, tenantCode, type);
}
} else {
defaultPath = storageOperate.getResDir(tenantCode);
if (type.equals(ResourceType.UDF)) {
defaultPath = storageOperate.getUdfDir(tenantCode);
}
resourcesList = storageOperate.listFilesStatusRecursively(fullName, defaultPath, tenantCode, type);
}
Visitor resourceTreeVisitor = new ResourceTreeVisitor(resourcesList);
result.put(Constants.DATA_LIST, resourceTreeVisitor.visit(defaultPath).getChildren());
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query resource list by program type
*
* @param loginUser login user
* @param type resource type
* @return resource list
*/
@Override
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
public Result<Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) {
Result<Object> result = new Result<>();
Set<Integer> resourceIds = resourcePermissionCheckService
.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger);
if (resourceIds.isEmpty()) {
result.setData(Collections.emptyList());
putMsg(result, Status.SUCCESS);
return result;
}
List<Resource> allResourceList = resourcesMapper.selectBatchIds(resourceIds);
String suffix = ".jar";
if (programType != null) {
switch (programType) {
case JAVA:
case SCALA:
break;
case PYTHON:
suffix = ".py";
break;
default:
}
}
List<Resource> resources = new ResourceFilter(suffix, new ArrayList<>(allResourceList)).filter();
List<StorageEntity> transformedResourceList = resources.stream()
.map(this::createStorageEntityBasedOnResource)
.collect(Collectors.toList());
Visitor visitor = new ResourceTreeVisitor(transformedResourceList);
result.setData(visitor.visit("").getChildren());
putMsg(result, Status.SUCCESS);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
return result;
}
/**
* transform resource object into StorageEntity object
*
* @param resource a resource object
* @return a storageEntity object
*/
private StorageEntity createStorageEntityBasedOnResource(Resource resource) {
StorageEntity entity = new StorageEntity();
entity.setFullName(resource.getFullName());
entity.setPfullName(resource.getPid() == -1 ? ""
: resourcesMapper.selectById(resource.getPid()).getFullName());
entity.setDirectory(resource.isDirectory());
entity.setAlias(resource.getAlias());
entity.setId(resource.getId());
entity.setType(resource.getType());
entity.setDescription(resource.getDescription());
return entity;
}
/**
* delete resource
*
* @param loginUser login user
* @param fullName resource full name
* @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource,
* can be different from the login user in the case of logging in as admin users.
* @return delete result code
* @throws IOException exception
*/
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> delete(User loginUser, String fullName,
String resTenantCode) throws IOException {
Result<Object> result = new Result<>();
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) {
logger.error("current user does not have permission");
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
String defaultPath = storageOperate.getResDir(tenantCode);
StorageEntity resource;
try {
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
resource = storageOperate.getFileStatus(fullName, defaultPath, resTenantCode, null);
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}", fullName, e);
putMsg(result, Status.RESOURCE_NOT_EXIST);
throw new ServiceException(String.format(e.getMessage() + " Resource path: %s", fullName));
}
if (resource == null) {
logger.error("Resource does not exist, resource full name:{}.", fullName);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
List<String> allChildren = storageOperate.listFilesStatusRecursively(fullName, defaultPath,
resTenantCode, resource.getType()).stream().map(storageEntity -> storageEntity.getFullName())
.collect(Collectors.toList());
Set<ResourcesTask> resourcesNeedToDeleteSet = new HashSet<>();
String[] allChildrenFullNameArray = allChildren.stream().toArray(String[]::new);
if (allChildrenFullNameArray.length != 0) {
resourcesNeedToDeleteSet.addAll(
resourceTaskMapper.selectBatchFullNames(allChildrenFullNameArray));
}
if (resource.getType() == (ResourceType.UDF)) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceFullName(allChildrenFullNameArray);
if (CollectionUtils.isNotEmpty(udfFuncs)) {
logger.warn("Resource can not be deleted because it is bound by UDF functions, udfFuncIds:{}",
udfFuncs);
putMsg(result, Status.UDF_RESOURCE_IS_BOUND, udfFuncs.get(0).getFuncName());
return result;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
}
if (resourcesNeedToDeleteSet.size() > 0) {
for (ResourcesTask resourcesTask : resourcesNeedToDeleteSet) {
int taskId = resourcesTask.getTaskId();
if (processService.isTaskOnline(taskDefinitionMapper.selectById(taskId).getCode())) {
logger.error("can't be deleted,because it is used of process definition that's online");
logger.error("resource task relation id:{} is used of task code {}", resourcesTask.getId(),
taskDefinitionMapper.selectById(taskId).getCode());
putMsg(result, Status.RESOURCE_IS_USED);
return result;
}
}
for (ResourcesTask existResource : resourcesNeedToDeleteSet) {
int taskId = existResource.getTaskId();
long taskCode = taskDefinitionMapper.selectById(taskId).getCode();
List<ProcessTaskRelation> processTaskRelation = processTaskRelationMapper.selectByMap(
Collections.singletonMap("post_task_code", taskCode));
if (processTaskRelation.size() > 0) {
long processDefinitionCode = processTaskRelation.get(0).getProcessDefinitionCode();
int processDefinitionVersion = processTaskRelation.get(0).getProcessDefinitionVersion();
List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryByProcessCode(
processTaskRelation.get(0).getProjectCode(),
processDefinitionCode);
List<TaskDefinition> taskDefinitionLogList = new ArrayList<>();
if (taskRelationList.size() > 0) {
ProcessDefinitionLog processDefinition =
processDefinitionLogMapper.queryByDefinitionCodeAndVersion(
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
processDefinitionCode, processDefinitionVersion);
for (ProcessTaskRelation taskRelation : taskRelationList) {
long taskCodeInProcess = taskRelation.getPostTaskCode();
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCodeInProcess);
if (taskCodeInProcess == taskCode) {
taskDefinition.setTaskParams(RemoveResourceFromResourceList(existResource.getFullName(),
taskDefinition.getTaskParams(), false));
}
taskDefinitionLogList.add(taskDefinition);
}
if (processDefinition != null) {
processDefinitionService.updateProcessDefinition(loginUser,
processDefinition.getProjectCode(),
processDefinition.getName(),
processDefinition.getCode(),
processDefinition.getDescription(),
processDefinition.getGlobalParams(),
processDefinition.getLocations(),
processDefinition.getTimeout(),
tenantCode,
JSONUtils.toJsonString(taskRelationList.toArray()),
JSONUtils.toJsonString(taskDefinitionLogList.toArray()),
"",
processDefinition.getExecutionType());
}
}
}
}
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
storageOperate.delete(fullName, allChildren, true);
putMsg(result, Status.SUCCESS);
return result;
}
private String RemoveResourceFromResourceList(String stringToDelete, String taskParameter, boolean isDir) {
Map<String, Object> taskParameters = JSONUtils.parseObject(
taskParameter,
new TypeReference<Map<String, Object>>() {
});
if (taskParameters.containsKey("resourceList")) {
String resourceListStr = JSONUtils.toJsonString(taskParameters.get("resourceList"));
List<ResourceInfo> resourceInfoList = JSONUtils.toList(resourceListStr, ResourceInfo.class);
List<ResourceInfo> updatedResourceInfoList;
if (isDir) {
String stringToDeleteWSeparator = stringToDelete + FOLDER_SEPARATOR;
updatedResourceInfoList = resourceInfoList.stream()
.filter(Objects::nonNull)
.filter(resourceInfo -> !resourceInfo.getResourceName().startsWith(stringToDeleteWSeparator))
.collect(Collectors.toList());
} else {
updatedResourceInfoList = resourceInfoList.stream()
.filter(Objects::nonNull)
.filter(resourceInfo -> !resourceInfo.getResourceName().equals(stringToDelete))
.collect(Collectors.toList());
}
taskParameters.put("resourceList", updatedResourceInfoList);
return JSONUtils.toJsonString(taskParameters);
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
return taskParameter;
}
private String AddResourceToResourceList(String oldPrefix, String newPrefix, String resFullName,
String taskParameter, boolean isDir) {
Map<String, Object> taskParameters = JSONUtils.parseObject(
taskParameter,
new TypeReference<Map<String, Object>>() {
});
if (taskParameters.containsKey("resourceList")) {
String resourceListStr = JSONUtils.toJsonString(taskParameters.get("resourceList"));
List<ResourceInfo> resourceInfos = JSONUtils.toList(resourceListStr, ResourceInfo.class);
ResourceInfo newResource = new ResourceInfo();
if (isDir) {
String oldFullNameWSeparator = oldPrefix + FOLDER_SEPARATOR;
String newFullNameWSpearator = newPrefix + FOLDER_SEPARATOR;
newResource.setResourceName(resFullName.replace(oldFullNameWSeparator, newFullNameWSpearator));
} else {
newResource.setResourceName(newPrefix);
}
resourceInfos.add(newResource);
taskParameters.put("resourceList", resourceInfos);
return JSONUtils.toJsonString(taskParameters);
}
return taskParameter;
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
private String RemoveResourceFromIdsNew(int idToDelete, String idNews) {
String[] resourceIds = idNews.split(",");
Set<Integer> resourceIdSet = Arrays.stream(resourceIds)
.map(Integer::parseInt)
.filter(integerId -> !integerId.equals(idToDelete))
.collect(Collectors.toSet());
return Joiner.on(",").join(resourceIdSet);
}
/**
* 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)) {
logger.error("Resource with same name exists so can not create again, resourceType:{}, resourceName:{}.",
type, RegexUtils.escapeNRT(fullName));
putMsg(result, Status.RESOURCE_EXIST);
}
return result;
}
/**
* verify resource by full name or pid and type
*
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
* @param fileName resource file name
* @param type resource type
* @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource,
* can be different from the login user in the case of logging in as admin users.
* @return true if the resource full name or pid not exists, otherwise return false
*/
@Override
public Result<Object> queryResourceByFileName(User loginUser, String fileName, ResourceType type,
String resTenantCode) {
Result<Object> result = new Result<>();
if (StringUtils.isBlank(fileName)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR);
return result;
}
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) {
logger.error("current user does not have permission");
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
return result;
}
String defaultPath = storageOperate.getResDir(resTenantCode);
if (type.equals(ResourceType.UDF)) {
defaultPath = storageOperate.getUdfDir(resTenantCode);
}
StorageEntity file;
try {
file = storageOperate.getFileStatus(defaultPath + fileName, defaultPath, resTenantCode, type);
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}", defaultPath + fileName, e);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
putMsg(result, Status.SUCCESS);
result.setData(file);
return result;
}
/**
* get resource by id
* @param fullName resource full name
* @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource,
* can be different from the login user in the case of logging in as admin users.
* @return resource
*/
@Override
public Result<Object> queryResourceByFullName(User loginUser, String fullName, String resTenantCode,
ResourceType type) throws IOException {
Result<Object> result = new Result<>();
User user = userMapper.selectById(loginUser.getId());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) {
logger.error("current user does not have permission");
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
String defaultPath = storageOperate.getResDir(resTenantCode);
if (type.equals(ResourceType.UDF)) {
defaultPath = storageOperate.getUdfDir(resTenantCode);
}
StorageEntity file;
try {
file = storageOperate.getFileStatus(fullName, defaultPath, resTenantCode, type);
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}", fullName, e);
putMsg(result, Status.RESOURCE_NOT_EXIST);
throw new ServiceException(String.format(e.getMessage() + " Resource path: %s", fullName));
}
putMsg(result, Status.SUCCESS);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
result.setData(file);
return result;
}
/**
* view resource file online
*
* @param fullName resource fullName
* @param resTenantCode owner's tenant code of the resource
* @param skipLineNum skip line number
* @param limit limit
* @return resource content
*/
@Override
public Result<Object> readResource(User loginUser, String fullName, String resTenantCode,
int skipLineNum, int limit) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) {
logger.error("current user does not have permission");
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
String nameSuffix = Files.getFileExtension(fullName);
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes();
if (StringUtils.isNotEmpty(resourceViewSuffixes)) {
List<String> strList = Arrays.asList(resourceViewSuffixes.split(","));
if (!strList.contains(nameSuffix)) {
logger.error("Resource suffix does not support view,resourceFullName:{}, suffix:{}.", fullName,
nameSuffix);
putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW);
return result;
}
}
List<String> content = new ArrayList<>();
try {
if (storageOperate.exists(fullName)) {
content = storageOperate.vimFile(tenantCode, fullName, skipLineNum, limit);
} else {
logger.error("read file {} not exist in storage", fullName);
putMsg(result, Status.RESOURCE_FILE_NOT_EXIST, fullName);
return result;
}
} catch (Exception e) {
logger.error("Resource {} read failed", fullName, e);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
putMsg(result, Status.HDFS_OPERATION_ERROR);
return result;
}
putMsg(result, Status.SUCCESS);
Map<String, Object> map = new HashMap<>();
map.put(ALIAS, fullName);
map.put(CONTENT, String.join("\n", content));
result.setData(map);
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 currentDir current directory
* @return create result code
*/
@Override
@Transactional
public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix,
String desc, String content, String currentDir) {
Result<Object> result = new Result<>();
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, "")) {
logger.error("current user does not have permission");
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
if (FileUtils.directoryTraversal(fileName)) {
logger.warn("File name verify failed, fileName:{}.", RegexUtils.escapeNRT(fileName));
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
String nameSuffix = fileSuffix.trim();
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes();
if (StringUtils.isNotEmpty(resourceViewSuffixes)) {
List<String> strList = Arrays.asList(resourceViewSuffixes.split(","));
if (!strList.contains(nameSuffix)) {
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
logger.warn("Resource suffix does not support view, suffix:{}.", nameSuffix);
putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW);
return result;
}
}
String name = fileName.trim() + "." + nameSuffix;
String fullName = "";
String userResRootPath = storageOperate.getResDir(tenantCode);
if (!currentDir.contains(userResRootPath)) {
fullName = userResRootPath + name;
} else {
fullName = currentDir + name;
}
result = verifyResourceName(fullName, type, loginUser);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
result = uploadContentToStorage(loginUser, fullName, tenantCode, content);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
throw new ServiceException(result.getMsg());
}
return result;
}
/**
* create or update resource.
* If the folder is not already created, it will be
*
* @param loginUser user who create or update resource
* @param fileFullName The full name of resource.Includes path and suffix.
* @param desc description of resource
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
* @param content content of resource
* @return create result code
*/
@Override
@Transactional
public Result<Object> onlineCreateOrUpdateResourceWithDir(User loginUser, String fileFullName, String desc,
String content) {
if (checkResourceExists(fileFullName)) {
Resource resource = resourcesMapper.queryResource(fileFullName, ResourceType.FILE.ordinal()).get(0);
Result<Object> result = this.updateResourceContent(loginUser, fileFullName,
resource.getUserName(), content);
if (result.getCode() == Status.SUCCESS.getCode()) {
resource.setDescription(desc);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
}
return result;
} else {
String resourceSuffix = fileFullName.substring(fileFullName.indexOf(PERIOD) + 1);
String fileNameWithSuffix = fileFullName.substring(fileFullName.lastIndexOf(FOLDER_SEPARATOR) + 1);
String resourceDir = fileFullName.replace(fileNameWithSuffix, EMPTY_STRING);
String resourceName = fileNameWithSuffix.replace(PERIOD + resourceSuffix, EMPTY_STRING);
String[] dirNames = resourceDir.split(FOLDER_SEPARATOR);
int pid = -1;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
StringBuilder currDirPath = new StringBuilder();
for (String dirName : dirNames) {
if (StringUtils.isNotEmpty(dirName)) {
pid = queryOrCreateDirId(loginUser, pid, currDirPath.toString(), dirName);
currDirPath.append(FOLDER_SEPARATOR).append(dirName);
}
}
return this.onlineCreateResource(
loginUser, ResourceType.FILE, resourceName, resourceSuffix, desc, content,
currDirPath.toString());
}
}
@Override
@Transactional
public Integer createOrUpdateResource(String userName, String fullName, String description,
String resourceContent) {
User user = userMapper.queryByUserNameAccurately(userName);
int suffixLabelIndex = fullName.indexOf(PERIOD);
if (suffixLabelIndex == -1) {
String msg = String.format("The suffix of file can not be empty, fullName:%s.", fullName);
logger.warn(msg);
throw new IllegalArgumentException(msg);
}
if (!fullName.startsWith(FOLDER_SEPARATOR)) {
fullName = FOLDER_SEPARATOR + fullName;
}
Result<Object> createResult = onlineCreateOrUpdateResourceWithDir(
user, fullName, description, resourceContent);
if (createResult.getCode() == Status.SUCCESS.getCode()) {
Map<String, Object> resultMap = (Map<String, Object>) createResult.getData();
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
return (int) resultMap.get("id");
}
String msg = String.format("Create or update resource error, resourceName:%s.", fullName);
logger.error(msg);
throw new IllegalArgumentException(msg);
}
private int queryOrCreateDirId(User user, int pid, String currentDir, String dirName) {
String dirFullName = currentDir + FOLDER_SEPARATOR + dirName;
if (checkResourceExists(dirFullName)) {
List<Resource> resourceList = resourcesMapper.queryResource(dirFullName, ResourceType.FILE.ordinal());
return resourceList.get(0).getId();
} else {
Result<Object> createDirResult = this.createDirectory(
user, dirName, EMPTY_STRING, ResourceType.FILE, pid, currentDir);
if (createDirResult.getCode() == Status.SUCCESS.getCode()) {
return -1;
} else {
String msg = String.format("Create dir error, dirFullName:%s.", dirFullName);
logger.error(msg);
throw new IllegalArgumentException(msg);
}
}
}
private void permissionPostHandle(ResourceType resourceType, User loginUser, Integer resourceId) {
AuthorizationType authorizationType =
resourceType.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
: AuthorizationType.UDF_FILE;
permissionPostHandle(authorizationType, loginUser.getId(), Collections.singletonList(resourceId), logger);
}
private Result<Object> checkResourceUploadStartupState() {
Result<Object> result = new Result<>();
putMsg(result, Status.SUCCESS);
if (!PropertyUtils.getResUploadStartupState()) {
logger.error("Storage does not start up, resource upload startup state: {}.",
PropertyUtils.getResUploadStartupState());
putMsg(result, Status.STORAGE_NOT_STARTUP);
return result;
}
return result;
}
private Result<Object> verifyResource(User loginUser, ResourceType type, String fullName, int pid) {
Result<Object> result = verifyResourceName(fullName, type, loginUser);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
return verifyPid(loginUser, pid);
}
private Result<Object> verifyPid(User loginUser, int pid) {
Result<Object> result = new Result<>();
putMsg(result, Status.SUCCESS);
if (pid != -1) {
Resource parentResource = resourcesMapper.selectById(pid);
if (parentResource == null) {
logger.error("Parent resource does not exist, parentResourceId:{}.", pid);
putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
return result;
}
if (!canOperator(loginUser, parentResource.getUserId())) {
logger.warn("User does not have operation privilege, loginUserName:{}.", loginUser.getUserName());
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
}
return result;
}
/**
* updateProcessInstance resource
*
* @param fullName resource full name
* @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource,
* can be different from the login user in the case of logging in as admin users.
* @param content content
* @return update result cod
*/
@Override
@Transactional
public Result<Object> updateResourceContent(User loginUser, String fullName, String resTenantCode,
String content) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) {
logger.error("current user does not have permission");
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
StorageEntity resource;
try {
resource = storageOperate.getFileStatus(fullName, "", resTenantCode, ResourceType.FILE);
} catch (Exception e) {
logger.error("error occurred when fetching resource information , resource full name {}", fullName);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
if (resource == null) {
logger.error("Resource does not exist, resource full name:{}.", fullName);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
String nameSuffix = Files.getFileExtension(resource.getAlias());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes();
if (StringUtils.isNotEmpty(resourceViewSuffixes)) {
List<String> strList = Arrays.asList(resourceViewSuffixes.split(","));
if (!strList.contains(nameSuffix)) {
logger.warn("Resource suffix does not support view, resource full name:{}, suffix:{}.",
fullName, nameSuffix);
putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW);
return result;
}
}
result = uploadContentToStorage(loginUser, resource.getFullName(), resTenantCode, content);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
throw new ServiceException(result.getMsg());
} else
logger.info("Update resource content complete, resource full name:{}.", fullName);
return result;
}
/**
* @param fullName resource full name
* @param tenantCode tenant code
* @param content content
* @return result
*/
private Result<Object> uploadContentToStorage(User loginUser, String fullName, String tenantCode, String content) {
Result<Object> result = new Result<>();
String localFilename = "";
try {
localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString());
if (!FileUtils.writeContent2File(content, localFilename)) {
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
logger.error("Write file error, fileName:{}, content:{}.", localFilename,
RegexUtils.escapeNRT(content));
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
String resourcePath = storageOperate.getResDir(tenantCode);
logger.info("resource path is {}, resource dir is {}", fullName, resourcePath);
if (!storageOperate.exists(resourcePath)) {
storageOperate.createTenantDirIfNotExists(tenantCode);
logger.info("Create tenant dir because path {} does not exist, tenantCode:{}.", resourcePath,
tenantCode);
}
if (storageOperate.exists(fullName)) {
storageOperate.delete(fullName, false);
}
storageOperate.upload(tenantCode, localFilename, fullName, true, true);
} catch (Exception e) {
logger.error("Upload content to storage error, tenantCode:{}, destFileName:{}.", tenantCode, localFilename,
e);
result.setCode(Status.HDFS_OPERATION_ERROR.getCode());
result.setMsg(String.format("copy %s to hdfs %s fail", localFilename, fullName));
return result;
}
logger.info("Upload content to storage complete, tenantCode:{}, destFileName:{}.", tenantCode, localFilename);
putMsg(result, Status.SUCCESS);
return result;
}
/**
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
* download file
* @return resource content
* @throws IOException exception
*/
@Override
public org.springframework.core.io.Resource downloadResource(User loginUser,
String fullName) throws IOException {
if (!PropertyUtils.getResUploadStartupState()) {
logger.warn("Storage does not start up, resource upload startup state: {}.",
PropertyUtils.getResUploadStartupState());
throw new ServiceException("hdfs not startup");
}
if (fullName.endsWith("/")) {
logger.error("resource id {} is directory,can't download it", fullName);
throw new ServiceException("can't download directory");
}
int userId = loginUser.getId();
User user = userMapper.selectById(userId);
if (user == null) {
logger.error("User does not exits, userId:{}.", userId);
throw new ServiceException(String.format("Resource owner id %d does not exist", userId));
}
String tenantCode = "";
if (user.getTenantId() != 0) {
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()));
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
tenantCode = tenant.getTenantCode();
}
String[] aliasArr = fullName.split("/");
String alias = aliasArr[aliasArr.length - 1];
String localFileName = FileUtils.getDownloadFilename(alias);
logger.info("Resource path is {}, download local filename is {}", alias, localFileName);
try {
storageOperate.download(tenantCode, fullName, localFileName, false, true);
return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName);
} catch (IOException e) {
logger.error("Download resource error, the path is {}, and local filename is {}, the error message is {}",
fullName, localFileName, e.getMessage());
throw new ServerException("Download the resource file failed ,it may be related to your storage");
}
}
/**
* list all file
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code
*/
@Override
public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
List<Resource> resourceList;
if (isAdmin(loginUser)) {
resourceList = resourcesMapper.queryResourceExceptUserId(userId);
} else {
resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1);
}
List<ResourceComponent> list;
if (CollectionUtils.isNotEmpty(resourceList)) {
List<StorageEntity> transformedResourceList = resourceList.stream()
.map(this::createStorageEntityBasedOnResource)
.collect(Collectors.toList());
Visitor visitor = new ResourceTreeVisitor(transformedResourceList);
list = visitor.visit("").getChildren();
} else {
list = new ArrayList<>(0);
}
result.put(Constants.DATA_LIST, list);
putMsg(result, Status.SUCCESS);
return result;
}
@Override
public Resource queryResourcesFileInfo(String userName, String fileName) {
User user = userMapper.queryByUserNameAccurately(userName);
Result<Object> resourceResponse = this.queryResourceByFileName(user, fileName, ResourceType.FILE, "");
if (resourceResponse.getCode() != Status.SUCCESS.getCode()) {
String msg =
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
String.format("Query resource by fullName failed, userName:%s, fullName:%s", userName, fileName);
logger.error(msg);
throw new IllegalArgumentException(msg);
}
return (Resource) resourceResponse.getData();
}
@Override
public DeleteDataTransferResponse deleteDataTransferData(User loginUser, Integer days) {
DeleteDataTransferResponse result = new DeleteDataTransferResponse();
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
String baseFolder = storageOperate.getResourceFileName(tenantCode, "DATA_TRANSFER");
LocalDateTime now = LocalDateTime.now();
now = now.minus(days, ChronoUnit.DAYS);
String deleteDate = now.toLocalDate().toString().replace("-", "");
List<StorageEntity> storageEntities;
try {
storageEntities = new ArrayList<>(
storageOperate.listFilesStatus(baseFolder, baseFolder, tenantCode, ResourceType.FILE));
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
} catch (Exception e) {
logger.error("delete data transfer data error", e);
putMsg(result, Status.DELETE_RESOURCE_ERROR);
return result;
}
List<String> successList = new ArrayList<>();
List<String> failList = new ArrayList<>();
for (StorageEntity storageEntity : storageEntities) {
File path = new File(storageEntity.getFullName());
String date = path.getName();
if (date.compareTo(deleteDate) <= 0) {
try {
storageOperate.delete(storageEntity.getFullName(), true);
successList.add(storageEntity.getFullName());
} catch (Exception ex) {
logger.error("delete data transfer data {} error, please delete it manually", date, ex);
failList.add(storageEntity.getFullName());
}
}
}
result.setSuccessList(successList);
result.setFailedList(failList);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* unauthorized file
*
* @param loginUser login user
* @param userId user id
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
* @return unauthorized result code
*/
@Override
public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
List<Resource> resourceList;
if (isAdmin(loginUser)) {
resourceList = resourcesMapper.queryResourceExceptUserId(userId);
} else {
resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1);
}
List<Resource> list;
if (resourceList != null && !resourceList.isEmpty()) {
Set<Resource> resourceSet = new HashSet<>(resourceList);
List<Resource> authedResourceList = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM);
getAuthorizedResourceList(resourceSet, authedResourceList);
list = new ArrayList<>(resourceSet);
} else {
list = new ArrayList<>(0);
}
List<StorageEntity> transformedResourceList = list.stream()
.map(this::createStorageEntityBasedOnResource)
.collect(Collectors.toList());
Visitor visitor = new ResourceTreeVisitor(transformedResourceList);
result.put(Constants.DATA_LIST, visitor.visit("").getChildren());
putMsg(result, Status.SUCCESS);
return result;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
/**
* unauthorized udf function
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code
*/
@Override
public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
List<UdfFunc> udfFuncList;
if (isAdmin(loginUser)) {
udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId);
} else {
udfFuncList = udfFunctionMapper.selectByMap(Collections.singletonMap("user_id", loginUser.getId()));
}
List<UdfFunc> resultList = new ArrayList<>();
Set<UdfFunc> udfFuncSet;
if (CollectionUtils.isNotEmpty(udfFuncList)) {
udfFuncSet = new HashSet<>(udfFuncList);
List<UdfFunc> authedUDFFuncList = udfFunctionMapper.queryAuthedUdfFunc(userId);
getAuthorizedResourceList(udfFuncSet, authedUDFFuncList);
resultList = new ArrayList<>(udfFuncSet);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
result.put(Constants.DATA_LIST, resultList);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* authorized udf function
*
* @param loginUser login user
* @param userId user id
* @return authorized result code
*/
@Override
public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId);
result.put(Constants.DATA_LIST, udfFuncs);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* authorized file
*
* @param loginUser login user
* @param userId user id
* @return authorized result
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
*/
@Override
public Map<String, Object> authorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
List<Resource> authedResources = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM);
List<StorageEntity> transformedResourceList = authedResources.stream()
.map(this::createStorageEntityBasedOnResource)
.collect(Collectors.toList());
Visitor visitor = new ResourceTreeVisitor(transformedResourceList);
String visit = JSONUtils.toJsonString(visitor.visit(""), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
logger.info(visit);
String jsonTreeStr =
JSONUtils.toJsonString(visitor.visit("").getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
logger.info(jsonTreeStr);
result.put(Constants.DATA_LIST, visitor.visit("").getChildren());
putMsg(result, Status.SUCCESS);
return result;
}
/**
* get authorized resource list
*
* @param resourceSet resource set
* @param authedResourceList authorized resource list
*/
private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) {
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
Set<?> authedResourceSet;
if (CollectionUtils.isNotEmpty(authedResourceList)) {
authedResourceSet = new HashSet<>(authedResourceList);
resourceSet.removeAll(authedResourceSet);
}
}
/**
* 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() != null && 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) {
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
List<Integer> children = resourcesMapper.listChildren(resourceId);
for (int childId : children) {
childList.add(childId);
listAllChildren(childId, childList);
}
}
/**
* query authored resource list (own and authorized)
*
* @param loginUser login user
* @param type ResourceType
* @return all authored resource list
*/
private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) {
Set<Integer> resourceIds = resourcePermissionCheckService
.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger);
if (resourceIds.isEmpty()) {
return Collections.emptyList();
}
List<Resource> resources = resourcesMapper.selectBatchIds(resourceIds);
resources = resources.stream().filter(rs -> rs.getType() == type).collect(Collectors.toList());
return resources;
}
/**
* query resource list by userId and perm
*
* @param userId userId
* @param perm perm
* @return resource list
*/
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
private List<Resource> queryResourceList(Integer userId, int perm) {
List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, perm);
return CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourcesMapper.queryResourceListById(resIds);
}
private AuthorizationType checkResourceType(ResourceType type) {
return type.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID : AuthorizationType.UDF_FILE;
}
/**
* check permission by comparing login user's tenantCode with tenantCode in the request
*
* @param isAdmin is the login user admin
* @param userTenantCode loginUser's tenantCode
* @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource,
* can be different from the login user in the case of logging in as admin users.
* @return isValid
*/
private boolean isUserTenantValid(boolean isAdmin, String userTenantCode,
String resTenantCode) throws ServiceException {
if (!isAdmin) {
resTenantCode = resTenantCode == null ? "" : resTenantCode;
if (!StringUtils.isBlank(resTenantCode) && !resTenantCode.equals(userTenantCode)) {
return false;
}
}
return true;
}
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import static org.mockito.ArgumentMatchers.eq;
import org.apache.dolphinscheduler.api.dto.resources.DeleteDataTransferResponse;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
import org.apache.dolphinscheduler.api.service.impl.BaseServiceImpl;
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.Constants;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.FileUtils;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.service.storage.StorageEntity;
import org.apache.dolphinscheduler.service.storage.StorageOperate;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.apache.commons.collections.CollectionUtils;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
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
*/
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class ResourcesServiceTest {
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceTest.class);
@InjectMocks
private ResourcesServiceImpl resourcesService;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
@Mock
private ResourceMapper resourcesMapper;
@Mock
private TenantMapper tenantMapper;
@Mock
private StorageOperate storageOperate;
@Mock
private UserMapper userMapper;
@Mock
private UdfFuncMapper udfFunctionMapper;
@Mock
private ProcessDefinitionMapper processDefinitionMapper;
@Mock
private ResourceUserMapper resourceUserMapper;
@Mock
private ResourcePermissionCheckService resourcePermissionCheckService;
private static final Logger serviceLogger = LoggerFactory.getLogger(BaseServiceImpl.class);
private static final Logger resourceLogger = LoggerFactory.getLogger(ResourcesServiceImpl.class);
private MockedStatic<FileUtils> mockedStaticFileUtils;
private MockedStatic<Files> mockedStaticFiles;
private MockedStatic<org.apache.dolphinscheduler.api.utils.FileUtils> mockedStaticDolphinschedulerFileUtils;
private MockedStatic<PropertyUtils> mockedStaticPropertyUtils;
@BeforeEach
public void setUp() {
mockedStaticFileUtils = Mockito.mockStatic(FileUtils.class);
mockedStaticFiles = Mockito.mockStatic(Files.class);
mockedStaticDolphinschedulerFileUtils =
Mockito.mockStatic(org.apache.dolphinscheduler.api.utils.FileUtils.class);
mockedStaticPropertyUtils = Mockito.mockStatic(PropertyUtils.class);
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
@AfterEach
public void after() {
mockedStaticFileUtils.close();
mockedStaticFiles.close();
mockedStaticDolphinschedulerFileUtils.close();
mockedStaticPropertyUtils.close();
}
@Test
public void testCreateResource() {
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
user.setId(1);
user.setUserType(UserType.GENERAL_USER);
MockMultipartFile mockMultipartFile = new MockMultipartFile("test.pdf", "test.pdf", "pdf", "test".getBytes());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(userMapper.selectById(user.getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(null);
Result result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest",
ResourceType.FILE, mockMultipartFile, "/");
logger.info(result.toString());
Assertions.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
user.setTenantId(1);
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest",
ResourceType.FILE, null, "/");
logger.info(result.toString());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
Assertions.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
mockMultipartFile = new MockMultipartFile("test.pdf", "".getBytes());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest",
ResourceType.FILE, mockMultipartFile, "/");
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_FILE_IS_EMPTY.getMsg(), result.getMsg());
mockMultipartFile = new MockMultipartFile("test.pdf", "test.pdf", "pdf", "test".getBytes());
Mockito.when(Files.getFileExtension("test.pdf")).thenReturn("pdf");
Mockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.createResource(user, "ResourcesServiceTest.jar", "ResourcesServiceTest",
ResourceType.FILE, mockMultipartFile, "/");
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_SUFFIX_FORBID_CHANGE.getMsg(), result.getMsg());
mockMultipartFile = new MockMultipartFile("ResourcesServiceTest.pdf", "ResourcesServiceTest.pdf",
"pdf", "test".getBytes());
Mockito.when(Files.getFileExtension("ResourcesServiceTest.pdf")).thenReturn("pdf");
result = resourcesService.createResource(user, "ResourcesServiceTest.pdf", "ResourcesServiceTest",
ResourceType.UDF, mockMultipartFile, "/");
logger.info(result.toString());
Assertions.assertEquals(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg(), result.getMsg());
String tooLongFileName = getRandomStringWithLength(Constants.RESOURCE_FULL_NAME_MAX_LENGTH) + ".pdf";
mockMultipartFile = new MockMultipartFile(tooLongFileName, tooLongFileName, "pdf", "test".getBytes());
Mockito.when(Files.getFileExtension(tooLongFileName)).thenReturn("pdf");
Mockito.when(storageOperate.getResDir("123")).thenReturn("/dolphinscheduler/123/resources/");
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
result = resourcesService.createResource(user, tooLongFileName, tooLongFileName, ResourceType.FILE,
mockMultipartFile, "/");
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_FULL_NAME_TOO_LONG_ERROR.getMsg(), result.getMsg());
}
@Test
public void testCreateDirecotry() {
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
user.setId(1);
user.setUserType(UserType.GENERAL_USER);
Result result = resourcesService.createDirectory(user, "directoryTest", "directory test",
ResourceType.FILE, -1, "/");
logger.info(result.toString());
Assertions.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
user.setId(1);
user.setTenantId(1);
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(userMapper.selectById(user.getId())).thenReturn(getUser());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(storageOperate.getResDir("123")).thenReturn("/dolphinscheduler/123/resources/");
try {
Mockito.when(storageOperate.exists("/dolphinscheduler/123/resources/directoryTest")).thenReturn(true);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.existResource("/directoryTest", 0)).thenReturn(true);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, -1, "/");
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg());
result = resourcesService.createDirectory(user, "directoryTest",
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
ResourceType.FILE, -1, "/");
logger.info(result.toString());
Assertions.assertEquals(Status.DESCRIPTION_TOO_LONG_ERROR.getMsg(), result.getMsg());
}
@Test
public void testUpdateResource() {
User user = new User();
user.setId(1);
user.setUserType(UserType.GENERAL_USER);
user.setTenantId(1);
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Mockito.when(userMapper.selectById(user.getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(storageOperate.getResDir("123")).thenReturn("/dolphinscheduler/123/resources/");
Result result = resourcesService.updateResource(user, "ResourcesServiceTest",
"123", "ResourcesServiceTest", "", ResourceType.FILE, null);
logger.info(result.toString());
Assertions.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
user.setUserType(UserType.GENERAL_USER);
Tenant tenantWNoPermission = new Tenant();
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
tenantWNoPermission.setTenantCode("321");
Mockito.when(tenantMapper.queryById(1)).thenReturn(tenantWNoPermission);
result = resourcesService.updateResource(user,
"/dolphinscheduler/123/resources/ResourcesServiceTest",
"123",
"ResourcesServiceTest", "", ResourceType.FILE, null);
logger.info(result.toString());
Assertions.assertEquals(Status.NO_CURRENT_OPERATING_PERMISSION.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Mockito.when(storageOperate.exists(Mockito.any())).thenReturn(false);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
try {
Mockito.when(storageOperate.getFileStatus("/dolphinscheduler/123/resources/ResourcesServiceTest",
"/dolphinscheduler/123/resources/",
"123", ResourceType.FILE)).thenReturn(getStorageEntityResource());
result = resourcesService.updateResource(user, "/dolphinscheduler/123/resources/ResourcesServiceTest",
"123",
"ResourcesServiceTest", "", ResourceType.FILE, null);
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}", "/dolphinscheduler/123/resources/ResourcesServiceTest",
e);
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
try {
Mockito.when(storageOperate.exists("/dolphinscheduler/123/resources/ResourcesServiceTest2.jar"))
.thenReturn(true);
} catch (IOException e) {
logger.error("error occurred when checking resource: "
+ "/dolphinscheduler/123/resources/ResourcesServiceTest2.jar");
}
try {
Mockito.when(storageOperate.getFileStatus("/dolphinscheduler/123/resources/ResourcesServiceTest1.jar",
"/dolphinscheduler/123/resources/",
"123", ResourceType.UDF)).thenReturn(getStorageEntityUdfResource());
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}",
"/dolphinscheduler/123/resources/ResourcesServiceTest1.jar", e);
}
result = resourcesService.updateResource(user, "/dolphinscheduler/123/resources/ResourcesServiceTest1.jar",
"123", "ResourcesServiceTest2.jar", "", ResourceType.UDF, null);
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(Mockito.anyInt())).thenReturn(null);
result = resourcesService.updateResource(user, "ResourcesServiceTest1.jar",
"", "ResourcesServiceTest", "", ResourceType.UDF, null);
logger.info(result.toString());
Assertions.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
result = resourcesService.updateResource(user, "/dolphinscheduler/123/resources/ResourcesServiceTest1.jar",
"123", "ResourcesServiceTest1.jar", "", ResourceType.UDF, null);
logger.info(result.toString());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
Assertions.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testQueryResourceListPaging() {
User loginUser = new User();
loginUser.setId(1);
loginUser.setTenantId(1);
loginUser.setTenantCode("tenant1");
loginUser.setUserType(UserType.ADMIN_USER);
IPage<Resource> resourcePage = new Page<>(1, 10);
resourcePage.setTotal(1);
resourcePage.setRecords(getResourceList());
List<StorageEntity> mockResList = new ArrayList<StorageEntity>();
mockResList.add(getStorageEntityResource());
List<User> mockUserList = new ArrayList<User>();
mockUserList.add(getUser());
Mockito.when(userMapper.selectList(null)).thenReturn(mockUserList);
Mockito.when(userMapper.selectById(getUser().getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(getUser().getTenantId())).thenReturn(getTenant());
Mockito.when(storageOperate.getResDir("123")).thenReturn("/dolphinscheduler/123/resources/");
try {
Mockito.when(storageOperate.listFilesStatus("/dolphinscheduler/123/resources/",
"/dolphinscheduler/123/resources/",
"123", ResourceType.FILE)).thenReturn(mockResList);
} catch (Exception e) {
logger.error("QueryResourceListPaging Error");
}
Result result = resourcesService.queryResourceListPaging(loginUser, "", "",
ResourceType.FILE, "Test", 1, 10);
logger.info(result.toString());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
Assertions.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode());
PageInfo pageInfo = (PageInfo) result.getData();
Assertions.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
}
@Test
public void testQueryResourceList() {
User loginUser = new User();
loginUser.setId(0);
loginUser.setUserType(UserType.ADMIN_USER);
Mockito.when(userMapper.selectList(null)).thenReturn(Arrays.asList(loginUser));
Mockito.when(userMapper.selectById(loginUser.getId())).thenReturn(loginUser);
Mockito.when(tenantMapper.queryById(Mockito.anyInt())).thenReturn(getTenant());
Mockito.when(storageOperate.getResDir("123")).thenReturn("/dolphinscheduler/123/resources/");
Mockito.when(storageOperate.listFilesStatusRecursively("/dolphinscheduler/123/resources/",
"/dolphinscheduler/123/resources/",
"123",
ResourceType.FILE)).thenReturn(Arrays.asList(getStorageEntityResource()));
Map<String, Object> result = resourcesService.queryResourceList(loginUser, ResourceType.FILE, "");
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resourceList = (List<Resource>) result.get(Constants.DATA_LIST);
Assertions.assertTrue(CollectionUtils.isNotEmpty(resourceList));
Mockito.when(storageOperate.getUdfDir("123")).thenReturn("/dolphinscheduler/123/udfs/");
Mockito.when(storageOperate.listFilesStatusRecursively("/dolphinscheduler/123/udfs/",
"/dolphinscheduler/123/udfs/",
"123",
ResourceType.UDF))
.thenReturn(Arrays.asList(getStorageEntityUdfResource()));
loginUser.setUserType(UserType.GENERAL_USER);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
result = resourcesService.queryResourceList(loginUser, ResourceType.UDF, "");
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resourceList = (List<Resource>) result.get(Constants.DATA_LIST);
Assertions.assertTrue(CollectionUtils.isNotEmpty(resourceList));
}
@Test
public void testDelete() {
User loginUser = new User();
loginUser.setId(0);
loginUser.setUserType(UserType.GENERAL_USER);
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
try {
Result result = resourcesService.delete(loginUser, "", "");
logger.info(result.toString());
Assertions.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
loginUser.setUserType(UserType.ADMIN_USER);
loginUser.setTenantId(2);
Mockito.when(userMapper.selectById(loginUser.getId())).thenReturn(loginUser);
result = resourcesService.delete(loginUser, "", "");
logger.info(result.toString());
Assertions.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(Mockito.anyInt())).thenReturn(getTenant());
Mockito.when(storageOperate.getFileStatus("/dolphinscheduler/123/resources/ResourcesServiceTest",
null, "123", null))
.thenReturn(getStorageEntityResource());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
result = resourcesService.delete(loginUser, "/dolphinscheduler/123/resources/ResNotExist", "123");
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
loginUser.setTenantId(1);
result = resourcesService.delete(loginUser, "/dolphinscheduler/123/resources/ResourcesServiceTest",
"123");
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
} catch (Exception e) {
logger.error("delete error", e);
Assertions.assertTrue(false);
}
}
@Test
public void testVerifyResourceName() {
User user = new User();
user.setId(1);
user.setUserType(UserType.GENERAL_USER);
try {
Mockito.when(storageOperate.exists("/ResourcesServiceTest.jar")).thenReturn(true);
} catch (IOException e) {
logger.error("error occurred when checking resource: /ResourcesServiceTest.jar\"");
}
Result result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user);
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg());
result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user);
logger.info(result.toString());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
Assertions.assertTrue(Status.RESOURCE_EXIST.getCode() == result.getCode());
result = resourcesService.verifyResourceName("test2", ResourceType.FILE, user);
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testReadResource() {
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Result result = resourcesService.readResource(getUser(), "", "", 1, 10);
logger.info(result.toString());
Assertions.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(userMapper.selectById(getUser().getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(getUser().getTenantId())).thenReturn(getTenant());
result = resourcesService.readResource(getUser(), "", "", 1, 10);
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_FILE_NOT_EXIST.getCode(), (int) result.getCode());
Mockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class");
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.readResource(getUser(), "", "", 1, 10);
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
Mockito.when(userMapper.selectById(getUser().getId())).thenReturn(null);
Mockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar");
Mockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
result = resourcesService.readResource(getUser(), "", "", 1, 10);
logger.info(result.toString());
Assertions.assertEquals(Status.USER_NOT_EXIST.getCode(), (int) result.getCode());
Mockito.when(userMapper.selectById(getUser().getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(getUser().getTenantId())).thenReturn(null);
result = resourcesService.readResource(getUser(), "", "", 1, 10);
logger.info(result.toString());
Assertions.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
Mockito.when(userMapper.selectById(getUser().getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(getUser().getTenantId())).thenReturn(getTenant());
try {
Mockito.when(storageOperate.exists(Mockito.any())).thenReturn(true);
Mockito.when(storageOperate.vimFile(Mockito.any(), Mockito.any(), eq(1), eq(10))).thenReturn(getContent());
} catch (IOException e) {
logger.error("storage error", e);
}
Mockito.when(Files.getFileExtension("test.jar")).thenReturn("jar");
result = resourcesService.readResource(getUser(), "test.jar", "", 1, 10);
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testOnlineCreateResource() {
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = getUser();
user.setId(1);
Mockito.when(userMapper.selectById(user.getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
Result result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content",
"/");
logger.info(result.toString());
Assertions.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class");
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content",
"/");
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
Mockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar");
Mockito.when(storageOperate.getResDir("123")).thenReturn("/dolphinscheduler/123/resources/");
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
Mockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content",
"/");
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testOnlineCreateResourceWithDir() {
User user = getUser();
user.setId(1);
String dir1Path = "/dir1";
String dir2Path = "/dir2";
String resourceDir = dir1Path + dir2Path;
String resourceName = "test";
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
String resourceSuffix = "py";
String desc = "desc";
String content = "content";
String fullName = resourceDir + "/" + resourceName + "." + resourceSuffix;
Resource dir1 = new Resource();
dir1.setFullName(dir1Path);
dir1.setId(1);
dir1.setUserId(user.getId());
Resource dir2 = new Resource();
dir2.setFullName(resourceDir);
dir2.setUserId(user.getId());
Mockito.when(storageOperate.getDir(ResourceType.FILE, "123")).thenReturn("/dolphinscheduler/123/resources/");
Mockito.when(storageOperate.getResDir("123")).thenReturn("/dolphinscheduler/123/resources/");
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
Mockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
try {
Mockito.when(storageOperate.mkdir("123", "/dolphinscheduler/123/resources" + dir1Path)).thenReturn(true);
Mockito.when(storageOperate.mkdir("123", "/dolphinscheduler/123/resources" + dir2Path)).thenReturn(true);
} catch (IOException e) {
logger.error("create resource directory {} failed", fullName);
}
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(userMapper.selectById(user.getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(user.getTenantId())).thenReturn(getTenant());
Result<Object> result = resourcesService.onlineCreateOrUpdateResourceWithDir(user, fullName, desc, content);
Assertions.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
@Test
public void testUpdateResourceContent() {
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Result result = resourcesService.updateResourceContent(getUser(), "", "", "content");
logger.info(result.toString());
Assertions.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(userMapper.selectById(getUser().getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
try {
Mockito.when(storageOperate.getFileStatus("/dolphinscheduler/123/resources/ResourcesServiceTest.jar",
"",
"123", ResourceType.FILE)).thenReturn(null);
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}", "", e);
}
result = resourcesService.updateResourceContent(getUser(),
"/dolphinscheduler/123/resources/ResourcesServiceTest.jar",
"123", "content");
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class");
try {
Mockito.when(storageOperate.getFileStatus("", "", "123", ResourceType.FILE))
.thenReturn(getStorageEntityResource());
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}", "", e);
}
result = resourcesService.updateResourceContent(getUser(), "", "123", "content");
logger.info(result.toString());
Assertions.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
Mockito.when(userMapper.selectById(getUser().getId())).thenReturn(null);
result = resourcesService.updateResourceContent(getUser(), "", "123", "content");
logger.info(result.toString());
Assertions.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
Mockito.when(userMapper.selectById(getUser().getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(null);
result = resourcesService.updateResourceContent(getUser(), "", "123", "content");
logger.info(result.toString());
Assertions.assertTrue(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getCode() == result.getCode());
try {
Mockito.when(storageOperate.getFileStatus("/dolphinscheduler/123/resources/ResourcesServiceTest.jar",
"",
"123", ResourceType.FILE)).thenReturn(getStorageEntityResource());
} catch (Exception e) {
logger.error(e.getMessage() + " Resource path: {}", "", e);
}
Mockito.when(Files.getFileExtension(Mockito.anyString())).thenReturn("jar");
Mockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar");
Mockito.when(userMapper.selectById(getUser().getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
Mockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.updateResourceContent(getUser(),
"/dolphinscheduler/123/resources/ResourcesServiceTest.jar",
"123", "content");
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testDownloadResource() {
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
org.springframework.core.io.Resource resourceMock = Mockito.mock(org.springframework.core.io.Resource.class);
try {
org.springframework.core.io.Resource resource = resourcesService.downloadResource(getUser(), "");
Assertions.assertNull(resource);
Mockito.when(org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(Mockito.any()))
.thenReturn(resourceMock);
resource = resourcesService.downloadResource(getUser(), "");
Assertions.assertNotNull(resource);
} catch (Exception e) {
logger.error("DownloadResource error", e);
Assertions.assertTrue(false);
}
}
@Test
public void testAuthorizeResourceTree() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.authorizeResourceTree(user, userId);
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assertions.assertTrue(CollectionUtils.isNotEmpty(resources));
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourcesMapper.queryResourceListAuthored(user.getId(), -1)).thenReturn(getResourceList());
result = resourcesService.authorizeResourceTree(user, userId);
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assertions.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());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assertions.assertTrue(CollectionUtils.isNotEmpty(resources));
user.setId(2);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
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());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assertions.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testUnauthorizedUDFFunction() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(udfFunctionMapper.queryUdfFuncExceptUserId(userId)).thenReturn(getUdfFuncList());
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getSingleUdfFuncList());
Map<String, Object> result = resourcesService.unauthorizedUDFFunction(user, userId);
logger.info(result.toString());
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assertions.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());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assertions.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
}
@Test
public void testAuthorizedUDFFunction() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList());
Map<String, Object> result = resourcesService.authorizedUDFFunction(user, userId);
logger.info(result.toString());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assertions.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());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assertions.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
}
@Test
public void testAuthorizedFile() {
User user = getUser();
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(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());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assertions.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());
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assertions.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testDeleteDataTransferData() throws Exception {
User user = getUser();
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
Mockito.when(userMapper.selectById(user.getId())).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(user.getTenantId())).thenReturn(getTenant());
StorageEntity storageEntity1 = Mockito.mock(StorageEntity.class);
StorageEntity storageEntity2 = Mockito.mock(StorageEntity.class);
StorageEntity storageEntity3 = Mockito.mock(StorageEntity.class);
StorageEntity storageEntity4 = Mockito.mock(StorageEntity.class);
StorageEntity storageEntity5 = Mockito.mock(StorageEntity.class);
Mockito.when(storageEntity1.getFullName()).thenReturn("DATA_TRANSFER/20220101");
Mockito.when(storageEntity2.getFullName()).thenReturn("DATA_TRANSFER/20220102");
Mockito.when(storageEntity3.getFullName()).thenReturn("DATA_TRANSFER/20220103");
Mockito.when(storageEntity4.getFullName()).thenReturn("DATA_TRANSFER/20220104");
Mockito.when(storageEntity5.getFullName()).thenReturn("DATA_TRANSFER/20220105");
List<StorageEntity> storageEntityList = new ArrayList<>();
storageEntityList.add(storageEntity1);
storageEntityList.add(storageEntity2);
storageEntityList.add(storageEntity3);
storageEntityList.add(storageEntity4);
storageEntityList.add(storageEntity5);
Mockito.when(storageOperate.listFilesStatus(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
.thenReturn(storageEntityList);
LocalDateTime localDateTime = LocalDateTime.of(2022, 1, 5, 0, 0, 0);
try (MockedStatic<LocalDateTime> mockHook = Mockito.mockStatic(LocalDateTime.class)) {
mockHook.when(LocalDateTime::now).thenReturn(localDateTime);
DeleteDataTransferResponse response = resourcesService.deleteDataTransferData(user, 3);
Assertions.assertEquals(response.getSuccessList().size(), 2);
Assertions.assertEquals(response.getSuccessList().get(0), "DATA_TRANSFER/20220101");
Assertions.assertEquals(response.getSuccessList().get(1), "DATA_TRANSFER/20220102");
}
try (MockedStatic<LocalDateTime> mockHook = Mockito.mockStatic(LocalDateTime.class)) {
mockHook.when(LocalDateTime::now).thenReturn(localDateTime);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
DeleteDataTransferResponse response = resourcesService.deleteDataTransferData(user, 0);
Assertions.assertEquals(response.getSuccessList().size(), 5);
}
}
@Test
public void testCatFile() {
Mockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
try {
List<String> list = storageOperate.vimFile(Mockito.any(), Mockito.anyString(), eq(1), eq(10));
Assertions.assertNotNull(list);
} catch (IOException e) {
logger.error("hadoop error", e);
}
}
private List<Resource> getResourceList() {
List<Resource> resources = new ArrayList<>();
resources.add(getResource(1));
resources.add(getResource(2));
resources.add(getResource(3));
return resources;
}
private Set<Integer> getSetIds() {
Set<Integer> resources = new HashSet<>();
resources.add(1);
return resources;
}
private List<Resource> getSingleResourceList() {
return Collections.singletonList(getResource(1));
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
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 StorageEntity getStorageEntityResource() {
StorageEntity entity = new StorageEntity();
entity.setAlias("ResourcesServiceTest");
entity.setFileName("ResourcesServiceTest");
entity.setDirectory(false);
entity.setDescription("");
entity.setUserName("123");
entity.setType(ResourceType.FILE);
entity.setFullName("/dolphinscheduler/123/resources/ResourcesServiceTest");
return entity;
}
private Resource getResource(int resourceId) {
Resource resource = new Resource();
resource.setId(resourceId);
resource.setPid(-1);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(ResourceType.FILE);
return resource;
}
private Resource getResource(int resourceId, ResourceType type) {
Resource resource = new Resource();
resource.setId(resourceId);
resource.setPid(-1);
resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(type);
return resource;
}
private Resource getUdfResource() {
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 StorageEntity getStorageEntityUdfResource() {
StorageEntity entity = new StorageEntity();
entity.setAlias("ResourcesServiceTest1.jar");
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
entity.setFileName("ResourcesServiceTest1.jar");
entity.setDirectory(false);
entity.setDescription("");
entity.setUserName("123");
entity.setType(ResourceType.UDF);
entity.setFullName("/dolphinscheduler/123/resources/ResourcesServiceTest1.jar");
return entity;
}
private UdfFunc getUdfFunc() {
UdfFunc udfFunc = new UdfFunc();
udfFunc.setId(1);
return udfFunc;
}
private UdfFunc getUdfFunc(int udfId) {
UdfFunc udfFunc = new UdfFunc();
udfFunc.setId(udfId);
return udfFunc;
}
private List<UdfFunc> getUdfFuncList() {
List<UdfFunc> udfFuncs = new ArrayList<>();
udfFuncs.add(getUdfFunc(1));
udfFuncs.add(getUdfFunc(2));
udfFuncs.add(getUdfFunc(3));
return udfFuncs;
}
private List<UdfFunc> getSingleUdfFuncList() {
return Collections.singletonList(getUdfFunc(3));
}
private User getUser() {
User user = new User();
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,466 |
[Bug] [Resource] Resource authorization is disabled
|
### 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
Resource authorization is disabled
### What you expected to happen
Normal
### How to reproduce
Resource authorization
### Anything else
No
### 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/12466
|
https://github.com/apache/dolphinscheduler/pull/12467
|
f249f2b257847787605758797669abecf1b782d8
|
606a5aeee5b44b095ddf922e2c8c0de485e56c45
| 2022-10-20T10:47:44Z |
java
| 2022-11-06T13:15:27Z |
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
|
user.setId(1);
user.setUserType(UserType.GENERAL_USER);
user.setTenantId(1);
user.setTenantCode("tenantCode");
return user;
}
private List<String> getContent() {
List<String> contentList = new ArrayList<>();
contentList.add("test");
return contentList;
}
private List<Map<String, Object>> getResources() {
List<Map<String, Object>> resources = new ArrayList<>();
Map<String, Object> resource = new HashMap<>();
resource.put("id", 1);
resource.put("resource_ids", "1");
resources.add(resource);
return resources;
}
private static String getRandomStringWithLength(int length) {
Random r = new Random();
StringBuilder sb = new StringBuilder();
while (sb.length() < length) {
char c = (char) (r.nextInt(26) + 'a');
sb.append(c);
}
return sb.toString();
}
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
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
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
* 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.Constants.ALIAS;
import static org.apache.dolphinscheduler.common.constants.Constants.CONTENT;
import static org.apache.dolphinscheduler.common.constants.Constants.EMPTY_STRING;
import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR;
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_SS;
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S;
import static org.apache.dolphinscheduler.common.constants.Constants.JAR;
import static org.apache.dolphinscheduler.common.constants.Constants.PERIOD;
import org.apache.dolphinscheduler.api.dto.resources.DeleteDataTransferResponse;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter;
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor;
import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
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.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.ProgramType;
import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
import org.apache.dolphinscheduler.common.utils.FileUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog;
import org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.ResourcesTask;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
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.ProcessDefinitionLogMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceTaskMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
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.plugin.task.api.model.ResourceInfo;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.dolphinscheduler.service.storage.StorageEntity;
import org.apache.dolphinscheduler.service.storage.StorageOperate;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.IOException;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
import java.rmi.ServerException;
import java.text.MessageFormat;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.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 org.springframework.web.multipart.MultipartFile;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.base.Joiner;
import com.google.common.io.Files;
/**
* resources service impl
*/
@Service
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesService {
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceImpl.class);
@Autowired
private ResourceMapper resourcesMapper;
@Autowired
private ResourceTaskMapper resourceTaskMapper;
@Autowired
private TaskDefinitionMapper taskDefinitionMapper;
@Autowired
private UdfFuncMapper udfFunctionMapper;
@Autowired
private ProcessService processService;
@Autowired
private ProcessDefinitionService processDefinitionService;
@Autowired
private TenantMapper tenantMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private ResourceUserMapper resourceUserMapper;
@Autowired
private ProcessDefinitionLogMapper processDefinitionLogMapper;
@Autowired
private ProcessTaskRelationMapper processTaskRelationMapper;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
@Autowired(required = false)
private StorageOperate storageOperate;
/**
* 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
public Result<Object> createDirectory(User loginUser,
String name,
String description,
ResourceType type,
int pid,
String currentDir) {
Result<Object> result = new Result<>();
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
if (FileUtils.directoryTraversal(name)) {
logger.warn("Parameter name is invalid, name:{}.", RegexUtils.escapeNRT(name));
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, "")) {
logger.error("current user does not have permission");
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
if (checkDescriptionLength(description)) {
logger.warn("Parameter description is too long.");
putMsg(result, Status.DESCRIPTION_TOO_LONG_ERROR);
return result;
}
String userResRootPath = ResourceType.UDF.equals(type) ? storageOperate.getUdfDir(tenantCode)
: storageOperate.getResDir(tenantCode);
String fullName = !currentDir.contains(userResRootPath) ? userResRootPath + name : currentDir + name;
try {
if (checkResourceExists(fullName)) {
logger.error("resource directory {} has exist, can't recreate", fullName);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
} catch (Exception e) {
logger.warn("Resource exists, can not create again, fullName:{}.", fullName, e);
throw new ServiceException("resource already exists, can't recreate");
}
createDirectory(loginUser, fullName, type, result);
return result;
}
private String getFullName(String currentDir, String name) {
return currentDir.equals(FOLDER_SEPARATOR) ? String.format(FORMAT_SS, currentDir, name)
: String.format(FORMAT_S_S, currentDir, name);
}
/**
* create resource
*
* @param loginUser login user
* @param name alias
* @param desc description
* @param type type
* @param file file
* @param currentDir current directory
* @return create result code
*/
@Override
@Transactional
public Result<Object> createResource(User loginUser,
String name,
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
String desc,
ResourceType type,
MultipartFile file,
String currentDir) {
Result<Object> result = new Result<>();
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, "")) {
logger.error("current user does not have permission");
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
result = verifyFile(name, type, file);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
String userResRootPath = ResourceType.UDF.equals(type) ? storageOperate.getUdfDir(tenantCode)
: storageOperate.getResDir(tenantCode);
String currDirNFileName = !currentDir.contains(userResRootPath) ? userResRootPath + name : currentDir + name;
try {
if (checkResourceExists(currDirNFileName)) {
logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name));
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
} catch (Exception e) {
throw new ServiceException("resource already exists, can't recreate");
}
if (currDirNFileName.length() > Constants.RESOURCE_FULL_NAME_MAX_LENGTH) {
logger.error(
"Resource file's name is longer than max full name length, fullName:{}, " +
"fullNameSize:{}, maxFullNameSize:{}",
RegexUtils.escapeNRT(name), currDirNFileName.length(), Constants.RESOURCE_FULL_NAME_MAX_LENGTH);
putMsg(result, Status.RESOURCE_FULL_NAME_TOO_LONG_ERROR);
return result;
}
if (!upload(loginUser, currDirNFileName, file, type)) {
logger.error("upload resource: {} file: {} failed.", RegexUtils.escapeNRT(name),
RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
throw new ServiceException(
String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
} else
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
logger.info("Upload resource file complete, resourceName:{}, fileName:{}.",
RegexUtils.escapeNRT(name), RegexUtils.escapeNRT(file.getOriginalFilename()));
return result;
}
/**
* update the folder's size of the resource
*
* @param resource the current resource
* @param size size
*/
private void updateParentResourceSize(Resource resource, long size) {
if (resource.getSize() > 0) {
String[] splits = resource.getFullName().split("/");
for (int i = 1; i < splits.length; i++) {
String parentFullName = Joiner.on("/").join(Arrays.copyOfRange(splits, 0, i));
if (StringUtils.isNotBlank(parentFullName)) {
List<Resource> resources =
resourcesMapper.queryResource(parentFullName, resource.getType().ordinal());
if (CollectionUtils.isNotEmpty(resources)) {
Resource parentResource = resources.get(0);
if (parentResource.getSize() + size >= 0) {
parentResource.setSize(parentResource.getSize() + size);
} else {
parentResource.setSize(0L);
}
resourcesMapper.updateById(parentResource);
logger.info("Resource size update complete, resourceFullName:{}, newSize:{}.",
parentResource.getFullName(), parentResource.getSize());
}
}
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
}
}
/**
* check resource is exists
*
* @param fullName fullName
* @return true if resource exists
*/
private boolean checkResourceExists(String fullName) {
Boolean existResource = false;
try {
existResource = storageOperate.exists(fullName);
} catch (IOException e) {
logger.error("error occurred when checking resource: " + fullName, e);
}
return Boolean.TRUE.equals(existResource);
}
/**
* update resource
*
* @param loginUser login user
* @param resourceFullName resource full name
* @param resTenantCode tenantCode in the request field "resTenantCode" for tenant code owning the resource,
* can be different from the login user in the case of logging in as admin users.
* @param name name
* @param desc description
* @param type resource type
* @param file resource file
* @return update result code
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
*/
@Override
@Transactional
public Result<Object> updateResource(User loginUser,
String resourceFullName,
String resTenantCode,
String name,
String desc,
ResourceType type,
MultipartFile file) {
Result<Object> result = new Result<>();
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
User user = userMapper.selectById(loginUser.getId());
if (user == null) {
logger.error("user {} not exists", loginUser.getId());
putMsg(result, Status.USER_NOT_EXIST, loginUser.getId());
return result;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return result;
}
String tenantCode = tenant.getTenantCode();
if (!isUserTenantValid(isAdmin(loginUser), tenantCode, resTenantCode)) {
logger.error("current user does not have permission");
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
String defaultPath = storageOperate.getResDir(tenantCode);
StorageEntity resource;
try {
resource = storageOperate.getFileStatus(resourceFullName, defaultPath, resTenantCode, type);
} catch (Exception e) {
logger.error("Get file status fail, resource path: {}", resourceFullName, e);
putMsg(result, Status.RESOURCE_NOT_EXIST);
throw new ServiceException((String.format("Get file status fail, resource path: %s", resourceFullName)));
}
if (!PropertyUtils.getResUploadStartupState()) {
logger.error("Storage does not start up, resource upload startup state: {}.",
PropertyUtils.getResUploadStartupState());
putMsg(result, Status.STORAGE_NOT_STARTUP);
return result;
}
if (resource.isDirectory() && storageOperate.returnStorageType().equals(ResUploadType.S3)
&& !resource.getFileName().equals(name)) {
logger.warn("Directory in S3 storage can not be renamed.");
putMsg(result, Status.S3_CANNOT_RENAME);
return result;
}
if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) {
logger.info("Resource does not need to be updated due to no change, resource full name:{}.",
resourceFullName);
putMsg(result, Status.SUCCESS);
return result;
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
String originFullName = resource.getFullName();
String originResourceName = resource.getAlias();
originFullName = originFullName.endsWith("/") ? StringUtils.chop(originFullName) : originFullName;
name = name.endsWith("/") ? StringUtils.chop(name) : name;
String fullName = String.format(FORMAT_SS,
originFullName.substring(0, originFullName.lastIndexOf(FOLDER_SEPARATOR) + 1), name);
if (!originResourceName.equals(name)) {
try {
if (checkResourceExists(fullName)) {
logger.error("resource {} already exists, can't recreate", fullName);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
} catch (Exception e) {
throw new ServiceException(String.format("error occurs while querying resource: %s", fullName));
}
}
result = verifyFile(name, type, file);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
Date now = new Date();
long originFileSize = resource.getSize();
resource.setAlias(name);
resource.setFileName(name);
resource.setFullName(fullName);
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
resource.setDescription(desc);
resource.setUpdateTime(now);
if (file != null) {
resource.setSize(file.getSize());
}
if (originResourceName.equals(name) && file == null) {
return result;
}
List<ResourcesTask> existResourcesList;
if (resource.isDirectory()) {
existResourcesList = resourceTaskMapper.selectSubfoldersFullNames(originFullName + FOLDER_SEPARATOR);
} else {
existResourcesList = resourceTaskMapper.selectByMap(
Collections.singletonMap("full_name", originFullName));
}
if (existResourcesList.size() > 0 && !fullName.equals(originFullName)) {
for (ResourcesTask existResource : existResourcesList) {
int taskId = existResource.getTaskId();
if (processService.isTaskOnline(taskDefinitionMapper.selectById(taskId).getCode())) {
logger.error("can't be updated,because it is used of process definition that's online");
logger.error("resource task relation id:{} is used of task code {}", existResource.getId(),
taskDefinitionMapper.selectById(taskId).getCode());
putMsg(result, Status.RESOURCE_IS_USED);
return result;
}
}
for (ResourcesTask existResource : existResourcesList) {
int taskId = existResource.getTaskId();
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
long taskCode = taskDefinitionMapper.selectById(taskId).getCode();
List<ProcessTaskRelation> processTaskRelation = processTaskRelationMapper.selectByMap(
Collections.singletonMap("post_task_code", taskCode));
if (processTaskRelation.size() > 0) {
long processDefinitionCode = processTaskRelation.get(0).getProcessDefinitionCode();
int processDefinitionVersion = processTaskRelation.get(0).getProcessDefinitionVersion();
List<ProcessTaskRelation> taskRelationList = processTaskRelationMapper.queryByProcessCode(
processTaskRelation.get(0).getProjectCode(),
processDefinitionCode);
List<TaskDefinition> taskDefinitionLogList = new ArrayList<>();
if (taskRelationList.size() > 0) {
ProcessDefinitionLog processDefinition =
processDefinitionLogMapper.queryByDefinitionCodeAndVersion(
processDefinitionCode, processDefinitionVersion);
for (ProcessTaskRelation taskRelation : taskRelationList) {
long taskCodeInProcess = taskRelation.getPostTaskCode();
TaskDefinition taskDefinition = taskDefinitionMapper.queryByCode(taskCodeInProcess);
if (taskCodeInProcess == taskCode) {
taskDefinition.setTaskParams(RemoveResourceFromResourceList(originFullName,
taskDefinition.getTaskParams(),
resource.isDirectory()));
taskDefinition.setTaskParams(AddResourceToResourceList(originFullName,
fullName,
existResource.getFullName(),
taskDefinition.getTaskParams(),
resource.isDirectory()));
|
closed
|
apache/dolphinscheduler
|
https://github.com/apache/dolphinscheduler
| 12,812 |
[Bug] [Api] Added param description
|
### 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
Added param description in function.
### What you expected to happen
Param description in function lost.
### How to reproduce
ResourceServiceImpl upload.
### 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/12812
|
https://github.com/apache/dolphinscheduler/pull/12813
|
23ead4f0e822e0726d586f8a0a4d0820da700fec
|
04c6b5e4131c87258e47cdcfb4d5b3f21f9e78e4
| 2022-11-08T05:46:42Z |
java
| 2022-11-08T13:17:40Z |
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
|
}
taskDefinitionLogList.add(taskDefinition);
}
if (processDefinition != null) {
processDefinitionService.updateProcessDefinition(loginUser,
processDefinition.getProjectCode(),
processDefinition.getName(),
processDefinition.getCode(),
processDefinition.getDescription(),
processDefinition.getGlobalParams(),
processDefinition.getLocations(),
processDefinition.getTimeout(),
tenantCode,
JSONUtils.toJsonString(taskRelationList.toArray()),
JSONUtils.toJsonString(taskDefinitionLogList.toArray()),
"",
processDefinition.getExecutionType());
}
}
}
}
}
if (file != null) {
if (!upload(loginUser, fullName, file, type)) {
logger.error("Storage operation error, resourceName:{}, originFileName:{}.",
name, RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.HDFS_OPERATION_ERROR);
throw new ServiceException(
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.