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