Difficulty in setting visibility of a component to access group
Hi,
I am trying to change visibility of a component to access group using setComponentOwnerAndVisibility() method of IWorkspaceManager.
1. I have created access group using:
IAccessGroupClientService clientService = (IAccessGroupClientService) repo.getClientLibrary(IAccessGroupClientService.class);
IWorkItemCommon workItemCommon = (IWorkItemCommon)repo.getClientLibrary(IWorkItemCommon.class);
IAccessGroup accessGroup = (IAccessGroup) workItemCommon.getAuditableCommon().createAuditable(IAccessGroup.ITEM_TYPE);
accessGroup.setName("Test_AccessGroup_1");
2. Added required team areas to this access group:
accessGroup.add(team, ReadAccessContextType.MEMBERS);
3. Setting visibility of a component using:
wm.setComponentOwnerAndVisibility(component, owner, (IReadScope) IReadScope.FACTORY.createAccessGroupScope(accessGroup), monitor);
But getting java.lang.IllegalArgumentException for this method
java.lang.IllegalArgumentException
at com.ibm.team.repository.common.model.impl.ItemTypeImpl.createItemHandle(ItemTypeImpl.java:151)
at com.ibm.team.scm.common.internal.dto.impl.AccessGroupScopeImpl.setAccessGroupId(AccessGroupScopeImpl.java:226)
at com.ibm.team.scm.common.dto.IReadScope$1.createAccessGroupScope(IReadScope.java:133)
Anyone has any clue?
One answer
https://rsjazz.wordpress.com/2016/02/03/setting-access-control-permissions-for-scm-versionables/ explains the API for that.
IPermissionContextProvider accessGroupContext = IPermissionContextProvider.FACTORY.create(accessGroupHandle);
provides the context.