fix(测试跟踪): 同步到禅道缺陷图片无法显示问题
--bug=1018569 --user=宋昌昌 【测试跟踪】同步到禅道的缺陷图片无法显示 https://www.tapd.cn/55049933/s/1270622
This commit is contained in:
parent
26f513d2a4
commit
1cb9ce521f
|
@ -16,14 +16,16 @@ public class ZentaoGetClient extends ZentaoClient {
|
||||||
private static final String STORY_GET="&module=story&methodName=getProductStories¶ms=productID={key}&t=json&zentaosid=";
|
private static final String STORY_GET="&module=story&methodName=getProductStories¶ms=productID={key}&t=json&zentaosid=";
|
||||||
private static final String USER_GET="&module=user&methodName=getList&t=json&zentaosid=";
|
private static final String USER_GET="&module=user&methodName=getList&t=json&zentaosid=";
|
||||||
private static final String BUILDS_GET="&module=build&methodName=getProductBuildPairs&productID={0}&zentaosid={1}";
|
private static final String BUILDS_GET="&module=build&methodName=getProductBuildPairs&productID={0}&zentaosid={1}";
|
||||||
private static final String FILE_UPLOAD="&module=file&methodName=saveUpload¶ms=objectType={1},objectID={2},zentaosid={3}";
|
private static final String FILE_UPLOAD="&module=file&methodName=saveUpload¶ms=objectType=bug&zentaosid={1}";
|
||||||
private static final String FILE_DELETE="/?m=file&f=delete&t=json&fileID={1}&confirm=yes&zentaosid={2}";
|
private static final String FILE_DELETE="/?m=file&f=delete&t=json&fileID={1}&confirm=yes&zentaosid={2}";
|
||||||
private static final String FILE_DOWNLOAD="/?m=file&f=download&t=json&fileID={1}&mouse=click&zentaosid={2}";
|
private static final String FILE_DOWNLOAD="/?m=file&f=download&t=json&fileID={1}&mouse=click&zentaosid={2}";
|
||||||
private static final String CREATE_META_DATA="?m=bug&f=create&productID={0}&t=json&zentaosid={1}";
|
private static final String CREATE_META_DATA="?m=bug&f=create&productID={0}&t=json&zentaosid={1}";
|
||||||
private static final String REPLACE_IMG_URL="<img src=\"%s/index.php?m=file&f=read&fileID=$1\"/>";
|
private static final String REPLACE_IMG_URL="<img src=\"%s/index.php?m=file&f=read&fileID=$1\"/>";
|
||||||
private static final Pattern IMG_PATTERN = Pattern.compile("m=file&f=read&fileID=(.*?)\"/>");
|
private static final Pattern IMG_PATTERN = Pattern.compile("m=file&f=read&fileID=(.*?)\"/>");
|
||||||
private static final String PRODUCT_GET = "&module=product&methodName=getById¶ms=productID={0}&zentaosid={1}";
|
private static final String PRODUCT_GET = "&module=product&methodName=getById¶ms=productID={0}&zentaosid={1}";
|
||||||
// 注意 recTotal={1}&recPerPage={2}&pageID={3} 顺序不能调换,有点恶心
|
/**
|
||||||
|
* 注意 recTotal={1}&recPerPage={2}&pageID={3} 顺序不能调换,有点恶心
|
||||||
|
*/
|
||||||
private static final String BUG_LIST_URL = "/?m=bug&f=browse&productID={0}&branch=&browseType=all¶m=0&orderBy=&recTotal={1}&recPerPage={2}&pageID={3}&t=json&zentaosid={4}";
|
private static final String BUG_LIST_URL = "/?m=bug&f=browse&productID={0}&branch=&browseType=all¶m=0&orderBy=&recTotal={1}&recPerPage={2}&pageID={3}&t=json&zentaosid={4}";
|
||||||
|
|
||||||
RequestUrl request = new RequestUrl();
|
RequestUrl request = new RequestUrl();
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
|
||||||
private static final String USER_GET = "/api-getModel-user-getList?zentaosid=";
|
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 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 CREATE_META_DATA="/bug-create-{0}.json?zentaosid={1}";
|
||||||
private static final String FILE_UPLOAD = "/api-getModel-file-saveUpload-objectType={1},objectID={2}?zentaosid={3}";
|
private static final String FILE_UPLOAD = "/api-getModel-file-saveUpload-objectType=bug?zentaosid={1}";
|
||||||
private static final String FILE_DELETE = "/file-delete-{1}-.yes.json?zentaosid={2}";
|
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 FILE_DOWNLOAD="/file-download-{1}-.click.json?zentaosid={2}";
|
||||||
private static final String REPLACE_IMG_URL = "<img src=\"%s/file-read-$1\"/>";
|
private static final String REPLACE_IMG_URL = "<img src=\"%s/file-read-$1\"/>";
|
||||||
|
|
|
@ -26,6 +26,8 @@ import io.metersphere.service.issue.domain.zentao.ZentaoConfig;
|
||||||
import io.metersphere.xpack.track.dto.PlatformStatusDTO;
|
import io.metersphere.xpack.track.dto.PlatformStatusDTO;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.http.entity.mime.MultipartEntity;
|
||||||
|
import org.apache.http.entity.mime.content.FileBody;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.logging.log4j.util.Strings;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
|
@ -437,16 +439,16 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
||||||
String session = zentaoClient.login();
|
String session = zentaoClient.login();
|
||||||
HttpHeaders httpHeaders = new HttpHeaders();
|
HttpHeaders httpHeaders = new HttpHeaders();
|
||||||
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
||||||
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(paramMap, httpHeaders);
|
|
||||||
paramMap.add("files", resource);
|
paramMap.add("files", resource);
|
||||||
|
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(paramMap, httpHeaders);
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
try {
|
try {
|
||||||
String fileUpload = zentaoClient.requestUrl.getFileUpload();
|
String fileUpload = zentaoClient.requestUrl.getFileUpload();
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange(fileUpload, HttpMethod.POST, requestEntity,
|
ResponseEntity<String> responseEntity = restTemplate.exchange(fileUpload, HttpMethod.POST, requestEntity,
|
||||||
String.class, "bug", null, session);
|
String.class, session);
|
||||||
String body = responseEntity.getBody();
|
String body = responseEntity.getBody();
|
||||||
Map obj = JSON.parseMap(body);
|
Map obj = JSON.parseMap(body);
|
||||||
Map data = (Map) obj.get("data");
|
Map data = (Map) JSON.parseObject(obj.get("data").toString());
|
||||||
Set<String> set = data.keySet();
|
Set<String> set = data.keySet();
|
||||||
if (!set.isEmpty()) {
|
if (!set.isEmpty()) {
|
||||||
id = (String) set.toArray()[0];
|
id = (String) set.toArray()[0];
|
||||||
|
|
Loading…
Reference in New Issue