if (initiatorVariableName != null) {
String authenticatedUserId = Context.getCommandContext().getAuthenticatedUserId();
processInstance.setVariable(initiatorVariableName, authenticatedUserId);
}
ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
HistoryLevel historyLevel = configuration.getHistoryLevel();
// TODO: This smells bad, as the rest of the history is done via the ParseListener
if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_START, processInstance)) {
final HistoryEventProducer eventFactory = configuration.getHistoryEventProducer();
final HistoryEventHandler eventHandler = configuration.getHistoryEventHandler();
// publish event for historic process instance start
HistoryEvent pise = eventFactory.createProcessInstanceStartEvt(processInstance);
eventHandler.handleEvent(pise);