It's all about the answers!

Ask a question

How do I determine which user is running an Asynchronous Task

Andrew Soloninka (5511924) | asked Jul 03 '13, 3:55 p.m.
edited Jul 03 '13, 4:53 p.m.
 I have an Asynchronous Task that runs perfectly on Tomcat and Jetty on my system. However, when I deploy it on Websphere Application Server.on another system, The Asynchronous Task errors:

TeamOperationCanceledException: CRJAZ6053E The 'Request Build' operation cannot be completed. Permission is required to complete the operation.

How do I determine which user is running the Asynchronous Task?

Accepted answer

permanent link
Jorge Diaz (8664434) | answered Jul 04 '13, 5:23 a.m.
edited Jul 04 '13, 5:25 a.m.
Hi Andrew,

looking at AbstractAutoScheduledTask, it has the following method:

public final String getRunAsUserId() {
        return Contributor.ADMIN;

Which is called as part of the task context setup.

I ran a dummy test in a task, within the "runTask()" method:

IRepositoryItemService repoService = getService(IRepositoryItemService.class);
IContributorHandle contribHandle = getAuthenticatedContributor();
IContributor contrib = (IContributor) repoService.fetchItem(contribHandle, IRepositoryItemService.COMPLETE);
System.out.println("User ID" + contrib.getUserId() + " name: " + contrib.getName());	

and it printed out in my console:


Hope this helps.


Andrew Soloninka selected this answer as the correct answer

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.