fix: 禅道path_info方式同步缺陷报错
【缺陷双向同步功能,在请求方式默认为PATH_INFO时,无法同步禅道的缺陷至MS,同步报错,请修改】https://www.tapd.cn/33805590/bugtrace/bugs/view?bug_id=11338055900010086377
This commit is contained in:
parent
eb80bb6f1e
commit
c66473b16f
|
@ -140,7 +140,11 @@ public class ZentaoPlatform extends AbstractIssuePlatform {
|
||||||
issuesMapper.updateByPrimaryKeySelective(issue);
|
issuesMapper.updateByPrimaryKeySelective(issue);
|
||||||
}
|
}
|
||||||
issue.setTitle(bugObj.getTitle());
|
issue.setTitle(bugObj.getTitle());
|
||||||
issue.setDescription(steps);
|
|
||||||
|
// 保留之前上传的图片
|
||||||
|
String images = getImages(issue.getDescription());
|
||||||
|
issue.setDescription(steps + "\n" + images);
|
||||||
|
|
||||||
issue.setReporter(bugObj.getOpenedBy());
|
issue.setReporter(bugObj.getOpenedBy());
|
||||||
issue.setPlatform(key);
|
issue.setPlatform(key);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package io.metersphere.track.issue.client;
|
package io.metersphere.track.issue.client;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONException;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.track.issue.domain.zentao.*;
|
import io.metersphere.track.issue.domain.zentao.*;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
|
@ -29,9 +31,6 @@ public abstract class ZentaoClient extends BaseClient {
|
||||||
ENDPOINT = url;
|
ENDPOINT = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意 recTotal={1}&recPerPage={2}&pageID={3} 顺序不能调换,实在恶心
|
|
||||||
private static final String BUG_LIST_URL = "?m=bug&f=browse&productID={0}&branch=&browseType=¶m=0&orderBy=&recTotal={1}&recPerPage={2}&pageID={3}&t=json&zentaosid={4}";
|
|
||||||
|
|
||||||
public String login() {
|
public String login() {
|
||||||
GetUserResponse getUserResponse = new GetUserResponse();
|
GetUserResponse getUserResponse = new GetUserResponse();
|
||||||
String sessionId = "";
|
String sessionId = "";
|
||||||
|
@ -46,6 +45,8 @@ public abstract class ZentaoClient extends BaseClient {
|
||||||
getUserResponse = (GetUserResponse) getResultForObject(GetUserResponse.class, response);
|
getUserResponse = (GetUserResponse) getResultForObject(GetUserResponse.class, response);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e);
|
LogUtil.error(e);
|
||||||
|
if (e instanceof JSONException)
|
||||||
|
MSException.throwException(Translator.get("zentao_test_type_error"));
|
||||||
MSException.throwException(e.getMessage());
|
MSException.throwException(e.getMessage());
|
||||||
}
|
}
|
||||||
GetUserResponse.User user = getUserResponse.getUser();
|
GetUserResponse.User user = getUserResponse.getUser();
|
||||||
|
@ -121,7 +122,7 @@ public abstract class ZentaoClient extends BaseClient {
|
||||||
|
|
||||||
public JSONArray getBugsByProjectId(String projectId, int pageNum, int pageSize) {
|
public JSONArray getBugsByProjectId(String projectId, int pageNum, int pageSize) {
|
||||||
String sessionId = login();
|
String sessionId = login();
|
||||||
ResponseEntity<String> response = restTemplate.exchange(getBaseUrl() + BUG_LIST_URL,
|
ResponseEntity<String> response = restTemplate.exchange(requestUrl.getBugList(),
|
||||||
HttpMethod.GET, null, String.class, projectId, 9999999, pageSize, pageNum, sessionId);
|
HttpMethod.GET, null, String.class, projectId, 9999999, pageSize, pageNum, sessionId);
|
||||||
return JSONObject.parseObject(response.getBody()).getJSONObject("data").getJSONArray("bugs");
|
return JSONObject.parseObject(response.getBody()).getJSONObject("data").getJSONArray("bugs");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ public class ZentaoGetClient extends ZentaoClient {
|
||||||
private static final String FILE_UPLOAD="&module=file&methodName=saveUpload&t=json&zentaosid=";
|
private static final String FILE_UPLOAD="&module=file&methodName=saveUpload&t=json&zentaosid=";
|
||||||
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=(.*?)\"/>");
|
||||||
|
// 注意 recTotal={1}&recPerPage={2}&pageID={3} 顺序不能调换,有点恶心
|
||||||
|
private static final String BUG_LIST_URL = "/?m=bug&f=browse&productID={0}&branch=&browseType=¶m=0&orderBy=&recTotal={1}&recPerPage={2}&pageID={3}&t=json&zentaosid={4}";
|
||||||
|
|
||||||
RequestUrl request = new RequestUrl();
|
RequestUrl request = new RequestUrl();
|
||||||
|
|
||||||
|
@ -38,6 +40,7 @@ public class ZentaoGetClient extends ZentaoClient {
|
||||||
request.setImgPattern(IMG_PATTERN);
|
request.setImgPattern(IMG_PATTERN);
|
||||||
request.setBugUpdate(getUrl(BUG_UPDATE));
|
request.setBugUpdate(getUrl(BUG_UPDATE));
|
||||||
request.setBugDelete(getNotSuperModelUrl(BUG_DELETE));
|
request.setBugDelete(getNotSuperModelUrl(BUG_DELETE));
|
||||||
|
request.setBugList(getNotSuperModelUrl(BUG_LIST_URL));
|
||||||
requestUrl = request;
|
requestUrl = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ public class ZentaoPathInfoClient extends ZentaoClient {
|
||||||
private static final String FILE_UPLOAD = "/api-getModel-file-saveUpload.json?zentaosid=";
|
private static final String FILE_UPLOAD = "/api-getModel-file-saveUpload.json?zentaosid=";
|
||||||
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\"/>";
|
||||||
private static final Pattern IMG_PATTERN = Pattern.compile("file-read-(.*?)\"/>");
|
private static final Pattern IMG_PATTERN = Pattern.compile("file-read-(.*?)\"/>");
|
||||||
|
private static final String BUG_LIST_URL = "/bug-browse-{1}---0--{2}-{3}-{4}.json?zentaosid={5}";
|
||||||
|
|
||||||
|
|
||||||
public ZentaoPathInfoClient(String url) {
|
public ZentaoPathInfoClient(String url) {
|
||||||
super(url);
|
super(url);
|
||||||
|
@ -39,6 +41,7 @@ public class ZentaoPathInfoClient extends ZentaoClient {
|
||||||
request.setImgPattern(IMG_PATTERN);
|
request.setImgPattern(IMG_PATTERN);
|
||||||
request.setBugUpdate(getUrl(BUG_UPDATE));
|
request.setBugUpdate(getUrl(BUG_UPDATE));
|
||||||
request.setBugDelete(getUrl(BUG_DELETE));
|
request.setBugDelete(getUrl(BUG_DELETE));
|
||||||
|
request.setBugList(getUrl(BUG_LIST_URL));
|
||||||
requestUrl = request;
|
requestUrl = request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ public class RequestUrl {
|
||||||
private String sessionGet;
|
private String sessionGet;
|
||||||
private String bugCreate;
|
private String bugCreate;
|
||||||
private String bugUpdate;
|
private String bugUpdate;
|
||||||
|
private String bugList;
|
||||||
private String bugDelete;
|
private String bugDelete;
|
||||||
private String bugGet;
|
private String bugGet;
|
||||||
private String storyGet;
|
private String storyGet;
|
||||||
|
|
|
@ -71,3 +71,5 @@ expect_name_exists=
|
||||||
id_not_rightful=
|
id_not_rightful=
|
||||||
mock_warning=
|
mock_warning=
|
||||||
invalid_parameter=
|
invalid_parameter=
|
||||||
|
workspace_template_settings_issue=
|
||||||
|
zentao_test_type_error=
|
||||||
|
|
|
@ -285,5 +285,6 @@ test_case_status=Case status
|
||||||
id_not_rightful=ID is not rightful
|
id_not_rightful=ID is not rightful
|
||||||
# mock
|
# mock
|
||||||
mock_warning=No matching Mock expectation was found
|
mock_warning=No matching Mock expectation was found
|
||||||
|
zentao_test_type_error=请求方式错误
|
||||||
#项目报告
|
#项目报告
|
||||||
enterprise_test_report=Enterprise report
|
enterprise_test_report=Enterprise report
|
||||||
|
|
|
@ -284,5 +284,6 @@ test_case_status=用例状态
|
||||||
id_not_rightful=ID 不合法
|
id_not_rightful=ID 不合法
|
||||||
# mock
|
# mock
|
||||||
mock_warning=未找到匹配的Mock期望
|
mock_warning=未找到匹配的Mock期望
|
||||||
|
zentao_test_type_error=invalid Zentao request
|
||||||
#项目报告
|
#项目报告
|
||||||
enterprise_test_report=项目报告
|
enterprise_test_report=项目报告
|
||||||
|
|
|
@ -284,5 +284,6 @@ test_case_status=用例狀態
|
||||||
id_not_rightful=ID 不合法
|
id_not_rightful=ID 不合法
|
||||||
# mock
|
# mock
|
||||||
mock_warning=未找到匹配的Mock期望
|
mock_warning=未找到匹配的Mock期望
|
||||||
|
zentao_test_type_error=請求方式錯誤
|
||||||
#项目报告
|
#项目报告
|
||||||
enterprise_test_report=項目報告
|
enterprise_test_report=項目報告
|
||||||
|
|
Loading…
Reference in New Issue