Browse Source

[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>
3.1.0-release
fuchanghai 2 years ago committed by GitHub
parent
commit
cb001b581a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
  2. 5
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
  3. 90
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
  4. 128
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java

16
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java

@ -17,6 +17,10 @@
package org.apache.dolphinscheduler.api.service.impl; 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.enums.Status;
import org.apache.dolphinscheduler.api.service.DataSourceService; import org.apache.dolphinscheduler.api.service.DataSourceService;
import org.apache.dolphinscheduler.api.utils.PageInfo; 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.datasource.BaseDataSourceParamDTO;
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider;
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; 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.BaseConnectionParam;
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; import org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType; 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.dolphinscheduler.spi.utils.StringUtils;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -52,8 +55,8 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.slf4j.Logger; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.*;
/** /**
* data source service impl * data source service impl
@ -83,8 +86,6 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
@Autowired @Autowired
private DataSourceUserMapper datasourceUserMapper; private DataSourceUserMapper datasourceUserMapper;
@Autowired
private ResourcePermissionCheckService resourcePermissionCheckService;
private static final String TABLE = "TABLE"; private static final String TABLE = "TABLE";
private static final String VIEW = "VIEW"; 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) { public Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) {
DataSourceUtils.checkDatasourceParam(datasourceParam); DataSourceUtils.checkDatasourceParam(datasourceParam);
Result<Object> result = new Result<>(); 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); putMsg(result, Status.USER_NO_OPERATION_PERM);
return result; return result;
} }
@ -264,7 +265,6 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
dataSourceList = dataSourceMapper.selectPagingByIds(dataSourcePage, new ArrayList<>(ids), searchVal); dataSourceList = dataSourceMapper.selectPagingByIds(dataSourcePage, new ArrayList<>(ids), searchVal);
} }
List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>(); List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>();
handlePasswd(dataSources); handlePasswd(dataSources);
pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L)); pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L));

5
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java

@ -23,7 +23,6 @@ import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationCon
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.PROJECT_UPDATE; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.PROJECT_UPDATE;
import org.apache.dolphinscheduler.api.enums.Status; 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.service.ProjectService;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
@ -66,7 +65,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
* project service impl * project service impl
**/ **/
@Service @Service
public class ProjectServiceImpl extends BaseServiceImpl implements ProjectService{ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectService {
private static final Logger logger = LoggerFactory.getLogger(ProjectServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(ProjectServiceImpl.class);
@ -82,8 +81,6 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
@Autowired @Autowired
private UserMapper userMapper; private UserMapper userMapper;
@Autowired
private ResourcePermissionCheckService resourcePermissionCheckService;
/** /**
* create project * create project

90
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java

@ -17,14 +17,15 @@
package org.apache.dolphinscheduler.api.service.impl; package org.apache.dolphinscheduler.api.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import static org.apache.dolphinscheduler.common.Constants.ALIAS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import static org.apache.dolphinscheduler.common.Constants.CONTENT;
import com.fasterxml.jackson.databind.SerializationFeature; import static org.apache.dolphinscheduler.common.Constants.EMPTY_STRING;
import com.google.common.base.Joiner; import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR;
import com.google.common.io.Files; import static org.apache.dolphinscheduler.common.Constants.FORMAT_SS;
import org.apache.commons.beanutils.BeanMap; import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S;
import org.apache.commons.collections.CollectionUtils; import static org.apache.dolphinscheduler.common.Constants.JAR;
import org.apache.commons.lang3.StringUtils; import static org.apache.dolphinscheduler.common.Constants.PERIOD;
import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant; import org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter; 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.UdfFuncMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.apache.commons.beanutils.BeanMap;
import org.springframework.beans.factory.annotation.Autowired; import org.apache.commons.collections.CollectionUtils;
import org.springframework.dao.DuplicateKeyException; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.rmi.ServerException; import java.rmi.ServerException;
@ -83,14 +80,19 @@ import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.apache.dolphinscheduler.common.Constants.ALIAS; import org.slf4j.Logger;
import static org.apache.dolphinscheduler.common.Constants.CONTENT; import org.slf4j.LoggerFactory;
import static org.apache.dolphinscheduler.common.Constants.EMPTY_STRING; import org.springframework.beans.factory.annotation.Autowired;
import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR; import org.springframework.dao.DuplicateKeyException;
import static org.apache.dolphinscheduler.common.Constants.FORMAT_SS; import org.springframework.stereotype.Service;
import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S; import org.springframework.transaction.annotation.Transactional;
import static org.apache.dolphinscheduler.common.Constants.JAR; import org.springframework.web.multipart.MultipartFile;
import static org.apache.dolphinscheduler.common.Constants.PERIOD;
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 * resources service impl
@ -121,8 +123,6 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
@Autowired(required = false) @Autowired(required = false)
private StorageOperate storageOperate; private StorageOperate storageOperate;
@Autowired
private ResourcePermissionCheckService resourcePermissionCheckService;
/** /**
* create directory * create directory
@ -146,7 +146,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
Result<Object> result = new Result<>(); Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FOLDER_ONLINE_CREATE : ApiFuncIdentificationConstant.UDF_FOLDER_ONLINE_CREATE; 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); boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result; return result;
} }
@ -227,7 +227,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
Result<Object> result = new Result<>(); Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPLOAD : ApiFuncIdentificationConstant.UDF_UPLOAD; String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPLOAD : ApiFuncIdentificationConstant.UDF_UPLOAD;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey); boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result; return result;
} }
@ -355,7 +355,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
Result<Object> result = new Result<>(); Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE; String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(type), funcPermissionKey); boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(type), funcPermissionKey);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result; return result;
} }
@ -364,14 +364,13 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
return result; return result;
} }
Resource resource = resourcesMapper.selectById(resourceId); Resource resource = resourcesMapper.selectById(resourceId);
if (resource == null) { if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST); putMsg(result, Status.RESOURCE_NOT_EXIST);
return result; return result;
} }
if (!PropertyUtils.getResUploadStartupState()){ if (!PropertyUtils.getResUploadStartupState()) {
putMsg(result, Status.STORAGE_NOT_STARTUP); putMsg(result, Status.STORAGE_NOT_STARTUP);
return result; return result;
} }
@ -744,7 +743,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
Result<Object> result = new Result<>(); Result<Object> result = new Result<>();
Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger);
if (resourceIds.isEmpty()){ if (resourceIds.isEmpty()) {
result.setData(Collections.emptyList()); result.setData(Collections.emptyList());
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; 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; String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DELETE : ApiFuncIdentificationConstant.UDF_DELETE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey); boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(resultCheck, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(resultCheck, Status.NO_CURRENT_OPERATING_PERMISSION);
return resultCheck; return resultCheck;
} }
@ -873,7 +872,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
Result<Object> result = new Result<>(); Result<Object> result = new Result<>();
String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_RENAME : ApiFuncIdentificationConstant.UDF_FILE_VIEW; String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_RENAME : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey); boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, funcPermissionKey);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result; 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; String funcPermissionKey = type.equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_VIEW : ApiFuncIdentificationConstant.UDF_FILE_VIEW;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resource.getId()}, checkResourceType(type), funcPermissionKey); boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resource.getId()}, checkResourceType(type), funcPermissionKey);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result; 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; 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); boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{id}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result; 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; 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); boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result; 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) { 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<>(); Result<Object> result = new Result<>();
boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE); boolean canOperatorPermissions = canOperatorPermissions(loginUser, null, AuthorizationType.RESOURCE_FILE_ID, ApiFuncIdentificationConstant.FILE_ONLINE_CREATE);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result; 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; String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_UPDATE : ApiFuncIdentificationConstant.UDF_UPDATE;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey); boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey);
if (!canOperatorPermissions){ if (!canOperatorPermissions) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION); putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result; return result;
} }
@ -1333,7 +1332,6 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
String resourcePath = storageOperate.getResDir(tenantCode); String resourcePath = storageOperate.getResDir(tenantCode);
logger.info("resource path is {}, resource dir is {}", storageFileName, resourcePath); logger.info("resource path is {}, resource dir is {}", storageFileName, resourcePath);
if (!storageOperate.exists(tenantCode, resourcePath)) { if (!storageOperate.exists(tenantCode, resourcePath)) {
// create if tenant dir not exists // create if tenant dir not exists
storageOperate.createTenantDirIfNotExists(tenantCode); 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; String funcPermissionKey = resource.getType().equals(ResourceType.FILE) ? ApiFuncIdentificationConstant.FILE_DOWNLOAD : ApiFuncIdentificationConstant.UDF_DOWNLOAD;
boolean canOperatorPermissions = canOperatorPermissions(loginUser, new Object[]{resourceId}, checkResourceType(resource.getType()), funcPermissionKey); 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()); logger.error("{}: {}", Status.NO_CURRENT_OPERATING_PERMISSION.getMsg(), PropertyUtils.getResUploadStartupState());
throw new ServiceException(Status.NO_CURRENT_OPERATING_PERMISSION.getMsg()); throw new ServiceException(Status.NO_CURRENT_OPERATING_PERMISSION.getMsg());
} }
@ -1424,7 +1422,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
@Override @Override
public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) { public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()){ if (!resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1494,7 +1492,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
@Override @Override
public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) { public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()){ if (!resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1532,7 +1530,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
@Override @Override
public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) { public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()){ if (!resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1552,7 +1550,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
@Override @Override
public Map<String, Object> authorizedFile(User loginUser, Integer userId) { public Map<String, Object> authorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()){ if (!resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1648,7 +1646,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
*/ */
private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) { private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) {
Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger); Set<Integer> resourceIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(checkResourceType(type), loginUser.getId(), logger);
if (resourceIds.isEmpty()){ if (resourceIds.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
List<Resource> resources = resourcesMapper.selectBatchIds(resourceIds); List<Resource> resources = resourcesMapper.selectBatchIds(resourceIds);

128
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java

@ -17,11 +17,8 @@
package org.apache.dolphinscheduler.api.service.impl; package org.apache.dolphinscheduler.api.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.USER_MANAGER;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException; 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.UDFUserMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
import org.slf4j.Logger; import org.apache.commons.collections.CollectionUtils;
import org.slf4j.LoggerFactory; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException; import java.io.IOException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.USER_MANAGER; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/** /**
* users service impl * users service impl
@ -129,8 +132,6 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
@Autowired @Autowired
private K8sNamespaceUserMapper k8sNamespaceUserMapper; private K8sNamespaceUserMapper k8sNamespaceUserMapper;
@Autowired
private ResourcePermissionCheckService resourcePermissionCheckService;
/** /**
* create user, only system admin have permission * create user, only system admin have permission
@ -159,7 +160,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
//check all user params //check all user params
String msg = this.checkUserParams(userName, userPassword, email, phone); String msg = this.checkUserParams(userName, userPassword, email, phone);
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED, msg); putMsg(result, Status.FUNCTION_DISABLED, msg);
return result; return result;
} }
@ -185,7 +186,6 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
// resource upload startup // resource upload startup
if (PropertyUtils.getResUploadStartupState()) { if (PropertyUtils.getResUploadStartupState()) {
storageOperate.createTenantDirIfNotExists(tenant.getTenantCode()); storageOperate.createTenantDirIfNotExists(tenant.getTenantCode());
//
} }
result.put(Constants.DATA_LIST, user); result.put(Constants.DATA_LIST, user);
@ -337,7 +337,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
@Override @Override
public Result<Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { public Result<Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Result<Object> result = new Result<>(); Result<Object> result = new Result<>();
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -387,7 +387,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -453,62 +453,6 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
user.setState(state); user.setState(state);
Date now = new Date(); Date now = new Date();
user.setUpdateTime(now); 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); user.setTenantId(tenantId);
// updateProcessInstance user // updateProcessInstance user
userMapper.updateById(user); userMapper.updateById(user);
@ -528,7 +472,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
@Transactional @Transactional
public Map<String, Object> deleteUserById(User loginUser, int id) throws IOException { public Map<String, Object> deleteUserById(User loginUser, int id) throws IOException {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -553,7 +497,6 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
// delete user // delete user
userMapper.queryTenantCodeByUserId(id); userMapper.queryTenantCodeByUserId(id);
accessTokenMapper.deleteAccessTokenByUserId(id); accessTokenMapper.deleteAccessTokenByUserId(id);
userMapper.deleteById(id); userMapper.deleteById(id);
@ -577,7 +520,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -621,7 +564,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -676,7 +619,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -718,7 +661,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) { public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -816,7 +759,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
public Map<String, Object> grantUDFFunction(User loginUser, int userId, String udfIds) { public Map<String, Object> grantUDFFunction(User loginUser, int userId, String udfIds) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -864,7 +807,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
public Map<String, Object> grantNamespaces(User loginUser, int userId, String namespaceIds) { public Map<String, Object> grantNamespaces(User loginUser, int userId, String namespaceIds) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -915,7 +858,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -961,7 +904,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1004,7 +947,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
@Override @Override
public Map<String, Object> queryAllGeneralUsers(User loginUser) { public Map<String, Object> queryAllGeneralUsers(User loginUser) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1078,7 +1021,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
public Map<String, Object> unauthorizedUser(User loginUser, Integer alertgroupId) { public Map<String, Object> unauthorizedUser(User loginUser, Integer alertgroupId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1118,7 +1061,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
@Override @Override
public Map<String, Object> authorizedUser(User loginUser, Integer alertGroupId) { public Map<String, Object> authorizedUser(User loginUser, Integer alertGroupId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1141,7 +1084,6 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
return tenantMapper.queryById(tenantId) != null; return tenantMapper.queryById(tenantId) != null;
} }
/** /**
* @return if check failed return the field, otherwise return 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 //check user params
String msg = this.checkUserParams(userName, userPassword, email, ""); String msg = this.checkUserParams(userName, userPassword, email, "");
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1255,7 +1197,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
public Map<String, Object> activateUser(User loginUser, String userName) { public Map<String, Object> activateUser(User loginUser, String userName) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }
@ -1303,7 +1245,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
public Map<String, Object> batchActivateUser(User loginUser, List<String> userNames) { public Map<String, Object> batchActivateUser(User loginUser, List<String> userNames) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if(resourcePermissionCheckService.functionDisabled()){ if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED); putMsg(result, Status.FUNCTION_DISABLED);
return result; return result;
} }

Loading…
Cancel
Save