From f95263176f4d7338a6049b5a75a558f33ec1a8ef Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 26 Apr 2022 18:44:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=81=E4=B8=9A=E7=89=88=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8C=E6=AD=A5jira=E7=BC=BA=E9=99=B7=E7=BC=BA?= =?UTF-8?q?=E5=B0=91=E9=83=A8=E5=88=86=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/track/issue/JiraPlatform.java | 29 +++++++++---------- .../issue/client/JiraAbstractClient.java | 2 +- .../db/migration/V115__1.20__release.sql | 2 ++ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java index 031729ab71..052fe6e3cd 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -27,9 +27,6 @@ import io.metersphere.track.service.IssuesService; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; -import org.commonmark.node.Node; -import org.commonmark.parser.Parser; -import org.commonmark.renderer.html.HtmlRenderer; import org.springframework.web.client.HttpClientErrorException; import java.io.File; @@ -97,16 +94,18 @@ public class JiraPlatform extends AbstractIssuePlatform { // 附件处理 Map fileContentMap = new HashMap<>(); - for (int i = 0; i < attachments.size(); i++) { - JSONObject attachment = attachments.getJSONObject(i); - String filename = attachment.getString("filename"); - String content = attachment.getString("content"); - if (StringUtils.equals(attachment.getString("mimeType"), "image/jpeg")) { - String contentUrl = "![" + filename + "](" + content + ")"; - fileContentMap.put(filename, contentUrl); - } else { - String contentUrl = "附件[" + filename + "]下载地址:" + content; - fileContentMap.put(filename, contentUrl); + if (CollectionUtils.isNotEmpty(attachments)) { + for (int i = 0; i < attachments.size(); i++) { + JSONObject attachment = attachments.getJSONObject(i); + String filename = attachment.getString("filename"); + String content = attachment.getString("content"); + if (StringUtils.equals(attachment.getString("mimeType"), "image/jpeg")) { + String contentUrl = "![" + filename + "](" + content + ")"; + fileContentMap.put(filename, contentUrl); + } else { + String contentUrl = "附件[" + filename + "]下载地址:" + content; + fileContentMap.put(filename, contentUrl); + } } } @@ -137,7 +136,7 @@ public class JiraPlatform extends AbstractIssuePlatform { JSONObject statusObj = (JSONObject) fields.get("status"); if (statusObj != null) { JSONObject statusCategory = (JSONObject) statusObj.get("statusCategory"); - return statusCategory.getString("name"); + return statusObj.getString("name") == null ? statusCategory.getString("name") : statusObj.getString("name"); } return ""; } @@ -292,7 +291,7 @@ public class JiraPlatform extends AbstractIssuePlatform { if (StringUtils.isNotBlank(issuesRequest.getDescription())) { desc = dealWithImage(issuesRequest.getDescription()); } - + fields.put("project", project); project.put("key", jiraKey); diff --git a/backend/src/main/java/io/metersphere/track/issue/client/JiraAbstractClient.java b/backend/src/main/java/io/metersphere/track/issue/client/JiraAbstractClient.java index 2b5ffe044c..9e0d408b90 100644 --- a/backend/src/main/java/io/metersphere/track/issue/client/JiraAbstractClient.java +++ b/backend/src/main/java/io/metersphere/track/issue/client/JiraAbstractClient.java @@ -229,7 +229,7 @@ public abstract class JiraAbstractClient extends BaseClient { public JiraIssueListResponse getProjectIssues(int startAt, int maxResults, String projectKey, String issueType) { ResponseEntity responseEntity; - responseEntity = restTemplate.exchange(getBaseUrl() + "/search?startAt={1}&maxResults={2}&jql=project={3}+AND+issuetype={4}&fields=status,assignee,summary,created,updated,attachment,description", + responseEntity = restTemplate.exchange(getBaseUrl() + "/search?startAt={1}&maxResults={2}&jql=project={3}+AND+issuetype={4}", HttpMethod.GET, getAuthHttpEntity(), String.class, startAt, maxResults, projectKey, issueType); return (JiraIssueListResponse)getResultForObject(JiraIssueListResponse.class, responseEntity); } diff --git a/backend/src/main/resources/db/migration/V115__1.20__release.sql b/backend/src/main/resources/db/migration/V115__1.20__release.sql index f94696d6e0..729136d580 100644 --- a/backend/src/main/resources/db/migration/V115__1.20__release.sql +++ b/backend/src/main/resources/db/migration/V115__1.20__release.sql @@ -300,3 +300,5 @@ ALTER TABLE `api_scenario_reference_id` ADD INDEX index_method ( `method` ); ALTER TABLE `api_scenario` ADD INDEX index_project_id ( `project_id`); ALTER TABLE share_info ADD lang varchar(10) NULL; + +UPDATE system_parameter SET param_value = 'http://grid-local:4444' WHERE param_key = 'base.selenium.docker.url';