[Fix-10080]When the created tenant name is too long, an error message will be prompted (#10081)

* [Fix-10080]When the created tenant name is too long, an error message will be prompted

* [Fix-10080]When the created tenant name is too long, an error message will be prompted

* [Fix-10080]When the created tenant name is too long, an error message will be prompted

Co-authored-by: houshitao <shitaohou@163.com>
(cherry picked from commit 67cf7b2800)
This commit is contained in:
hstdream 2022-05-18 01:36:40 +08:00 committed by Jiajie Zhong
parent aa51c66d91
commit 4f11be7126
3 changed files with 15 additions and 2 deletions

View File

@ -401,7 +401,8 @@ public enum Status {
QUERY_UNAUTHORIZED_NAMESPACE_ERROR(1300012, "query unauthorized namespace error", "查询未授权命名空间错误"),
QUERY_AUTHORIZED_NAMESPACE_ERROR(1300013, "query authorized namespace error", "查询授权命名空间错误"),
QUERY_CAN_USE_K8S_CLUSTER_ERROR(1300014, "login user query can used k8s cluster list error", "查询可用k8s集群错误"),
RESOURCE_FULL_NAME_TOO_LONG_ERROR(1300015, "resource's fullname is too long error", "资源文件名过长");
RESOURCE_FULL_NAME_TOO_LONG_ERROR(1300015, "resource's fullname is too long error", "资源文件名过长"),
TENANT_FULL_NAME_TOO_LONG_ERROR(1300016, "tenant's fullname is too long error", "租户名过长");
private final int code;
private final String enMsg;

View File

@ -40,12 +40,13 @@ import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.apache.dolphinscheduler.common.Constants.TENANT_FULL_NAME_MAX_LENGTH;
/**
* tenant service impl
*/
@ -89,11 +90,17 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
return result;
}
if(StringUtils.length(tenantCode) > TENANT_FULL_NAME_MAX_LENGTH){
putMsg(result, Status.TENANT_FULL_NAME_TOO_LONG_ERROR);
return result;
}
if (!RegexUtils.isValidLinuxUserName(tenantCode)) {
putMsg(result, Status.CHECK_OS_TENANT_CODE_ERROR);
return result;
}
if (checkTenantExists(tenantCode)) {
putMsg(result, Status.OS_TENANT_CODE_EXIST, tenantCode);
return result;

View File

@ -823,4 +823,9 @@ public final class Constants {
*/
public static final String SCHEDULE_TIMEZONE = "schedule_timezone";
public static final int RESOURCE_FULL_NAME_MAX_LENGTH = 128;
/**
* tenant
*/
public static final int TENANT_FULL_NAME_MAX_LENGTH = 30;
}