You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by le...@apache.org on 2022/05/17 17:36:50 UTC

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

This is an automated email from the ASF dual-hosted git repository.

leonbao pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 67cf7b2800 [Fix-10080]When the created tenant name is too long, an error message will be prompted (#10081)
67cf7b2800 is described below

commit 67cf7b280087d4424bf0c2a698c9c12ab874bd2e
Author: hstdream <33...@users.noreply.github.com>
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 <sh...@163.com>
---
 .../main/java/org/apache/dolphinscheduler/api/enums/Status.java  | 3 ++-
 .../dolphinscheduler/api/service/impl/TenantServiceImpl.java     | 9 ++++++++-
 .../main/java/org/apache/dolphinscheduler/common/Constants.java  | 5 +++++
 3 files changed, 15 insertions(+), 2 deletions(-)

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 6108a6ed76..e0a38c1e5f 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
@@ -402,7 +402,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;
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 fb92c1583d..6bb2870452 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
@@ -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;
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 d1d240f28c..57b5c92970 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
@@ -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;
 }