mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
This commit is contained in:
@@ -202,6 +202,12 @@ public class ModelServiceImpl implements ModelService {
|
|||||||
String message = String.format("模型名称[%s]包含特殊字符(%s), 请修改", modelReq.getName(), forbiddenCharacters);
|
String message = String.format("模型名称[%s]包含特殊字符(%s), 请修改", modelReq.getName(), forbiddenCharacters);
|
||||||
throw new InvalidArgumentException(message);
|
throw new InvalidArgumentException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!NameCheckUtils.isValidIdentifier(modelReq.getBizName())) {
|
||||||
|
String message = String.format("模型英文名[%s]需要为下划线字母数字组合, 请修改", modelReq.getBizName());
|
||||||
|
throw new InvalidArgumentException(message);
|
||||||
|
}
|
||||||
|
|
||||||
List<Dim> dims = modelReq.getModelDetail().getDimensions();
|
List<Dim> dims = modelReq.getModelDetail().getDimensions();
|
||||||
List<Measure> measures = modelReq.getModelDetail().getMeasures();
|
List<Measure> measures = modelReq.getModelDetail().getMeasures();
|
||||||
List<Identify> identifies = modelReq.getModelDetail().getIdentifiers();
|
List<Identify> identifies = modelReq.getModelDetail().getIdentifiers();
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class NameCheckUtils {
|
public class NameCheckUtils {
|
||||||
|
|
||||||
public static final String forbiddenCharactersRegex = "[()%#()]";
|
public static final String forbiddenCharactersRegex = "[()%#()]";
|
||||||
|
public static final String identifierRegex = "^[_a-zA-Z0-9]+$";
|
||||||
|
|
||||||
public static String findForbiddenCharacters(String str) {
|
public static String findForbiddenCharacters(String str) {
|
||||||
if (StringUtils.isBlank(str)) {
|
if (StringUtils.isBlank(str)) {
|
||||||
@@ -22,4 +24,13 @@ public class NameCheckUtils {
|
|||||||
return foundCharacters.toString().trim();
|
return foundCharacters.toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Boolean isValidIdentifier(String str) {
|
||||||
|
if (StringUtils.isBlank(str)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Pattern pattern = Pattern.compile(identifierRegex);
|
||||||
|
Matcher matcher = pattern.matcher(str);
|
||||||
|
return matcher.find();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user