This is an automated email from the ASF dual-hosted git repository.
zhongjiajie pushed a commit to branch 2.0.7-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/2.0.7-prepare by this push:
new fb68147c25 [Fix-10080]When the created tenant name is too long, an
error message will be prompted (#10081)
fb68147c25 is described below
commit fb68147c25480d8ae75c1ea8de4edfd24ef79e6f
Author: hstdream <[email protected]>
AuthorDate: Wed May 18 01:36:40 2022 +0800
[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 <[email protected]>
(cherry picked from commit 67cf7b280087d4424bf0c2a698c9c12ab874bd2e)
---
.../main/java/org/apache/dolphinscheduler/api/enums/Status.java | 3 ++-
.../dolphinscheduler/api/service/impl/TenantServiceImpl.java | 7 +++++++
.../main/java/org/apache/dolphinscheduler/common/Constants.java | 5 +++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
index 3d88b1b79c..0dd6cbf36d 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
@@ -350,7 +350,8 @@ public enum Status {
UPDATE_ENVIRONMENT_WORKER_GROUP_RELATION_ERROR(1200013,"You can't modify
the worker group, because the worker group [{0}] and this environment [{1}]
already be used in the task [{2}]",
"您不能修改工作组选项,因为该工作组 [{0}] 和 该环境 [{1}] 已经被用在任务 [{2}] 中"),
NOT_ALLOW_TO_DISABLE_OWN_ACCOUNT(130020, "Not allow to disable your own
account", "不能停用自己的账号"),
- VERIFY_PARAMETER_NAME_FAILED(1300009, "The file name verify failed",
"文件命名校验失败");
+ VERIFY_PARAMETER_NAME_FAILED(1300009, "The file name verify failed",
"文件命名校验失败"),
+ TENANT_FULL_NAME_TOO_LONG_ERROR(1300016, "tenant's fullname is too long
error", "租户名过长");
private final int code;
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
index 0601725797..86845ad8d9 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
@@ -17,6 +17,8 @@
package org.apache.dolphinscheduler.api.service.impl;
+import static
org.apache.dolphinscheduler.common.Constants.TENANT_FULL_NAME_MAX_LENGTH;
+
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.TenantService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
@@ -90,6 +92,11 @@ 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;
diff --git
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
index eb2f46b796..1f6558a0db 100644
---
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
+++
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
@@ -1092,4 +1092,9 @@ public final class Constants {
public static final int DRY_RUN_FLAG_YES = 1;
public static final String CACHE_KEY_VALUE_ALL = "'all'";
+
+ /**
+ * tenant
+ */
+ public static final int TENANT_FULL_NAME_MAX_LENGTH = 30;
}