mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
sonarqube质量修复
This commit is contained in:
+1
@@ -23,6 +23,7 @@ public class ErrorCodeConstants {
|
||||
public static final ErrorCode FILE_NOT_EXISTS = new ErrorCode(1_001_003_001, "文件不存在");
|
||||
public static final ErrorCode FILE_IS_EMPTY = new ErrorCode(1_001_003_002, "文件为空");
|
||||
public static final ErrorCode FILE_REMOVE_FAIL = new ErrorCode(1_001_003_003, "文件删除失败");
|
||||
public static final ErrorCode FILE_OUTPUT_ERROR = new ErrorCode(1_001_003_004, "文件{}输出错误");
|
||||
|
||||
// ========== 代码生成器 1-001-004-000 ==========
|
||||
public static final ErrorCode CODEGEN_TABLE_EXISTS = new ErrorCode(1_003_001_000, "表定义已经存在");
|
||||
|
||||
+3
-2
@@ -599,7 +599,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
// 获取文件名
|
||||
String filename = file.getName();
|
||||
// 将文件写入输入流
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
try (FileInputStream fis = new FileInputStream(file);
|
||||
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
|
||||
byte[] buffer = new byte[fis.available()];
|
||||
fis.read(buffer);
|
||||
fis.close();
|
||||
@@ -608,7 +609,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
|
||||
response.addHeader("Content-Length", "" + file.length());
|
||||
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
outputStream.write(buffer);
|
||||
outputStream.flush();
|
||||
|
||||
+3
-2
@@ -26,7 +26,8 @@ public class FileHelperUtil {
|
||||
// 获取文件名
|
||||
String filename = file.getName();
|
||||
// 将文件写入输入流
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
try (FileInputStream fis = new FileInputStream(file);
|
||||
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream())) {
|
||||
byte[] buffer = new byte[fis.available()];
|
||||
fis.read(buffer);
|
||||
fis.close();
|
||||
@@ -35,7 +36,7 @@ public class FileHelperUtil {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
|
||||
response.addHeader("Content-Length", "" + file.length());
|
||||
OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
outputStream.write(buffer);
|
||||
outputStream.flush();
|
||||
|
||||
+2
-34
@@ -1,8 +1,6 @@
|
||||
package com.cf.imes.module.executor.util.fileConversion.admin.api.webcad;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* @projectName: cf_imes_server
|
||||
@@ -11,38 +9,10 @@ import java.security.cert.X509Certificate;
|
||||
*/
|
||||
public class SSLUtils {
|
||||
private static void trustAllHttpsCertificates() throws Exception {
|
||||
TrustManager[] trustAllCerts = new TrustManager[1];
|
||||
TrustManager tm = new miTM();
|
||||
trustAllCerts[0] = tm;
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init(null, trustAllCerts, null);
|
||||
SSLContext sc = SSLContext.getInstance("TLSv1.2");
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
}
|
||||
|
||||
static class miTM implements TrustManager, X509TrustManager {
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isServerTrusted(X509Certificate[] certs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isClientTrusted(X509Certificate[] certs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType)
|
||||
throws CertificateException {
|
||||
return;
|
||||
}
|
||||
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType)
|
||||
throws CertificateException {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略HTTPS请求的SSL证书,必须在openConnection之前调用
|
||||
*
|
||||
@@ -50,11 +20,9 @@ public class SSLUtils {
|
||||
*/
|
||||
public static void ignoreSsl() {
|
||||
try {
|
||||
HostnameVerifier hv = new HostnameVerifier() {
|
||||
public boolean verify(String urlHostName, SSLSession session) {
|
||||
HostnameVerifier hv = (urlHostName, session) -> {
|
||||
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
trustAllHttpsCertificates();
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(hv);
|
||||
|
||||
+12
-15
@@ -2,6 +2,7 @@ package com.cf.imes.module.executor.util.fileConversion.admin.files.xml;
|
||||
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.alibaba.nacos.shaded.com.google.common.base.Function;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plate.PlateGoodDO;
|
||||
@@ -35,6 +36,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.cf.imes.module.infra.enums.ErrorCodeConstants.FILE_OUTPUT_ERROR;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class XMLUtil {
|
||||
@@ -93,18 +96,20 @@ public class XMLUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void writeErr(HttpServletResponse response, String xmlStr, String name) throws IOException {
|
||||
public static void writeErr(HttpServletResponse response, String xmlStr, String name) {
|
||||
// 设置响应头
|
||||
response.setContentType("application/xml; charset=UTF-8");
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(name, StandardCharsets.UTF_8));
|
||||
|
||||
// 获取输出流
|
||||
Writer writer = new OutputStreamWriter(response.getOutputStream(), StandardCharsets.UTF_8);
|
||||
try (Writer writer = new OutputStreamWriter(response.getOutputStream(), StandardCharsets.UTF_8)) {
|
||||
|
||||
// 输出 XML 数据
|
||||
writer.write(xmlStr);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
|
||||
// 设置响应头
|
||||
response.setContentType("application/xml; charset=UTF-8");
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(name, StandardCharsets.UTF_8.name()));
|
||||
} catch (IOException e) {
|
||||
throw ServiceExceptionUtil.exception(FILE_OUTPUT_ERROR, name);
|
||||
}
|
||||
}
|
||||
|
||||
private void setIfInvalid(Supplier<String> getter, Function<String, String> errorMessageFactory, Consumer<String> setter, boolean error) {
|
||||
@@ -1286,12 +1291,4 @@ public class XMLUtil {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
// 加工组数据对应检查
|
||||
public void checkGroupCorresponding(Map<String,Object> plateMap, List<GroupXmlVO> groupXmlVOList, AtomicBoolean flag) {
|
||||
|
||||
}
|
||||
|
||||
// 造型中孤岛对应关系检查
|
||||
public void checkIslandCorresponding(IsletXmlVOS islandXmlVOList, AtomicBoolean flag) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user