3 Replies Latest reply on Nov 10, 2005 11:20 AM by m_ok

    null actorId in logs

    m_ok

      Hi,
      I had a look at the currently opened issues in JIRA and couldn't find any mention of the problem I'm having.
      Logging, Who did What and When, is an important aspect in the field of the application we're developping.
      What and When are currently answered correctly by the log classes but Who is always null.
      Looking at the code for ProcessLog, I see that the actorId is expected to come from the parent log.

       public String getActorId() {
       String actorId = null;
       if (parent!=null) {
       // AuthenticationLog overriddes the getActorId
       actorId = parent.getActorId();
       }
       return actorId;
      

      However, when a process instance is created, for example, the log class has no parent.
      If I take into consideration the comment in the piece of code above, there's supposed to be a sort of AuthenticationLog class available that overrides getActorId (and probably could provide a setActorId).
      This class however, is nowhere to be found in the starterkit.
      Do we have to provide our own log class for this purpose? I'd be surprised as everything else is logged in great detail. But if so, then how would I go about adding this log to a process instance that has not yet been created?
      Can you tell me if it's just something that's been overlooked in this release? Or have I stumbled on a bug?
      Thanks!


        • 1. getActorId() in ProcessLog?
          m_ok

          All right, I'll change my question a bit.

          What's the purpose of the getActorId method in the ProcessLog class?

          Thanks!

          • 2. Re: null actorId in logs
            tom.baeyens

            the actorId is taken from Authentication.getAuthenticatedActorId();

            that method delegates to a configurable Authenticator implementation.

            the default implementation is the one that uses a thread local. that thread local can be manipulated with Authentication.pushAuthenticatedActorId and Authentication.popAuthenticatedActorId

            regards, tom.

            • 3. Re: null actorId in logs
              m_ok

              (already on page 6! seems like it was on page one yesterady : )

              Thank you for your answer, Tom.
              I (think/hope I) broadly understand the different default Authenticators, that you can push and pop the authenticated user, and that we can provide customized ones (in the same way as with the AssignmentHandler or TaskControllerHandler).

              What confused me is that the id of the actor that triggered the log (Who) , is not persisted even though there is a specific get for it. That's why I was asking what the purpose of the method is.

              Because currently, the date (When) is saved in the JBPM_LOG table, as well as contextual info depending on the log type (What). I can use getDate() to know when the event occured, I can use the name of the log class and its specific gets to know what happened but getActorId() will not always return who is behind this. Granted it's not necessary in every log.

              Case in point is the ProcessInstanceCreateLog class. The getActorId() method relies on the parent class (in a CompositeLog sense, not OO sense)to provide the info. However, since a ProcessInstanceCreateLog as no parent then the actorId is null. Now what do I do if I want to know who started the process, if the actorId is not persisted? I ended up writing a custom Log class but is there another way?
              (Oh yeah, I know I should've checked the log table a long time ago to realise the actorId is not persisted ; )