在Atlassian JIRA插件中为7.X替换不推荐使用的AbstractEditHandlerDetailsWebAction [英] Replacing deprecated AbstractEditHandlerDetailsWebAction in Atlassian JIRA plugin for 7.X

查看:85
本文介绍了在Atlassian JIRA插件中为7.X替换不推荐使用的AbstractEditHandlerDetailsWebAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注我已经倒数第二步撞到了砖墙上:

I've hit a brick wall with the second to last step:

3)在src/main/java/com/example/plugins/tutorial/jira/mailhandlerdemo目录中创建一个名为EditDemoHandlerDetailsWebAction.java的新文件,并为其提供以下内容:

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());
    }
}

该类继承自AbstractEditHandlerDetailsWebAction,它使我们可以专注于参数验证.它负责添加,编辑和取消处理程序生命周期本身.

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版本

This tutorial is supposed to support JIRA 5.0+ including the newest version up to 7.2

我正在使用JIRA 7.1.8

I am using JIRA 7.1.8

我的问题是maven无法找到

My problem is that maven is unable to locate the dependency for

import com.atlassian.jira.plugins.mail.webwork.AbstractEditHandlerDetailsWebAction;

经过一番挖掘,我发现com.atlassian.jira.plugins.mail

After a TON of digging, I have found that com.atlassian.jira.plugins.mail exists in the specs for up to JIRA 5.1.8

但是,从5.2-m03的规范开始 ,该文件夹不存在,这就是为什么maven无法找到它的原因.

However, in the specs for 5.2-m03 onward, this folder is not present, which is why maven cant find it.

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

Moreover, I can't find any information stating that these classes were deprecated nor any suggestion as to what I should replace this code with for my version of JIRA.

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

So, what can I use in place of the seemingly deprecated com.atlassian.jira.plugins.mail.webwork.AbstractEditHandlerDetailsWebAction; in the above class?

推荐答案

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

For whatever reason, the version numbers of the JIRA mail plugin became dissociated from the version numbers of JIRA itself. You will be able to build the project once you ensure that you are referencing the correct version of the mail plugin.

我能够按如下所示进行构建:

I was able to get it to build as follows:

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

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

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

Figure out which version of the JIRA mail plugin is in use

You can do this easily by looking in the JIRA install directory. In my JIRA 7.1 install, the mail plugin was 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应用的补丁:

Adjust the POM to correspond to the correct version of the mail plugin

Here is the patch I applied against the 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.

在那之后,它为我建造.

After that, it builds for me.

这篇关于在Atlassian JIRA插件中为7.X替换不推荐使用的AbstractEditHandlerDetailsWebAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆