cancel
Showing results for 
Search instead for 
Did you mean: 

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

mowl
Champ in-the-making
Champ in-the-making
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
2 REPLIES 2

lvenkat
Champ in-the-making
Champ in-the-making
Hi,
   Is there a solution yet for this problem ?  Even I have a requirement which is similar.

Thanks

trademak
Star Contributor
Star Contributor
Yes, you should use Authentication.setAuthenticatedUserId() . This method has no dependency on the identity service, so that should work just fine.

Best regards,