fix: 获取jira模板报错提示优化

--bug=1009273 --user=陈建星 [github#8805]使用jira模版选择数据异常 https://www.tapd.cn/55049933/s/1087964444
This commit is contained in:
chenjianxing 2021-12-29 11:07:21 +08:00 committed by fit2-zhao
parent de2665e53c
commit a5e120848f
5 changed files with 14 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.i18n.Translator;
import io.metersphere.track.issue.domain.jira.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.io.FileSystemResource;
@ -35,14 +36,19 @@ public abstract class JiraAbstractClient extends BaseClient {
public Map<String, JiraCreateMetadataResponse.Field> getCreateMetadata(String projectKey, String issueType) {
String url = getBaseUrl() + "/issue/createmeta?projectKeys={1}&issuetypeNames={2}&expand=projects.issuetypes.fields";
ResponseEntity<String> response = null;
Map<String, JiraCreateMetadataResponse.Field> fields = null;
try {
response = restTemplate.exchange(url, HttpMethod.GET, getAuthHttpEntity(), String.class, projectKey, issueType);
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
MSException.throwException(e.getMessage());
}
Map<String, JiraCreateMetadataResponse.Field> fields = ((JiraCreateMetadataResponse) getResultForObject(JiraCreateMetadataResponse.class, response))
.getProjects().get(0).getIssuetypes().get(0).getFields();
try {
fields = ((JiraCreateMetadataResponse) getResultForObject(JiraCreateMetadataResponse.class, response))
.getProjects().get(0).getIssuetypes().get(0).getFields();
} catch (Exception e) {
MSException.throwException(Translator.get("issue_jira_info_error"));
}
fields.remove("project");
fields.remove("issuetype");
return fields;

View File

@ -73,3 +73,4 @@ mock_warning=
invalid_parameter=
workspace_template_settings_issue=
zentao_test_type_error=
issue_jira_info_error=

View File

@ -292,3 +292,4 @@ enterprise_test_report=Enterprise report
null_environment_group_name = Environment group name is null
environment_group_name = Environment group name
environment_group_exist = already exists
issue_jira_info_error=Check the service integration information or Jira project ID

View File

@ -290,4 +290,5 @@ enterprise_test_report=项目报告
#环境组
null_environment_group_name = 环境组名称不存在
environment_group_name = 环境组名称
environment_group_exist = 已存在
environment_group_exist = 已存在
issue_jira_info_error=请检查服务集成信息或Jira项目ID

View File

@ -290,4 +290,5 @@ enterprise_test_report=項目報告
#环境组
null_environment_group_name = 環境組名稱不存在
environment_group_name = 環境組名稱
environment_group_exist = 已存在
environment_group_exist = 已存在
issue_jira_info_error=請檢查服務集成信息或Jira項目ID