fix(测试跟踪): 同步jira图片失败
--bug=1013769 --user=陈建星 【测试跟踪】github#13768,项目MS创建缺陷中含有图片-点击同步缺陷到JIRA-MS缺陷中的图片消失-JIRA中的图片还在 https://www.tapd.cn/55049933/s/1172335
This commit is contained in:
parent
08e6bb223d
commit
51acb89783
|
@ -75,6 +75,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
String status = getStatus(fields);
|
||||
|
||||
String description = dealWithDescription(fields.getString("description"), fields.getJSONArray("attachment"));
|
||||
fields.put("description", description);
|
||||
|
||||
JSONObject assignee = (JSONObject) fields.get("assignee");
|
||||
issue.setTitle(fields.getString("summary"));
|
||||
|
@ -100,7 +101,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
JSONObject attachment = attachments.getJSONObject(i);
|
||||
String filename = attachment.getString("filename");
|
||||
String content = attachment.getString("content");
|
||||
if (StringUtils.equals(attachment.getString("mimeType"), "image/jpeg")) {
|
||||
if (StringUtils.contains(attachment.getString("mimeType"), "image")) {
|
||||
String contentUrl = "![" + filename + "](" + content + ")";
|
||||
fileContentMap.put(filename, contentUrl);
|
||||
} else {
|
||||
|
@ -117,6 +118,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
List<String> keys = fileContentMap.keySet().stream().filter(key -> splitStr.contains(key)).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(keys)) {
|
||||
description = description.replace(splitStr, fileContentMap.get(keys.get(0)));
|
||||
fileContentMap.remove(keys.get(0));
|
||||
} else {
|
||||
if (splitStr.contains("MS附件:")) {
|
||||
// 解析标签内容
|
||||
|
@ -130,6 +132,10 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
}
|
||||
|
||||
for (String key: fileContentMap.keySet()) {
|
||||
// 同步jira上传的附件
|
||||
description += "\n" + fileContentMap.get(key);
|
||||
}
|
||||
return description;
|
||||
}
|
||||
|
||||
|
@ -215,15 +221,14 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
}
|
||||
|
||||
private List<File> getImageFiles(IssuesUpdateRequest issuesRequest) {
|
||||
List<File> files = getImageFiles(issuesRequest.getDescription());
|
||||
List<File> files = new ArrayList<>();
|
||||
List<CustomFieldItemDTO> customFields = CustomFieldService.getCustomFields(issuesRequest.getCustomFields());
|
||||
customFields.forEach(item -> {
|
||||
String fieldName = item.getCustomData();
|
||||
if (StringUtils.isNotBlank(fieldName)) {
|
||||
if (item.getValue() != null) {
|
||||
if (StringUtils.isNotBlank(item.getType())) {
|
||||
if (StringUtils.equalsAny(item.getType(), "richText")
|
||||
&& !item.getId().equals("description")) {
|
||||
if (StringUtils.equalsAny(item.getType(), "richText")) {
|
||||
files.addAll(getImageFiles(item.getValue().toString()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,12 +243,24 @@ public abstract class JiraAbstractClient extends BaseClient {
|
|||
}
|
||||
|
||||
public JiraIssueListResponse getProjectIssues(int startAt, int maxResults, String projectKey, String issueType) {
|
||||
return getProjectIssues(startAt, maxResults, projectKey, issueType, null);
|
||||
}
|
||||
|
||||
public JiraIssueListResponse getProjectIssues(int startAt, int maxResults, String projectKey, String issueType, String fields) {
|
||||
ResponseEntity<String> responseEntity;
|
||||
responseEntity = restTemplate.exchange(getBaseUrl() + "/search?startAt={1}&maxResults={2}&jql=project={3}+AND+issuetype={4}",
|
||||
String url = getBaseUrl() + "/search?startAt={1}&maxResults={2}&jql=project={3}+AND+issuetype={4}";
|
||||
if (StringUtils.isNotBlank(fields)) {
|
||||
url = url + "&fields=" + fields;
|
||||
}
|
||||
responseEntity = restTemplate.exchange(url,
|
||||
HttpMethod.GET, getAuthHttpEntity(), String.class, startAt, maxResults, projectKey, issueType);
|
||||
return (JiraIssueListResponse)getResultForObject(JiraIssueListResponse.class, responseEntity);
|
||||
}
|
||||
|
||||
public JiraIssueListResponse getProjectIssuesAttachment(int startAt, int maxResults, String projectKey, String issueType) {
|
||||
return getProjectIssues(startAt, maxResults, projectKey, issueType, "attachment");
|
||||
|
||||
}
|
||||
public void setTransitions(String jiraKey, JiraTransitionsResponse.Transitions transitions) {
|
||||
LogUtil.info("setTransitions: " + transitions);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
|
|
Loading…
Reference in New Issue