Browse Source

[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)
3.0.0/version-upgrade
hstdream 3 years ago committed by Jiajie Zhong
parent
commit
4f11be7126
  1. 3
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
  2. 9
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
  3. 5
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java

3
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java

@ -401,7 +401,8 @@ public enum Status {
QUERY_UNAUTHORIZED_NAMESPACE_ERROR(1300012, "query unauthorized namespace error", "查询未授权命名空间错误"), QUERY_UNAUTHORIZED_NAMESPACE_ERROR(1300012, "query unauthorized namespace error", "查询未授权命名空间错误"),
QUERY_AUTHORIZED_NAMESPACE_ERROR(1300013, "query authorized 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集群错误"), 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 int code;
private final String enMsg; private final String enMsg;

9
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java

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

5
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java

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

Loading…
Cancel
Save