From f7cdcea87339e23847a51b93b1f1904523cdfc4f Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Tue, 7 May 2024 19:28:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8A=E4=BC=A0DB2=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1040360 --user=陈建星 系统设置下的插件无法上传DB2的驱动 https://www.tapd.cn/55049933/s/1512699 --- .../JdbcDriverPluginDescriptorFinder.java | 22 +++++++++++++++---- .../definition/ApiDefinitionRunRequest.java | 3 --- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/plugin/JdbcDriverPluginDescriptorFinder.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/plugin/JdbcDriverPluginDescriptorFinder.java index 91bace08c2..7a0565f962 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/plugin/JdbcDriverPluginDescriptorFinder.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/plugin/JdbcDriverPluginDescriptorFinder.java @@ -1,11 +1,11 @@ package io.metersphere.sdk.plugin; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.pf4j.ManifestPluginDescriptorFinder; import org.pf4j.PluginDescriptor; import org.pf4j.PluginRuntimeException; import org.pf4j.util.FileUtils; -import org.pf4j.util.StringUtils; import java.io.IOException; import java.io.InputStream; @@ -61,18 +61,32 @@ public class JdbcDriverPluginDescriptorFinder extends ManifestPluginDescriptorFi // 将类名作为ID String id = driverClass; pluginDescriptor.setPluginId(id.split("\n")[0]); - if (StringUtils.isNullOrEmpty(id)) { + if (StringUtils.isBlank(id)) { return null; } String description = attributes.getValue("Plugin-Description"); - if (StringUtils.isNullOrEmpty(description)) { + if (StringUtils.isBlank(description)) { pluginDescriptor.setPluginDescription(""); } else { pluginDescriptor.setPluginDescription(description); } String version = attributes.getValue("Implementation-Version"); - if (StringUtils.isNotNullOrEmpty(version)) { + if (StringUtils.isNotBlank(version)) { pluginDescriptor.setPluginVersion(version); + } else { + // 如果没有 Implementation-Version 属性,就查找是否有版本相关的属性,设置为版本 + for (Object key : attributes.keySet()) { + Object var = attributes.get(key); + if (key != null && var != null && StringUtils.containsIgnoreCase(key.toString(), "Version")) { + pluginDescriptor.setPluginVersion(var.toString()); + break; + } + } + } + + if (StringUtils.isBlank(version)) { + // 没有版本相关的属性,就用id兜底 + pluginDescriptor.setPluginVersion(id); } String provider = attributes.getValue("Implementation-Vendor"); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRunRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRunRequest.java index 10d4c75811..68e9d11b01 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRunRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRunRequest.java @@ -2,7 +2,6 @@ package io.metersphere.api.dto.definition; import io.metersphere.api.dto.debug.ApiDebugRunRequest; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; import lombok.Data; @@ -12,11 +11,9 @@ public class ApiDefinitionRunRequest extends ApiDebugRunRequest { private String environmentId; @Schema(description = "http协议类型post/get/其它协议则是协议名(mqtt)") - @NotBlank private String method; @Schema(description = "http协议路径/其它协议则为空") - @NotBlank private String path; @Schema(description = "模块fk")