How to trigger Issue Update event?

Sanjeev Kulkarni August 9, 2011

I want the recording, updating of change histroy and issue update event to trigger for any change in the custom fields of an issue through a single API call. Currently I am able to record, update the change histroy but issue update is not getting triggered. shown below is

1) The piece of code i have tried with

Map modifiedFields = issue.getModifiedFields();
DefaultIssueChangeHolder issueChangeHolder = new DefaultIssueChangeHolder();
for (Iterator iterator = modifiedFields.keySet().iterator(); iterator.hasNext();)
{
String fieldId = (String) iterator.next();
FieldManager fieldManager = ComponentManager.getInstance().getFieldManager();
if (fieldManager.isOrderableField(fieldId))
{
OrderableField field = fieldManager.getOrderableField(fieldId);
FieldLayoutItem fieldLayoutItem;
try
{
fieldLayoutItem = ComponentManager.getInstance().getFieldLayoutManager().
getFieldLayout(issue.getGenericValue()).getFieldLayoutItem(field);
final ModifiedValue modifiedValue = (ModifiedValue) modifiedFields.get(fieldId);
field.updateValue(fieldLayoutItem, issue, modifiedValue, issueChangeHolder);
}
catch (FieldLayoutStorageException e)
{
// TODO Auto-generated catch block
}

}
}

2) other piece of code I tried is

public void updateIssue(MutableIssue issueObject, OperationContext operationContext, User user, ErrorCollection errors, I18nHelper i18n)
throws RemoteException
{
try
{
webwork.dispatcher.ActionResult aResult = updateFieldsHelperBean.updateIssue(issueObject, operationContext, user, errors, i18n);
ActionUtils.checkForErrors(aResult);
}
catch(Throwable e)
{
log.error((new StringBuilder()).append("Exception occurred editing issue: ").append(e).toString(), e);
throw new RemoteException((new StringBuilder()).append("Error occurred editing issue: ").append(errors.getErrors()).append(" ").append(errors.getErrorMessages()).toString(), e);
}
}

3 answers

0 votes
Sanjeev Kulkarni August 25, 2011

jkas;ljdfal;kjf

0 votes
Shruthi K G August 10, 2011

Hi Nic,

On behalf of sanjeev, i am relplying back to you.

No it's neither run under post-function nor listener. We have developed a tool which imports data available in excel file and the code is run under Import functionality. Re-indexing(indexing) is happening properly. Presently to trigger the Issue update event we are calling the below code

public void fn_TriggerIssueUpdateEvent(MutableIssue issue)
{
HashMap params = new HashMap();
params.put("baseurl", ManagerFactory.getApplicationProperties().getString(APKeys.JIRA_BASEURL));
//prevent a mail from being generated
params.put("dispatchEvent", new Boolean(false));
Long evtTypeId=Long.valueOf(2);
EventType event = ComponentManager.getInstance().getEventTypeManager().getEventType( evtTypeId );
IssueEvent issueEvent = new IssueEvent( issue, params, u, event.getId() );
IssueEventDispatcher.dispatchEvent( issueEvent );
}

We want to avoid calling the above function every time the custom field is updated and hence are looking for an alternative.

Best regards

Sanjeev

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2011

Where is this being run? Post-function, listener? etc?

Also, is it indexing ok? (This is nothing to do with the event, but it's worth checking)

Sanjeev Kulkarni August 25, 2011

No it's neither run under post-function nor listener. We have developed a tool which imports data available in excel file and the code is run under Import functionality. Re-indexing(indexing) is happening properly. Presently to trigger the Issue update event we are calling the below code

public void fn_TriggerIssueUpdateEvent(MutableIssue issue)
{
HashMap params = new HashMap();
params.put("baseurl", ManagerFactory.getApplicationProperties().getString(APKeys.JIRA_BASEURL));
//prevent a mail from being generated
params.put("dispatchEvent", new Boolean(false));
Long evtTypeId=Long.valueOf(2);
EventType event = ComponentManager.getInstance().getEventTypeManager().getEventType( evtTypeId );
IssueEvent issueEvent = new IssueEvent( issue, params, u, event.getId() );
IssueEventDispatcher.dispatchEvent( issueEvent );
}

We want to avoid calling the above function every time the custom field is updated and hence are looking for an alternative.

Best regards

Sanjeev

Suggest an answer

Log in or Sign up to answer