This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 6cedc3b4ce5 Merge MissingEncryptorException (#26044)
6cedc3b4ce5 is described below
commit 6cedc3b4ce5a23d21cb91414e520becf3f371ec1
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jun 4 20:35:59 2023 +0800
Merge MissingEncryptorException (#26044)
---
.../user-manual/error-code/sql-error-code.cn.md | 4 +--
.../user-manual/error-code/sql-error-code.en.md | 4 +--
.../checker/EncryptRuleConfigurationChecker.java | 8 ++----
.../MissingAssistedQueryEncryptorException.java | 33 ----------------------
.../metadata/MissingEncryptorException.java | 4 +--
.../MissingLikeQueryEncryptorException.java | 33 ----------------------
.../shardingsphere/encrypt/rule/EncryptRule.java | 8 ++----
7 files changed, 10 insertions(+), 84 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 0fadca54c86..ef786510acb 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
@@ -255,11 +255,9 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| HY004 | 20780 | Encrypt algorithm \`%s\` initialization failed,
reason is: %s. |
| HY004 | 20781 | \`%s\` column's encryptor name \`%s\` does not
match encrypt algorithm type \`%s\`. |
| 44000 | 20703 | Cipher column of \`%s\` can not be null in
database \`%s\`. |
-| 44000 | 20704 | Can not found encryptor in table \`%s\` and column
\`%s\`. |
+| 44000 | 20704 | Can not find (STANDARD\|ASSIST_QUERY\|LIKE_QUERY)
encryptor in table \`%s\` and column \`%s\`. |
| 44000 | 20705 | Assisted query column of \`%s\` can not be null in
database \`%s\`. |
-| 44000 | 20706 | Can not found assist query encryptor in table
\`%s\` and column \`%s\`. |
| 44000 | 20707 | Like query column of \`%s\` can not be null in
database \`%s\`. |
-| 44000 | 20708 | Can not found like query encryptor in table \`%s\`
and column \`%s\`. |
| 44000 | 20709 | Can not find encrypt table: \`%s\`.
|
| 44000 | 20710 | Can not found registered encryptor \`%s\` in
database \`%s\`. |
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 5f7a4d4aaa9..7fe1c61e5ab 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
@@ -270,11 +270,9 @@ SQL error codes provide by standard `SQL State`, `Vendor
Code` and `Reason`, whi
| HY004 | 20780 | Encrypt algorithm \`%s\` initialization failed,
reason is: %s. |
| HY004 | 20781 | \`%s\` column's encryptor name \`%s\` does not
match encrypt algorithm type \`%s\`. |
| 44000 | 20703 | Cipher column of \`%s\` can not be null in
database \`%s\`. |
-| 44000 | 20704 | Can not found encryptor in table \`%s\` and column
\`%s\`. |
+| 44000 | 20704 | Can not find (STANDARD\|ASSIST_QUERY\|LIKE_QUERY)
encryptor in table \`%s\` and column \`%s\`. |
| 44000 | 20705 | Assisted query column of \`%s\` can not be null in
database \`%s\`. |
-| 44000 | 20706 | Can not found assist query encryptor in table
\`%s\` and column \`%s\`. |
| 44000 | 20707 | Like query column of \`%s\` can not be null in
database \`%s\`. |
-| 44000 | 20708 | Can not found like query encryptor in table \`%s\`
and column \`%s\`. |
| 44000 | 20709 | Can not find encrypt table: \`%s\`.
|
| 44000 | 20710 | Can not found registered encryptor \`%s\` in
database \`%s\`. |
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
index 7ab4756fd60..92d7157dfd4 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationChecker.java
@@ -23,11 +23,9 @@ import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleCo
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.constant.EncryptOrder;
-import
org.apache.shardingsphere.encrypt.exception.metadata.MissingAssistedQueryEncryptorException;
import
org.apache.shardingsphere.encrypt.exception.metadata.EncryptAssistedQueryColumnNotFoundException;
import
org.apache.shardingsphere.encrypt.exception.metadata.EncryptCipherColumnNotFoundException;
import
org.apache.shardingsphere.encrypt.exception.metadata.EncryptLikeQueryColumnNotFoundException;
-import
org.apache.shardingsphere.encrypt.exception.metadata.MissingLikeQueryEncryptorException;
import
org.apache.shardingsphere.encrypt.exception.metadata.MissingEncryptorException;
import
org.apache.shardingsphere.encrypt.exception.metadata.UnregisteredEncryptorException;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
@@ -66,7 +64,7 @@ public final class EncryptRuleConfigurationChecker implements
RuleConfigurationC
private void checkCipherColumnConfiguration(final String databaseName,
final String tableName, final String logicColumnName,
final
EncryptColumnItemRuleConfiguration cipherColumnConfig, final Map<String,
AlgorithmConfiguration> encryptors) {
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(cipherColumnConfig.getName()),
() -> new EncryptCipherColumnNotFoundException(logicColumnName, databaseName));
-
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(cipherColumnConfig.getEncryptorName()),
() -> new MissingEncryptorException(tableName, logicColumnName));
+
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(cipherColumnConfig.getEncryptorName()),
() -> new MissingEncryptorException(tableName, logicColumnName, "STANDARD"));
ShardingSpherePreconditions.checkState(encryptors.containsKey(cipherColumnConfig.getEncryptorName()),
() -> new UnregisteredEncryptorException(databaseName,
cipherColumnConfig.getEncryptorName()));
}
@@ -74,7 +72,7 @@ public final class EncryptRuleConfigurationChecker implements
RuleConfigurationC
private void checkAssistColumnConfiguration(final String databaseName,
final String tableName, final String logicColumnName,
final
EncryptColumnItemRuleConfiguration assistedQueryColumnConfig, final Map<String,
AlgorithmConfiguration> encryptors) {
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(assistedQueryColumnConfig.getName()),
() -> new EncryptAssistedQueryColumnNotFoundException(logicColumnName,
databaseName));
-
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(assistedQueryColumnConfig.getEncryptorName()),
() -> new MissingAssistedQueryEncryptorException(tableName, logicColumnName));
+
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(assistedQueryColumnConfig.getEncryptorName()),
() -> new MissingEncryptorException(tableName, logicColumnName,
"ASSIST_QUERY"));
ShardingSpherePreconditions.checkState(
encryptors.containsKey(assistedQueryColumnConfig.getEncryptorName()), () -> new
UnregisteredEncryptorException(databaseName,
assistedQueryColumnConfig.getEncryptorName()));
}
@@ -82,7 +80,7 @@ public final class EncryptRuleConfigurationChecker implements
RuleConfigurationC
private void checkLikeColumnConfiguration(final String databaseName, final
String tableName, final String logicColumnName,
final
EncryptColumnItemRuleConfiguration likeQueryColumnConfig, final Map<String,
AlgorithmConfiguration> encryptors) {
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(likeQueryColumnConfig.getName()),
() -> new EncryptLikeQueryColumnNotFoundException(logicColumnName,
databaseName));
-
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(likeQueryColumnConfig.getEncryptorName()),
() -> new MissingLikeQueryEncryptorException(tableName, logicColumnName));
+
ShardingSpherePreconditions.checkState(!Strings.isNullOrEmpty(likeQueryColumnConfig.getEncryptorName()),
() -> new MissingEncryptorException(tableName, logicColumnName, "LIKE_QUERY"));
ShardingSpherePreconditions.checkState(encryptors.containsKey(likeQueryColumnConfig.getEncryptorName()),
() -> new UnregisteredEncryptorException(databaseName,
likeQueryColumnConfig.getEncryptorName()));
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingAssistedQueryEncryptorException.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingAssistedQueryEncryptorException.java
deleted file mode 100644
index 847ed508a46..00000000000
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingAssistedQueryEncryptorException.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.encrypt.exception.metadata;
-
-import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
-import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
-
-/**
- * Missing assisted query encryptor exception.
- */
-public final class MissingAssistedQueryEncryptorException extends
EncryptSQLException {
-
- private static final long serialVersionUID = -8700683634804933320L;
-
- public MissingAssistedQueryEncryptorException(final String tableName,
final String logicColumnName) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 6, "Can not found assist
query encryptor in table `%s` and column `%s`.", tableName, logicColumnName);
- }
-}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingEncryptorException.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingEncryptorException.java
index 810f7f28a95..9ddaee87185 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingEncryptorException.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingEncryptorException.java
@@ -27,7 +27,7 @@ public final class MissingEncryptorException extends
EncryptSQLException {
private static final long serialVersionUID = -4847495252826650747L;
- public MissingEncryptorException(final String tableName, final String
logicColumnName) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 4, "Can not found
encryptor in table `%s` and column `%s`.", tableName, logicColumnName);
+ public MissingEncryptorException(final String tableName, final String
logicColumnName, final String encryptorType) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 4, "Can not find %s
encryptor in table `%s` and column `%s`.", encryptorType, tableName,
logicColumnName);
}
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingLikeQueryEncryptorException.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingLikeQueryEncryptorException.java
deleted file mode 100644
index e4e5720db79..00000000000
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/exception/metadata/MissingLikeQueryEncryptorException.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.encrypt.exception.metadata;
-
-import org.apache.shardingsphere.encrypt.exception.EncryptSQLException;
-import
org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
-
-/**
- * Missing like query encryptor exception.
- */
-public final class MissingLikeQueryEncryptorException extends
EncryptSQLException {
-
- private static final long serialVersionUID = 1620586484949188815L;
-
- public MissingLikeQueryEncryptorException(final String tableName, final
String logicColumnName) {
- super(XOpenSQLState.CHECK_OPTION_VIOLATION, 8, "Can not found like
query encryptor in table `%s` and column `%s`.", tableName, logicColumnName);
- }
-}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
index 5848b67063d..aff92e634e0 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
@@ -29,9 +29,7 @@ import
org.apache.shardingsphere.encrypt.api.encrypt.like.LikeEncryptAlgorithm;
import
org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm;
import org.apache.shardingsphere.encrypt.context.EncryptContextBuilder;
import
org.apache.shardingsphere.encrypt.exception.algorithm.MismatchedEncryptAlgorithmTypeException;
-import
org.apache.shardingsphere.encrypt.exception.metadata.MissingAssistedQueryEncryptorException;
import
org.apache.shardingsphere.encrypt.exception.metadata.MissingEncryptorException;
-import
org.apache.shardingsphere.encrypt.exception.metadata.MissingLikeQueryEncryptorException;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule;
@@ -183,7 +181,7 @@ public final class EncryptRule implements DatabaseRule,
TableContainedRule, Colu
public List<Object> encrypt(final String databaseName, final String
schemaName, final String tableName, final String logicColumnName, final
List<Object> originalValues) {
@SuppressWarnings("rawtypes")
Optional<StandardEncryptAlgorithm> encryptor =
findStandardEncryptor(tableName, logicColumnName);
- ShardingSpherePreconditions.checkState(encryptor.isPresent(), () ->
new MissingEncryptorException(tableName, logicColumnName));
+ ShardingSpherePreconditions.checkState(encryptor.isPresent(), () ->
new MissingEncryptorException(tableName, logicColumnName, "STANDARD"));
EncryptContext context = EncryptContextBuilder.build(databaseName,
schemaName, tableName, logicColumnName);
return encrypt(encryptor.get(), originalValues, context);
}
@@ -265,7 +263,7 @@ public final class EncryptRule implements DatabaseRule,
TableContainedRule, Colu
public List<Object> getEncryptAssistedQueryValues(final String
databaseName, final String schemaName, final String tableName, final String
logicColumnName, final List<Object> originalValues) {
@SuppressWarnings("rawtypes")
Optional<AssistedEncryptAlgorithm> assistedQueryEncryptor =
findAssistedQueryEncryptor(tableName, logicColumnName);
-
ShardingSpherePreconditions.checkState(assistedQueryEncryptor.isPresent(), ()
-> new MissingAssistedQueryEncryptorException(tableName, logicColumnName));
+
ShardingSpherePreconditions.checkState(assistedQueryEncryptor.isPresent(), ()
-> new MissingEncryptorException(tableName, logicColumnName, "ASSIST_QUERY"));
EncryptContext context = EncryptContextBuilder.build(databaseName,
schemaName, tableName, logicColumnName);
return getEncryptAssistedQueryValues(assistedQueryEncryptor.get(),
originalValues, context);
}
@@ -293,7 +291,7 @@ public final class EncryptRule implements DatabaseRule,
TableContainedRule, Colu
public List<Object> getEncryptLikeQueryValues(final String databaseName,
final String schemaName, final String tableName, final String logicColumnName,
final List<Object> originalValues) {
@SuppressWarnings("rawtypes")
Optional<LikeEncryptAlgorithm> likeQueryEncryptor =
findLikeQueryEncryptor(tableName, logicColumnName);
- ShardingSpherePreconditions.checkState(likeQueryEncryptor.isPresent(),
() -> new MissingLikeQueryEncryptorException(tableName, logicColumnName));
+ ShardingSpherePreconditions.checkState(likeQueryEncryptor.isPresent(),
() -> new MissingEncryptorException(tableName, logicColumnName, "LIKE_QUERY"));
EncryptContext context = EncryptContextBuilder.build(databaseName,
schemaName, tableName, logicColumnName);
return getEncryptLikeQueryValues(likeQueryEncryptor.get(),
originalValues, context);
}