Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Upgrade mail handler to support JIRA 4.3

Pepe
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2011
We slightly modified the stock CreateOrComment mail handler for a client and have been maintaining it since. The upgrade procedure has been to grab the latest stock mail handler code and manually merge in our changes. Interestingly the stock mail handler code in JIRA 4.3.4 does not seem to have changed since 4.0.1. The now deprecatedUpdateIssueBean is still used and IssueService is not.
The changes to JIRA 4.3 (and the introduction of IssueService in 4.1) seem to have broken our handler and rendered JIRA unstable. The most recent upgrade has been from JIRA 4.0.1 to 4.3.4.Our handler has modifications to:
  • AbstractCommentHandler.java
  • CreateOrCommentWithCCHandler.java
  • CreateIssueWithCCHandler.java
  • FullCommentHandler.java
Using the plugin as is yielded "java.lang.NoSuchMethodError: com.atlassian.jira.issue.util.IssueUpdateBean" and pulling IssueUpdateBean.java into the package allows the mail handler to function though it seems to have degraded JIRA's performance and leaves it unstable. Upon startup the few messages will create a tickets properly and then at least the pop/imap handlers stop functioning and eventually the entire Scheduler stops functioning. The only log entry is:
Test Mail Service [com.atlassian.mail.MailUtils] Unable to extract text from MIME part with Content-Type 'multipart/alternative; boundary=0016e6d99a29c5e0b104a6b6abd7
Atlassian recommends plugins move to use IssueService. Reference material includes Updating JIRA Plugins and Plugin Developer Notes
I don't fully understand why our approach isn't working anymore when the stock mail handler uses the same code. There must be a part of the mail system that changed that I'm not accounting for. Any advice on the best way forward?

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Pepe
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2011

I was thinking I needed to swap IssueService for IssueUpdater and IssueUpdateBean but it seems that IssueUpdate* just needs to be purged from AbstractCommentHandler.java. All I did was remove the references to the IssueUpdate* objects and replace them with GenericValue dummys as needed. Tested and so far functional in JIRA 4.3.4.

Here's a diff.

tof:tmp cpepe$ diff -r AbstractCommentHandler.java.stock-4.3.4 AbstractCommentHandler.java

1c1,9

< package com.atlassian.jira.service.util.handler;

---

> /*

> * Create or comment Handler that addes email recipients (to/cc list) as comment to newly

> * created issues. This is the stock JIRA mail handler that has been slightly modified.

> *

> * @author Christopher Pepe <pepeca@praecipio.com>

> * @date 11 Feb 2010

> */

>

> package com.praecipio.jira.plugins;

14,15d21

< import com.atlassian.jira.issue.util.IssueUpdateBean;

< import com.atlassian.jira.issue.util.IssueUpdater;

28a35,36

> import com.atlassian.jira.service.util.handler.AbstractMessageHandler;

>

33,34c41

< private final IssueUpdater issueUpdater;

<

---

>

41c48

< ComponentManager.getInstance().getIssueUpdater(),

---

> ComponentManager.getComponentInstanceOfType(GenericValue.class),

48c55

< protected AbstractCommentHandler(PermissionManager permissionManager, IssueUpdater issueUpdater, CommentManager commentManager, IssueFactory issueFactory, ApplicationProperties applicationProperties, JiraApplicationContext jiraApplicationContext)

---

> protected AbstractCommentHandler(PermissionManager permissionManager, GenericValue g, CommentManager commentManager, IssueFactory issueFactory, ApplicationProperties applicationProperties, JiraApplicationContext jiraApplicationContext)

52d58

< this.issueUpdater = issueUpdater;

154c160

<

---

>

158,176c164,165

< // Get the eventTypeId to dispatch

< Long eventTypeId = getEventTypeId(attachmentsChangeItems);

<

< // Need to update the Updated Date of an issue and dispatch an event

< IssueUpdateBean issueUpdateBean = new IssueUpdateBean(issue, issue, eventTypeId, reporter);

< // Set the comment on is issueUpdateBean such that the disptached event will have access to it.

< // The comment is also needed for generating notification e-mails

< issueUpdateBean.setComment(comment);

< if (attachmentsChangeItems != null && !attachmentsChangeItems.isEmpty())

< {

< // If there were attachments added, add their change items to the issueUpdateBean

< issueUpdateBean.setChangeItems(attachmentsChangeItems);

< }

<

< issueUpdateBean.setDispatchEvent(true);

< issueUpdateBean.setParams(EasyMap.build("eventsource", IssueEventSource.ACTION));

< // Do not let the issueUpdater generate change items. We have already generated all the needed ones.

< // So pass in 'false'.

< issueUpdater.doUpdate(issueUpdateBean, false);

---

> /* Praecipio edit: assuming this logic is handled in IssueService, seems to work without it.

> Can probably strip out all references to update() but leaving stub for now */

0 votes
Pepe
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2011

Still getting "2011-06-27 19:24:53,334 QuartzWorker-1 WARN ServiceRunner PRAE Pop Mail [com.atlassian.mail.MailUtils] Unable to extract text from MIME part with Content-Type 'multipart/alternative; boundary=00151750dadef9db5c04a6bc58a6" but seems stable and creates issues. Will report back in the morning.

0 votes
Pepe
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2011

AbstractCommentHandler.java is the only place that IssueUpdater and IssueUpdateBean are used. Swapping out those classes for IssueService looks promising.

TAGS
AUG Leaders

Atlassian Community Events