How to use API (advisor) to query and list restricted work items?
Hi,
I'm using that code to find work items from an Advisor. Now I'm facing a problem: that query is returning work items based on logged user profile. So if a specific user doesn't have access to a specific work item, that query is not returning that specific work item.
To my advisor is important to find that work item and check some atributes.
How to execute that query using an "admin" user or add an option to ignore current user permissions / profile?
WorkItemQueryModel model= WorkItemQueryModel.ROOT;IItemQuery query = IItemQuery.FACTORY.newInstance(model);IPredicate predicatePA = model.projectArea()._eq(query.newItemHandleArg());IPredicate predicateIterator = model.target()._eq(query.newItemHandleArg());IPredicate predicateType = model.workItemType()._eq(query.newStringArg());IPredicate predicate = predicatePA._and(predicateIterator)._and(predicateType);query.filter(predicate);
com.ibm.team.workitem.common.internal.util.ItemQueryIterator<IWorkItemHandle> iterator = new com.ibm.team.workitem.common.internal.util.ItemQueryIterator<IWorkItemHandle>(auditableCommon, query, new Object[] { projectArea, iterationHandle, workItemType });
List<IWorkItem> workItems = auditableCommon.resolveAuditables(iterator.toList(monitor), profile, monitor);
Accepted answer
In that case I would suggest to think about creating a service such as the e-mail notification service or another asynchronous task that runs in a different user context. Jorge provides an example that might be a starting point here: http://jorgediazblog.wordpress.com/2013/06/28/rtc-custom-scheduled-async-task-example-explained/
You can find the E-Mail Notification code in the SDK, I found it recently, I would search the SDK for 'mail' or something.
I am not sure if there are drawbacks with that approach e.g. potential conflicts if the asynchronous task writes the work items.
You can find the E-Mail Notification code in the SDK, I found it recently, I would search the SDK for 'mail' or something.
I am not sure if there are drawbacks with that approach e.g. potential conflicts if the asynchronous task writes the work items.
Comments
3 other answers
If the user running the advisor does not have access to the query results, the only thing you can tell from the result is, if there are restricted work items. You could decide on that if the advisor should fail. I don't think you can hack the user context.
Comments
My scenario is complicate...
[Work Item 123]
[New Work Item 456]
A specific user is creating the [New Work Item 456] and don't have read access to [Work Item 123].
But using a advisor (precondition or follow-up action) I have to link [New Work Item 456] with [Work Item 123].
To create that link I have to execute a query and find the [Work Item 123] by type and iteration.
My problem is: if [Work Item 123] is protected (read access) I can't find it running a query on that user context.
I would like to change the user context to could find all work items or user the query API to create a query with some parameter that could ignore the read access protection.
Comments
sam detweiler
Nov 02 '13, 9:31 a.m.1 vote