diff --git a/system-setting/backend/src/main/java/io/metersphere/service/PluginService.java b/system-setting/backend/src/main/java/io/metersphere/service/PluginService.java index c4911f48b5..5016f58f96 100644 --- a/system-setting/backend/src/main/java/io/metersphere/service/PluginService.java +++ b/system-setting/backend/src/main/java/io/metersphere/service/PluginService.java @@ -11,6 +11,7 @@ import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.FileUtils; import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.i18n.Translator; import io.metersphere.log.utils.ReflexObjectUtil; import io.metersphere.log.vo.DetailColumn; import io.metersphere.log.vo.OperatingLogDetails; @@ -126,19 +127,26 @@ public class PluginService { public void addPlugin(MultipartFile file, String scenario) { checkPluginExist(file); - if (StringUtils.equalsIgnoreCase(scenario, PluginScenario.platform.name())) { - PluginWithBLOBs plugin = platformPluginService.addPlatformPlugin(file); - platformPluginService.notifiedPlatformPluginAdd(plugin.getId()); - } else { - List plugins = apiPluginService.addApiPlugin(file); - plugins.forEach(this::addPlugin); - // 存入MinIO - if (CollectionUtils.isNotEmpty(plugins)) { - String pluginId = plugins.get(0).getPluginId(); - FileRequest request = getRequest(pluginId); - fileManagerService.upload(file, request); + try { + if (StringUtils.equalsIgnoreCase(scenario, PluginScenario.platform.name())) { + PluginWithBLOBs plugin = platformPluginService.addPlatformPlugin(file); + platformPluginService.notifiedPlatformPluginAdd(plugin.getId()); + } else { + List plugins = apiPluginService.addApiPlugin(file); + plugins.forEach(this::addPlugin); + // 存入MinIO + if (CollectionUtils.isNotEmpty(plugins)) { + String pluginId = plugins.get(0).getPluginId(); + FileRequest request = getRequest(pluginId); + fileManagerService.upload(file, request); + } else { + MSException.throwException(Translator.get("plugin_parse_error")); + } } + } catch (Exception ex) { + MSException.throwException(Translator.get("plugin_parse_error")); } + } private FileRequest getRequest(String pluginId) { diff --git a/system-setting/backend/src/main/resources/i18n/messages_en_US.properties b/system-setting/backend/src/main/resources/i18n/messages_en_US.properties index bbce8df8aa..fd0a198d27 100644 --- a/system-setting/backend/src/main/resources/i18n/messages_en_US.properties +++ b/system-setting/backend/src/main/resources/i18n/messages_en_US.properties @@ -2,4 +2,5 @@ error_lang_invalid=Invalid language parameter, new read_permission_file_fail=Failed to read permission file! platform_plugin_not_exit=Platform docking function has been plug-in, please download the corresponding version of the plug-in: workspace_name_exceeds_length_limit=Workspace name exceeds length limit -platform_plugin_exit=plugin is already exist! \ No newline at end of file +platform_plugin_exit=plugin is already exist! +plugin_parse_error=Plugin parse error \ No newline at end of file diff --git a/system-setting/backend/src/main/resources/i18n/messages_zh_CN.properties b/system-setting/backend/src/main/resources/i18n/messages_zh_CN.properties index ba6e80f19f..ca8a37a151 100644 --- a/system-setting/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/system-setting/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -2,4 +2,5 @@ error_lang_invalid=语言参数错误, 新 read_permission_file_fail=读取权限文件失败! platform_plugin_not_exit=平台对接功能已插件化,请下载对应版本的插件: workspace_name_exceeds_length_limit=工作空间名称超出长度限制 -platform_plugin_exit=插件已存在! \ No newline at end of file +platform_plugin_exit=插件已存在! +plugin_parse_error=插件解析失败 \ No newline at end of file diff --git a/system-setting/backend/src/main/resources/i18n/messages_zh_TW.properties b/system-setting/backend/src/main/resources/i18n/messages_zh_TW.properties index 782c4064b5..c41c3e72b7 100644 --- a/system-setting/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/system-setting/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -2,4 +2,5 @@ error_lang_invalid=語言參數錯誤,新 read_permission_file_fail=讀取權限文件失敗! platform_plugin_not_exit=平臺對接功能已插件化,請下載對應版本的插件: workspace_name_exceeds_length_limit=工作空間名稱超出長度限制 -platform_plugin_exit=插件已存在! \ No newline at end of file +platform_plugin_exit=插件已存在! +plugin_parse_error=插件解析失敗! \ No newline at end of file