Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: OSGI module don't populate userId in audit when add new user Liferay 7.2
Hi all,
With my team are developing an osgi module to handle user creation by external application. But we noticed that audit_auditevent is not being populated correctly.
We saw that userId and username columns are not being populated.
To provide more context about execution, in the post action to the osgi module, we send the creator userId, so we force that value into the httpServletRequest, so when we initialize the ServiceContext, the user who is performing the action is being populated.
On other hand, when the user is created through the control panel, the data is propertly populated.
Any clue about what is missing?
Thanks.
I'm not sure how your process is working, but Liferay has an Audit filter which loads data into an AuditThreadLocal and that is used when building new Audit messages and submitting them into the Audit framework (where eventually they will get persisted).
I guess, depending upon how your process works, you're not going through these regular channels and therefore things are not properly set up for the Audit framework to work properly, thus leading to these gaps in your data...
Thanks David for your reply.
Actually, we are using the OSGI module to be consumed by external service, so there is no session when the module is executed.
We noticed that the AuditThreadLocal is populated with user information using data from a SharedSession object, which is not populated gived the explaination above.
So, what we did, was to populate the variable realUserId from AuditThreadLocal in a request filter (liferay user info is present as header sent to the osgi module) and now we have that info properly populated in the Event.
Thanks again for your reply, it helps us to solve the problem.