mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 13:22:07 +08:00
sonarqube质量修复
This commit is contained in:
+9
-9
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.framework.file.core.client.s3;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.cf.imes.framework.file.core.client.AbstractFileClient;
|
||||
import io.minio.*;
|
||||
@@ -29,7 +29,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||
@Override
|
||||
protected void doInit() {
|
||||
// 补全 domain
|
||||
if (StrUtil.isEmpty(config.getDomain())) {
|
||||
if (CharSequenceUtil.isEmpty(config.getDomain())) {
|
||||
config.setDomain(buildDomain());
|
||||
}
|
||||
// 初始化客户端
|
||||
@@ -50,7 +50,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||
if (HttpUtil.isHttp(config.getEndpoint()) || HttpUtil.isHttps(config.getEndpoint())) {
|
||||
return config.getEndpoint();
|
||||
}
|
||||
return StrUtil.format("https://{}", config.getEndpoint());
|
||||
return CharSequenceUtil.format("https://{}", config.getEndpoint());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,10 +61,10 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||
private String buildDomain() {
|
||||
// 如果已经是 http 或者 https,则不进行拼接.主要适配 MinIO
|
||||
if (HttpUtil.isHttp(config.getEndpoint()) || HttpUtil.isHttps(config.getEndpoint())) {
|
||||
return StrUtil.format("{}/{}", config.getEndpoint(), config.getBucket());
|
||||
return CharSequenceUtil.format("{}/{}", config.getEndpoint(), config.getBucket());
|
||||
}
|
||||
// 阿里云、腾讯云、华为云都适合。七牛云比较特殊,必须有自定义域名
|
||||
return StrUtil.format("https://{}.{}", config.getBucket(), config.getEndpoint());
|
||||
return CharSequenceUtil.format("https://{}.{}", config.getBucket(), config.getEndpoint());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,13 +75,13 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> {
|
||||
private String buildRegion() {
|
||||
// 阿里云必须有 region,否则会报错
|
||||
if (config.getEndpoint().contains(ENDPOINT_ALIYUN)) {
|
||||
return StrUtil.subBefore(config.getEndpoint(), '.', false)
|
||||
.replaceAll("-internal", "")// 去除内网 Endpoint 的后缀
|
||||
.replaceAll("https://", "");
|
||||
return CharSequenceUtil.subBefore(config.getEndpoint(), '.', false)
|
||||
.replace("-internal", "")// 去除内网 Endpoint 的后缀
|
||||
.replace("https://", "");
|
||||
}
|
||||
// 腾讯云必须有 region,否则会报错
|
||||
if (config.getEndpoint().contains(ENDPOINT_TENCENT)) {
|
||||
return StrUtil.subAfter(config.getEndpoint(), "cos.", false)
|
||||
return CharSequenceUtil.subAfter(config.getEndpoint(), "cos.", false)
|
||||
.replaceAll("." + ENDPOINT_TENCENT, ""); // 去除 Endpoint
|
||||
}
|
||||
return null;
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.framework.file.core.client.s3;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.cf.imes.framework.file.core.client.FileClientConfig;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
@@ -68,7 +68,7 @@ public class S3FileClientConfig implements FileClientConfig {
|
||||
@JsonIgnore
|
||||
public boolean isDomainValid() {
|
||||
// 如果是七牛,必须带有 domain
|
||||
if (StrUtil.contains(endpoint, ENDPOINT_QINIU) && StrUtil.isEmpty(domain)) {
|
||||
if (CharSequenceUtil.contains(endpoint, ENDPOINT_QINIU) && CharSequenceUtil.isEmpty(domain)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user