AnsweredAssumed Answered

TaskService.addComment(...) has no argument for the userId

Question asked by mowl on May 18, 2012
Latest reply on Jun 4, 2013 by trademak
Hi there,

We're currently integrating Activiti with a spring-based application.
We don't use Activiti's IdentityService or the Activiti Explorer at all.

We tried to add comments to a task but the method "TaskService.addComment(…)" has no argument for the userId.

The userId is retrieved in "org.activiti.engine.impl.cmd.AddCommentCmd" by using
String userId = Authentication.getAuthenticatedUserId()

As a workaround I could just set the authenticated userId using
identityService.setAuthenticatedUserId("johndoe");
and remove it afterward but this seams not best way to do.

Beside "TaskService.addComment(…)" the userId is also needed in
org.activiti.engine.TaskService.createAttachment(String, String, String, String, String, InputStream)
org.activiti.engine.TaskService.createAttachment(String, String, String, String, String, String)

In both cases the current userId is needed in "org.activiti.engine.impl.cmd.CreateAttachmentCmd" for creating a comment if the history is enabled.

I'm not sure if this is a bug so I started here instead of creating a Jira, but I think the dependency to the IdentityService should be removed.

Thanks for your feedback on this.
Michael

Outcomes