Skip to content

Commit

Permalink
Merge pull request #13 from actiontech/issue-password
Browse files Browse the repository at this point in the history
Issue password
  • Loading branch information
sjjian authored Nov 8, 2023
2 parents c12210c + 8e20859 commit 29a4b93
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 1 addition & 5 deletions src/main/java/com/actiontech/sqle/from/SQLESettingUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ protected void textChanged(@NotNull DocumentEvent e) {
@Override
protected void textChanged(@NotNull DocumentEvent e) {
String passwordContent = new String(sqlePassword.getPassword());
if (StringUtils.containsAny(NOT_SUPPORT_CHARACTER, passwordContent)) {
NotifyUtil.showNotifyPopup(sqlePassword, "Your password have special symbol, please use file config, or explain will not be used in analysis");
} else {
settings.setPassword(passwordContent);
}
settings.setPassword(passwordContent);
}
});

Expand Down
20 changes: 12 additions & 8 deletions src/main/java/com/actiontech/sqle/util/HttpClientUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public ArrayList<String> GetDataSourceNameList(String projectName, String dbType
}

String dataSourcePath = String.format(HttpClientUtil.dataSourcePath, projectName);
String reqPath = String.format("%s?filter_db_type=%s&page_index=%s&page_size=%s", dataSourcePath, dbType, "1", "999999");
String encodedDbType = URLEncoder.encode(dbType, "UTF-8");
String reqPath = String.format("%s?filter_db_type=%s&page_index=%s&page_size=%s", dataSourcePath, encodedDbType, "1", "999999");
JsonObject resp = sendGet(uriHead + reqPath);

if (resp.get("code").getAsInt() != 0) {
Expand Down Expand Up @@ -219,14 +220,17 @@ public SQLEAuditResult AuditSQL(String[] contents, AuditType type, String projec
return gson.fromJson(data, new SQLEAuditResult().getClass());
}

public String GetRuleKnowledge(String projectName, String ruleName) throws Exception {
public String GetRuleKnowledge(String dbType, String ruleName) throws Exception {
if (token == null || token.isEmpty()) {
Login();
}

String knowledge = GetOriginRuleKnowledge(projectName, ruleName);
// sqle服务端默认只能解析%20表示的空格
// 注意:java 的 URLEncoder.encode 方法默认将空格转换为+号
String encodeDbType = dbType.replace(" ", "%20");
String knowledge = GetOriginRuleKnowledge(encodeDbType, ruleName);
if (knowledge == null) {
knowledge = GetCustomRuleKnowledge(projectName, ruleName);
knowledge = GetCustomRuleKnowledge(encodeDbType, ruleName);
}

if (null == knowledge || knowledge.isEmpty()) {
Expand All @@ -236,12 +240,12 @@ public String GetRuleKnowledge(String projectName, String ruleName) throws Excep
return knowledge;
}

public String GetOriginRuleKnowledge(String projectName, String ruleName) throws Exception {
public String GetOriginRuleKnowledge(String dbType, String ruleName) throws Exception {
if (token == null || token.isEmpty()) {
Login();
}

String reqPath = String.format(ruleKnowledgePath, projectName, ruleName);
String reqPath = String.format(ruleKnowledgePath, dbType, ruleName);
JsonObject resp = sendGet(uriHead + reqPath);
if (resp.get("code").getAsInt() == 8003) {
return "SQLE社区版不支持查看规则知识库";
Expand All @@ -255,12 +259,12 @@ public String GetOriginRuleKnowledge(String projectName, String ruleName) throws
return data.get("knowledge_content").getAsString();
}

public String GetCustomRuleKnowledge(String projectName, String ruleName) throws Exception {
public String GetCustomRuleKnowledge(String dbType, String ruleName) throws Exception {
if (token == null || token.isEmpty()) {
Login();
}

String reqPath = String.format(customRuleKnowledgePath, projectName, ruleName);
String reqPath = String.format(customRuleKnowledgePath, dbType, ruleName);
JsonObject resp = sendGet(uriHead + reqPath);
if (resp.get("code").getAsInt() == 8003) {
return "SQLE社区版不支持查看规则知识库";
Expand Down

0 comments on commit 29a4b93

Please sign in to comment.