fix(系统设置): 插件上传DB2驱动失败

--bug=1040360 --user=陈建星 系统设置下的插件无法上传DB2的驱动 https://www.tapd.cn/55049933/s/1512699
This commit is contained in:
AgAngle 2024-05-07 19:28:41 +08:00 committed by Craftsman
parent 44521c61fc
commit f7cdcea873
2 changed files with 18 additions and 7 deletions

View File

@ -1,11 +1,11 @@
package io.metersphere.sdk.plugin; package io.metersphere.sdk.plugin;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.pf4j.ManifestPluginDescriptorFinder; import org.pf4j.ManifestPluginDescriptorFinder;
import org.pf4j.PluginDescriptor; import org.pf4j.PluginDescriptor;
import org.pf4j.PluginRuntimeException; import org.pf4j.PluginRuntimeException;
import org.pf4j.util.FileUtils; import org.pf4j.util.FileUtils;
import org.pf4j.util.StringUtils;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -61,18 +61,32 @@ public class JdbcDriverPluginDescriptorFinder extends ManifestPluginDescriptorFi
// 将类名作为ID // 将类名作为ID
String id = driverClass; String id = driverClass;
pluginDescriptor.setPluginId(id.split("\n")[0]); pluginDescriptor.setPluginId(id.split("\n")[0]);
if (StringUtils.isNullOrEmpty(id)) { if (StringUtils.isBlank(id)) {
return null; return null;
} }
String description = attributes.getValue("Plugin-Description"); String description = attributes.getValue("Plugin-Description");
if (StringUtils.isNullOrEmpty(description)) { if (StringUtils.isBlank(description)) {
pluginDescriptor.setPluginDescription(""); pluginDescriptor.setPluginDescription("");
} else { } else {
pluginDescriptor.setPluginDescription(description); pluginDescriptor.setPluginDescription(description);
} }
String version = attributes.getValue("Implementation-Version"); String version = attributes.getValue("Implementation-Version");
if (StringUtils.isNotNullOrEmpty(version)) { if (StringUtils.isNotBlank(version)) {
pluginDescriptor.setPluginVersion(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"); String provider = attributes.getValue("Implementation-Vendor");

View File

@ -2,7 +2,6 @@ package io.metersphere.api.dto.definition;
import io.metersphere.api.dto.debug.ApiDebugRunRequest; import io.metersphere.api.dto.debug.ApiDebugRunRequest;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
@ -12,11 +11,9 @@ public class ApiDefinitionRunRequest extends ApiDebugRunRequest {
private String environmentId; private String environmentId;
@Schema(description = "http协议类型post/get/其它协议则是协议名(mqtt)") @Schema(description = "http协议类型post/get/其它协议则是协议名(mqtt)")
@NotBlank
private String method; private String method;
@Schema(description = "http协议路径/其它协议则为空") @Schema(description = "http协议路径/其它协议则为空")
@NotBlank
private String path; private String path;
@Schema(description = "模块fk") @Schema(description = "模块fk")