fix(测试跟踪): 非sass版同步缺陷附件报错
--bug=1015126 --user=陈建星 【测试跟踪】本地安装的 jira,往 ms 同步缺陷报错了 https://www.tapd.cn/55049933/s/1206687
This commit is contained in:
parent
fdc0e6423b
commit
4d5f4f192a
|
@ -140,7 +140,7 @@ public class FileService {
|
|||
String uploadPath = FileUtils.ATTACHMENT_DIR + "/" + attachmentType + "/" + belongId;
|
||||
File parentFile = new File(uploadPath);
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdir();
|
||||
parentFile.mkdirs();
|
||||
}
|
||||
try (OutputStream os = new FileOutputStream(uploadPath + "/" + attachmentName)){
|
||||
InputStream in = new ByteArrayInputStream(bytes);
|
||||
|
|
|
@ -527,14 +527,15 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
|
||||
issues.forEach(item -> {
|
||||
try {
|
||||
getUpdateIssue(item, jiraClientV2.getIssues(item.getPlatformId()));
|
||||
JiraIssue jiraIssue = jiraClientV2.getIssues(item.getPlatformId());
|
||||
getUpdateIssue(item, jiraIssue);
|
||||
String customFields = item.getCustomFields();
|
||||
// 把自定义字段存入新表
|
||||
List<CustomFieldResource> customFieldResource = customFieldService.getCustomFieldResource(customFields);
|
||||
customFieldMap.put(item.getId(), customFieldResource);
|
||||
issuesMapper.updateByPrimaryKeySelective(item);
|
||||
// 同步第三方平台附件
|
||||
syncJiraIssueAttachments(item, jiraClientV2.getIssues(item.getPlatformId()));
|
||||
syncJiraIssueAttachments(item, jiraIssue);
|
||||
} catch (HttpClientErrorException e) {
|
||||
if (e.getRawStatusCode() == 404) {
|
||||
// 标记成删除
|
||||
|
@ -874,14 +875,17 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
String filename = attachment.getString("filename");
|
||||
if ((issue.getDescription() == null || !issue.getDescription().contains(filename))
|
||||
&& (issue.getCustomFields() == null || !issue.getCustomFields().contains(filename))) {
|
||||
String id = attachment.getString("id");
|
||||
byte[] content = jiraClientV2.getAttachmentContent(id);
|
||||
FileAttachmentMetadata fileAttachmentMetadata = fileService.saveAttachmentByBytes(content, AttachmentType.ISSUE.type(), issue.getId(), filename);
|
||||
AttachmentModuleRelation attachmentModuleRelation = new AttachmentModuleRelation();
|
||||
attachmentModuleRelation.setAttachmentId(fileAttachmentMetadata.getId());
|
||||
attachmentModuleRelation.setRelationId(issue.getId());
|
||||
attachmentModuleRelation.setRelationType(AttachmentType.ISSUE.type());
|
||||
attachmentModuleRelationMapper.insert(attachmentModuleRelation);
|
||||
try {
|
||||
byte[] content = jiraClientV2.getAttachmentContent(attachment.getString("content"));
|
||||
FileAttachmentMetadata fileAttachmentMetadata = fileService.saveAttachmentByBytes(content, AttachmentType.ISSUE.type(), issue.getId(), filename);
|
||||
AttachmentModuleRelation attachmentModuleRelation = new AttachmentModuleRelation();
|
||||
attachmentModuleRelation.setAttachmentId(fileAttachmentMetadata.getId());
|
||||
attachmentModuleRelation.setRelationId(issue.getId());
|
||||
attachmentModuleRelation.setRelationType(AttachmentType.ISSUE.type());
|
||||
attachmentModuleRelationMapper.insert(attachmentModuleRelation);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -257,11 +257,10 @@ public abstract class JiraAbstractClient extends BaseClient {
|
|||
return (JiraIssueListResponse)getResultForObject(JiraIssueListResponse.class, responseEntity);
|
||||
}
|
||||
|
||||
public byte[] getAttachmentContent(String contentId) {
|
||||
public byte[] getAttachmentContent(String url) {
|
||||
ResponseEntity<byte[]> responseEntity;
|
||||
String url = getBaseUrl() + "/attachment/content/{1}";
|
||||
responseEntity = restTemplate.exchange(url,
|
||||
HttpMethod.GET, getAuthHttpEntity(), byte[].class, contentId);
|
||||
HttpMethod.GET, getAuthHttpEntity(), byte[].class);
|
||||
return responseEntity.getBody();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue