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

peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new a06a8e598 errorcode code optimization (#3507)
a06a8e598 is described below

commit a06a8e598157adf4cab5906f249bc5b54fcacd0d
Author: 成彬彬 <[email protected]>
AuthorDate: Fri Sep 23 18:21:06 2022 +0800

    errorcode code optimization (#3507)
---
 .../linkis-gateway-httpclient-support_errorcode.md | 13 ++++
 .../LinkisGwHttpclientSupportErrorCodeSummary.java | 74 ++++++++++++++++++++++
 .../StaticAuthenticationStrategy.scala             |  9 +--
 .../TokenAuthenticationStrategy.scala              |  5 +-
 .../exception/AuthenticationFailedException.scala  |  4 +-
 .../dws/exception/UnknownVersionException.scala    |  6 +-
 6 files changed, 97 insertions(+), 14 deletions(-)

diff --git a/docs/errorcode/linkis-gateway-httpclient-support_errorcode.md 
b/docs/errorcode/linkis-gateway-httpclient-support_errorcode.md
new file mode 100644
index 000000000..54b02180e
--- /dev/null
+++ b/docs/errorcode/linkis-gateway-httpclient-support_errorcode.md
@@ -0,0 +1,13 @@
+## linkis-gateway-httpclient-support errorcode
+
+| 模块名(服务名) | 错误码  | 描述 | Exception Class|
+| -------- | -------- | ----- |-----|
+|linkis-gateway-httpclient-support|10901|the value of authTokenValue in 
ClientConfig must be exists, since no password is found to 
login(ClientConfig中authTokenValue的值必须存在,因为没有找到密码登录.)|LinkisGwHttpclientSupportErrorCodeSummary|
+|linkis-gateway-httpclient-support|10901|cannot use token authentication, 
since no user is found to 
proxy(无法使用令牌身份验证,因为找不到代理用户)|LinkisGwHttpclientSupportErrorCodeSummary|
+|linkis-gateway-httpclient-support|10901|ClientConfig must specify the DWS 
version(ClientConfig必须指定DWS版本)|LinkisGwHttpclientSupportErrorCodeSummary|
+
+
+
+
+
+
diff --git 
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/java/org/apache/linkis/httpclient/errorcode/LinkisGwHttpclientSupportErrorCodeSummary.java
 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/java/org/apache/linkis/httpclient/errorcode/LinkisGwHttpclientSupportErrorCodeSummary.java
new file mode 100644
index 000000000..bea45beb5
--- /dev/null
+++ 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/java/org/apache/linkis/httpclient/errorcode/LinkisGwHttpclientSupportErrorCodeSummary.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.httpclient.errorcode;
+
+public enum LinkisGwHttpclientSupportErrorCodeSummary {
+  AUTHTOKENVALUE_BE_EXISTS(
+      10901,
+      "the value of authTokenValue in ClientConfig must be exists, since no 
password is found to login(ClientConfig中authTokenValue的值必须存在,因为没有找到密码登录.)",
+      "the value of authTokenValue in ClientConfig must be exists, since no 
password is found to login(ClientConfig中authTokenValue的值必须存在,因为没有找到密码登录.)"),
+  TOKEN_AUTHENTICATION(
+      10901,
+      "cannot use token authentication, since no user is found to 
proxy(无法使用令牌身份验证,因为找不到代理用户)",
+      "cannot use token authentication, since no user is found to 
proxy(无法使用令牌身份验证,因为找不到代理用户)"),
+  CLIENTCONFIG_MUST(
+      10901,
+      "ClientConfig must specify the DWS version(ClientConfig必须指定DWS版本)",
+      "ClientConfig must specify the DWS version(ClientConfig必须指定DWS版本)");
+  /** 错误码 */
+  private int errorCode;
+  /** 错误描述 */
+  private String errorDesc;
+  /** 错误可能出现的原因 */
+  private String comment;
+
+  LinkisGwHttpclientSupportErrorCodeSummary(int errorCode, String errorDesc, 
String comment) {
+    this.errorCode = errorCode;
+    this.errorDesc = errorDesc;
+    this.comment = comment;
+  }
+
+  public int getErrorCode() {
+    return errorCode;
+  }
+
+  public void setErrorCode(int errorCode) {
+    this.errorCode = errorCode;
+  }
+
+  public String getErrorDesc() {
+    return errorDesc;
+  }
+
+  public void setErrorDesc(String errorDesc) {
+    this.errorDesc = errorDesc;
+  }
+
+  public String getComment() {
+    return comment;
+  }
+
+  public void setComment(String comment) {
+    this.comment = comment;
+  }
+
+  @Override
+  public String toString() {
+    return "errorCode: " + this.errorCode + ", errorDesc:" + this.errorDesc;
+  }
+}
diff --git 
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/StaticAuthenticationStrategy.scala
 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/StaticAuthenticationStrategy.scala
index 80682268e..2bd50a1ac 100644
--- 
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/StaticAuthenticationStrategy.scala
+++ 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/StaticAuthenticationStrategy.scala
@@ -27,6 +27,7 @@ import org.apache.linkis.httpclient.authentication.{
 import org.apache.linkis.httpclient.dws.exception.AuthenticationFailedException
 import org.apache.linkis.httpclient.dws.request.DWSAuthenticationAction
 import org.apache.linkis.httpclient.dws.response.DWSAuthenticationResult
+import 
org.apache.linkis.httpclient.errorcode.LinkisGwHttpclientSupportErrorCodeSummary.AUTHTOKENVALUE_BE_EXISTS
 import org.apache.linkis.httpclient.request.{Action, UserAction, UserPwdAction}
 
 import org.apache.commons.lang3.StringUtils
@@ -64,9 +65,7 @@ class StaticAuthenticationStrategy(override protected val 
sessionMaxAliveTime: L
     def pwd: String = if 
(StringUtils.isNotBlank(getClientConfig.getAuthTokenValue)) {
       getClientConfig.getAuthTokenValue
     } else {
-      throw new AuthenticationFailedException(
-        "the value of authTokenValue in ClientConfig must be exists, since no 
password is found to login."
-      )
+      throw new 
AuthenticationFailedException(AUTHTOKENVALUE_BE_EXISTS.getErrorDesc)
     }
 
     requestAction match {
@@ -78,9 +77,7 @@ class StaticAuthenticationStrategy(override protected val 
sessionMaxAliveTime: L
         action.addRequestPayload("password", pwd)
       case _ =>
         if (StringUtils.isBlank(getClientConfig.getAuthTokenKey)) {
-          throw new AuthenticationFailedException(
-            "the value of authTokenKey in ClientConfig must be exists, since 
no user is found to login."
-          )
+          throw new 
AuthenticationFailedException(AUTHTOKENVALUE_BE_EXISTS.getErrorDesc)
         }
         action.addRequestPayload("userName", getClientConfig.getAuthTokenKey)
         action.addRequestPayload("password", pwd)
diff --git 
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/TokenAuthenticationStrategy.scala
 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/TokenAuthenticationStrategy.scala
index 899cdbe2a..e2a0843b7 100644
--- 
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/TokenAuthenticationStrategy.scala
+++ 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/authentication/TokenAuthenticationStrategy.scala
@@ -19,6 +19,7 @@ package org.apache.linkis.httpclient.dws.authentication
 
 import org.apache.linkis.httpclient.authentication._
 import org.apache.linkis.httpclient.dws.exception.AuthenticationFailedException
+import 
org.apache.linkis.httpclient.errorcode.LinkisGwHttpclientSupportErrorCodeSummary.TOKEN_AUTHENTICATION
 import org.apache.linkis.httpclient.request.{Action, UserAction}
 
 import org.apache.http.HttpResponse
@@ -53,9 +54,7 @@ class TokenAuthenticationStrategy(override protected val 
sessionMaxAliveTime: Lo
           override def updateLastAccessTime(): Unit = {}
         }
       case _ =>
-        throw new AuthenticationFailedException(
-          "cannot use token authentication, since no user is found to proxy."
-        )
+        throw new 
AuthenticationFailedException(TOKEN_AUTHENTICATION.getErrorDesc)
     }
 
   override protected def getAuthenticationAction(
diff --git 
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/exception/AuthenticationFailedException.scala
 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/exception/AuthenticationFailedException.scala
index 5adaa8121..11c4d2455 100644
--- 
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/exception/AuthenticationFailedException.scala
+++ 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/exception/AuthenticationFailedException.scala
@@ -18,5 +18,7 @@
 package org.apache.linkis.httpclient.dws.exception
 
 import org.apache.linkis.common.exception.ErrorException
+import 
org.apache.linkis.httpclient.errorcode.LinkisGwHttpclientSupportErrorCodeSummary.AUTHTOKENVALUE_BE_EXISTS
 
-class AuthenticationFailedException(errorDesc: String) extends 
ErrorException(10901, errorDesc)
+class AuthenticationFailedException(errorDesc: String)
+    extends ErrorException(AUTHTOKENVALUE_BE_EXISTS.getErrorCode, errorDesc)
diff --git 
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/exception/UnknownVersionException.scala
 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/exception/UnknownVersionException.scala
index 8df3d6941..5f2db3c42 100644
--- 
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/exception/UnknownVersionException.scala
+++ 
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/src/main/scala/org/apache/linkis/httpclient/dws/exception/UnknownVersionException.scala
@@ -18,9 +18,7 @@
 package org.apache.linkis.httpclient.dws.exception
 
 import org.apache.linkis.common.exception.ErrorException
+import 
org.apache.linkis.httpclient.errorcode.LinkisGwHttpclientSupportErrorCodeSummary.CLIENTCONFIG_MUST
 
 class UnknownVersionException
-    extends ErrorException(
-      10901,
-      "ClientConfig must specify the DWS version(ClientConfig必须指定DWS版本)!"
-    )
+    extends ErrorException(CLIENTCONFIG_MUST.getErrorCode, 
CLIENTCONFIG_MUST.getErrorDesc)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to