Error while fetching related workitens
Hello,
Im doing an advisor (@save operation) to check if some spefic type is related to work item.
I want to fetch the relateds items and do something if the type is a task, for example. But when the user try to save the work and dont have permission to read the related items, PermissionDeniedException is throwed.
I would like to know if there is a way to check the work item type when the user dont have the permission. My code:
IWorkItemHandle wiRelatedHandle = (IWorkItemHandle) related
.resolve();
//This line throws PermissionDeniedException
IWorkItem workItemRelated = (IWorkItem) auditableCommon
.resolveAuditable(wiRelatedHandle, IWorkItem.SMALL_PROFILE,
monitor);
if (workItemRelated.getWorkItemType().equals(type))
hasTask=true;
}
Thanks.
Im doing an advisor (@save operation) to check if some spefic type is related to work item.
I want to fetch the relateds items and do something if the type is a task, for example. But when the user try to save the work and dont have permission to read the related items, PermissionDeniedException is throwed.
I would like to know if there is a way to check the work item type when the user dont have the permission. My code:
IWorkItemHandle wiRelatedHandle = (IWorkItemHandle) related
.resolve();
//This line throws PermissionDeniedException
IWorkItem workItemRelated = (IWorkItem) auditableCommon
.resolveAuditable(wiRelatedHandle, IWorkItem.SMALL_PROFILE,
monitor);
if (workItemRelated.getWorkItemType().equals(type))
hasTask=true;
}
Thanks.
One answer
No. Unless you do as Donald suggests, there is no way around the security..
just put a try catch around it and catch the exception and ignore it is all you can do.
you should be in a loop processing all the related workitems..
for(IReference ir: ((ISaveParameter) data). getNewReferences(). getReferences(WorkItemEndPoints.RELATED_WORK_ITEM))
{
try {
// your code
}
catch(PermissionDeniedException ex)
{
// ignore it
}
}
just put a try catch around it and catch the exception and ignore it is all you can do.
you should be in a loop processing all the related workitems..
for(IReference ir: ((ISaveParameter) data). getNewReferences(). getReferences(WorkItemEndPoints.RELATED_WORK_ITEM))
{
try {
// your code
}
catch(PermissionDeniedException ex)
{
// ignore it
}
}
Comments
Donald Nong
Dec 11 '14, 8:35 p.m.I know of some users who would create a new client interface, log on with a dedicated user and do all the "privileged" stuff. Doing this way will make the code more complicated though.