Setting Restricted Access programmatically
Hi All,
Am using Restricted Access feature provided in RTC v3.0 for controlling view access for couple of work items for list of users. I understand that we can have it enabled on web client by including "Restricted Access" attribute in our editor presentation. Now I have a scenario wherein, I would need to create work items programmatically. I would want these newly created ones also to be set for access controlling by default. Can I set this attribute "Restricted Access" also in my program to achieve this?? Any pointers in this direction would greatly help. Thanks
Thanks & regards,
Mohan
Am using Restricted Access feature provided in RTC v3.0 for controlling view access for couple of work items for list of users. I understand that we can have it enabled on web client by including "Restricted Access" attribute in our editor presentation. Now I have a scenario wherein, I would need to create work items programmatically. I would want these newly created ones also to be set for access controlling by default. Can I set this attribute "Restricted Access" also in my program to achieve this?? Any pointers in this direction would greatly help. Thanks
Thanks & regards,
Mohan
One answer
Hello Mohan,
yes you can set the Restricted Access att of a WorkItem programmatically. You basically need to get the UUID from the Project Area you want to set the value for and set the contextId attribute. Here I add you some snippets to try to help out:
Hope this eskeleton snippets help.
Regads,
Jorge
yes you can set the Restricted Access att of a WorkItem programmatically. You basically need to get the UUID from the Project Area you want to set the value for and set the contextId attribute. Here I add you some snippets to try to help out:
// Assume pArea1 is WI's Project Area
// and PArea2 is to what you want to set security context
// Both assignable to IProjectArea
IWorkItemClient service = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
// Retrieve Restricted Attribute
IAttribute restrictedAtt = service.findAttribute(pArea1, "contextId", monitor);
// I assume you already have your WorkItem WorkingCopy
IWorkItem workItem = <workingCopy>.getWorkItem();
// From a Project Area, you have to get the UUID
UUID secContext = pArea2.getContextId();
workItem.setValue(restrictedAtt, secContext);
...
Hope this eskeleton snippets help.
Regads,
Jorge
Comments
I'm using 4.0.3, and I'd like to programatically set Restricted Access to an Access Group. Is this possible? I haven't figured out how to return the UUID for the Access Group.
The code above would work for 4.0.3 as well.
That code is getting the UUID for the Project Area though... I'm trying to get the UUID for an Access Group. Or am I missing something?
See https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ and look into how I get the SecurityContextProvider that actually uses them. Look into the code.
I think it is
workItemCommon.getAuditableCommon().getAccessGroups()
So you get them from an AuditableCommon service or client library.