I've implemeted an issue event listener in my plugin where I can distinguish between more general types of events ( resolved, closed, updated .. etc ). I need a spcific process to occur ONLY when an attachment has been added to an issue. My problem is an attachment event is seen as an ISSUE_UPDATED event, which is failry generic considering a handful of other actions can trigger this event type. I don't want to trigger my specific process on any issue update event. Is there there a way to "filter" or distinguish an attachement event from all others?
Thanks, some of that info was a little outdated but it definitely led me in the right direction.
If anyone is looking for the same type of task, i suggest looking into the following two:
https://developer.atlassian.com/display/JIRADEV/Database+Schema
and
your INF/classes/entitydefs/entitymodel.xml file.
Here's a snippet that worked out for what I was looking for:
private boolean isAnAttachmentEvent(IssueEvent event) { boolean isAttachmentEvent = false; List<GenericValue> changeItems = null; try { GenericValue log = event.getChangeLog(); changeItems = log.internalDelegator.findByAnd("ChangeItem",EasyMap.build("group",log.get("id"))); } catch (GenericEntityException e) { System.out.println(e.getMessage()); } if(changeItems == null) return false; Iterator<GenericValue> it = changeItems.iterator(); while(it.hasNext()){ String p = it.next().getString("field"); if(p.equalsIgnoreCase("Attachment")) isAttachmentEvent = true; } return isAttachmentEvent; }
You should be able to get the ChangeLog for the event from IssueEvent and then scan that to see if a file was attached
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just found some example code on how to go through the change history, it may not be the most up to date but it will give you a statr: http://confluence.atlassian.com/display/JIRACOM/JiraIssueChangeHistory
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.