为 7.X 替换 Atlassian JIRA 插件中已弃用的 AbstractEditHandlerDetailsWebAction
Replacing deprecated AbstractEditHandlerDetailsWebAction in Atlassian JIRA plugin for 7.X
我正在关注 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 找不到它的原因。
此外,我找不到任何说明这些 classes 已被弃用的信息,也找不到任何关于我应该用我的 JIRA 版本替换此代码的建议。
那么,我可以用什么来代替上面class中看似弃用的com.atlassian.jira.plugins.mail.webwork.AbstractEditHandlerDetailsWebAction;
?
无论出于何种原因,JIRA 邮件插件的版本号与 JIRA 本身的版本号分离。一旦您确保引用了正确版本的邮件插件,您就可以构建项目。
我能够按如下方式构建它:
从教程中克隆 repo
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
。
之后,它为我构建。
我正在关注 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 找不到它的原因。
此外,我找不到任何说明这些 classes 已被弃用的信息,也找不到任何关于我应该用我的 JIRA 版本替换此代码的建议。
那么,我可以用什么来代替上面class中看似弃用的com.atlassian.jira.plugins.mail.webwork.AbstractEditHandlerDetailsWebAction;
?
无论出于何种原因,JIRA 邮件插件的版本号与 JIRA 本身的版本号分离。一旦您确保引用了正确版本的邮件插件,您就可以构建项目。
我能够按如下方式构建它:
从教程中克隆 repo
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
。
之后,它为我构建。