Skip to content

Commit

Permalink
pref:完善研发商店组件配置文件参数校验 #11269
Browse files Browse the repository at this point in the history
  • Loading branch information
Kzhou991 committed Dec 20, 2024
1 parent 648c089 commit 85041cf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ object StoreMessageCode {
const val ATOM_PACKAGE_FILE_NOT_FOUND = "2120042"
const val USER_REPOSITORY_TASK_JSON_SUBFIELD_IS_NOT_SUPPORT = "2120043" // 研发商店:插件配置文件[task.json]{0}字段里面的{1}字段暂时只支持{2}
const val USER_REPOSITORY_TASK_JSON_FIELD_IS_NOT_SUPPORT= "2120044" // 研发商店:插件配置文件[task.json]{0}字段暂时只支持{1}

const val USER_REPOSITORY_TASK_JSON_SUBFIELD_IS_NULL = "2120045" // 研发商店:插件配置文件[task.json]{0}字段里面的{1}字段不能为空
const val USER_REPOSITORY_TASK_JSON_SUBFIELD_IS_INVALID = "2120046" // 研发商店:插件配置文件[task.json]{0}字段里面的{1}字段格式不正确,请检查
const val USER_TEMPLATE_VERSION_IS_NOT_FINISH = "2120201" // 研发商店:模板{0}的{1}版本发布未结束,请稍后再试
const val USER_TEMPLATE_RELEASE_STEPS_ERROR = "2120202" // 研发商店:模板发布流程状态变更顺序不正确
const val USER_TEMPLATE_ATOM_VISIBLE_DEPT_IS_INVALID = "2120203" // 研发商店:模板的可见范围不在插件{0}的可见范围之内,如有需要请联系插件的发布者
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ class MarketAtomCommonServiceImpl : MarketAtomCommonService {
validateTaskJsonField(
dataMap = osExecutionInfoMap,
fieldName = KEY_TARGET,
parentFieldName = KEY_OS,
expectedType = String::class
)
val target = osExecutionInfoMap[KEY_TARGET].toString()
Expand Down Expand Up @@ -583,19 +584,33 @@ class MarketAtomCommonServiceImpl : MarketAtomCommonService {

val fieldValue = dataMap[fieldName]
if (checkForBlank) {
if (fieldValue == null || (fieldValue is String && fieldValue.isEmpty())) {
if (fieldValue == null || (fieldValue is String && fieldValue.isBlank())) {
if (parentFieldName != null) {
throw ErrorCodeException(
errorCode = StoreMessageCode.USER_REPOSITORY_TASK_JSON_SUBFIELD_IS_NULL,
params = arrayOf(parentFieldName,fieldName)
)
}else{
throw ErrorCodeException(
errorCode = StoreMessageCode.USER_REPOSITORY_TASK_JSON_FIELD_IS_NULL,
params = arrayOf(fieldName)
)
}
}
}
if (!expectedType.isInstance(fieldValue)) {
if (parentFieldName != null) {
throw ErrorCodeException(
errorCode = StoreMessageCode.USER_REPOSITORY_TASK_JSON_SUBFIELD_IS_INVALID,
params = arrayOf(parentFieldName,fieldName)
)
}else{
throw ErrorCodeException(
errorCode = StoreMessageCode.USER_REPOSITORY_TASK_JSON_FIELD_IS_NULL,
errorCode = StoreMessageCode.USER_REPOSITORY_TASK_JSON_FIELD_IS_INVALID,
params = arrayOf(fieldName)
)
}
}
if (!expectedType.isInstance(fieldValue)) {
throw ErrorCodeException(
errorCode = StoreMessageCode.USER_REPOSITORY_TASK_JSON_FIELD_IS_INVALID,
params = arrayOf(fieldName)
)
}

if (supportedFieldTypeCheck) {
if (supportedFieldTypes != null && fieldValue !in supportedFieldTypes) {
Expand Down
6 changes: 4 additions & 2 deletions support-files/i18n/store/message_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
2120040=store: Atom configuration file [task.json] config format is incorrect.{0}
2120041=store: pull file[{0}]failed,fail cause:{1}
2120042=atom file [{0}] not exist,please check that the file is located in the correct path
2120043=store: In the plugin configuration file [task.json], the field {0} contains the subfield {1}, which currently only supports {2}
2120044=store: In the plugin configuration file [task.json], the field {0} currently only supports {1}
2120043=store:In the plugin configuration file [task.json], the field {1} in {0} currently only supports {2}.
2120044=store:In the plugin configuration file [task.json], the field {0} currently only supports {1}
2120045=store:In the plugin configuration file [task.json], the field {1} in {0} cannot be empty.
2120046=store:In the plugin configuration file [task.json], the format of the field {1} in {0} is incorrect. Please check.
2120201=store: the release of {1} version of template {0} is not over. Please try again later.
2120202=store: template release process status change order is incorrect
2120203=store: the visible range of the template is not within the visible range of the atom {0}. If necessary, please contact the publisher of the atom.
Expand Down
2 changes: 2 additions & 0 deletions support-files/i18n/store/message_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
2120042=插件包文件[{0}]不存在,请检查文件所在路径是否正确
2120043=研发商店:插件配置文件[task.json]{0}字段里面的{1}字段暂时只支持{2}
2120044=研发商店:插件配置文件[task.json]{0}字段暂时只支持{1}
2120045=研发商店:插件配置文件[task.json]{0}字段里面的{1}字段不能为空
2120046=研发商店:插件配置文件[task.json]{0}字段里面的{1}字段格式不正确,请检查
2120201=研发商店: 模板{0}的{1}版本发布未结束,请稍后再试
2120202=研发商店: 模板发布流程状态变更顺序不正确
2120203=研发商店: 模板的可见范围不在插件{0}的可见范围之内,如有需要请联系插件的发布者
Expand Down

0 comments on commit 85041cf

Please sign in to comment.