diff --git a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java index 3f59d2509c..0df75f36db 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java @@ -115,6 +115,8 @@ public class DatasourceServer implements DatasourceApi { all_scope, add_scope } + public static final List notFullDs = List.of("folder", "Excel", "API"); + private TypeReference> listTypeReference = new TypeReference>() { }; @Resource @@ -152,7 +154,7 @@ public class DatasourceServer implements DatasourceApi { DatasourceConfiguration configuration = JsonUtil.parseObject(dataSourceDTO.getConfiguration(), DatasourceConfiguration.class); boolean hasRepeat = false; for (CoreDatasource datasource : datasources) { - if (Arrays.asList("API", "Excel", "folder").contains(datasource.getType())) { + if (notFullDs.stream().anyMatch(e -> datasource.getType().contains(e))) { continue; } if (StringUtils.isEmpty(datasource.getConfiguration())) { @@ -699,9 +701,8 @@ public class DatasourceServer implements DatasourceApi { datasourceTaskServer.deleteByDSId(datasourceId); } - datasourceMapper.deleteById(datasourceId); - if (!Arrays.asList("API", "Excel", "folder", "APILark", "ExcelRemote").contains(coreDatasource.getType())) { + if (notFullDs.stream().allMatch(e -> !coreDatasource.getType().contains(e))) { calciteProvider.delete(coreDatasource); } diff --git a/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java b/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java index 1f8b91707d..7a23d6bd25 100755 --- a/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java +++ b/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java @@ -67,6 +67,7 @@ public class HttpClientUtil { throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage()); } } + private static CloseableHttpClient buildHttpClient(boolean ssl) { try { if (ssl) { @@ -381,17 +382,13 @@ public class HttpClientUtil { String tranName = UUID.randomUUID().toString() + "." + suffix; name.put("fileName", fileName); name.put("tranName", tranName); - try { - FileOutputStream outputStream = new FileOutputStream(path + tranName); - byte[] buffer = new byte[4096]; - int bytesRead; - while ((bytesRead = response.getEntity().getContent().read(buffer)) != -1) { - outputStream.write(buffer, 0, bytesRead); - } - } finally { - + File localFile = new File(path + tranName); + FileOutputStream outputStream = new FileOutputStream(localFile); + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = response.getEntity().getContent().read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); } - } catch (Exception e) { logger.error("HttpClient查询失败", e); throw new RuntimeException("HttpClient查询失败: " + e.getMessage(), e);