How to check access to a work item ?
![](http://jazz.net/_images/myphoto/53329f45c9bafb46bd773c2b8c99936d.jpg)
Hi All,
Say that I am accessing a workitem w1. Description field of w1 mentions one attachment say attachment 100.
And say I do not have access to this attachment. How do I detect it ?
I have fetched attachment handle and reached following stage:
IAttachmentHandle attachHandle = (IAttachmentHandle) iReference.resolve();
IAuditableClient auditableClient = (IAuditableClient) teamRepo
.getClientLibrary(IAuditableClient.class);
IAttachment attachment = (IAttachment) auditableClient
.resolveAuditable((IAttachmentHandle) attachHandle, IAttachment.DEFAULT_PROFILE, null);
The highlighted line above throws me an exception as I don not have access to it. I want to detect the access rights. How can I do it?
Say that I am accessing a workitem w1. Description field of w1 mentions one attachment say attachment 100.
And say I do not have access to this attachment. How do I detect it ?
I have fetched attachment handle and reached following stage:
IAttachmentHandle attachHandle = (IAttachmentHandle) iReference.resolve();
IAuditableClient auditableClient = (IAuditableClient) teamRepo
.getClientLibrary(IAuditableClient.class);
IAttachment attachment = (IAttachment) auditableClient
.resolveAuditable((IAttachmentHandle) attachHandle, IAttachment.DEFAULT_PROFILE, null);
The highlighted line above throws me an exception as I don not have access to it. I want to detect the access rights. How can I do it?
One answer
![](http://jazz.net/_images/myphoto/53329f45c9bafb46bd773c2b8c99936d.jpg)
I am not aware of fine grained read access permissions for work item attachments. If you have access to the work item, you have access to the attachments. There is a permission aware API to resolve handles you could use if in doubt.
https://rsjazz.wordpress.com/2012/09/21/downloading-attachments-from-work-items/
and
https://rsjazz.wordpress.com/2012/08/01/uploading-attachments-to-work-items/
explain the attachments API
https://rsjazz.wordpress.com/2012/09/21/downloading-attachments-from-work-items/
and
https://rsjazz.wordpress.com/2012/08/01/uploading-attachments-to-work-items/
explain the attachments API