status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java | public static class TenantResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> {
private final TenantMapper tenantMapper;
public TenantResourceList(TenantMapper tenantMapper) {
this.tenantMapper = tenantMapper;
}
@Override
public List<AuthorizationType> authorizationTypes() {
return Collections.singletonList(AuthorizationType.TENANT);
}
@Override
public boolean permissionCheck(int userId, String url, Logger logger) {
return true;
}
@Override
public Set<Integer> listAuthorizedResource(int userId, Logger logger) {
return Collections.emptySet();
}
}
/**
* DataSource Resource
*/
@Component |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java | public static class DataSourceResourceList implements ResourceAcquisitionAndPermissionCheck<Integer> {
private final DataSourceMapper dataSourceMapper;
public DataSourceResourceList(DataSourceMapper dataSourceMapper) {
this.dataSourceMapper = dataSourceMapper;
}
@Override
public List<AuthorizationType> authorizationTypes() {
return Collections.singletonList(AuthorizationType.DATASOURCE);
}
@Override
public boolean permissionCheck(int userId, String url, Logger logger) {
return true;
}
@Override
public Set<Integer> listAuthorizedResource(int userId, Logger logger) {
return dataSourceMapper.listAuthorizedDataSource(userId, null).stream().map(DataSource::getId).collect(toSet());
}
}
/**
* DataAnalysis Resource
*/
@Component |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java | public static class DataAnalysisList implements ResourceAcquisitionAndPermissionCheck<Integer> {
private final CommandMapper commandMapper;
public DataAnalysisList(CommandMapper commandMapper) {
this.commandMapper = commandMapper;
}
@Override
public List<AuthorizationType> authorizationTypes() {
return Collections.singletonList(AuthorizationType.DATA_ANALYSIS);
}
@Override
public boolean permissionCheck(int userId, String url, Logger logger) {
return true;
}
@Override
public Set<Integer> listAuthorizedResource(int userId, Logger logger) {
return Collections.emptySet();
}
}
/**
* DataQuality Resource
*/
@Component |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java | public static class DataQualityList implements ResourceAcquisitionAndPermissionCheck<Integer> {
private final DqRuleMapper dqRuleMapper;
public DataQualityList(DqRuleMapper dqRuleMapper) {
this.dqRuleMapper = dqRuleMapper;
}
@Override
public List<AuthorizationType> authorizationTypes() {
return Collections.singletonList(AuthorizationType.DATA_QUALITY);
}
@Override
public boolean permissionCheck(int userId, String url, Logger logger) {
return true;
}
@Override
public Set<Integer> listAuthorizedResource(int userId, Logger logger) {
return Collections.emptySet();
}
}
/**
* AccessToken Resource
*/
@Component |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java | public static class AccessTokenList implements ResourceAcquisitionAndPermissionCheck<Integer> {
private final AccessTokenMapper accessTokenMapper;
public AccessTokenList(AccessTokenMapper accessTokenMapper) {
this.accessTokenMapper = accessTokenMapper;
}
@Override
public List<AuthorizationType> authorizationTypes() {
return Collections.singletonList(AuthorizationType.ACCESS_TOKEN);
}
@Override
public boolean permissionCheck(int userId, String url, Logger logger) {
return true;
}
@Override
public Set<Integer> listAuthorizedResource(int userId, Logger logger) {
return accessTokenMapper.listAuthorizedAccessToken(userId, null).stream().map(AccessToken::getId).collect(toSet());
}
}
interface ResourceAcquisitionAndPermissionCheck<T> { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java | /**
* authorization types
* @return
*/
List<AuthorizationType> authorizationTypes();
/**
* get all resources under the user (no admin)
*
* @param userId
* @return
*/
Set<T> listAuthorizedResource(int userId, Logger logger);
/**
* permission check
* @param userId
* @return
*/
boolean permissionCheck(int userId, String permissionKey, Logger logger);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.base.Joiner;
import com.google.common.io.Files;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.CollectionUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter;
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor;
import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.ResourcesService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.RegexUtils;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.ProgramType;
import org.apache.dolphinscheduler.common.enums.ResUploadType;
import org.apache.dolphinscheduler.common.storage.StorageOperate;
import org.apache.dolphinscheduler.common.utils.FileUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.ResourcesUser;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.rmi.ServerException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import static org.apache.dolphinscheduler.common.Constants.ALIAS;
import static org.apache.dolphinscheduler.common.Constants.CONTENT;
import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | import static org.apache.dolphinscheduler.common.Constants.FORMAT_SS;
import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S;
import static org.apache.dolphinscheduler.common.Constants.JAR;
/**
* resources service impl
*/
@Service
public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesService {
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceImpl.class);
@Autowired
private ResourceMapper resourcesMapper;
@Autowired
private UdfFuncMapper udfFunctionMapper;
@Autowired
private TenantMapper tenantMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private ResourceUserMapper resourceUserMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
@Autowired(required = false)
private StorageOperate storageOperate;
@Autowired
private ResourcePermissionCheckService resourcePermissionCheckService;
/**
* create directory
*
* @param loginUser login user
* @param name alias |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param description description
* @param type type
* @param pid parent id
* @param currentDir current directory
* @return create directory result
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> createDirectory(User loginUser,
String name,
String description,
ResourceType type,
int pid,
String currentDir) {
Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE : ApiFuncIdentificationConstant.UDF_FOLDER_ONLINE_CREATE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
if (FileUtils.directoryTraversal(name)) {
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
String fullName = getFullName(currentDir, name); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | result = verifyResource(loginUser, type, fullName, pid);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
if (checkResourceExists(fullName, type.ordinal())) {
logger.error("resource directory {} has exist, can't recreate", fullName);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
Date now = new Date();
Resource resource = new Resource(pid, name, fullName, true, description, name, loginUser.getId(), type, 0, now, now);
try {
resourcesMapper.insert(resource);
putMsg(result, Status.SUCCESS);
permissionPostHandle(resource.getType(), loginUser, resource.getId());
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (DuplicateKeyException e) {
logger.error("resource directory {} has exist, can't recreate", fullName);
putMsg(result, Status.RESOURCE_EXIST);
return result;
} catch (Exception e) {
logger.error("resource already exists, can't recreate ", e);
throw new ServiceException("resource already exists, can't recreate");
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | createDirectory(loginUser, fullName, type, result);
return result;
}
private String getFullName(String currentDir, String name) {
return currentDir.equals(FOLDER_SEPARATOR) ? String.format(FORMAT_SS, currentDir, name) : String.format(FORMAT_S_S, currentDir, name);
}
/**
* create resource
*
* @param loginUser login user
* @param name alias
* @param desc description
* @param file file
* @param type type
* @param pid parent id
* @param currentDir current directory
* @return create result code
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> createResource(User loginUser,
String name,
String desc,
ResourceType type,
MultipartFile file,
int pid,
String currentDir) {
Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPLOAD : ApiFuncIdentificationConstant.UDF_UPLOAD; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
result = verifyPid(loginUser, pid);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
String tenantCode = getTenantCode(loginUser.getId(), result);
if (StringUtils.isEmpty(tenantCode)) {
return result;
}
result = verifyFile(name, type, file);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
String fullName = getFullName(currentDir, name);
if (checkResourceExists(fullName, type.ordinal())) {
logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name));
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
if (fullName.length() > Constants.RESOURCE_FULL_NAME_MAX_LENGTH) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | logger.error("resource {}'s full name {}' is longer than the max length {}", RegexUtils.escapeNRT(name), fullName, Constants.RESOURCE_FULL_NAME_MAX_LENGTH);
putMsg(result, Status.RESOURCE_FULL_NAME_TOO_LONG_ERROR);
return result;
}
Date now = new Date();
Resource resource = new Resource(pid, name, fullName, false, desc, file.getOriginalFilename(), loginUser.getId(), type, file.getSize(), now, now);
try {
resourcesMapper.insert(resource);
updateParentResourceSize(resource, resource.getSize());
putMsg(result, Status.SUCCESS);
permissionPostHandle(resource.getType(), loginUser, resource.getId());
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (Exception e) {
logger.error("resource already exists, can't recreate ", e);
throw new ServiceException("resource already exists, can't recreate");
}
if (!upload(loginUser, fullName, file, type)) {
logger.error("upload resource: {} file: {} failed.", RegexUtils.escapeNRT(name), RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | /**
* update the folder's size of the resource
*
* @param resource the current resource
* @param size size
*/
private void updateParentResourceSize(Resource resource, long size) {
if (resource.getSize() > 0) {
String[] splits = resource.getFullName().split("/");
for (int i = 1; i < splits.length; i++) {
String parentFullName = Joiner.on("/").join(Arrays.copyOfRange(splits, 0, i));
if (StringUtils.isNotBlank(parentFullName)) {
List<Resource> resources = resourcesMapper.queryResource(parentFullName, resource.getType().ordinal());
if (CollectionUtils.isNotEmpty(resources)) {
Resource parentResource = resources.get(0);
if (parentResource.getSize() + size >= 0) {
parentResource.setSize(parentResource.getSize() + size);
} else {
parentResource.setSize(0L);
}
resourcesMapper.updateById(parentResource);
}
}
}
}
}
/**
* check resource is exists
*
* @param fullName fullName |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param type type
* @return true if resource exists
*/
private boolean checkResourceExists(String fullName, int type) {
Boolean existResource = resourcesMapper.existResource(fullName, type);
return Boolean.TRUE.equals(existResource);
}
/**
* update resource
*
* @param loginUser login user
* @param resourceId resource id
* @param name name
* @param desc description
* @param type resource type
* @param file resource file
* @return update result code
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> updateResource(User loginUser,
int resourceId,
String name,
String desc,
ResourceType type,
MultipartFile file) {
Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(type), funcPermissionKey);
if (!canOperatorPermissions){ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
if (!PropertyUtils.getResUploadStartupState()){
putMsg(result, Status.STORAGE_NOT_STARTUP);
return result;
}
if (resource.isDirectory() && storageOperate.returnStorageType().equals(ResUploadType.S3) && !resource.getFileName().equals(name)) {
putMsg(result, Status.S3_CANNOT_RENAME);
return result;
}
if (!canOperator(loginUser, resource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) {
putMsg(result, Status.SUCCESS);
return result;
}
String originFullName = resource.getFullName(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | String originResourceName = resource.getAlias();
String fullName = String.format(FORMAT_SS, originFullName.substring(0, originFullName.lastIndexOf(FOLDER_SEPARATOR) + 1), name);
if (!originResourceName.equals(name) && checkResourceExists(fullName, type.ordinal())) {
logger.error("resource {} already exists, can't recreate", name);
putMsg(result, Status.RESOURCE_EXIST);
return result;
}
result = verifyFile(name, type, file);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
String tenantCode = getTenantCode(resource.getUserId(), result);
if (StringUtils.isEmpty(tenantCode)) {
return result;
}
String originFileName = storageOperate.getFileName(resource.getType(), tenantCode, originFullName);
try {
if (!storageOperate.exists(tenantCode, originFileName)) {
logger.error("{} not exist", originFileName);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new ServiceException(Status.HDFS_OPERATION_ERROR);
}
if (!resource.isDirectory()) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | String originSuffix = Files.getFileExtension(originFullName);
String suffix = Files.getFileExtension(fullName);
boolean suffixIsChanged = false;
if (StringUtils.isBlank(suffix) && StringUtils.isNotBlank(originSuffix)) {
suffixIsChanged = true;
}
if (StringUtils.isNotBlank(suffix) && !suffix.equals(originSuffix)) {
suffixIsChanged = true;
}
if (suffixIsChanged) {
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("resources_id", resourceId);
List<ResourcesUser> resourcesUsers = resourceUserMapper.selectByMap(columnMap);
if (CollectionUtils.isNotEmpty(resourcesUsers)) {
List<Integer> userIds = resourcesUsers.stream().map(ResourcesUser::getUserId).collect(Collectors.toList());
List<User> users = userMapper.selectBatchIds(userIds);
String userNames = users.stream().map(User::getUserName).collect(Collectors.toList()).toString();
logger.error("resource is authorized to user {},suffix not allowed to be modified", userNames);
putMsg(result, Status.RESOURCE_IS_AUTHORIZED, userNames);
return result;
}
}
}
Date now = new Date();
long originFileSize = resource.getSize();
resource.setAlias(name); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | resource.setFileName(name);
resource.setFullName(fullName);
resource.setDescription(desc);
resource.setUpdateTime(now);
if (file != null) {
resource.setSize(file.getSize());
}
try {
resourcesMapper.updateById(resource);
if (resource.isDirectory()) {
List<Integer> childrenResource = listAllChildren(resource, false);
if (CollectionUtils.isNotEmpty(childrenResource)) {
String matcherFullName = Matcher.quoteReplacement(fullName);
List<Resource> childResourceList;
Integer[] childResIdArray = childrenResource.toArray(new Integer[childrenResource.size()]);
List<Resource> resourceList = resourcesMapper.listResourceByIds(childResIdArray);
childResourceList = resourceList.stream().map(t -> {
t.setFullName(t.getFullName().replaceFirst(originFullName, matcherFullName));
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
resourcesMapper.batchUpdateResource(childResourceList);
if (ResourceType.UDF.equals(resource.getType())) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(childResIdArray);
if (CollectionUtils.isNotEmpty(udfFuncs)) {
udfFuncs = udfFuncs.stream().map(t -> {
t.setResourceName(t.getResourceName().replaceFirst(originFullName, matcherFullName));
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | udfFunctionMapper.batchUpdateUdfFunc(udfFuncs);
}
}
}
} else if (ResourceType.UDF.equals(resource.getType())) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(new Integer[]{resourceId});
if (CollectionUtils.isNotEmpty(udfFuncs)) {
udfFuncs = udfFuncs.stream().map(t -> {
t.setResourceName(fullName);
t.setUpdateTime(now);
return t;
}).collect(Collectors.toList());
udfFunctionMapper.batchUpdateUdfFunc(udfFuncs);
}
}
putMsg(result, Status.SUCCESS);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
} catch (Exception e) {
logger.error(Status.UPDATE_RESOURCE_ERROR.getMsg(), e);
throw new ServiceException(Status.UPDATE_RESOURCE_ERROR);
}
if (originResourceName.equals(name) && file == null) {
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
if (file != null) {
if (!upload(loginUser, fullName, file, type)) {
logger.error("upload resource: {} file: {} failed.", name, RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.HDFS_OPERATION_ERROR);
throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename()));
}
if (!fullName.equals(originFullName)) {
try {
storageOperate.delete(tenantCode, originFileName, false);
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new ServiceException(String.format("delete resource: %s failed.", originFullName));
}
}
updateParentResourceSize(resource, resource.getSize() - originFileSize);
return result;
}
String destHdfsFileName = storageOperate.getFileName(resource.getType(), tenantCode, fullName);
try {
logger.info("start copy {} -> {}", originFileName, destHdfsFileName);
storageOperate.copy(originFileName, destHdfsFileName, true, true);
} catch (Exception e) {
logger.error(MessageFormat.format(" copy {0} -> {1} fail", originFileName, destHdfsFileName), e);
putMsg(result, Status.HDFS_COPY_FAIL);
throw new ServiceException(Status.HDFS_COPY_FAIL);
}
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
private Result<Object> verifyFile(String name, ResourceType type, MultipartFile file) {
Result<Object> result = new Result<>();
putMsg(result, Status.SUCCESS);
if (FileUtils.directoryTraversal(name)) {
logger.error("file alias name {} verify failed", name);
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
if (file != null && FileUtils.directoryTraversal(Objects.requireNonNull(file.getOriginalFilename()))) {
logger.error("file original name {} verify failed", file.getOriginalFilename());
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
if (file != null) {
if (file.isEmpty()) {
logger.error("file is empty: {}", RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.RESOURCE_FILE_IS_EMPTY);
return result;
}
String fileSuffix = Files.getFileExtension(file.getOriginalFilename());
String nameSuffix = Files.getFileExtension(name);
if (!fileSuffix.equalsIgnoreCase(nameSuffix)) {
logger.error("rename file suffix and original suffix must be consistent: {}", RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE);
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) {
logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg());
putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR);
return result;
}
if (file.getSize() > Constants.MAX_FILE_SIZE) {
logger.error("file size is too large: {}", RegexUtils.escapeNRT(file.getOriginalFilename()));
putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT);
return result;
}
}
return result;
}
/**
* query resources list paging
*
* @param loginUser login user
* @param type resource type
* @param searchVal search value
* @param pageNo page number
* @param pageSize page size
* @return resource list page
*/
@Override
public Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) {
Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
Page<Resource> page = new Page<>(pageNo, pageSize);
if (directoryId != -1) {
Resource directory = resourcesMapper.selectById(directoryId);
if (directory == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
}
PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize);
Set<Integer> resourcesIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger);
if (resourcesIds.isEmpty()) {
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, directoryId, type.ordinal(), searchVal, new ArrayList<>(resourcesIds));
pageInfo.setTotal((int) resourceIPage.getTotal());
pageInfo.setTotalList(resourceIPage.getRecords());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* create directory
* xxx The steps to verify resources are cumbersome and can be optimized
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param loginUser login user
* @param fullName full name
* @param type resource type
* @param result Result
*/
private void createDirectory(User loginUser, String fullName, ResourceType type, Result<Object> result) {
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
String directoryName = storageOperate.getFileName(type, tenantCode, fullName);
String resourceRootPath = storageOperate.getDir(type, tenantCode);
try {
if (!storageOperate.exists(tenantCode, resourceRootPath)) {
storageOperate.createTenantDirIfNotExists(tenantCode);
}
if (!storageOperate.mkdir(tenantCode, directoryName)) {
logger.error("create resource directory {} failed", directoryName);
putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
throw new ServiceException(String.format("create resource directory: %s failed.", directoryName));
}
} catch (Exception e) {
logger.error("create resource directory {} failed", directoryName);
putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
throw new ServiceException(String.format("create resource directory: %s failed.", directoryName));
}
}
/**
* upload file to hdfs
*
* @param loginUser login user
* @param fullName full name
* @param file file |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | */
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;
}
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString());
String fileName = storageOperate.getFileName(type, tenantCode, fullName);
String resourcePath = storageOperate.getDir(type, tenantCode);
try {
if (!storageOperate.exists(tenantCode, resourcePath)) {
storageOperate.createTenantDirIfNotExists(tenantCode);
}
org.apache.dolphinscheduler.api.utils.FileUtils.copyInputStreamToFile(file, localFilename);
storageOperate.upload(tenantCode, localFilename, fileName, true, true);
} catch (Exception e) {
FileUtils.deleteFile(localFilename);
logger.error(e.getMessage(), e);
return false;
}
return true;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | /**
* query resource list
*
* @param loginUser login user
* @param type resource type
* @return resource list
*/
@Override
public Map<String, Object> queryResourceList(User loginUser, ResourceType type) {
Map<String, Object> result = new HashMap<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type);
Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList);
result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren());
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query resource list by program type
*
* @param loginUser login user
* @param type resource type
* @return resource list
*/
@Override |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | 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<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
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();
Visitor resourceTreeVisitor = new ResourceTreeVisitor(resources);
result.setData(resourceTreeVisitor.visit().getChildren()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | putMsg(result, Status.SUCCESS);
return result;
}
/**
* delete resource
*
* @param loginUser login user
* @param resourceId resource id
* @return delete result code
* @throws IOException exception
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> delete(User loginUser, int resourceId) throws IOException {
Result<Object> resultCheck = new Result<>();
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
putMsg(resultCheck, Status.RESOURCE_NOT_EXIST);
return resultCheck;
}
String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DELETE : ApiFuncIdentificationConstant.UDF_DELETE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(resultCheck, Status.NO_CURRENT_OPERATING_PERMISSION);
return resultCheck;
}
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
if (!canOperator(loginUser, resource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
String tenantCode = getTenantCode(resource.getUserId(), result);
if (StringUtils.isEmpty(tenantCode)) {
return result;
}
List<Map<String, Object>> list = processDefinitionMapper.listResources();
Map<Integer, Set<Long>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list);
Set<Integer> resourceIdSet = resourceProcessMap.keySet();
List<Integer> allChildren = listAllChildren(resource, true);
Integer[] needDeleteResourceIdArray = allChildren.toArray(new Integer[allChildren.size()]);
if (resource.getType() == (ResourceType.UDF)) {
List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(needDeleteResourceIdArray);
if (CollectionUtils.isNotEmpty(udfFuncs)) {
logger.error("can't be deleted,because it is bound by UDF functions:{}", udfFuncs);
putMsg(result, Status.UDF_RESOURCE_IS_BOUND, udfFuncs.get(0).getFuncName());
return result;
}
}
if (resourceIdSet.contains(resource.getPid())) {
logger.error("can't be deleted,because it is used of process definition");
putMsg(result, Status.RESOURCE_IS_USED);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | resourceIdSet.retainAll(allChildren);
if (CollectionUtils.isNotEmpty(resourceIdSet)) {
logger.error("can't be deleted,because it is used of process definition");
for (Integer resId : resourceIdSet) {
logger.error("resource id:{} is used of process definition {}",resId,resourceProcessMap.get(resId));
}
putMsg(result, Status.RESOURCE_IS_USED);
return result;
}
String storageFilename = storageOperate.getFileName(resource.getType(), tenantCode, resource.getFullName());
resourcesMapper.selectBatchIds(Arrays.asList(needDeleteResourceIdArray)).forEach(item -> {
updateParentResourceSize(item, item.getSize() * -1);
});
resourcesMapper.deleteIds(needDeleteResourceIdArray);
resourceUserMapper.deleteResourceUserArray(0, needDeleteResourceIdArray);
storageOperate.delete(tenantCode, storageFilename, true);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* 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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | */
@Override
public Result<Object> verifyResourceName(String fullName, ResourceType type, User loginUser) {
Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_RENAME : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
putMsg(result, Status.SUCCESS);
if (checkResourceExists(fullName, type.ordinal())) {
logger.error("resource type:{} name:{} has exist, can't create again.", type, RegexUtils.escapeNRT(fullName));
putMsg(result, Status.RESOURCE_EXIST);
} else {
Tenant tenant = tenantMapper.queryById(loginUser.getTenantId());
if (tenant != null) {
String tenantCode = tenant.getTenantCode();
try {
String filename = storageOperate.getFileName(type, tenantCode, fullName);
if (storageOperate.exists(tenantCode, filename)) {
putMsg(result, Status.RESOURCE_FILE_EXIST, filename);
}
} catch (Exception e) {
logger.error("verify resource failed and the reason is {}", e.getMessage());
putMsg(result, Status.STORE_OPERATE_CREATE_ERROR);
}
} else {
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
}
return result;
}
/**
* verify resource by full name or pid and type
*
* @param fullName resource full name
* @param id resource id
* @param type resource type
* @return true if the resource full name or pid not exists, otherwise return false
*/
@Override
public Result<Object> queryResource(User loginUser, String fullName, Integer id, ResourceType type) {
Result<Object> result = new Result<>();
if (StringUtils.isBlank(fullName) && id == null) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR);
return result;
}
Resource resource;
if (StringUtils.isNotBlank(fullName)) {
List<Resource> resourceList = resourcesMapper.queryResource(fullName, type.ordinal());
if (CollectionUtils.isEmpty(resourceList)) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
resource = resourceList.get(0);
} else {
resource = resourcesMapper.selectById(id);
if (resource == null) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
resource = resourcesMapper.selectById(resource.getPid());
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
}
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resource.getId()}, checkResourceType(type), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
putMsg(result, Status.SUCCESS);
result.setData(resource);
return result;
}
/**
* get resource by id
* @param id resource id
* @return resource
*/
@Override
public Result<Object> queryResourceById(User loginUser, Integer id) {
Result<Object> result = new Result<>();
Resource resource = resourcesMapper.selectById(id);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | return result;
}
String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{id}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
putMsg(result, Status.SUCCESS);
result.setData(resource);
return result;
}
/**
* view resource file online
*
* @param resourceId resource id
* @param skipLineNum skip line number
* @param limit limit
* @return resource content
*/
@Override
public Result<Object> readResource(User loginUser, int resourceId, int skipLineNum, int limit) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | return result;
}
String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
String nameSuffix = Files.getFileExtension(resource.getAlias());
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes();
if (StringUtils.isNotEmpty(resourceViewSuffixes)) {
List<String> strList = Arrays.asList(resourceViewSuffixes.split(","));
if (!strList.contains(nameSuffix)) {
logger.error("resource suffix {} not support view, resource id {}", nameSuffix, resourceId);
putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW);
return result;
}
}
String tenantCode = getTenantCode(resource.getUserId(), result);
if (StringUtils.isEmpty(tenantCode)) {
return result;
}
String resourceFileName = storageOperate.getResourceFileName(tenantCode, resource.getFullName());
logger.info("resource path is {}", resourceFileName);
try {
if (storageOperate.exists(tenantCode, resourceFileName)) {
List<String> content = storageOperate.vimFile(tenantCode, resourceFileName, skipLineNum, limit);
putMsg(result, Status.SUCCESS); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | Map<String, Object> map = new HashMap<>();
map.put(ALIAS, resource.getAlias());
map.put(CONTENT, String.join("\n", content));
result.setData(map);
} else {
logger.error("read file {} not exist in storage", resourceFileName);
putMsg(result, Status.RESOURCE_FILE_NOT_EXIST, resourceFileName);
}
} catch (Exception e) {
logger.error("Resource {} read failed", resourceFileName, e);
putMsg(result, Status.HDFS_OPERATION_ERROR);
}
return result;
}
/**
* create resource file online
*
* @param loginUser login user
* @param type resource type
* @param fileName file name
* @param fileSuffix file suffix
* @param desc description
* @param content content
* @param pid pid
* @param currentDir current directory
* @return create result code
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content, int pid, String currentDir) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | Result<Object> result = new Result<>();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
if (FileUtils.directoryTraversal(fileName)) {
putMsg(result, Status.VERIFY_PARAMETER_NAME_FAILED);
return result;
}
String nameSuffix = fileSuffix.trim();
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes();
if (StringUtils.isNotEmpty(resourceViewSuffixes)) {
List<String> strList = Arrays.asList(resourceViewSuffixes.split(","));
if (!strList.contains(nameSuffix)) {
logger.error("resource suffix {} not support create", nameSuffix);
putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW);
return result;
}
}
String name = fileName.trim() + "." + nameSuffix;
String fullName = getFullName(currentDir, name);
result = verifyResource(loginUser, type, fullName, pid);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
Date now = new Date();
Resource resource = new Resource(pid, name, fullName, false, desc, name, loginUser.getId(), type, content.getBytes().length, now, now);
resourcesMapper.insert(resource);
updateParentResourceSize(resource, resource.getSize());
putMsg(result, Status.SUCCESS);
permissionPostHandle(resource.getType(), loginUser, resource.getId());
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {
resultMap.put(entry.getKey().toString(), entry.getValue());
}
}
result.setData(resultMap);
String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode();
result = uploadContentToStorage(loginUser, fullName, tenantCode, content);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
throw new ServiceException(result.getMsg());
}
return result;
}
private void permissionPostHandle(ResourceType resourceType, User loginUser, Integer resourceId) {
AuthorizationType authorizationType = resourceType.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID : AuthorizationType.UDF_FILE;
permissionPostHandle(authorizationType, loginUser.getId(), Collections.singletonList(resourceId), logger);
}
private Result<Object> checkResourceUploadStartupState() {
Result<Object> result = new Result<>();
putMsg(result, Status.SUCCESS); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | if (!PropertyUtils.getResUploadStartupState()) {
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.STORAGE_NOT_STARTUP);
return result;
}
return result;
}
private Result<Object> verifyResource(User loginUser, ResourceType type, String fullName, int pid) {
Result<Object> result = verifyResourceName(fullName, type, loginUser);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
return verifyPid(loginUser, pid);
}
private Result<Object> verifyPid(User loginUser, int pid) {
Result<Object> result = new Result<>();
putMsg(result, Status.SUCCESS);
if (pid != -1) {
Resource parentResource = resourcesMapper.selectById(pid);
if (parentResource == null) {
putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST);
return result;
}
if (!canOperator(loginUser, parentResource.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
}
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | /**
* updateProcessInstance resource
*
* @param resourceId resource id
* @param content content
* @return update result cod
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Object> updateResourceContent(User loginUser, int resourceId, String content) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
return result;
}
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
logger.error("read file not exist, resource id {}", resourceId);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
String nameSuffix = Files.getFileExtension(resource.getAlias());
String resourceViewSuffixes = FileUtils.getResourceViewSuffixes();
if (StringUtils.isNotEmpty(resourceViewSuffixes)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | List<String> strList = Arrays.asList(resourceViewSuffixes.split(","));
if (!strList.contains(nameSuffix)) {
logger.error("resource suffix {} not support updateProcessInstance, resource id {}", nameSuffix, resourceId);
putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW);
return result;
}
}
String tenantCode = getTenantCode(resource.getUserId(), result);
if (StringUtils.isEmpty(tenantCode)) {
return result;
}
long originFileSize = resource.getSize();
resource.setSize(content.getBytes().length);
resource.setUpdateTime(new Date());
resourcesMapper.updateById(resource);
result = uploadContentToStorage(loginUser, resource.getFullName(), tenantCode, content);
updateParentResourceSize(resource, resource.getSize() - originFileSize);
if (!result.getCode().equals(Status.SUCCESS.getCode())) {
throw new ServiceException(result.getMsg());
}
return result;
}
/**
* @param resourceName resource name
* @param tenantCode tenant code
* @param content content
* @return result
*/
private Result<Object> uploadContentToStorage(User loginUser,String resourceName, String tenantCode, String content) {
Result<Object> result = new Result<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | String localFilename = "";
String storageFileName = "";
try {
localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString());
if (!FileUtils.writeContent2File(content, localFilename)) {
logger.error("file {} fail, content is {}", localFilename, RegexUtils.escapeNRT(content));
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
storageFileName = storageOperate.getResourceFileName(tenantCode, resourceName);
String resourcePath = storageOperate.getResDir(tenantCode);
logger.info("resource path is {}, resource dir is {}", storageFileName, resourcePath);
if (!storageOperate.exists(tenantCode, resourcePath)) {
storageOperate.createTenantDirIfNotExists(tenantCode);
}
if (storageOperate.exists(tenantCode, storageFileName)) {
storageOperate.delete(tenantCode, storageFileName, false);
}
storageOperate.upload(tenantCode, localFilename, storageFileName, true, true);
} catch (Exception e) {
logger.error(e.getMessage(), e);
result.setCode(Status.HDFS_OPERATION_ERROR.getCode());
result.setMsg(String.format("copy %s to hdfs %s fail", localFilename, storageFileName));
return result;
}
putMsg(result, Status.SUCCESS);
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | }
/**
* download file
*
* @param resourceId resource id
* @return resource content
* @throws IOException exception
*/
@Override
public org.springframework.core.io.Resource downloadResource(User loginUser, int resourceId) throws IOException {
if (!PropertyUtils.getResUploadStartupState()) {
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
throw new ServiceException("hdfs not startup");
}
Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) {
logger.error("download file not exist, resource id {}", resourceId);
return null;
}
String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DOWNLOAD : ApiFuncIdentificationConstant.UDF_DOWNLOAD;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){
logger.error("{}: {}", Status.NO_CURRENT_OPERATING_PERMISSION.getMsg(), PropertyUtils.getResUploadStartupState());
throw new ServiceException(Status.NO_CURRENT_OPERATING_PERMISSION.getMsg());
}
if (resource.isDirectory()) {
logger.error("resource id {} is directory,can't download it", resourceId);
throw new ServiceException("can't download directory");
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | int userId = resource.getUserId();
User user = userMapper.selectById(userId);
if (user == null) {
logger.error("user id {} not exists", userId);
throw new ServiceException(String.format("resource owner id %d not exist", userId));
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant id {} not exists", user.getTenantId());
throw new ServiceException(String.format("The tenant id %d of resource owner not exist", user.getTenantId()));
}
String tenantCode = tenant.getTenantCode();
String fileName = storageOperate.getFileName(resource.getType(), tenantCode, resource.getFullName());
String localFileName = FileUtils.getDownloadFilename(resource.getAlias());
logger.info("resource path is {}, download local filename is {}", fileName, localFileName);
try {
storageOperate.download(tenantCode, fileName, localFileName, false, true);
return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName);
} catch (IOException e) {
logger.error("download resource error, the path is {}, and local filename is {}, the error message is {}", fileName, localFileName, e.getMessage());
throw new ServerException("download the resource file failed ,it may be related to your storage");
}
}
/**
* list all file
*
* @param loginUser login user
* @param userId user id
* @return unauthorized result code
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | @Override
public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()){
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
List<Resource> resourceList;
if (isAdmin(loginUser)) {
resourceList = resourcesMapper.queryResourceExceptUserId(userId);
} else {
resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1);
}
List<ResourceComponent> list;
if (CollectionUtils.isNotEmpty(resourceList)) {
Visitor visitor = new ResourceTreeVisitor(resourceList);
list = visitor.visit().getChildren();
} else {
list = new ArrayList<>(0);
}
result.put(Constants.DATA_LIST, list);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* unauthorized file
*
* @param loginUser login user |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | * @param userId user id
* @return unauthorized result code
*/
@Override
public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
List<Resource> resourceList;
if (isAdmin(loginUser)) {
resourceList = resourcesMapper.queryResourceExceptUserId(userId);
} else {
resourceList = resourcesMapper.queryResourceListAuthored(loginUser.getId(), -1);
}
List<Resource> list;
if (resourceList != null && !resourceList.isEmpty()) {
Set<Resource> resourceSet = new HashSet<>(resourceList);
List<Resource> authedResourceList = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM);
getAuthorizedResourceList(resourceSet, authedResourceList);
list = new ArrayList<>(resourceSet);
} else {
list = new ArrayList<>(0);
}
Visitor visitor = new ResourceTreeVisitor(list);
result.put(Constants.DATA_LIST, visitor.visit().getChildren());
putMsg(result, Status.SUCCESS);
return result;
}
/**
* unauthorized udf function |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | *
* @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);
}
result.put(Constants.DATA_LIST, resultList);
putMsg(result, Status.SUCCESS); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | 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
*/
@Override
public Map<String, Object> authorizedFile(User loginUser, Integer userId) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()){
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
List<Resource> authedResources = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM);
Visitor visitor = new ResourceTreeVisitor(authedResources);
String visit = JSONUtils.toJsonString(visitor.visit(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
logger.info(visit);
String jsonTreeStr = JSONUtils.toJsonString(visitor.visit().getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
logger.info(jsonTreeStr);
result.put(Constants.DATA_LIST, visitor.visit().getChildren());
putMsg(result, Status.SUCCESS);
return result;
}
/**
* get authorized resource list
*
* @param resourceSet resource set
* @param authedResourceList authorized resource list
*/
private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) {
Set<?> authedResourceSet;
if (CollectionUtils.isNotEmpty(authedResourceList)) {
authedResourceSet = new HashSet<>(authedResourceList);
resourceSet.removeAll(authedResourceSet);
}
}
/**
* get tenantCode by UserId |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | *
* @param userId user id
* @param result return result
* @return tenant code
*/
private String getTenantCode(int userId, Result<Object> result) {
User user = userMapper.selectById(userId);
if (user == null) {
logger.error("user {} not exists", userId);
putMsg(result, Status.USER_NOT_EXIST, userId);
return null;
}
Tenant tenant = tenantMapper.queryById(user.getTenantId());
if (tenant == null) {
logger.error("tenant not exists");
putMsg(result, Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST);
return null;
}
return tenant.getTenantCode();
}
/**
* list all children id
*
* @param resource resource
* @param containSelf whether add self to children list
* @return all children id
*/
List<Integer> listAllChildren(Resource resource, boolean containSelf) {
List<Integer> childList = new ArrayList<>();
if (resource.getId() != -1 && containSelf) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | childList.add(resource.getId());
}
if (resource.isDirectory()) {
listAllChildren(resource.getId(), childList);
}
return childList;
}
/**
* list all children id
*
* @param resourceId resource id
* @param childList child list
*/
void listAllChildren(int resourceId, List<Integer> childList) {
List<Integer> children = resourcesMapper.listChildren(resourceId);
for (int childId : children) {
childList.add(childId);
listAllChildren(childId, childList);
}
}
/**
* query authored resource list (own and authorized)
*
* @param loginUser login user
* @param type ResourceType
* @return all authored resource list
*/
private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) {
List<Resource> relationResources;
int userId = loginUser.getId(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java | if (isAdmin(loginUser)) {
userId = 0;
relationResources = new ArrayList<>();
} else {
relationResources = queryResourceList(userId, 0);
}
List<Resource> relationTypeResources =
relationResources.stream().filter(rs -> rs.getType() == type).collect(Collectors.toList());
List<Resource> ownResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal());
ownResourceList.addAll(relationTypeResources);
return ownResourceList;
}
/**
* query resource list by userId and perm
*
* @param userId userId
* @param perm perm
* @return resource list
*/
private List<Resource> queryResourceList(Integer userId, int perm) {
List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, perm);
return CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourcesMapper.queryResourceListById(resIds);
}
private AuthorizationType checkResourceType(ResourceType type) {
return type.equals(ResourceType.FILE) ? AuthorizationType.RESOURCE_FILE_ID : AuthorizationType.UDF_FILE;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.UdfFuncService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.UdfType;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* udf func service impl
*/
@Service |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | public class UdfFuncServiceImpl extends BaseServiceImpl implements UdfFuncService {
private static final Logger logger = LoggerFactory.getLogger(UdfFuncServiceImpl.class);
@Autowired
private ResourceMapper resourceMapper;
@Autowired
private UdfFuncMapper udfFuncMapper;
@Autowired
private UDFUserMapper udfUserMapper;
/**
* create udf function
*
* @param loginUser login user
* @param type udf type
* @param funcName function name
* @param argTypes argument types
* @param database database
* @param desc description
* @param resourceId resource id
* @param className class name
* @return create result code
*/
@Override
public Result<Object> createUdfFunction(User loginUser, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | String funcName,
String className,
String argTypes,
String database,
String desc,
UdfType type,
int resourceId) {
Result<Object> result = new Result<>();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.UDF, ApiFuncIdentificationConstant.UDF_FUNCTION_CREATE);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
if (!PropertyUtils.getResUploadStartupState()) {
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
return result;
}
if (checkUdfFuncNameExists(funcName)) {
putMsg(result, Status.UDF_FUNCTION_EXISTS);
return result;
}
Resource resource = resourceMapper.selectById(resourceId);
if (resource == null) {
logger.error("resourceId {} is not exist", resourceId);
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | UdfFunc udf = new UdfFunc();
Date now = new Date();
udf.setUserId(loginUser.getId());
udf.setFuncName(funcName);
udf.setClassName(className);
if (!StringUtils.isEmpty(argTypes)) {
udf.setArgTypes(argTypes);
}
if (!StringUtils.isEmpty(database)) {
udf.setDatabase(database);
}
udf.setDescription(desc);
udf.setResourceId(resourceId);
udf.setResourceName(resource.getFullName());
udf.setType(type);
udf.setCreateTime(now);
udf.setUpdateTime(now);
udfFuncMapper.insert(udf);
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.UDF, loginUser.getId(), Collections.singletonList(udf.getId()), logger);
return result;
}
/**
*
* @param name name
* @return check result code
*/
private boolean checkUdfFuncNameExists(String name) {
List<UdfFunc> resource = udfFuncMapper.queryUdfByIdStr(null, name); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | return resource != null && !resource.isEmpty();
}
/**
* query udf function
*
* @param id udf function id
* @return udf function detail
*/
@Override
public Result<Object> queryUdfFuncDetail(User loginUser, int id) {
Result<Object> result = new Result<>();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{id}, AuthorizationType.UDF, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
UdfFunc udfFunc = udfFuncMapper.selectById(id);
if (udfFunc == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
result.setData(udfFunc);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* updateProcessInstance udf function
*
* @param udfFuncId udf function id
* @param type resource type |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | * @param funcName function name
* @param argTypes argument types
* @param database data base
* @param desc description
* @param resourceId resource id
* @param className class name
* @return update result code
*/
@Override
public Result<Object> updateUdfFunc(User loginUser,
int udfFuncId,
String funcName,
String className,
String argTypes,
String database,
String desc,
UdfType type,
int resourceId) {
Result<Object> result = new Result<>();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, AuthorizationType.UDF, ApiFuncIdentificationConstant.UDF_FUNCTION_UPDATE);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
UdfFunc udf = udfFuncMapper.selectUdfById(udfFuncId);
if (udf == null) {
result.setCode(Status.UDF_FUNCTION_NOT_EXIST.getCode());
result.setMsg(Status.UDF_FUNCTION_NOT_EXIST.getMsg());
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | }
if (!PropertyUtils.getResUploadStartupState()) {
logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState());
putMsg(result, Status.HDFS_NOT_STARTUP);
return result;
}
if (!funcName.equals(udf.getFuncName())) {
if (checkUdfFuncNameExists(funcName)) {
logger.error("UdfFuncRequest {} has exist, can't create again.", funcName);
result.setCode(Status.UDF_FUNCTION_EXISTS.getCode());
result.setMsg(Status.UDF_FUNCTION_EXISTS.getMsg());
return result;
}
}
Resource resource = resourceMapper.selectById(resourceId);
if (resource == null) {
logger.error("resourceId {} is not exist", resourceId);
result.setCode(Status.RESOURCE_NOT_EXIST.getCode());
result.setMsg(Status.RESOURCE_NOT_EXIST.getMsg());
return result;
}
Date now = new Date();
udf.setFuncName(funcName);
udf.setClassName(className);
udf.setArgTypes(argTypes);
if (!StringUtils.isEmpty(database)) {
udf.setDatabase(database);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | udf.setDescription(desc);
udf.setResourceId(resourceId);
udf.setResourceName(resource.getFullName());
udf.setType(type);
udf.setUpdateTime(now);
udfFuncMapper.updateById(udf);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query udf function list paging
*
* @param loginUser login user
* @param pageNo page number
* @param pageSize page size
* @param searchVal search value
* @return udf function list page
*/
@Override
public Result<Object> queryUdfFuncListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Result<Object> result = new Result();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.UDF, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
PageInfo<UdfFunc> pageInfo = new PageInfo<>(pageNo, pageSize);
IPage<UdfFunc> udfFuncList = getUdfFuncsPage(loginUser, searchVal, pageSize, pageNo);
pageInfo.setTotal((int)udfFuncList.getTotal());
pageInfo.setTotalList(udfFuncList.getRecords()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* get udf functions
*
* @param loginUser login user
* @param searchVal search value
* @param pageSize page size
* @param pageNo page number
* @return udf function list page
*/
private IPage<UdfFunc> getUdfFuncsPage(User loginUser, String searchVal, Integer pageSize, int pageNo) {
Set<Integer> udfFuncIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.UDF, loginUser.getId(), logger);
Page<UdfFunc> page = new Page<>(pageNo, pageSize);
if (udfFuncIds.isEmpty()) {
return page;
}
return udfFuncMapper.queryUdfFuncPaging(page, new ArrayList<>(udfFuncIds), searchVal);
}
/**
* query udf list
*
* @param loginUser login user
* @param type udf type
* @return udf func list
*/
@Override
public Result<Object> queryUdfFuncList(User loginUser, Integer type) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | Result<Object> result = new Result<>();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.UDF, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
Set<Integer> udfFuncIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.UDF, loginUser.getId(), logger);
if (udfFuncIds.isEmpty()){
result.setData(Collections.emptyList());
putMsg(result, Status.SUCCESS);
return result;
}
List<UdfFunc> udfFuncList = udfFuncMapper.getUdfFuncByType(new ArrayList<>(udfFuncIds), type);
result.setData(udfFuncList);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* delete udf function
*
* @param id udf function id
* @return delete result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Result<Object> delete(User loginUser, int id) {
Result<Object> result = new Result<>();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{id}, AuthorizationType.UDF, ApiFuncIdentificationConstant.UDF_FUNCTION_DELETE);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java | return result;
}
udfFuncMapper.deleteById(id);
udfUserMapper.deleteByUdfFuncId(id);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* verify udf function by name
*
* @param name name
* @return true if the name can user, otherwise return false
*/
@Override
public Result<Object> verifyUdfFuncByName(User loginUser, String name) {
Result<Object> result = new Result<>();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.UDF, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW);
if (!canOperatorPermissions){
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
if (checkUdfFuncNameExists(name)) {
putMsg(result, Status.UDF_FUNCTION_EXISTS);
} else {
putMsg(result, Status.SUCCESS);
}
return result;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import static org.mockito.ArgumentMatchers.eq;
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.impl.BaseServiceImpl;
import org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.storage.StorageOperate;
import org.apache.dolphinscheduler.common.utils.FileUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.apache.commons.collections.CollectionUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.mock.web.MockMultipartFile;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.io.Files;
/**
* resources service test
*/
@RunWith(PowerMockRunner.class)
@PowerMockIgnore({"sun.security.*", "javax.net.*"})
@PrepareForTest({PropertyUtils.class,
FileUtils.class, org.apache.dolphinscheduler.api.utils.FileUtils.class,
Files.class})
public class ResourcesServiceTest {
private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceTest.class);
@InjectMocks
private ResourcesServiceImpl resourcesService;
@Mock
private ResourceMapper resourcesMapper;
@Mock
private TenantMapper tenantMapper;
@Mock
private StorageOperate storageOperate;
@Mock |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | private UserMapper userMapper;
@Mock
private UdfFuncMapper udfFunctionMapper;
@Mock
private ProcessDefinitionMapper processDefinitionMapper;
@Mock
private ResourceUserMapper resourceUserMapper;
@Mock
private ResourcePermissionCheckService resourcePermissionCheckService;
private static final Logger serviceLogger = LoggerFactory.getLogger(BaseServiceImpl.class);
private static final Logger resourceLogger = LoggerFactory.getLogger(ResourcesServiceImpl.class);
@Before
public void setUp() {
PowerMockito.mockStatic(FileUtils.class);
PowerMockito.mockStatic(Files.class);
PowerMockito.mockStatic(org.apache.dolphinscheduler.api.utils.FileUtils.class);
try {
} catch (Exception e) {
e.printStackTrace();
}
PowerMockito.mockStatic(PropertyUtils.class);
}
@Test
public void testCreateResource() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPLOAD, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | User user = new User();
user.setId(1);
user.setUserType(UserType.GENERAL_USER);
MockMultipartFile mockMultipartFile = new MockMultipartFile("test.pdf", "test.pdf", "pdf", "test".getBytes());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(null);
Result result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
user.setTenantId(1);
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
mockMultipartFile = new MockMultipartFile("test.pdf", "".getBytes());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_FILE_IS_EMPTY.getMsg(), result.getMsg());
mockMultipartFile = new MockMultipartFile("test.pdf", "test.pdf", "pdf", "test".getBytes());
PowerMockito.when(Files.getFileExtension("test.pdf")).thenReturn("pdf");
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.createResource(user, "ResourcesServiceTest.jar", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_FORBID_CHANGE.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.UDF_UPLOAD, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
mockMultipartFile = new MockMultipartFile("ResourcesServiceTest.pdf", "ResourcesServiceTest.pdf", "pdf", "test".getBytes());
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.pdf")).thenReturn("pdf");
result = resourcesService.createResource(user, "ResourcesServiceTest.pdf", "ResourcesServiceTest", ResourceType.UDF, mockMultipartFile, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPLOAD, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
String tooLongFileName = getRandomStringWithLength(Constants.RESOURCE_FULL_NAME_MAX_LENGTH) + ".pdf";
mockMultipartFile = new MockMultipartFile(tooLongFileName, tooLongFileName, "pdf", "test".getBytes());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
PowerMockito.when(Files.getFileExtension(tooLongFileName)).thenReturn("pdf");
result = resourcesService.createResource(user, tooLongFileName, tooLongFileName, ResourceType.FILE, mockMultipartFile, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_FULL_NAME_TOO_LONG_ERROR.getMsg(), result.getMsg());
}
@Test
public void testCreateDirecotry() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
user.setId(1);
user.setUserType(UserType.GENERAL_USER); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Result result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
user.setId(1);
user.setTenantId(1);
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(Mockito.anyInt())).thenReturn(null);
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_RENAME, serviceLogger)).thenReturn(true);
result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, 1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.PARENT_RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.existResource("/directoryTest", 0)).thenReturn(true);
result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg());
}
@Test
public void testUpdateResource() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
User user = new User();
user.setId(1); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setUserType(UserType.GENERAL_USER);
Result result = resourcesService.updateResource(user, 1, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{0}, 1, serviceLogger)).thenReturn(true);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.updateResource(user, 0, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
user.setId(2);
user.setUserType(UserType.GENERAL_USER);
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 2, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 2, serviceLogger)).thenReturn(true);
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM.getMsg(), result.getMsg());
user.setId(1);
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(storageOperate.getFileName(Mockito.any(), Mockito.any(), Mockito.anyString())).thenReturn("test1");
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF_FILE, 1, ApiFuncIdentificationConstant.UDF_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF_FILE, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
try {
Mockito.when(storageOperate.exists(Mockito.any(), Mockito.any())).thenReturn(false); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | } catch (IOException e) {
logger.error(e.getMessage(), e);
}
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null);
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
user.setId(1);
Mockito.when(userMapper.queryDetailsById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Mockito.when(storageOperate.exists(Mockito.any(), Mockito.any())).thenReturn(true);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest.jar", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
Mockito.when(resourcesMapper.existResource("/ResourcesServiceTest1.jar", 0)).thenReturn(true);
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.FILE, null);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.UDF_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(null);
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null);
logger.info(result.toString()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
Mockito.when(tenantMapper.queryById(Mockito.anyInt())).thenReturn(null);
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null);
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(storageOperate.getResourceFileName(Mockito.any(), Mockito.any())).thenReturn("test");
try {
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest1.jar", ResourceType.UDF, null);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testQueryResourceListPaging() {
User loginUser = new User();
loginUser.setId(1);
loginUser.setUserType(UserType.ADMIN_USER);
IPage<Resource> resourcePage = new Page<>(1, 10);
resourcePage.setTotal(1);
resourcePage.setRecords(getResourceList());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 0, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.RESOURCE_FILE_ID, 1, resourceLogger)).thenReturn(getSetIds()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(resourcesMapper.queryResourcePaging(Mockito.any(Page.class), eq(-1), eq(0), eq("test"), Mockito.any())).thenReturn(resourcePage);
Result result = resourcesService.queryResourceListPaging(loginUser, -1, ResourceType.FILE, "test", 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode());
PageInfo pageInfo = (PageInfo) result.getData();
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
}
@Test
public void testQueryResourceList() {
User loginUser = new User();
loginUser.setId(0);
loginUser.setUserType(UserType.ADMIN_USER);
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 0, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 0, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.RESOURCE_FILE_ID, 0, serviceLogger)).thenReturn(getSetIds());
Mockito.when(resourcesMapper.queryResourceListAuthored(0, 0)).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.queryResourceList(loginUser, ResourceType.FILE);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resourceList = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resourceList));
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 0, ApiFuncIdentificationConstant.UDF_FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 0, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.RESOURCE_FILE_ID, 0, serviceLogger)).thenReturn(getSetIds());
loginUser.setUserType(UserType.GENERAL_USER);
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(0, 0))
.thenReturn(Arrays.asList(Integer.valueOf(10), Integer.valueOf(11)));
Mockito.when(resourcesMapper.queryResourceListById(Arrays.asList(Integer.valueOf(10), Integer.valueOf(11))))
.thenReturn(Arrays.asList(getResource(10, ResourceType.FILE), getResource(11, ResourceType.UDF))); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(resourcesMapper.queryResourceListAuthored(0, 1)).thenReturn(getResourceList());
result = resourcesService.queryResourceList(loginUser, ResourceType.UDF);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resourceList = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(resourceList.size() == 4);
}
@Test
public void testDelete() {
User loginUser = new User();
loginUser.setId(0);
loginUser.setUserType(UserType.GENERAL_USER);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 0, ApiFuncIdentificationConstant.FILE_DELETE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 0, serviceLogger)).thenReturn(true);
try {
Result result = resourcesService.delete(loginUser, 1);
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 0, ApiFuncIdentificationConstant.FILE_DELETE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{2}, 0, serviceLogger)).thenReturn(true);
result = resourcesService.delete(loginUser, 2);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | result = resourcesService.delete(loginUser, 2);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
loginUser.setUserType(UserType.ADMIN_USER);
loginUser.setTenantId(2);
Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(loginUser);
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 0, ApiFuncIdentificationConstant.FILE_DELETE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 0, serviceLogger)).thenReturn(true);
result = resourcesService.delete(loginUser, 1);
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
loginUser.setTenantId(1);
Mockito.when(storageOperate.delete(Mockito.any(), Mockito.anyString(), Mockito.anyBoolean())).thenReturn(true);
Mockito.when(processDefinitionMapper.listResources()).thenReturn(getResources());
Mockito.when(resourcesMapper.deleteIds(Mockito.any())).thenReturn(1);
Mockito.when(resourceUserMapper.deleteResourceUserArray(Mockito.anyInt(), Mockito.any())).thenReturn(1);
result = resourcesService.delete(loginUser, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
} catch (Exception e) {
logger.error("delete error", e);
Assert.assertTrue(false);
}
}
@Test
public void testVerifyResourceName() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_RENAME, serviceLogger)).thenReturn(true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
User user = new User();
user.setId(1);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourcesMapper.existResource("/ResourcesServiceTest.jar", 0)).thenReturn(true);
Result result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
String unExistFullName = "/test.jar";
try {
Mockito.when(storageOperate.exists(Mockito.anyString(), eq(unExistFullName))).thenReturn(false);
} catch (IOException e) {
logger.error("hadoop error", e);
}
result = resourcesService.verifyResourceName("/test.jar", ResourceType.FILE, user);
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
user.setTenantId(1);
try {
Mockito.when(storageOperate.exists(Mockito.any(), eq("test"))).thenReturn(true);
} catch (IOException e) {
logger.error("hadoop error", e);
}
PowerMockito.when(storageOperate.getResourceFileName("123", "test1")).thenReturn("test");
result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user);
logger.info(result.toString());
Assert.assertTrue(Status.RESOURCE_EXIST.getCode() == result.getCode()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | result = resourcesService.verifyResourceName("test2", ResourceType.FILE, user);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testReadResource() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Result result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{2}, 1, serviceLogger)).thenReturn(true);
result = resourcesService.readResource(getUser(), 2, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class");
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar");
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NOT_EXIST.getCode(), (int) result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getMsg(), result.getMsg());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
try {
Mockito.when(storageOperate.exists(Mockito.any(), Mockito.anyString())).thenReturn(false);
} catch (IOException e) {
logger.error("hadoop error", e);
}
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_FILE_NOT_EXIST.getCode(), (int) result.getCode());
try {
Mockito.when(storageOperate.exists(Mockito.any(), Mockito.any())).thenReturn(true);
Mockito.when(storageOperate.vimFile(Mockito.any(), Mockito.any(), eq(1), eq(10))).thenReturn(getContent());
} catch (IOException e) {
logger.error("storage error", e);
}
result = resourcesService.readResource(getUser(), 1, 1, 10);
logger.info(result.toString()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testOnlineCreateResource() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
PowerMockito.when(storageOperate.getResourceFileName(Mockito.anyString(), eq("hdfsdDir"))).thenReturn("hdfsDir");
PowerMockito.when(storageOperate.getUdfDir("udfDir")).thenReturn("udfDir");
User user = getUser();
user.setId(1);
Result result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class");
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
try {
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar");
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
} catch (RuntimeException ex) {
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), ex.getMessage());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_RENAME, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 1, serviceLogger)).thenReturn(true);
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testUpdateResourceContent() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
Result result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertEquals(Status.STORAGE_NOT_STARTUP.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{2}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
result = resourcesService.updateResourceContent(getUser(), 2, "content");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("class");
result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg());
PowerMockito.when(FileUtils.getResourceViewSuffixes()).thenReturn("jar");
PowerMockito.when(Files.getFileExtension("ResourcesServiceTest.jar")).thenReturn("jar");
result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser());
result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertTrue(Status.CURRENT_LOGIN_USER_TENANT_NOT_EXIST.getCode() == result.getCode());
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test");
PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true);
result = resourcesService.updateResourceContent(getUser(), 1, "content");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
}
@Test
public void testDownloadResource() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_DOWNLOAD, serviceLogger)).thenReturn(true);
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, new Object[]{1}, 1, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | org.springframework.core.io.Resource resourceMock = Mockito.mock(org.springframework.core.io.Resource.class);
try {
org.springframework.core.io.Resource resource = resourcesService.downloadResource(getUser(), 1);
Assert.assertNull(resource);
Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(Mockito.any())).thenReturn(resourceMock);
resource = resourcesService.downloadResource(getUser(), 1);
Assert.assertNotNull(resource);
} catch (Exception e) {
logger.error("DownloadResource error", e);
Assert.assertTrue(false);
}
}
@Test
public void testAuthorizeResourceTree() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.authorizeResourceTree(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourcesMapper.queryResourceListAuthored(user.getId(), -1)).thenReturn(getResourceList());
result = resourcesService.authorizeResourceTree(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testUnauthorizedFile() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList());
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getSingleResourceList());
Map<String, Object> result = resourcesService.unauthorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
user.setId(2); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourcesMapper.queryResourceListAuthored(user.getId(), -1)).thenReturn(getResourceList());
result = resourcesService.unauthorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testUnauthorizedUDFFunction() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(udfFunctionMapper.queryUdfFuncExceptUserId(userId)).thenReturn(getUdfFuncList());
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getSingleUdfFuncList());
Map<String, Object> result = resourcesService.unauthorizedUDFFunction(user, userId);
logger.info(result.toString());
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(udfFunctionMapper.selectByMap(Collections.singletonMap("user_id", user.getId()))).thenReturn(getUdfFuncList());
result = resourcesService.unauthorizedUDFFunction(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
}
@Test
public void testAuthorizedUDFFunction() {
User user = getUser();
user.setId(1);
user.setUserType(UserType.ADMIN_USER);
int userId = 3;
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList());
Map<String, Object> result = resourcesService.authorizedUDFFunction(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
user.setUserType(UserType.GENERAL_USER);
user.setId(2);
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList());
result = resourcesService.authorizedUDFFunction(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs));
}
@Test
public void testAuthorizedFile() {
User user = getUser();
user.setId(1); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setUserType(UserType.ADMIN_USER);
int userId = 3;
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.authorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
user.setId(2);
user.setUserType(UserType.GENERAL_USER);
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList());
result = resourcesService.authorizedFile(user, userId);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
resources = (List<Resource>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(resources));
}
@Test
public void testCatFile() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
try {
Mockito.when(storageOperate.exists(Mockito.anyString(), Mockito.anyString())).thenReturn(true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Mockito.when(storageOperate.vimFile(Mockito.anyString(), Mockito.anyString(), eq(1), eq(10))).thenReturn(getContent());
List<String> list = storageOperate.vimFile(Mockito.any(), Mockito.anyString(), eq(1), eq(10));
Assert.assertNotNull(list);
} catch (IOException e) {
logger.error("hadoop error", e);
}
}
private List<Resource> getResourceList() {
List<Resource> resources = new ArrayList<>();
resources.add(getResource(1));
resources.add(getResource(2));
resources.add(getResource(3));
return resources;
}
private Set<Integer> getSetIds() {
Set<Integer> resources = new HashSet<>();
resources.add(1);
return resources;
}
private List<Resource> getSingleResourceList() {
return Collections.singletonList(getResource(1));
}
private Tenant getTenant() {
Tenant tenant = new Tenant();
tenant.setTenantCode("123");
return tenant;
}
private Resource getResource() {
Resource resource = new Resource();
resource.setPid(-1); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(ResourceType.FILE);
return resource;
}
private Resource getResource(int resourceId) {
Resource resource = new Resource();
resource.setId(resourceId);
resource.setPid(-1);
resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(ResourceType.FILE);
return resource;
}
private Resource getResource(int resourceId,ResourceType type) {
Resource resource = new Resource();
resource.setId(resourceId);
resource.setPid(-1);
resource.setUserId(1);
resource.setDescription("ResourcesServiceTest.jar");
resource.setAlias("ResourcesServiceTest.jar");
resource.setFullName("/ResourcesServiceTest.jar");
resource.setType(type);
return resource;
}
private Resource getUdfResource() { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | Resource resource = new Resource();
resource.setUserId(1);
resource.setDescription("udfTest");
resource.setAlias("udfTest.jar");
resource.setFullName("/udfTest.jar");
resource.setType(ResourceType.UDF);
return resource;
}
private UdfFunc getUdfFunc() {
UdfFunc udfFunc = new UdfFunc();
udfFunc.setId(1);
return udfFunc;
}
private UdfFunc getUdfFunc(int udfId) {
UdfFunc udfFunc = new UdfFunc();
udfFunc.setId(udfId);
return udfFunc;
}
private List<UdfFunc> getUdfFuncList() {
List<UdfFunc> udfFuncs = new ArrayList<>();
udfFuncs.add(getUdfFunc(1));
udfFuncs.add(getUdfFunc(2));
udfFuncs.add(getUdfFunc(3));
return udfFuncs;
}
private List<UdfFunc> getSingleUdfFuncList() {
return Collections.singletonList(getUdfFunc(3));
}
private User getUser() {
User user = new User(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java | user.setId(1);
user.setUserType(UserType.GENERAL_USER);
user.setTenantId(1);
user.setTenantCode("tenantCode");
return user;
}
private List<String> getContent() {
List<String> contentList = new ArrayList<>();
contentList.add("test");
return contentList;
}
private List<Map<String, Object>> getResources() {
List<Map<String, Object>> resources = new ArrayList<>();
Map<String, Object> resource = new HashMap<>();
resource.put("id", 1);
resource.put("resource_ids", "1");
resources.add(resource);
return resources;
}
private static String getRandomStringWithLength(int length) {
Random r = new Random();
StringBuilder sb = new StringBuilder();
while (sb.length() < length) {
char c = (char) (r.nextInt(26) + 'a');
sb.append(c);
}
return sb.toString();
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UdfFuncServiceTest.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.impl.BaseServiceImpl;
import org.apache.dolphinscheduler.api.service.impl.UdfFuncServiceImpl;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.UdfType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.UdfFunc; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UdfFuncServiceTest.java | import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* udf func service test
*/
@RunWith(PowerMockRunner.class) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UdfFuncServiceTest.java | @PrepareForTest(PropertyUtils.class)
public class UdfFuncServiceTest {
private static final Logger logger = LoggerFactory.getLogger(UdfFuncServiceTest.class);
@InjectMocks
private UdfFuncServiceImpl udfFuncService;
@Mock
private ResourceMapper resourceMapper;
@Mock
private UdfFuncMapper udfFuncMapper;
@Mock
private UDFUserMapper udfUserMapper; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UdfFuncServiceTest.java | @Before
public void setUp() {
PowerMockito.mockStatic(PropertyUtils.class);
}
@Mock
private ResourcePermissionCheckService resourcePermissionCheckService;
private static final Logger serviceLogger = LoggerFactory.getLogger(BaseServiceImpl.class);
private static final Logger udfLogger = LoggerFactory.getLogger(UdfFuncServiceImpl.class);
@Test
public void testCreateUdfFunction() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_CREATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, null, 0, serviceLogger)).thenReturn(true);
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
Result result = udfFuncService.createUdfFunction(getLoginUser(), "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, Integer.MAX_VALUE);
logger.info(result.toString());
Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(),result.getMsg());
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true);
result = udfFuncService.createUdfFunction(getLoginUser(), "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, Integer.MAX_VALUE);
logger.info(result.toString());
Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(),result.getMsg());
PowerMockito.when(resourceMapper.selectById(1)).thenReturn(getResource());
result = udfFuncService.createUdfFunction(getLoginUser(), "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(),result.getMsg()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 10,409 | [Bug] [Permission] No permission to modify the allocated resource data. | ### 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
No permission to modify the allocated resource data.
### What you expected to happen
Update success.
### How to reproduce
Allocate resource data and then modify it.
### Anything else
No Response.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/10409 | https://github.com/apache/dolphinscheduler/pull/10410 | f4dad689d493dcd0d64026c6df3350ca0f9ba805 | c843e3a31550c5a23c7e68624dfaa59bdd7957f8 | 2022-06-11T08:30:01Z | java | 2022-06-12T10:27:49Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UdfFuncServiceTest.java | }
@Test
public void testQueryUdfFuncDetail() {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, new Object[]{2}, 0, serviceLogger)).thenReturn(true);
PowerMockito.when(udfFuncMapper.selectById(1)).thenReturn(getUdfFunc());
Result<Object> result = udfFuncService.queryUdfFuncDetail(getLoginUser(), 2);
logger.info(result.toString());
Assert.assertTrue(Status.RESOURCE_NOT_EXIST.getCode() == result.getCode());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, new Object[]{1}, 0, serviceLogger)).thenReturn(true);
result = udfFuncService.queryUdfFuncDetail(getLoginUser(), 1);
logger.info(result.toString());
Assert.assertTrue(Status.SUCCESS.getCode() == result.getCode());
}
@Test
public void testUpdateUdfFunc() {
PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false);
PowerMockito.when(udfFuncMapper.selectUdfById(1)).thenReturn(getUdfFunc());
PowerMockito.when(resourceMapper.selectById(1)).thenReturn(getResource());
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_UPDATE, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, new Object[]{1}, 0, serviceLogger)).thenReturn(true);
Result<Object> result = udfFuncService.updateUdfFunc(getLoginUser(), 12, "UdfFuncServiceTest", "org.apache.dolphinscheduler.api.service.UdfFuncServiceTest", "String",
"UdfFuncServiceTest", "UdfFuncServiceTest", UdfType.HIVE, 1);
logger.info(result.toString());
Assert.assertTrue(Status.UDF_FUNCTION_NOT_EXIST.getCode() == result.getCode()); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.