fix(测试跟踪): 缺陷管理同步禅道附件及图片的问题

--bug=1016148,1016146 --user=宋昌昌 【测试跟踪】ms关联禅道。创建缺陷,上传图片 / 图片附件失败 https://www.tapd.cn/55049933/s/1231808
This commit is contained in:
song-cc-rock 2022-08-23 19:54:18 +08:00 committed by 刘瑞斌
parent 85e33eb9e0
commit 5291bfa9fa
3 changed files with 14 additions and 8 deletions

View File

@ -430,8 +430,8 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
RestTemplate restTemplate = new RestTemplate();
try {
String fileUpload = zentaoClient.requestUrl.getFileUpload();
ResponseEntity<String> responseEntity = restTemplate.exchange(fileUpload + session,
HttpMethod.POST, requestEntity, String.class);
ResponseEntity<String> responseEntity = restTemplate.exchange(fileUpload, HttpMethod.POST, requestEntity,
String.class, "bug", null, session);
String body = responseEntity.getBody();
JSONObject obj = JSONObject.parseObject(body);
JSONObject data = obj.getJSONObject("data");
@ -579,8 +579,14 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
List<FileAttachmentMetadata> allMsAttachments = attachmentService.listMetadata(request);
List<String> msAttachmentsName = allMsAttachments.stream().map(FileAttachmentMetadata::getName).collect(Collectors.toList());
JSONObject bugInfo = zentaoClient.getBugById(issue.getPlatformId());
JSONObject zenFiles = bugInfo.getJSONObject("files");
// 同步Jira中新的附件
Object files = bugInfo.get("files");
JSONObject zenFiles;
if (files instanceof JSONArray && ((JSONArray) files).size() == 0) {
zenFiles = null;
} else {
zenFiles = (JSONObject) files;
}
// 同步禅道中新的附件
if (zenFiles != null) {
for (String fileId : zenFiles.keySet()) {
JSONObject fileInfo = zenFiles.getJSONObject(fileId);
@ -602,7 +608,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
}
}
// 删除Jira中不存在的附件
// 删除禅道中不存在的附件
if (CollectionUtils.isNotEmpty(allMsAttachments)) {
List<FileAttachmentMetadata> deleteMsAttachments = allMsAttachments.stream()
.filter(msAttachment -> !znetaoAttachmentsName.contains(msAttachment.getName())).collect(Collectors.toList());

View File

@ -17,7 +17,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
private static final String USER_GET = "/api-getModel-user-getList?zentaosid=";
private static final String BUILDS_GET = "/api-getModel-build-getProductBuildPairs-productID={0}?zentaosid={1}";
private static final String CREATE_META_DATA="/bug-create-{0}.json?zentaosid={1}";
private static final String FILE_UPLOAD = "/api-getModel-file-saveUpload-{1}-{2}.json?zentaosid={3}";
private static final String FILE_UPLOAD = "/api-getModel-file-saveUpload-objectType={1},objectID={2}?zentaosid={3}";
private static final String FILE_DELETE = "/file-delete-{1}-.yes.json?zentaosid={2}";
private static final String FILE_DOWNLOAD="/file-download-{1}-.click.json?zentaosid={2}";
private static final String REPLACE_IMG_URL = "<img src=\"%s/file-read-$1\"/>";
@ -48,7 +48,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
request.setCreateMetaData(getUrl(CREATE_META_DATA));
request.setProductGet(getUrl(PRODUCT_GET));
request.setFileDelete(getUrl(FILE_DELETE));
request.setFileDelete(getUrl(FILE_DOWNLOAD));
request.setFileDownload(getUrl(FILE_DOWNLOAD));
requestUrl = request;
}