forked from github/dataease
fix: API数据源API地址错误提示信息优化
This commit is contained in:
parent
27912dfb1b
commit
cb9d94639a
@ -125,10 +125,12 @@ public class DatasourceServer implements DatasourceApi {
|
|||||||
if (Objects.equals(dataSourceDTO.getId(), dataSourceDTO.getPid())) {
|
if (Objects.equals(dataSourceDTO.getId(), dataSourceDTO.getPid())) {
|
||||||
DEException.throwException(Translator.get("i18n_pid_not_eq_id"));
|
DEException.throwException(Translator.get("i18n_pid_not_eq_id"));
|
||||||
}
|
}
|
||||||
List<Long> ids = new ArrayList<>();
|
if (dataSourceDTO.getPid() != 0) {
|
||||||
getParents(dataSourceDTO.getPid(), ids);
|
List<Long> ids = new ArrayList<>();
|
||||||
if (ids.contains(dataSourceDTO.getId())) {
|
getParents(dataSourceDTO.getPid(), ids);
|
||||||
DEException.throwException(Translator.get("i18n_pid_not_eq_id"));
|
if (ids.contains(dataSourceDTO.getId())) {
|
||||||
|
DEException.throwException(Translator.get("i18n_pid_not_eq_id"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dataSourceManage.move(dataSourceDTO);
|
dataSourceManage.move(dataSourceDTO);
|
||||||
}
|
}
|
||||||
|
@ -78,13 +78,14 @@ public class HttpClientUtil {
|
|||||||
* @return 响应结果字符串
|
* @return 响应结果字符串
|
||||||
*/
|
*/
|
||||||
public static String get(String url, HttpClientConfig config) {
|
public static String get(String url, HttpClientConfig config) {
|
||||||
CloseableHttpClient httpClient = buildHttpClient(url);
|
CloseableHttpClient httpClient = null;
|
||||||
HttpGet httpGet = new HttpGet(url);
|
|
||||||
|
|
||||||
if (config == null) {
|
|
||||||
config = new HttpClientConfig();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
httpClient = buildHttpClient(url);
|
||||||
|
HttpGet httpGet = new HttpGet(url);
|
||||||
|
|
||||||
|
if (config == null) {
|
||||||
|
config = new HttpClientConfig();
|
||||||
|
}
|
||||||
httpGet.setConfig(config.buildRequestConfig());
|
httpGet.setConfig(config.buildRequestConfig());
|
||||||
|
|
||||||
Map<String, String> header = config.getHeader();
|
Map<String, String> header = config.getHeader();
|
||||||
@ -98,7 +99,9 @@ public class HttpClientUtil {
|
|||||||
throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage());
|
throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
httpClient.close();
|
if(httpClient != null){
|
||||||
|
httpClient.close();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("HttpClient关闭连接失败", e);
|
logger.error("HttpClient关闭连接失败", e);
|
||||||
}
|
}
|
||||||
@ -143,14 +146,14 @@ public class HttpClientUtil {
|
|||||||
* @return 响应结果字符串
|
* @return 响应结果字符串
|
||||||
*/
|
*/
|
||||||
public static String post(String url, String json, HttpClientConfig config) {
|
public static String post(String url, String json, HttpClientConfig config) {
|
||||||
CloseableHttpClient httpClient = buildHttpClient(url);
|
CloseableHttpClient httpClient = null;
|
||||||
HttpPost httpPost = new HttpPost(url);
|
|
||||||
if (config == null) {
|
|
||||||
config = new HttpClientConfig();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
buildHttpClient(url);
|
||||||
|
HttpPost httpPost = new HttpPost(url);
|
||||||
|
if (config == null) {
|
||||||
|
config = new HttpClientConfig();
|
||||||
|
}
|
||||||
httpPost.setConfig(config.buildRequestConfig());
|
httpPost.setConfig(config.buildRequestConfig());
|
||||||
|
|
||||||
Map<String, String> header = config.getHeader();
|
Map<String, String> header = config.getHeader();
|
||||||
for (String key : header.keySet()) {
|
for (String key : header.keySet()) {
|
||||||
httpPost.addHeader(key, header.get(key));
|
httpPost.addHeader(key, header.get(key));
|
||||||
@ -168,7 +171,9 @@ public class HttpClientUtil {
|
|||||||
throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage());
|
throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
httpClient.close();
|
if(httpClient != null){
|
||||||
|
httpClient.close();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("HttpClient关闭连接失败", e);
|
logger.error("HttpClient关闭连接失败", e);
|
||||||
}
|
}
|
||||||
@ -195,14 +200,15 @@ public class HttpClientUtil {
|
|||||||
* @return 响应结果字符串
|
* @return 响应结果字符串
|
||||||
*/
|
*/
|
||||||
public static String post(String url, Map<String, String> body, HttpClientConfig config) {
|
public static String post(String url, Map<String, String> body, HttpClientConfig config) {
|
||||||
CloseableHttpClient httpClient = buildHttpClient(url);
|
CloseableHttpClient httpClient = null;
|
||||||
HttpPost httpPost = new HttpPost(url);
|
|
||||||
if (config == null) {
|
|
||||||
config = new HttpClientConfig();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
httpPost.setConfig(config.buildRequestConfig());
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
buildHttpClient(url);
|
||||||
|
HttpPost httpPost = new HttpPost(url);
|
||||||
|
if (config == null) {
|
||||||
|
config = new HttpClientConfig();
|
||||||
|
}
|
||||||
|
httpPost.setConfig(config.buildRequestConfig());
|
||||||
Map<String, String> header = config.getHeader();
|
Map<String, String> header = config.getHeader();
|
||||||
for (String key : header.keySet()) {
|
for (String key : header.keySet()) {
|
||||||
httpPost.addHeader(key, header.get(key));
|
httpPost.addHeader(key, header.get(key));
|
||||||
@ -227,7 +233,9 @@ public class HttpClientUtil {
|
|||||||
throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage());
|
throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
httpClient.close();
|
if(httpClient != null){
|
||||||
|
httpClient.close();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("HttpClient关闭连接失败", e);
|
logger.error("HttpClient关闭连接失败", e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user