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

sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 0cb1ea34190 Remove InvalidMaskAlgorithmNameException (#30564)
0cb1ea34190 is described below

commit 0cb1ea341907e48c659c1785ff942e0137654c59
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Mar 20 19:30:13 2024 +0800

    Remove InvalidMaskAlgorithmNameException (#30564)
    
    * Rename MaskAlgorithmPropertiesChecker
    
    * Rename MaskAlgorithmPropertiesChecker
    
    * Remove InvalidMaskAlgorithmNameException
    
    * Remove InvalidMaskAlgorithmNameException
---
 .../user-manual/error-code/sql-error-code.cn.md    | 10 ++-----
 .../user-manual/error-code/sql-error-code.en.md    | 10 ++-----
 .../mask/checker/MaskRuleConfigurationChecker.java | 11 ++++----
 .../checker/InvalidMaskAlgorithmNameException.java | 33 ----------------------
 .../apache/shardingsphere/mask/rule/MaskTable.java |  4 ---
 .../AlgorithmNotFoundOnColumnException.java        |  5 ++--
 .../AlgorithmNotFoundOnTableException.java         |  2 +-
 7 files changed, 14 insertions(+), 61 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md 
b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index 11cd4a5b43c..7635045242b 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -23,8 +23,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 42S02     | 10007       | Table or view \`%s\` does not exist.               
                            |
 | 42000     | 10010       | Rule does not exist.                               
                            |
 | 44000     | 10011       | Algorithm '%s.'%s' initialization failed, reason 
is: %s.                       |
-| 44000     | 10012       | Can not find '%s' algorithm on table '%s'.         
                            |
-| 44000     | 10013       | Can not find '%s' algorithm '%s' on table.column 
'%s'.'%s'.                    |
+| 42S02     | 10012       | Can not find '%s' algorithm on table '%s'.         
                            |
+| 42S02     | 10013       | Can not find '%s' algorithm '%s' on 
database.table.column '%s'.'%s'.'%s'.      |
 | HY000     | 10015       | Algorithm '%s.%s' execute failed, reason is: %s.   
                            |
 | 42S02     | 10020       | Schema \`%s\` does not exist.                      
                            |
 | 42S02     | 10021       | Single table \`%s\` does not exist.                
                            |
@@ -272,12 +272,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 42000     | 20840       | Insert value of index \`%s\` can not support for 
shadow.                                          |
 | 44000     | 20881       | Default shadow algorithm class should be implement 
HintShadowAlgorithm.                           |
 
-### 数据脱敏
-
-| SQL State | Vendor Code | 错误信息                                               
         |
-|-----------|-------------|-------------------------------------------------------------|
-| 42S02     | 20990       | Invalid mask algorithm \`%s\` in database \`%s\`.  
         |
-
 ### 联邦查询
 
 | SQL State | Vendor Code | 错误信息                                               
       |
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md 
b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 76228bf83ff..33baa394e34 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -23,8 +23,8 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 42S02     | 10007       | Table or view \`%s\` does not exist.               
                            |
 | 42000     | 10010       | Rule does not exist.                               
                            |
 | 44000     | 10011       | Algorithm '%s.'%s' initialization failed, reason 
is: %s.                       |
-| 44000     | 10012       | Can not find '%s' algorithm on table '%s'.         
                            |
-| 44000     | 10013       | Can not find '%s' algorithm '%s' on table.column 
'%s'.'%s'.                    |
+| 42S02     | 10012       | Can not find '%s' algorithm on table '%s'.         
                            |
+| 42S02     | 10013       | Can not find '%s' algorithm '%s' on 
database.table.column '%s'.'%s'.'%s'.      |
 | HY000     | 10015       | Algorithm '%s.%s' execute failed, reason is: %s.   
                            |
 | 42S02     | 10020       | Schema \`%s\` does not exist.                      
                            |
 | 42S02     | 10021       | Single table \`%s\` does not exist.                
                            |
@@ -287,12 +287,6 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 42000     | 20840       | Insert value of index \`%s\` can not support for 
shadow.                                          |
 | 44000     | 20881       | Default shadow algorithm class should be implement 
HintShadowAlgorithm.                           |
 
-### Data Masking
-
-| SQL State | Vendor Code | Reason                                             
         |
-|-----------|-------------|-------------------------------------------------------------|
-| 42S02     | 20990       | Invalid mask algorithm \`%s\` in database \`%s\`.  
         |
-
 ### SQL Federation
 
 | SQL State | Vendor Code | Reason                                             
       |
diff --git 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/checker/MaskRuleConfigurationChecker.java
 
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/checker/MaskRuleConfigurationChecker.java
index fd911e54094..1deb85c7958 100644
--- 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/checker/MaskRuleConfigurationChecker.java
+++ 
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/checker/MaskRuleConfigurationChecker.java
@@ -18,14 +18,14 @@
 package org.apache.shardingsphere.mask.checker;
 
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import 
org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmNotFoundOnColumnException;
 import 
org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationChecker;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
 import 
org.apache.shardingsphere.mask.api.config.rule.MaskColumnRuleConfiguration;
 import 
org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
 import org.apache.shardingsphere.mask.constant.MaskOrder;
-import 
org.apache.shardingsphere.mask.exception.checker.InvalidMaskAlgorithmNameException;
 
 import javax.sql.DataSource;
 import java.util.Collection;
@@ -43,13 +43,14 @@ public final class MaskRuleConfigurationChecker implements 
RuleConfigurationChec
     
     private void checkTables(final String databaseName, final 
Collection<MaskTableRuleConfiguration> tables, final Map<String, 
AlgorithmConfiguration> maskAlgorithms) {
         for (MaskTableRuleConfiguration each : tables) {
-            checkColumns(databaseName, each.getColumns(), maskAlgorithms);
+            checkColumns(databaseName, each.getName(), each.getColumns(), 
maskAlgorithms);
         }
     }
     
-    private void checkColumns(final String databaseName, final 
Collection<MaskColumnRuleConfiguration> columns, final Map<String, 
AlgorithmConfiguration> maskAlgorithms) {
+    private void checkColumns(final String databaseName, final String 
tableName, final Collection<MaskColumnRuleConfiguration> columns, final 
Map<String, AlgorithmConfiguration> maskAlgorithms) {
         for (MaskColumnRuleConfiguration each : columns) {
-            
ShardingSpherePreconditions.checkState(maskAlgorithms.containsKey(each.getMaskAlgorithm()),
 () -> new InvalidMaskAlgorithmNameException(databaseName, 
each.getMaskAlgorithm()));
+            
ShardingSpherePreconditions.checkState(maskAlgorithms.containsKey(each.getMaskAlgorithm()),
+                    () -> new AlgorithmNotFoundOnColumnException("mask", 
each.getMaskAlgorithm(), databaseName, tableName, each.getLogicColumn()));
         }
     }
     
diff --git 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/checker/InvalidMaskAlgorithmNameException.java
 
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/checker/InvalidMaskAlgorithmNameException.java
deleted file mode 100644
index 2d8549d253a..00000000000
--- 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/exception/checker/InvalidMaskAlgorithmNameException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.shardingsphere.mask.exception.checker;
-
-import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.mask.exception.MaskSQLException;
-
-/**
- * Invalid mask algorithm name exception.
- */
-public final class InvalidMaskAlgorithmNameException extends MaskSQLException {
-    
-    private static final long serialVersionUID = 1586639735142430235L;
-    
-    public InvalidMaskAlgorithmNameException(final String databaseName, final 
String maskAlgorithmName) {
-        super(XOpenSQLState.NOT_FOUND, 90, "Invalid mask algorithm `%s` in 
database `%s`.", maskAlgorithmName, databaseName);
-    }
-}
diff --git 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskTable.java
 
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskTable.java
index 81b0d171ce3..853fd9a1095 100644
--- 
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskTable.java
+++ 
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/rule/MaskTable.java
@@ -18,8 +18,6 @@
 package org.apache.shardingsphere.mask.rule;
 
 import com.cedarsoftware.util.CaseInsensitiveMap;
-import 
org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmNotFoundOnColumnException;
-import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.mask.api.config.rule.MaskColumnRuleConfiguration;
 import 
org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
 import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
@@ -37,8 +35,6 @@ public final class MaskTable {
     public MaskTable(final MaskTableRuleConfiguration config, final 
Map<String, MaskAlgorithm<?, ?>> maskAlgorithms) {
         columns = new CaseInsensitiveMap<>();
         for (MaskColumnRuleConfiguration each : config.getColumns()) {
-            
ShardingSpherePreconditions.checkState(maskAlgorithms.containsKey(each.getMaskAlgorithm()),
-                    () -> new AlgorithmNotFoundOnColumnException("mask", 
each.getMaskAlgorithm(), config.getName(), each.getLogicColumn()));
             columns.put(each.getLogicColumn(), new 
MaskColumn(each.getLogicColumn(), maskAlgorithms.get(each.getMaskAlgorithm())));
         }
     }
diff --git 
a/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmNotFoundOnColumnException.java
 
b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmNotFoundOnColumnException.java
index 4f19423d299..b4aa2962fd8 100644
--- 
a/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmNotFoundOnColumnException.java
+++ 
b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmNotFoundOnColumnException.java
@@ -27,7 +27,8 @@ public final class AlgorithmNotFoundOnColumnException extends 
MetaDataSQLExcepti
     
     private static final long serialVersionUID = -4570489906443880879L;
     
-    public AlgorithmNotFoundOnColumnException(final String algorithmType, 
final String algorithmName, final String tableName, final String columnName) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 13, "Can not find '%s' 
algorithm '%s' on table.column '%s'.'%s'.", algorithmType, algorithmName, 
tableName, columnName);
+    public AlgorithmNotFoundOnColumnException(final String algorithmType, 
final String algorithmName, final String databaseName, final String tableName, 
final String columnName) {
+        super(XOpenSQLState.NOT_FOUND, 13,
+                "Can not find '%s' algorithm '%s' on database.table.column 
'%s'.'%s'.'%s'.", algorithmType, algorithmName, databaseName, tableName, 
columnName);
     }
 }
diff --git 
a/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmNotFoundOnTableException.java
 
b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmNotFoundOnTableException.java
index f35329c21de..549e931f760 100644
--- 
a/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmNotFoundOnTableException.java
+++ 
b/infra/algorithm/core/src/main/java/org/apache/shardingsphere/infra/algorithm/core/exception/AlgorithmNotFoundOnTableException.java
@@ -28,6 +28,6 @@ public final class AlgorithmNotFoundOnTableException extends 
MetaDataSQLExceptio
     private static final long serialVersionUID = -6334833729231404326L;
     
     public AlgorithmNotFoundOnTableException(final String algorithmType, final 
String tableName) {
-        super(XOpenSQLState.CHECK_OPTION_VIOLATION, 13, "Can not find '%s' 
algorithm on table '%s'.", algorithmType, tableName);
+        super(XOpenSQLState.NOT_FOUND, 13, "Can not find '%s' algorithm on 
table '%s'.", algorithmType, tableName);
     }
 }

Reply via email to