I'm following Atlassian's Tutorial - Custom message (mail) handler for JIRA
I've hit a brick wall with the second to last step:
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.
This tutorial is supposed to support JIRA 5.0+ including the newest version up to 7.2
I am using JIRA 7.1.8
My problem is that maven is unable to locate the dependency for
import com.atlassian.jira.plugins.mail.webwork.AbstractEditHandlerDetailsWebAction;
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
However, in the specs for 5.2-m03 onward, this folder is not present, which is why maven cant find it.
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.
So, what can I use in place of the seemingly deprecated com.atlassian.jira.plugins.mail.webwork.AbstractEditHandlerDetailsWebAction;
in the above class?
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:
Clone the repo from the tutorial
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:
Adjust the POM to correspond to the correct version of the mail plugin
Here is the patch I applied against the pom.xml:
Fix other type issues
There is one other reference in DemoHandler that you'll have to change from
User
toApplicationUser
.After that, it builds for me.