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;
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");

View File

@ -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")