cancel
Showing results for 
Search instead for 
Did you mean: 

How is HistoricProcessInstanceEntity's startUserId set?

jwestra
Champ in-the-making
Champ in-the-making
I am trying to understand how this is set when a process instance on all of these scenarios:
===========================================================================
1. By None StartEvent both synchronous and asynchronous

I figured from <activiti:initiator> process variable.  Is this coming from Spring like example below?


String initiator = SecurityContextHolder.getContext().getAuthentication().getPrincipal();


2. By Message start event both synchronous and asynchronous

3. By Signal start event both synchronous and asynchronous

I figured I'd back track from the DB entity, to see, but when I do a Eclipse "Call Hierarchy" on HistoricProcessInstanceEntity.setStartUserId(), I get zero hits.  How is this field in the DB even populated then?
3 REPLIES 3

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,


  public HistoricProcessInstanceEntityImpl(ExecutionEntity processInstance) {
    id = processInstance.getId();
    processInstanceId = processInstance.getId();
    businessKey = processInstance.getBusinessKey();
    processDefinitionId = processInstance.getProcessDefinitionId();
    startTime = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
    startUserId = Authentication.getAuthenticatedUserId();
    startActivityId = processInstance.getActivityId();
    superProcessInstanceId = processInstance.getSuperExecution() != null ? processInstance.getSuperExecution().getProcessInstanceId() : null;

    // Inherit tenant id (if applicable)
    if (processInstance.getTenantId() != null) {
      tenantId = processInstance.getTenantId();
    }
  }


Regards
Martin

jwestra
Champ in-the-making
Champ in-the-making
Ah… I was fooled by that old trick of having a "setter" that is not used because the attribute it directly "set"!  Thanks for pointing that out, Martin. 

Given that the startUserId comes from Authentication.authenticatedUserIdThreadLocal, I'll record a few thoughts and please correct me if I am wrong on any of them.

How HistoricProcessInstance "startUserId" is set:
============================================================
1. None StartEvent

synchronous None StartEvent from the authenticated UserId, if any
asynchronous - no authenticated UserId exists, so HistoricProcessInstance.startUserId will never be set.

2. Message StartEvent

synchronous Message StartEvent from the authenticated UserId, if any
asynchronous - no authenticated UserId exists, so HistoricProcessInstance.startUserId will never be set.


3. Signal StartEvent

synchronous Signal StartEvent from the authenticated UserId, if any
asynchronous - no authenticated UserId exists, so HistoricProcessInstance.startUserId will never be set.


Is there any way to 'hook' in an Authenticated userid when an Activiti process instance is started asynchronously?


martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I did not try it but let's try to set Authenticated userId before message/signal start event.

Regards
Martin

let's be a way et
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.