It's all about the answers!

Ask a question

ALM_How to update the access list using java or OSLC api.

masoom Abdullah (5310) | asked Mar 22 '18, 2:37 a.m.

Hi all,

The Access Control for my project area is selected as "Users in the access list only".

I am able to get the list of users already present in the access list by using RTC Api code snippet as below.

IReadAccessListHandle accessListHandle=area.getReadAccessList();
IReadAccessList iReadAccessList = (IReadAccessList) itemManager.fetchCompleteItem(accessListHandle, itemManager.DEFAULT,new NullProgressMonitor());
IContributorHandle[] memberHandles=iReadAccessList.getContributors();

But i am unable to find any method to update this list.

One answer

permanent link
Ralph Schoon (61.1k33643) | answered Mar 22 '18, 11:18 a.m.

This is easy enough to find for the Java API, provided you follow the hint in to setup the RTC Eclipse client with the SDK.

That allows to search e.g. for the stuff you use un your question and in 2 minute you can find the JUnit test cases with the working code. Foe example you find

with this code:

    public void testAddToAndRemoveFromProjectAreaAccessList() throws TeamRepositoryException {
        // This will be the list that we expect at the end: user1, guest1, and guest2
        List expectedUsers = new ArrayList();
        // First, set up the project area by manually adding members to the access list.
        IContributor user1 = repo.contributorManager().fetchContributorByUserId(TestUserNames.TEST_JAZZ_USER1, null);
        IContributor user2 = repo.contributorManager().fetchContributorByUserId(TestUserNames.TEST_JAZZ_USER2, null);
        IReadAccessListHandle accessHandle = fProjectArea.getReadAccessList();
        IReadAccessList accessList = (IReadAccessList) repo.itemManager().fetchCompleteItem(accessHandle, IItemManager.REFRESH, null).getWorkingCopy();
        accessList.addContributors(new IContributorHandle[] { user1, user2 });
        getProcessItemService().save(accessList, null);

    IContributor guest1 = repo.contributorManager().fetchContributorByUserId(TestUserNames.TEST_JAZZ_GUEST1, null);
    IContributor guest2 = repo.contributorManager().fetchContributorByUserId(TestUserNames.TEST_JAZZ_GUEST2, null);

    // Make the working copy changes
    IProjectArea projectArea = getProjectAreaWithSettings();
    fWorkingCopy = (IProcessAreaWorkingCopy) getProcessItemService().getWorkingCopyManager().createPrivateWorkingCopy(projectArea);
    syncInitializeWorkingCopy(fWorkingCopy, null);
    ProjectAreaAccessControlWorkingCopy accessControl = ((ProjectAreaWorkingCopy) fWorkingCopy).getAccessControl();

Your answer

Register or to post your answer.