[Improvement-10760][dolphinscheduler-api] Some variables are redundant and fix checkstyle (#11213)
* [fix-10729]The request's url given by the test case looks different from the controller layer. Some usages and parameter format errors * [fix-10729]The request's url given by the test case looks different from the controller layer. Some usages and parameter format errors * [fix-10729]The request's url given by the test case looks different from the controller layer. Some usages and parameter format errors * [fix-10729]The request's url given by the test case looks different from the controller layer. Some usages and parameter format errors * [fix-10729]fix the code smell * [fix-10729]decorate DataSourceControllerTest with public * [fix-10729]replace import * * [fix-10729]checkstyle * [Improvement][ExecutorServiceImpl] remove some unnecessary * [fix-11181]text check and word spell * Update dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java Co-authored-by: Eric Gao <ericgao.apache@gmail.com> * Update dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java Co-authored-by: Eric Gao <ericgao.apache@gmail.com> * Update ExecutorServiceImpl.java remove the error logging and update the comment * Update dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java Co-authored-by: Eric Gao <ericgao.apache@gmail.com> * [Improvement-10760][dolphinscheduler-api] Some variables are redundant * [Improvement-10760][dolphinscheduler-api] Some variables are redundant and fix checkstyle * [Improvement-10760][dolphinscheduler-api] Some variables are redundant and fix checkstyle * [Improvement-10760][dolphinscheduler-api] add import * [Improvement-10760][dolphinscheduler-api] remove not use Co-authored-by: fuchanghai <changhai.fu@marketingforce.com> Co-authored-by: Eric Gao <ericgao.apache@gmail.com>
This commit is contained in:
parent
163df5f1a3
commit
cb001b581a
|
|
@ -17,6 +17,10 @@
|
|||
|
||||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.DATASOURCE_DELETE;
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.DATASOURCE_UPDATE;
|
||||
|
||||
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.DataSourceService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
|
|
@ -32,7 +36,6 @@ import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper;
|
|||
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
|
||||
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider;
|
||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils;
|
||||
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
|
||||
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;
|
||||
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
|
||||
import org.apache.dolphinscheduler.spi.enums.DbType;
|
||||
|
|
@ -40,7 +43,7 @@ import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
|
|||
import org.apache.dolphinscheduler.spi.utils.StringUtils;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
|
|
@ -52,8 +55,8 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -67,7 +70,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.*;
|
||||
|
||||
|
||||
/**
|
||||
* data source service impl
|
||||
|
|
@ -83,8 +86,6 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
|
|||
@Autowired
|
||||
private DataSourceUserMapper datasourceUserMapper;
|
||||
|
||||
@Autowired
|
||||
private ResourcePermissionCheckService resourcePermissionCheckService;
|
||||
|
||||
private static final String TABLE = "TABLE";
|
||||
private static final String VIEW = "VIEW";
|
||||
|
|
@ -104,7 +105,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
|
|||
public Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) {
|
||||
DataSourceUtils.checkDatasourceParam(datasourceParam);
|
||||
Result<Object> result = new Result<>();
|
||||
if (!canOperatorPermissions(loginUser,null, AuthorizationType.DATASOURCE, DATASOURCE_CREATE_DATASOURCE)) {
|
||||
if (!canOperatorPermissions(loginUser,null, AuthorizationType.DATASOURCE, ApiFuncIdentificationConstant.DATASOURCE_CREATE_DATASOURCE)) {
|
||||
putMsg(result, Status.USER_NO_OPERATION_PERM);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -264,7 +265,6 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
|
|||
dataSourceList = dataSourceMapper.selectPagingByIds(dataSourcePage, new ArrayList<>(ids), searchVal);
|
||||
}
|
||||
|
||||
|
||||
List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>();
|
||||
handlePasswd(dataSources);
|
||||
pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L));
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationCon
|
|||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.PROJECT_UPDATE;
|
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
|
||||
import org.apache.dolphinscheduler.api.service.ProjectService;
|
||||
import org.apache.dolphinscheduler.api.utils.PageInfo;
|
||||
import org.apache.dolphinscheduler.api.utils.Result;
|
||||
|
|
@ -66,7 +65,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
* project service impl
|
||||
**/
|
||||
@Service
|
||||
public class ProjectServiceImpl extends BaseServiceImpl implements ProjectService{
|
||||
public class ProjectServiceImpl extends BaseServiceImpl implements ProjectService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectServiceImpl.class);
|
||||
|
||||
|
|
@ -82,8 +81,6 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
|
|||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
private ResourcePermissionCheckService resourcePermissionCheckService;
|
||||
|
||||
/**
|
||||
* create project
|
||||
|
|
|
|||
|
|
@ -17,14 +17,15 @@
|
|||
|
||||
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;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import static org.apache.dolphinscheduler.common.Constants.ALIAS;
|
||||
import static org.apache.dolphinscheduler.common.Constants.CONTENT;
|
||||
import static org.apache.dolphinscheduler.common.Constants.EMPTY_STRING;
|
||||
import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR;
|
||||
import static org.apache.dolphinscheduler.common.Constants.FORMAT_SS;
|
||||
import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S;
|
||||
import static org.apache.dolphinscheduler.common.Constants.JAR;
|
||||
import static org.apache.dolphinscheduler.common.Constants.PERIOD;
|
||||
|
||||
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
|
||||
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
|
||||
import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter;
|
||||
|
|
@ -56,15 +57,11 @@ import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
|||
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
|
||||
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
|
||||
import org.apache.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 org.apache.commons.beanutils.BeanMap;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.rmi.ServerException;
|
||||
|
|
@ -83,14 +80,19 @@ 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.EMPTY_STRING;
|
||||
import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR;
|
||||
import static org.apache.dolphinscheduler.common.Constants.FORMAT_SS;
|
||||
import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S;
|
||||
import static org.apache.dolphinscheduler.common.Constants.JAR;
|
||||
import static org.apache.dolphinscheduler.common.Constants.PERIOD;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
/**
|
||||
* resources service impl
|
||||
|
|
@ -121,8 +123,6 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
@Autowired(required = false)
|
||||
private StorageOperate storageOperate;
|
||||
|
||||
@Autowired
|
||||
private ResourcePermissionCheckService resourcePermissionCheckService;
|
||||
|
||||
/**
|
||||
* create directory
|
||||
|
|
@ -146,7 +146,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
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){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
Result<Object> result = new Result<>();
|
||||
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPLOAD : ApiFuncIdentificationConstant.UDF_UPLOAD;
|
||||
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
|
||||
if (!canOperatorPermissions){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -355,7 +355,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
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){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -364,14 +364,13 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
Resource resource = resourcesMapper.selectById(resourceId);
|
||||
if (resource == null) {
|
||||
putMsg(result, Status.RESOURCE_NOT_EXIST);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!PropertyUtils.getResUploadStartupState()){
|
||||
if (!PropertyUtils.getResUploadStartupState()) {
|
||||
putMsg(result, Status.STORAGE_NOT_STARTUP);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -744,7 +743,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
Result<Object> result = new Result<>();
|
||||
|
||||
Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger);
|
||||
if (resourceIds.isEmpty()){
|
||||
if (resourceIds.isEmpty()) {
|
||||
result.setData(Collections.emptyList());
|
||||
putMsg(result, Status.SUCCESS);
|
||||
return result;
|
||||
|
|
@ -790,7 +789,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
}
|
||||
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){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(resultCheck, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return resultCheck;
|
||||
}
|
||||
|
|
@ -873,7 +872,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
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){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -941,7 +940,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
}
|
||||
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){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -965,7 +964,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
}
|
||||
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){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -996,7 +995,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
}
|
||||
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){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1060,7 +1059,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content, int pid, String currentDir) {
|
||||
Result<Object> result = new Result<>();
|
||||
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE);
|
||||
if (!canOperatorPermissions){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1274,7 +1273,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
}
|
||||
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){
|
||||
if (!canOperatorPermissions) {
|
||||
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1333,7 +1332,6 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
String resourcePath = storageOperate.getResDir(tenantCode);
|
||||
logger.info("resource path is {}, resource dir is {}", storageFileName, resourcePath);
|
||||
|
||||
|
||||
if (!storageOperate.exists(tenantCode, resourcePath)) {
|
||||
// create if tenant dir not exists
|
||||
storageOperate.createTenantDirIfNotExists(tenantCode);
|
||||
|
|
@ -1376,7 +1374,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
|
||||
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){
|
||||
if (!canOperatorPermissions) {
|
||||
logger.error("{}: {}", Status.NO_CURRENT_OPERATING_PERMISSION.getMsg(), PropertyUtils.getResUploadStartupState());
|
||||
throw new ServiceException(Status.NO_CURRENT_OPERATING_PERMISSION.getMsg());
|
||||
}
|
||||
|
|
@ -1424,7 +1422,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
@Override
|
||||
public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (!resourcePermissionCheckService.functionDisabled()){
|
||||
if (!resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1494,7 +1492,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
@Override
|
||||
public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (!resourcePermissionCheckService.functionDisabled()){
|
||||
if (!resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1532,7 +1530,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
@Override
|
||||
public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (!resourcePermissionCheckService.functionDisabled()){
|
||||
if (!resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1552,7 +1550,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
@Override
|
||||
public Map<String, Object> authorizedFile(User loginUser, Integer userId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if (!resourcePermissionCheckService.functionDisabled()){
|
||||
if (!resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1648,7 +1646,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
|
|||
*/
|
||||
private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) {
|
||||
Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger);
|
||||
if (resourceIds.isEmpty()){
|
||||
if (resourceIds.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Resource> resources = resourcesMapper.selectBatchIds(resourceIds);
|
||||
|
|
|
|||
|
|
@ -17,11 +17,8 @@
|
|||
|
||||
package org.apache.dolphinscheduler.api.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.USER_MANAGER;
|
||||
|
||||
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
|
||||
|
|
@ -59,28 +56,34 @@ import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
|||
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
|
||||
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
|
||||
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
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.TimeZone;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.USER_MANAGER;
|
||||
|
||||
/**
|
||||
* users service impl
|
||||
|
|
@ -129,8 +132,6 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
@Autowired
|
||||
private K8sNamespaceUserMapper k8sNamespaceUserMapper;
|
||||
|
||||
@Autowired
|
||||
private ResourcePermissionCheckService resourcePermissionCheckService;
|
||||
|
||||
/**
|
||||
* create user, only system admin have permission
|
||||
|
|
@ -159,7 +160,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
|
||||
//check all user params
|
||||
String msg = this.checkUserParams(userName, userPassword, email, phone);
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED, msg);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -185,7 +186,6 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
// resource upload startup
|
||||
if (PropertyUtils.getResUploadStartupState()) {
|
||||
storageOperate.createTenantDirIfNotExists(tenant.getTenantCode());
|
||||
//
|
||||
}
|
||||
|
||||
result.put(Constants.DATA_LIST, user);
|
||||
|
|
@ -337,7 +337,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
@Override
|
||||
public Result<Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
|
||||
Result<Object> result = new Result<>();
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -387,7 +387,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -453,62 +453,6 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
user.setState(state);
|
||||
Date now = new Date();
|
||||
user.setUpdateTime(now);
|
||||
|
||||
//if user switches the tenant, the user's resources need to be copied to the new tenant
|
||||
// if (user.getTenantId() != tenantId) {
|
||||
// Tenant oldTenant = tenantMapper.queryById(user.getTenantId());
|
||||
// //query tenant
|
||||
// Tenant newTenant = tenantMapper.queryById(tenantId);
|
||||
// // if hdfs startup
|
||||
// if (null != newTenant && PropertyUtils.getResUploadStartupState() && oldTenant != null) {
|
||||
// String newTenantCode = newTenant.getTenantCode();
|
||||
// String oldResourcePath = storageOperate.getResDir(oldTenant.getTenantCode());
|
||||
// String oldUdfsPath = storageOperate.getUdfDir(oldTenant.getTenantCode());
|
||||
//
|
||||
// try {// if old tenant dir exists
|
||||
// if (storageOperate.exists(oldTenant.getTenantCode(), oldResourcePath)) {
|
||||
// String newResourcePath = storageOperate.getResDir(newTenantCode);
|
||||
// String newUdfsPath = storageOperate.getUdfDir(newTenantCode);
|
||||
//
|
||||
// //file resources list
|
||||
// List<Resource> fileResourcesList = resourceMapper.queryResourceList(
|
||||
// null, userId, ResourceType.FILE.ordinal());
|
||||
// if (CollectionUtils.isNotEmpty(fileResourcesList)) {
|
||||
// ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(fileResourcesList);
|
||||
// ResourceComponent resourceComponent = resourceTreeVisitor.visit();
|
||||
// copyResourceFiles(oldTenant.getTenantCode(), newTenantCode, resourceComponent, oldResourcePath, newResourcePath);
|
||||
// }
|
||||
//
|
||||
// //udf resources
|
||||
// List<Resource> udfResourceList = resourceMapper.queryResourceList(
|
||||
// null, userId, ResourceType.UDF.ordinal());
|
||||
// if (CollectionUtils.isNotEmpty(udfResourceList)) {
|
||||
// ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(udfResourceList);
|
||||
// ResourceComponent resourceComponent = resourceTreeVisitor.visit();
|
||||
// copyResourceFiles(oldTenant.getTenantCode(), newTenantCode, resourceComponent, oldUdfsPath, newUdfsPath);
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// // if old tenant dir not exists , create
|
||||
// storageOperate.createTenantDirIfNotExists(oldTenant.getTenantCode());
|
||||
//
|
||||
// if (!storageOperate.exists(newTenant.getTenantCode(), storageOperate.getDir(null,newTenant.getTenantCode()))) {
|
||||
// storageOperate.createTenantDirIfNotExists(newTenant.getTenantCode());
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("create tenant {} failed ,the reason is {}", oldTenant, e.getMessage());
|
||||
// }
|
||||
//
|
||||
//
|
||||
// try {
|
||||
// storageOperate.createTenantDirIfNotExists(newTenant.getTenantCode());
|
||||
// } catch (Exception e) {
|
||||
// logger.error("create tenant {} failed ,the reason is {}", newTenant, e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// user.setTenantId(tenantId);
|
||||
// }
|
||||
user.setTenantId(tenantId);
|
||||
// updateProcessInstance user
|
||||
userMapper.updateById(user);
|
||||
|
|
@ -528,7 +472,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
@Transactional
|
||||
public Map<String, Object> deleteUserById(User loginUser, int id) throws IOException {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -552,8 +496,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
}
|
||||
// delete user
|
||||
userMapper.queryTenantCodeByUserId(id);
|
||||
|
||||
|
||||
|
||||
accessTokenMapper.deleteAccessTokenByUserId(id);
|
||||
|
||||
userMapper.deleteById(id);
|
||||
|
|
@ -577,7 +520,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -621,7 +564,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -676,7 +619,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -718,7 +661,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -816,7 +759,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
public Map<String, Object> grantUDFFunction(User loginUser, int userId, String udfIds) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -864,7 +807,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
public Map<String, Object> grantNamespaces(User loginUser, int userId, String namespaceIds) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -915,7 +858,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -961,7 +904,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1004,7 +947,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
@Override
|
||||
public Map<String, Object> queryAllGeneralUsers(User loginUser) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1078,7 +1021,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
public Map<String, Object> unauthorizedUser(User loginUser, Integer alertgroupId) {
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1118,7 +1061,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
@Override
|
||||
public Map<String, Object> authorizedUser(User loginUser, Integer alertGroupId) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1140,8 +1083,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
private boolean checkTenantExists(int tenantId) {
|
||||
return tenantMapper.queryById(tenantId) != null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return if check failed return the field, otherwise return null
|
||||
*/
|
||||
|
|
@ -1225,7 +1167,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
|
||||
//check user params
|
||||
String msg = this.checkUserParams(userName, userPassword, email, "");
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1255,7 +1197,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
public Map<String, Object> activateUser(User loginUser, String userName) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(Constants.STATUS, false);
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1303,7 +1245,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
|
|||
public Map<String, Object> batchActivateUser(User loginUser, List<String> userNames) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
|
||||
if(resourcePermissionCheckService.functionDisabled()){
|
||||
if (resourcePermissionCheckService.functionDisabled()) {
|
||||
putMsg(result, Status.FUNCTION_DISABLED);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue