0


我正在使用 JRJC jira-rest-java-client-2.0.0-m2。
我的目标是能够从问题中复制自定义字段并使用该值创建一个新问题。这通常工作得很好:

Field trigger = issue.getFieldByName("Trigger");
if (trigger != null) {
    newIssue.setFieldValue(trigger.getId(), trigger.getValue());
}

(newIssue 是 IssueInputBuilder 类型的对象;Issue 类型的问题)

但它不适用于下拉菜单(单选),这会引发以下异常:

com.atlassian.jira.rest.client.domain.input.CannotTransformValueException: Any of available transformers was able to transform given value. Value is: org.codehaus.jettison.json.JSONObject: {"self":"http:\/\/localhost:8080\/rest\/api\/2\/customFieldOption\/10100","value":"SQL Statement","id":"10100"}
    at com.atlassian.jira.rest.client.domain.input.ValueTransformerManager.apply(ValueTransformerManager.java:83)
    at com.atlassian.jira.rest.client.domain.input.IssueInputBuilder.setFieldValue(IssueInputBuilder.java:135)
    at com.sonydadc.lfiala.jira.CopyUtil.copy(CopyUtil.java:152)
    at com.sonydadc.lfiala.jira.JiraUtil.copyTask(JiraUtil.java:90)
    at com.sonydadc.lfiala.jira.Start.main(Start.java:13)

直接设置值不起作用eiter:

Field trigger = issue.getFieldByName("Trigger");
        if (trigger != null) {
            newIssue.setFieldValue(trigger.getId(), trigger);
        }

当我尝试这个时,会抛出这个异常:

com.atlassian.jira.rest.client.RestClientException: Could not find valid 'id' or 'value' in the Parent Option object.
    at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:165)
    at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:159)
    at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:48)
    at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:12)
    at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:285)
    at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:162)
    at com.google.common.util.concurrent.Futures$7.run(Futures.java:1072)
...

当 jira-client 尝试将 value 设置为 issueinputbuilder 时,会引发这些异常。
我该如何解决这个问题?

在此先感谢,劳伦兹

编辑我对 jira-rest-java-client-api 和 jira-rest-java-client-core 的最新 m25 版本进行了相同的尝试,但它也不起作用

仅供参考,我已经用谷歌搜索过了。很多。我没有找到任何可以解决我的问题的东西(至少不是在前几页:/)

4

1 回答 1

5

好的,我自己解决了:)

如果有人想知道这里是如何:

IssueField trigger = issue.getFieldByName("Trigger");
        if (trigger != null) {
            JSONObject triggerJO = (JSONObject) trigger.getValue();
            newIssue.setFieldValue(trigger.getId(), ComplexIssueInputFieldValue.with("value", triggerJO.get("value")));
        }

这与新的 api 版本 m25(jira-rest-java-client-api 和 jira-rest-java-client-core)一起运行。

于 2014-01-29T11:36:43.450 回答