gpt4 book ai didi

java - 替换 7.X 版 Atlassian JIRA 插件中已弃用的 AbstractEditHandlerDetailsWebAction

转载 作者:行者123 更新时间:2023-12-01 09:28:10 24 4
gpt4 key购买 nike

我正在关注Atlassian's Tutorial - Custom message (mail) handler for JIRA

我在倒数第二步中碰壁了:

3) Create a new file named EditDemoHandlerDetailsWebAction.java in src/main/java/com/example/plugins/tutorial/jira/mailhandlerdemo directory, and give it the following contents:

package com.example.plugins.tutorial.jira.mailhandlerdemo;

import com.atlassian.configurable.ObjectConfigurationException;
import com.atlassian.jira.plugins.mail.webwork.AbstractEditHandlerDetailsWebAction;
import com.atlassian.jira.service.JiraServiceContainer;
import com.atlassian.jira.service.services.file.AbstractMessageHandlingService;
import com.atlassian.jira.service.util.ServiceUtils;
import com.atlassian.jira.util.collect.MapBuilder;
import com.atlassian.plugin.PluginAccessor;

import java.util.Map;

public class EditDemoHandlerDetailsWebAction extends AbstractEditHandlerDetailsWebAction {
private final IssueKeyValidator issueKeyValidator;

public EditDemoHandlerDetailsWebAction(PluginAccessor pluginAccessor, IssueKeyValidator issueKeyValidator) {
super(pluginAccessor);
this.issueKeyValidator = issueKeyValidator;
}
private String issueKey;
public String getIssueKey() {
return issueKey;
}

public void setIssueKey(String issueKey) {
this.issueKey = issueKey;
}

// this method is called to let us populate our variables (or action state)
// with current handler settings managed by associated service (file or mail).
@Override
protected void copyServiceSettings(JiraServiceContainer jiraServiceContainer) throws ObjectConfigurationException {
final String params = jiraServiceContainer.getProperty(AbstractMessageHandlingService.KEY_HANDLER_PARAMS);
final Map<String, String> parameterMap = ServiceUtils.getParameterMap(params);
issueKey = parameterMap.get(DemoHandler.KEY_ISSUE_KEY);
}

@Override
protected Map<String, String> getHandlerParams() {
return MapBuilder.build(DemoHandler.KEY_ISSUE_KEY, issueKey);
}

@Override
protected void doValidation() {
if (configuration == null) {
return; // short-circuit in case we lost session, goes directly to doExecute which redirects user
}
super.doValidation();
issueKeyValidator.validateIssue(issueKey, new WebWorkErrorCollector());
}
}

The class inherits from AbstractEditHandlerDetailsWebAction which allows us to concentrate on parameter validation. It takes care of the add, edit, and cancel handler lifecycle itself.

本教程应该支持 JIRA 5.0+,包括最新版本到 7.2

我使用的是 JIRA 7.1.8

我的问题是maven无法找到

的依赖项
import com.atlassian.jira.plugins.mail.webwork.AbstractEditHandlerDetailsWebAction;

经过大量挖掘,我发现 com.atlassian.jira.plugins.mail exists in the specs for up to JIRA 5.1.8

但是,in the specs for 5.2-m03以后,这个文件夹就不存在了,这就是为什么maven找不到它。

此外,我找不到任何说明这些类已被弃用的信息,也找不到任何关于我应该用什么来替换我的 JIRA 版本的代码的建议。

那么,我可以使用什么来代替上面类中看似已弃用的 com.atlassian.jira.plugins.mail.webwork.AbstractEditHandlerDetailsWebAction;

最佳答案

无论出于何种原因,JIRA 邮件插件的版本号与 JIRA 本身的版本号变得分离。一旦确保引用了正确版本的邮件插件,您就可以构建项目。

我能够按如下方式构建它:

从教程中克隆存储库

git clone https://bitbucket.org/atlassian_tutorial/jira-add-email-handler.git

找出正在使用的 JIRA 邮件插件版本

您可以通过查看 JIRA 安装目录轻松完成此操作。在我安装的 JIRA 7.1 中,邮件插件是 v9.0.3:

$ find <PATH_TO_JIRA_INSTALL>/atlassian-jira -name '*jira-mail-plugin*.jar'

<your path here>/atlassian-jira/WEB-INF/atlassian-bundled-plugins/jira-mail-plugin-9.0.3.jar

调整 POM 以对应邮件插件的正确版本

这是我针对 pom.xml 应用的补丁:

diff --git a/pom.xml b/pom.xml
index f493ef2..a3bbb8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,7 @@
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-mail-plugin</artifactId>
- <version>${jira.version}</version>
+ <version>${jira.mail.plugin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -104,8 +104,9 @@
</build>

<properties>
- <jira.version>6.0.4</jira.version>
- <amps.version>4.2.0</amps.version>
+ <jira.version>7.1.8</jira.version>
+ <jira.mail.plugin.version>9.0.3</jira.mail.plugin.version> <!-- the version of the mail plugin shipped with your version of JIRA -->
+ <amps.version>5.0.4</amps.version> <!-- Adjust this to the specific version of the plugin SDK you have installed -->
<plugin.testrunner.version>1.1.1</plugin.testrunner.version>
<!-- TestKit version 5.x for JIRA 5.x, 6.x for JIRA 6.x -->
<testkit.version>5.2.26</testkit.version>

修复其他类型问题

DemoHandler 中还有另一个引用,您必须将其从 User 更改为 ApplicationUser

之后,它就为我构建了。

关于java - 替换 7.X 版 Atlassian JIRA 插件中已弃用的 AbstractEditHandlerDetailsWebAction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39670569/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com