How to invoke a IChangeEventHandler by server side programmatically
We would try to invoke an our IChangeEventHandler implementation by server side.
How could we create that IChangeEventHandler instance to be adviced by the change event manager (e.g., internal API)?
IChangeEvent event = IChangeEvent.FACTORY.newInstance(null);
// event.set???(???);
IServerProcess serverProcess = processService.getServerProcess(prjArea);
serverProcess.handleChangeEvent(event, prjArea);
Thanks in advance.
4 answers
As far as I can tell, you don't do that. You extend the event handler extension point and then your event handler is called, once you configure it for the project.
We already extended the event handler extension point "com.ibm.team.workitem.event.stateChanged" with our implementation and it works like a charm.
Also, we created a REST command to be able to simulate the invocation of that implementation and it works like a charm, too.
We are looking for the right way to generate the IChangeEvent instance to be used for that invocation:
IChangeEvent event = IChangeEvent.FACTORY.newInstance(null);
event.setCategory(StateChangeNotifier.ID_STATE_CHANGED_EVENT_CATEGORY);
event.setOwnerNamespace(IWorkItem.ITEM_TYPE.getName());
event.setContextId(???);
event.setProcessArea(prjArea);
event.setAuthor(getAuthenticatedContributor());
event.setTime(timeService.getCurrentTimestamp());
changeService.save(event);
For instance, we do not know how to set a correct contextId...
Thanks in advance.
Cheers.
I suppose you have extended com.ibm.team.process.service.eventHandlers and configured it with eventCategory="com.ibm.team.workitem.event.stateChanged" to intercept a workitem state transition.
In my opinion the contextId is the context UUID of the Workitem
or if you do not need it you can use for example:
In my opinion the contextId is the context UUID of the Workitem
IWorkItem workitem ....
event.setContextId(workitem.getContextId()); event.setItem(workitem)
or if you do not need it you can use for example:
event.setContextId(IContext.PUBLIC)