[英]groovy.lang.MissingMethodException : IssueLinkImpl instead of IssueLink
In JIRA I try to change the issuetypelink to another linktype with the changeIssueLinkType function. 在JIRA中,我尝试使用changeIssueLinkType函数将issuetypelink更改为另一个linktype。
I get the following error: 我收到以下错误:
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.link.DefaultIssueLinkManager.changeIssueLinkType() is applicable for argument types: (com.atlassian.jira.issue.link.IssueLinkImpl, com.atlassian.jira.issue.link.IssueLinkTypeImpl, com.atlassian.jira.user.DelegatingApplicationUser) values: [com.atlassian.jira.issue.link.IssueLinkImpl@fffff04e, com.atlassian.jira.issue.link.IssueLinkTypeImpl@ffe53fbd, ...] Possible solutions: changeIssueLinkType(com.atlassian.jira.issue.link.IssueLink, com.atlassian.jira.issue.link.IssueLinkType, com.atlassian.crowd.embedded.api.User)
I have no Idea how to fix it... 我不知道如何解决它...
code: 码:
for (IssueLinkType linktype : issueLinkTypes)
{
String name=linktype.getInward();
if(name.equals("is parent of"))
{
linkTypeNew=linktype;
break;
}
}
UserManager userManager = ComponentAccessor.getUserManager();
ApplicationUser sUser = userManager.getUserByKey("Username");
Collection<IssueLink> allIssueLinks = ComponentAccessor.getIssueLinkManager().getIssueLinks(linkID);
for (Iterator<IssueLink> outIterator = allIssueLinks.iterator(); outIterator.hasNext();) {
IssueLink issueLink = (IssueLink) outIterator.next();
ComponentAccessor.getIssueLinkManager().changeIssueLinkType(issueLink, linkTypeNew, sUser);
}
Would be great if someone could help me:-/ 如果有人可以帮助我会很棒: - /
Obviously your sUser
variable is of wrong type. 显然你的
sUser
变量类型错误。 The method changeIssueLinkType()
expects a user of type com.atlassian.crowd.embedded.api.User
whereas you pass a user of type com.atlassian.jira.user.DelegatingApplicationUser
. 方法
changeIssueLinkType()
需要com.atlassian.crowd.embedded.api.User
类型的用户,而您传递的类型为com.atlassian.jira.user.DelegatingApplicationUser
。
I'm not a JIRA API expert, but as a quick fix I'd suggest the following: 我不是JIRA API专家,但作为快速修复,我建议如下:
import com.atlassian.crowd.embedded.api.User
ApplicationUser sUser = userManager.getUserByKey("Username")
User user = sUser as User // this line might fail!
....
ComponentAccessor.issueLinkManager.changeIssueLinkType issueLink, linkTypeNew, user
If the line fails, you have to create an instance of User
on your own 如果该行失败,您必须自己创建一个
User
实例
Instead of passing in the sUser
object (it implements ApplicationUser
, which is not compatible with User
), you should call sUser.getDirectoryUser()
and supply that result to your method call in order to get the correct user object type. 您应该调用
sUser.getDirectoryUser()
并将该结果提供给方法调用,以获取正确的用户对象类型,而不是传入sUser
对象(它实现与User
不兼容的ApplicationUser
)。 You should also change the explicit ApplicationUser sUser = ...
initialization to just def sUser = ...
. 您还应该将显式
ApplicationUser sUser = ...
初始化更改为def sUser = ...
This works here because you have a DelegatingApplicationUser
object which supports the getDirectoryUser
method. 这可以在这里工作,因为你有一个支持
getDirectoryUser
方法的DelegatingApplicationUser
对象。 If you have a different type of ApplicationUser
implementation, which does not necessarily support that method, you would need to use a utility method to convert it. 如果您有不同类型的
ApplicationUser
实现(不一定支持该方法),则需要使用实用程序方法进行转换。 You can find more information on User
vs ApplicationUser
in Atlassian's documentation . 您可以在Atlassian的文档中找到有关
User
vs ApplicationUser
更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.